AppleProblem & solution
Faster Retrieval for Better, More Efficient RAG
Summary
Maximum inner product search (MIPS) is central to retrieval-augmented generation, recommendation, and search, but exhaustive comparison grows costly with millions of high-dimensional keys. Apple researchers propose amortized MIPS, training small neural networks offline once on a fixed key database to learn the support function, a convex function that maps a query to the largest inner product with any key. They introduce SupportNet, which approximates support functions per cluster for exact routing, and KeyNet, which directly predicts the best-matching key vector using a consistency loss from Euler’s theorem. The method exploits known query distributions, such as short user questions in RAG, to trade a one-time training cost for faster inference. On the Natural Questions dataset, KeyNet achieves 99% recall while examining about 11 times fewer keys than raw query search, and SupportNet provides calibrated scores for re-ranking.
Context
Maximum inner product search (MIPS) is a key operation in retrieval-augmented generation, recommendation systems, and search, where a query vector must be matched against a large database of key vectors. Traditional approximate methods use clustering and quantization but ignore query distribution. This work leverages the support function of the key set, which is convex, and uses neural networks trained on the query distribution to speed up retrieval.
Approach / What changed
Train small neural networks (SupportNet and KeyNet) offline on a fixed key database using regression on ground-truth MIPS solutions computed via exhaustive search. SupportNet approximates the support function per cluster for exact routing, while KeyNet directly predicts the best key vector, with a consistency loss derived from Euler’s theorem. At inference, the networks map queries to clusters or key predictions, reducing the search space.
Takeaways
Amortized MIPS trains neural networks offline on a fixed key database to learn the support function, which is convex and provides exact routing information per cluster.
KeyNet uses a consistency loss from Euler’s theorem for homogeneous functions to keep its key predictions geometrically consistent with the support function.
On the Natural Questions dataset, KeyNet achieves 99% recall while examining about 11 times fewer keys than querying with raw query vectors, demonstrating significant speedup.
FAQ
How does SupportNet improve routing compared to centroid-based routing?
SupportNet learns the support function of each cluster, which quantifies the best possible match for any query within that cluster, unlike centroid routing which only considers distance to the centroid and can miss outliers. This allows exact routing by selecting the cluster with the highest support score.
What is the trade-off between SupportNet and KeyNet?
KeyNet is better when inference speed is the bottleneck and only the best key is needed, while SupportNet provides a calibrated score useful for re-ranking or thresholding and stays competitive at small model sizes.
How robust is the approach to distribution shift in queries?
The post mentions that both SupportNet and KeyNet are reasonably robust to mild distribution shift in query patterns, though they are trained on the precomputed query distribution.
Source and freshness
- Source
- machinelearning.apple.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.