Skip to main content
Back

Apple and MIT's Amortized MIPS Cuts Vector Search FLOPs by 4x

Apple researchers train small neural nets to predict MIPS solutions directly, cutting retrieval compute by up to 4x on benchmarks up to 15M vectors

Pro

  • Apple and MIT researchers propose Amortized MIPS, training neural nets to directly predict MIPS solutions instead of building search indices.
  • Key insight: the MIPS value function is the support function of the key database, a convex function whose gradient equals the optimal key vector.
  • Two models: SupportNet (ICNN-based cluster router) and KeyNet (direct key regressor, drop-in query replacement for FAISS/ScaNN).
  • On NQ with 128 clusters, SupportNet achieves 95% routing accuracy at k=4 vs. k=16 needed by centroid baseline, a 4x FLOPs reduction.
  • KeyNet improves recall-vs-compute Pareto fronts across FAISS-IVF, ScaNN, SOAR, and LeanVec on databases up to 15M keys.
  • Code is open-sourced; method requires a stable query distribution and degrades under significant distribution shift.

Every time a RAG pipeline fetches a document, a recommender system picks a product, or a softmax layer selects a class, the underlying operation is the same: find the vector in a database that has the highest dot product with a query. This is Maximum Inner Product Search (MIPS), and at scale it is expensive. A team from Apple and MIT has now proposed a fundamentally different way to solve it.

Their approach, called Amortized MIPS, trains a small neural network to predict the answer to a MIPS query directly, rather than building an index and searching it at runtime. The key insight is mathematical: the function that maps a query to its best-matching key is not arbitrary. It is the support function of the key database, a well-studied object from convex analysis with exploitable structure.

Why standard MIPS is hard to speed up

MIPS plays a crucial role in recommendation systems, information retrieval, retrieval-augmented generation, and large-scale classification. While exact search requires O(nd) time, this becomes computationally prohibitive when dealing with large-scale datasets containing millions of high-dimensional vectors.

The standard fix is approximate MIPS (AMIPS): build an index structure (inverted files, graphs, hash tables) and search only part of it. These approaches typically rely on indexing structures or quantization schemes that must be queried at inference time, and make no or limited use of the query distribution. That last point is the opening the paper exploits. In most production systems, queries come from a stable distribution. A recommendation engine always gets user-preference vectors; a RAG system always gets question embeddings. Why not learn that distribution?

The convex geometry trick

The paper's central insight connects MIPS to a classical concept: the support function of a set. For a database of key vectors, the support function takes a query and returns the maximum dot product achievable. This function has two useful properties:

  • It is convex (it is the pointwise maximum of linear functions).
  • Its gradient equals the optimal key. By the envelope theorem, differentiating the support function with respect to the query gives you the key that achieves the maximum dot product.

This means that if you can learn a good approximation of the support function, you get the best-matching key for free via automatic differentiation. These structural properties motivate two learning paradigms: either train a network to predict the real-valued function (SupportNet), or to directly predict the top key (KeyNet).

Diagram showing SupportNet cluster routing vs KeyNet direct key prediction vs centroid baseline

Two architectures, two use cases

SupportNet is built on an Input Convex Neural Network (ICNN), a special architecture where all hidden-to-hidden weight matrices are constrained to be non-negative, which guarantees the output is convex in the input. SupportNet can serve as a cluster router, steering queries toward relevant database partitions. At inference, the predicted optimal key is recovered by running a backward pass through the network.

KeyNet is a standard MLP that directly regresses the optimal key vector. KeyNet's vector output can be used as a drop-in replacement for the original query that can be fed directly to off-the-shelf indexing pipelines. No backward pass is needed at inference, making it faster per query.

Both models are trained on a dataset of (query, optimal-key) pairs that are precomputed once via exhaustive search. The training losses are carefully designed around the math:

  • SupportNet uses a score regression loss (fit the scalar support function value) plus a gradient matching loss (fit the gradient to the true optimal key).
  • KeyNet uses a direct key regression loss plus a score consistency loss derived from Euler's theorem for homogeneous functions, which encourages the predicted key to have the right inner product with the query.

