Imagine a picture library with years of commissions. A client asks for the photograph of a cobalt jug with a chipped handle. The search tool instantly finds dozens of blue vessels, then carefully orders the best matches. The right photograph never appears. If it was left off the first shortlist, the final ranking could be excellent at its job and still fail the client.
That is the trade-off behind a useful idea from AI research: do a cheaper first pass over a large collection, then spend more effort on the candidates that survive. Matryoshka Representation Learning is a way to train the same embedding to support both passes. The practical question is how much detail the first pass can give up before it stops finding the items you need.
One embedding, several usable lengths
An embedding represents an item as a list of numbers. A search system can compare those lists to look for related items. A dimension is one position in that list. Matryoshka embeddings take their name from nesting dolls: the first part of a longer list is trained to work as a shorter representation. The shorter version lives inside the longer one.
In their NeurIPS 2022 paper, Aditya Kusupati and colleagues trained representations with objectives at multiple lengths, rather than treating the full list as the only output that must work. The idea is to keep useful information in early dimensions while giving longer versions room for more detail. It does not mean the dimensions correspond to readable labels such as ‘blue’, ‘ceramic’ or ‘cracked’. Nor does it imply that cutting an arbitrary embedding in half will preserve its usefulness.
The researchers demonstrated adaptive retrieval on ImageNet collections. They used a short representation to find candidates and a longer one to score the candidates again. Their companion code and examples describe the two lengths and the size of the shortlist as separate choices. Results from those image datasets show what was possible in the tested setting. They do not tell you how short a representation can be for your own archive, or how fast the whole search will feel once it is connected to a live service.
A better ranking cannot rescue an absent candidate
Suppose the picture library runs an experiment. A search using longer embeddings brings the chipped jug into the results. The shorter search retrieves lookalikes but leaves the jug outside the group sent for a second pass. The second pass can sort those lookalikes more carefully. It cannot introduce a photograph it was never given. In this example, the place to investigate is the first pass, even if the most impressive component is the one doing the final ranking.
There are at least two different adjustments to try. A longer first-pass embedding may preserve distinctions the shorter version misses. A larger shortlist may keep the right item in play even when its first-pass score is mediocre. Neither is guaranteed to help on every query. A bigger shortlist also gives the next stage more work, so compare the improvement with the actual cost of processing it.
The full-length search is useful as a comparison, but it is not a catalogue of right answers. It might miss a photograph whose caption is sparse, or rank the wrong blue jug highly. Include queries where a librarian, photographer or editor has already identified good matches. If exact identifiers or filenames matter, test a separate lookup for them rather than expecting a similarity score to do every job.
Test the first pass and the finished search separately
Pick a small collection of real tasks before you choose any settings. Include broad searches where several images would work, and exact requests where missing one item makes the result useless. Include distinctions that matter to your audience: a product variant, a particular edition, or a detail that was never written into the caption. Have someone who knows the collection check the expected results.
- Check shortlist coverage. For each query, record whether the shortlist includes a known good match. Where several matches matter, record how many it retains. An absent item is a first-pass problem.
- Check the visible order. When the right item is present, ask whether it finishes high enough for a user to find it. That is a different question from whether it survived the first pass.
- Time the whole request. Include creating the query embedding, finding candidates, fetching what the second pass needs and returning the results. A shorter index lookup does not automatically mean a faster experience.
- Inspect the misses by query type. A good overall result can hide repeated failures on unusual requests. Look at those cases before deciding what speed gain is worth keeping.
The same reasoning applies to cost. If your design stores short vectors in an index but also keeps longer ones for rescoring, account for both. Compare the memory or storage used by the complete setup and check whether the second pass needs extra data transfers. For a broader way to judge such trade-offs, see MaryChuks’ guide to evaluating reliability beyond one accuracy score.
A fast shortlist is valuable when it carries the right possibilities forward. Before reducing the first-pass length, decide which misses you can tolerate and which would send a reader away empty-handed. The best evidence is not how neatly the results are sorted. It is whether the items that matter are still there to be sorted.
Sources
- Kusupati et al., Matryoshka Representation Learning (NeurIPS, 2022).
- RAIVN Lab: companion implementation and retrieval examples.
Discover more from Marychuks.com AI, Psychology, Business & CreativeVerse
Subscribe to get the latest posts sent to your email.
2 thoughts on “Matryoshka Embeddings: A Faster Search Still Needs the Right Shortlist”