TL;DR
Maximum inner product search (MIPS) takes a query vector and a large collection of stored vectors , and returns the stored vector with the largest dot product with the query. It looks like nearest neighbour search, but it is not the same problem: a long vector can have a big dot product without being close to the query. Padding each stored vector with one extra coordinate turns MIPS into exact nearest neighbour search, so the fast indexes built for distance search can be reused.
Where you'll see it: in recommender systems, where a user vector is scored against millions of item vectors, and in the retrieval step of retrieval-augmented generation, where a question embedding is scored against a document index.
Intuition
Score, not distance
Imagine a shop that recommends products. Each product has a vector that describes it, and each user has a vector that describes their taste. A product's score for a user is how well the two line up, which the dot product measures. The best recommendation is the product with the highest score, not the product whose vector sits closest to the user's.
Distance and score are different things. Distance asks "how far apart are these points?" A score asks "how much do these point the same way, weighted by how big they are?" A product with a very large vector can have a high score even when it is far from the user, because the size of its vector pushes the score up.
flowchart LR A[Stored vectors x_i] --> B[Append sqrt of M squared minus norm squared] Q[Query q] --> C[Append 0] B --> D[Nearest neighbour index on augmented vectors] C --> D D --> E[Top result = largest dot product]
Why it matters for search
Search systems usually store vectors ahead of time and answer each query by scanning them. The scan has to rank by one number per stored vector, and that number should match what the model was trained to produce. If the model was trained with dot products, ranking by distance can return different results. MIPS is the name for doing the ranking by dot product directly and quickly.
The math
Given a set and a query , MIPS returns
The query is fixed at search time, while the stored vectors are fixed in advance and can be indexed.
Why it is not nearest neighbour search
Expand the squared distance between the query and a stored vector. The norm of each vector is , and :
The first term is the same for every stored vector, so it does not affect the ranking. Minimising distance is therefore the same as maximising . If every stored vector has the same norm, the norm term is constant and the two problems agree. If the norms differ, they can disagree, and a plain nearest neighbour index returns the wrong answer for MIPS.
Turning MIPS into nearest neighbour search
Let . Append one coordinate to each stored vector and a zero to the query:
Every augmented stored vector now has norm exactly . Compute the distance in the new space:
Only the last term depends on , so the nearest augmented vector is the one with the largest dot product. This transformation is exact. Any nearest neighbour index applied to the augmented vectors solves MIPS exactly.
The transformation is also a trick with a cost: the extra coordinate can make vectors with small norms harder to separate in high-dimensional indexes, and the query has to be handled differently from the stored vectors. Asymmetric hashing methods were built to avoid this cost.
Cost of the exact answer
Scanning every vector takes dot products of length , so about multiplications per query. For and that is about multiplications for one query. Exact MIPS is therefore too slow for interactive search at that scale, and approximate methods are used instead.
Worked examples
Query . Stored vectors and .
- Dot products: and .
- Maximum inner product winner: , with score .
- Distances: , length . , length .
- Nearest neighbour winner: , at distance .
The two methods disagree. is far away but long, and its large norm gives it the top score.
Same vectors, with .
- Norms: and .
- Extra coordinates: for , . For , .
- Augmented vectors: and . Both now have norm .
- Augmented query: .
- Squared distances: . .
- Check with the formula: , and for . Both match.
- Nearest augmented vector: , which is the maximum inner product winner from the previous example.
Interpretation: a plain distance index built on the original vectors would return . The same index built on the augmented vectors returns , which is the correct MIPS answer.
A catalogue of items with dimensions, and one user vector.
- Exact scan: multiplications per user.
- A serving system with users per second would need about multiplications per second for exact scans, far beyond one CPU core.
- An approximate index that examines about 1% of the items reduces the work to about multiplications per user, a factor of 100.
- The index may miss the true best item some of the time. Measure that miss rate on held-out users before deploying, because the recall, not the speed, decides whether the recommendations are good.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Few items, low dimension | Index overhead is larger than the scan | Exact brute-force scan |
| Norms vary widely | Distance index ranks the wrong items | Augmented-vector transform, then a graph or tree index |
| Vectors are unit length | Dot product equals cosine similarity | Plain nearest neighbour search, no transform needed |
| Millions of high-dimensional vectors | Tree indexes degrade toward a scan | Graph indexes such as HNSW, or quantised indexes |
| Memory is tight | Full-precision vectors do not fit | Product quantisation, which stores compressed codes |
| Scores must be exact at the top | Approximate index misses the best item | Re-rank a short candidate list with exact dot products |
A common failure is measuring speed without measuring recall. An index that is ten times faster but misses the best item one time in five can make search worse. Always report recall against exact MIPS on a sample of queries.
History
Dot-product scoring predates the term. Latent factor models in collaborative filtering, which scored users and items by the dot product of learned vectors, were widely used in the late 2000s. The problem of finding the top items quickly was studied as a separate question by the mid-2010s.
In 2014, Bachrach and colleagues at Microsoft showed the augmentation trick above for a recommender system, which made it possible to reuse Euclidean nearest neighbour indexes for dot-product scores. Shortly after, Shrivastava and Li proposed asymmetric locality-sensitive hashing for the same problem, and Neyshabur and Srebro analysed when symmetric hashing could be used. Graph indexes such as HNSW, published in 2016, became the standard approximate method for distance search and are now commonly applied to MIPS through the same transform.
The problem became urgent again around 2020, when dense retrievers such as the one in Karpukhin and colleagues' work scored passages with dot products over large indexes. Retrieval-augmented systems inherited the same need, and MIPS became a standard component of their serving stacks. The transformation caught on because it let production teams keep their existing nearest neighbour infrastructure.
Check yourself
QuestionRecall: in one sentence, how does MIPS differ from nearest neighbour search?Show answer
Nearest neighbour search ranks stored vectors by distance to the query, while MIPS ranks them by dot product with the query. The two agree only when all stored vectors have the same norm, because the norm term in the squared distance then does not change the order.
QuestionComputation: with , the vector and , which vector has the larger dot product with , and which is closer in Euclidean distance?Show answer
Dot products: and , so wins MIPS. Distances: , length . , length . So is the nearest neighbour. The two methods disagree here because has the larger norm.
QuestionWhy: why does appending the coordinate make every stored vector have the same norm?Show answer
The squared norm of the augmented vector is . The norms are equal because the appended coordinate was chosen to fill the gap between each vector's norm and the largest norm .
QuestionApplied: a team uses a graph index on unit-length embeddings and sees good recall. They switch to unnormalised embeddings and recall drops. What is the likely cause, and what is the fix?Show answer
Unit-length vectors make the dot product equal to cosine similarity, so distance and score agree and a plain nearest neighbour index is correct. Unnormalised vectors bring back the norm term, so the index ranks by distance while the model was trained to rank by dot product. The fix is to apply the augmented-vector transform before indexing, or to re-rank the index's candidates by exact dot product.