How it integrates with existing systems

The two models slot into existing retrieval pipelines in complementary ways. SupportNet is used for cluster routing: instead of comparing a query to cluster centroids (the standard IVF approach), it scores each cluster by predicting the maximum achievable dot product within that cluster. This is more accurate than centroid comparison because a cluster's best match can be far from its centroid.

KeyNet is used as a query transformer: it takes the original query and outputs a predicted key vector, which is then fed to any off-the-shelf index (FAISS-IVF, ScaNN, SOAR, LeanVec) in place of the original query. Because the predicted key is geometrically closer to the true answer, the index finds it with fewer probes.

# Conceptual usage of KeyNet as a drop-in query transformer
import faiss
# Train KeyNet once on (query, optimal_key) pairs
keynet = KeyNet(d=384, layers=8, param_fraction=0.05)
keynet.train(query_embeddings, optimal_key_embeddings)
# At inference: transform query before passing to FAISS
query_vec = encoder.encode("What is the capital of France?")
transformed_query = keynet(query_vec)   # predicted key vector
results = faiss_index.search(transformed_query, k=10)

Benchmarks and results

Experiments on the BEIR benchmark show that, for document embeddings, learned SupportNets and KeyNets significantly improve IVF match rates when accounting for compute effort, whether measured in FLOPs, number of probes, or wall-clock time. The datasets tested span four orders of magnitude in size: FIQA (52K keys), Quora (513K), Natural Questions (2.6M), HotpotQA (5.2M), and BioASQ (15M).

The routing results are particularly striking. On NQ with 128 clusters, the learned SupportNet router correctly routes approximately 72% of queries at k=1 versus approximately 56% for the centroid baseline, and reaches approximately 95% at k=4, matching what the centroid baseline only achieves at k=16, at roughly 4x the FLOPs.

For approximate search integration, the picture is consistent across all four indexing backends tested:

  • XS and S KeyNet models (1-5% of database size in parameters) offer the best recall-per-FLOP trade-off.
  • Larger models (L, XL) recover competitiveness under wall-clock latency constraints due to GPU parallelism.
  • Gains are most pronounced when queries and keys come from different distributions (NQ, HotpotQA) and smaller on near-duplicate datasets (Quora).
  • Results hold across MPNet and DistilRoBERTa encoders at d=768 without retuning.

The real breakthrough: query-aware compression

The deeper implication is that amortized MIPS offers a new way to think about database compression. Standard quantization methods compress keys without knowing what queries will look like. Amortized MIPS opens up new directions to compress databases with a specific query distribution in mind. The model essentially learns which parts of the key space matter for the queries you actually receive, and encodes that knowledge in its weights.

There is also an interesting connection to optimal transport theory. The mapping from query to optimal key is, by construction, the gradient of a convex function, which is exactly the form of an optimal transport map (a Brenier map). This means amortized MIPS can be framed as a supervised optimal transport learning problem, with ground-truth pairings available for free via exhaustive search during training.

Limitations and when to use it

The method has a clear prerequisite: it assumes access to a relevant distribution of queries, and performance may degrade under distribution shift. The paper tests this explicitly and finds that improvements persist through moderate noise levels (sigma up to 0.03 on a unit-sphere embedding), but degrade at higher shift. It is best suited for systems where the query distribution is stable, such as production search or recommendation engines with consistent user behavior.

It is also worth noting that the training pipeline requires precomputing exact MIPS solutions for a large set of training queries, which is a one-time cost but can be non-trivial for very large databases. The paper reports that downstream metrics plateau around 3 billion training samples, which is the practical sweet spot for the S-size model.

The code is available on GitHub under Apple's ml-research repository, and experiments were run on the BEIR benchmark using standard sentence encoders, making it straightforward to reproduce and adapt.