<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Parichay Das on Medium]]></title>
        <description><![CDATA[Stories by Parichay Das on Medium]]></description>
        <link>https://medium.com/@parichaydas?source=rss-4829654c8984------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Parichay Das on Medium</title>
            <link>https://medium.com/@parichaydas?source=rss-4829654c8984------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:31:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parichaydas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One Vector, 32K Tokens: Is Chunking Finally Optional?]]></title>
            <link>https://medium.com/@parichaydas/one-vector-32k-tokens-is-chunking-finally-optional-3b66d7816f45?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b66d7816f45</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 17:41:10 GMT</pubDate>
            <atom:updated>2026-10-31T17:41:10.593Z</atom:updated>
            <content:encoded><![CDATA[<p><em>UltraBERT-Embed-150M, five retrieval strategies in Qdrant, and what 1-bit TurboQuant does to the result</em></p><p>Chunk size is the first decision in almost every retrieval pipeline, and it is usually made by habit. 512 tokens, some overlap, move on. The reason was never that 512 is the right unit of meaning. It was that encoders stopped reading after 512 tokens, so documents had to be cut to fit.</p><p>UltraBERT-Embed-150M removes that constraint. It reads up to 32K tokens and returns one 768-dimension vector. Most long documents now fit in a single pass. So the obvious question follows: if the model can read the whole document, why keep cutting it up?</p><p>Qdrant asked that question in a recent benchmark. This article reproduces part of that setup in a local Qdrant 1.20 environment, compares five retrieval strategies, and tests how far the vectors can be compressed before the results move. The short answer is that chunking stays. The longer answer is more useful, because it explains <strong>why</strong> a long context window and good retrieval are separate problems.</p><h3>What UltraBERT-Embed-150M actually gives you</h3><p>UltraBERT-Embed-150M comes from DMIS Lab. It is a dense embedding model built on UltraBERT, an English encoder trained for 32K-token inputs. Three numbers define it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HM9hFU5SXKJvgVWVTtyrjw.png" /></figure><p>The last row is where the trade-off lives. A 300-token paragraph and a 30,000-token transcript both end up as 3,072 bytes. The model can read more. The vector cannot hold more.</p><h3>What Qdrant’s benchmark found</h3><p>Qdrant’s team (Dylan Couzon and Anush) published the reference study on 19 October 2026. They used five long-document tasks from LongEmbed, where documents average 7,600 to 13,800 tokens, plus MLDR, a 200,000-article English Wikipedia set with 800 questions. Each document was embedded two ways: one whole-document vector, and 512-token chunks where a document scores by its best chunk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0Mjb5nUAfD4RQ-F7IZW1Q.png" /><figcaption><em>Source: Qdrant, “UltraBERT Fits 32K Tokens in One Vector. RIP Chunking?” (Oct 2026). nDCG@10, except recall@1 for Passkey and Needle.</em></figcaption></figure><p>The pattern is consistent. The whole-document vector wins only on SummScreenFD, where the query describes an entire TV episode. Wherever the answer sits in a few passages, chunks win, and the margin is large on QMSum and MLDR.</p><p>Needle is the clearest evidence. Qdrant reports that the whole-document vector found the right essay 84% of the time at 256 tokens, but only 30% of the time at 32K tokens. At that length, 512-token chunks reached 56%. The model did read the needle. The vector simply had no room left to remember it.</p><p>Fusing both representations did not rescue the whole-document vector either. Qdrant saw small gains on SummScreenFD and Needle, and losses against chunks alone on 2WikiMultihopQA, QMSum and MLDR.</p><h3>Why a longer window does not mean better retrieval</h3><p>It helps to think of an embedding as a fixed budget. Every vector from this model gets 768 dimensions. A 512-token chunk spends that budget on 512 tokens. A 32K-token document spends the same budget on 64 times as much text. Pooling has to decide what to keep, and it keeps what dominates: the topic, the genre, the overall gist.</p><p>That is exactly what a summary-style query needs, which is why SummScreenFD favours the whole vector. It is exactly what a fact lookup does not need. A question about one configuration flag, one decision in a meeting, or one sentence in an essay is asking about a detail that pooling averaged away.</p><p>So the context window and the retrieval unit are two different design choices. The window decides how much text the model can <strong>see</strong> when building a representation. The retrieval unit decides how much text one vector is expected to <strong>stand for</strong>. UltraBERT widens the first. It does nothing to the second.</p><h3>The experiment setup</h3><p>The local implementation follows the same idea at a smaller scale. It has four goals:</p><p>• <strong>Compare retrieval strategies:</strong> whole-document vectors, 512-token chunks, multivector MaxSim, hybrid RRF and a two-stage pipeline.</p><p>• <strong>Test detail retrieval:</strong> check whether a specific fact hidden inside a long document can be found.</p><p>• <strong>Measure storage cost:</strong> compare 1-bit TurboQuant with and without rescoring against exact search.</p><ul><li><strong>Score quality:</strong> Recall@1, Recall@10, and Top-10 overlap with exact search.</li></ul><p>Environment: Qdrant server <strong>1.20.0</strong>, Python client, sentence-transformers, transformers, PyTorch and NumPy.</p><pre>python -m pip install --no-cache-dir --upgrade \<br>    qdrant-client sentence-transformers transformers torch numpy</pre><p>Every document is embedded twice. One pass sends the full text through UltraBERT-Embed and produces one vector. A second pass splits the text into 512-token chunks and embeds each one. Qdrant can store these in two layouts, and the choice matters later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mI6DQTMsHKsXqpUcsc4hJg.png" /><figcaption><em>Figure 1. Ingestion. The same model produces a document-level vector and chunk-level vectors. Qdrant can hold both on one point or store chunks as separate points.</em></figcaption></figure><p>• <strong>Option A, one point per document.</strong> Two named vectors: whole (one 768-d vector) and chunks (a multivector holding every chunk). This keeps a document atomic and lets a single query combine both views.</p><p>• <strong>Option B, one point per chunk.</strong> Each chunk is its own point with a doc_id payload. A grouped search returns each document once. This is the layout Qdrant used at 200K-article scale, because each chunk vector can be quantized and indexed on its own.</p><p>A configuration sketch for Option A looks like this:</p><pre>from qdrant_client import QdrantClient, models<br> <br>client = QdrantClient(url=&quot;http://localhost:6333&quot;)<br> <br>client.create_collection(<br>    collection_name=&quot;docs&quot;,<br>    vectors_config={<br>        &quot;whole&quot;: models.VectorParams(size=768, distance=models.Distance.COSINE),<br>        &quot;chunks&quot;: models.VectorParams(<br>            size=768,<br>            distance=models.Distance.COSINE,<br>            multivector_config=models.MultiVectorConfig(<br>                comparator=models.MultiVectorComparator.MAX_SIM<br>            ),<br>        ),<br>    },<br>)</pre><h3>Five ways to query the same documents</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezDyww0YH-T_IGhau7-Bhg.png" /><figcaption><em>Figure 2. Query strategies. Each returns a ranked list of documents, scored with Recall@1 and Recall@10.</em></figcaption></figure><p>1. <strong>Whole-document vector.</strong> Nearest-neighbour search on whole. One comparison per document.</p><p>2. <strong>512-token chunks, grouped.</strong> Search chunk points and group by doc_id, so a document scores by its best chunk.</p><p>3. <strong>Multivector MaxSim.</strong> Search the chunks multivector. Qdrant scores each document with MaxSim across its chunk vectors.</p><p>4. <strong>Hybrid RRF.</strong> Prefetch candidates from whole and from chunks, then fuse the two rankings with Reciprocal Rank Fusion.</p><p><strong>Two-stage retrieval.</strong> Use the whole-document vector to build a shortlist, then rank that shortlist by chunk similarity.</p><p>Strategies 4 and 5 map directly onto Qdrant’s Query API:</p><pre>q = embed(query_text)   # one 768-d vector<br> <br># Hybrid RRF: fuse document-level and chunk-level rankings<br>hybrid = client.query_points(<br>    collection_name=&quot;docs&quot;,<br>    prefetch=[<br>        models.Prefetch(query=q, using=&quot;whole&quot;, limit=50),<br>        models.Prefetch(query=[q], using=&quot;chunks&quot;, limit=50),<br>    ],<br>    query=models.FusionQuery(fusion=models.Fusion.RRF),<br>    limit=10,<br>)<br> <br># Two-stage: shortlist on &#39;whole&#39;, re-rank the shortlist on &#39;chunks&#39;<br>two_stage = client.query_points(<br>    collection_name=&quot;docs&quot;,<br>    prefetch=models.Prefetch(query=q, using=&quot;whole&quot;, limit=50),<br>    query=[q],<br>    using=&quot;chunks&quot;,<br>    limit=10,</pre><h3>Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uKub-I_0dkH3jjPvVBzp9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bL5f223DF-zFEeEfRwOFA.png" /><figcaption><em>Figure 3. Recall@1 and Recall@10 across the five strategies in the local run.</em></figcaption></figure><p>Hybrid RRF had the best Recall@1 at 0.550. Whole-document and hybrid retrieval both reached Recall@10 of 1.000. Everything else tied at 0.475 for Recall@1.</p><p>Three observations are worth more than the ranking itself.</p><h3>Identical MaxSim and grouped-chunk scores are expected</h3><p>MaxSim was built for late-interaction models, where the query is also a set of token vectors. It sums, over query vectors, the best match among document vectors. Here the query is <strong>one</strong> vector. With a single query vector, MaxSim collapses to “the best-matching chunk”, which is exactly what a grouped search computes. The two strategies are mathematically the same scoring rule, so matching results are a sanity check, not a finding. Had they differed, the cause would be the approximate index or grouping limits, and that would be worth investigating.</p><p>The practical consequence: with a single-vector query, choose between Option A and Option B on operational grounds (atomic updates, quantization, payload filtering), not on expected quality.</p><h3>The whole-document vector did better here than in Qdrant’s study</h3><p>In this run, the whole-document vector reached perfect Recall@10 while chunk-only strategies did not. Qdrant’s MLDR results point the other way. The two are not in conflict. A small corpus makes the top 10 easy to hit for a document-level representation, and Recall@10 rewards getting the right topic into the list. Recall@1, which demands the exact document first, is where the detail-heavy strategies start to matter, and it is where fusion helped.</p><h3>The sample is small, so the margins are small too</h3><p>Every Recall@1 value in the table is a multiple of 0.025, which is consistent with a set of 40 queries. If so, the hybrid gain from 0.475 to 0.550 is three queries. That is a direction, not a conclusion.</p><h3>Compressing the vectors with TurboQuant</h3><p>Chunks have a cost. Qdrant’s MLDR collection averaged seven chunks per article, 1.43 million vectors in total, about 4 GB in float32. That is the bill that makes teams reach for one vector per document.</p><p>TurboQuant changes the arithmetic. It applies a fast random rotation before quantizing, which spreads information evenly across coordinates and lets one global quantization map work on any vector distribution. Queries stay in full precision, so only stored vectors pay the compression error. At 1 bit, Qdrant reports each 768-d vector shrinking from 3,072 bytes to 104, about 30 times smaller, which puts all 200,000 articles’ chunk vectors near 140 MB.</p><p>The local run used the same setting and compared Top-10 results against exact search:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4df7Kcb6jK5R4tLXRdVoSQ.png" /></figure><p>Without rescoring, 77.2% of the exact Top-10 survived. With rescoring at ×2 or ×4 oversampling, the overlap reached 100%.</p><p>Two points matter when reading this next to Qdrant’s numbers. First, overlap is a strict metric. A document that slips from rank 10 to rank 11 counts as a miss even if no user would notice. Qdrant measured retained nDCG@10 instead, and reported 95% for 1-bit chunks without rescoring and 98% with it. Different metrics, same direction.</p><p>Second, rescoring is not free. It reads the original vectors. Qdrant measured 4 to 11 ms extra per query with originals on disk, and over 100 ms when the disk cache was cold. Perfect overlap at ×2 in a small collection says little about tail latency on a large one. Qdrant also found that whole-document vectors compress worse than chunk vectors: 89% of quality retained at 1 bit, recovering at 2 bits. If a whole-document vector is kept, start it at 2 bits.</p><p>A chunk collection configured the way Qdrant’s docs describe, with quantized vectors pinned in RAM and originals cold on disk:</p><pre>client.create_collection(<br>    collection_name=&quot;chunks&quot;,<br>    vectors_config=models.VectorParams(<br>        size=768,<br>        distance=models.Distance.COSINE,<br>        memory=models.Memory.COLD,          # originals on disk<br>    ),<br>    quantization_config=models.TurboQuantization(<br>        turbo=models.TurboQuantQuantizationConfig(<br>            bits=models.TurboQuantBitSize.BITS1,<br>            memory=models.Memory.PINNED,     # quantized in RAM<br>        ),<br>    ),<br>)<br> <br>hits = client.query_points_groups(<br>    collection_name=&quot;chunks&quot;,<br>    query=q,<br>    group_by=&quot;doc_id&quot;,<br>    group_size=1,<br>    limit=10,<br>    search_params=models.SearchParams(<br>        quantization=models.QuantizationSearchParams(rescore=True, oversampling=2.0)<br>    ),<br>)</pre><h3>Choosing a representation by workload</h3><p>The results translate into fairly direct defaults. These are starting points to measure against, not settled answers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-VH3HvrXBKwrObDwX8Q5g.png" /></figure><h3>Where this goes wrong</h3><p>• <strong>Assuming the window replaces the unit.</strong> A 32K window that turns every document into one vector will look fine on topic-level tests and fail quietly on fact lookups.</p><p>• <strong>Ignoring embedding cost.</strong> Qdrant measured whole-transcript embedding at roughly three times the time of 512-token chunks on an NVIDIA L4. Long inputs are not free at ingestion.</p><p>• <strong>Fusing by default.</strong> Hybrid fusion helped Recall@1 here and hurt nDCG on three tasks in Qdrant’s study. RRF weights tuned on one dataset do not transfer automatically.</p><p>• <strong>Trusting small evaluations.</strong> A 40-query set can show direction. It cannot rank strategies that differ by a few points.</p><p>• <strong>Compressing without measuring rescoring latency.</strong> The quality comes back with rescoring. The latency cost depends on where the originals live and how warm the cache is.</p><h3>Limitations of this experiment</h3><p>This is a proof of concept. The corpus is small, the query set is small, and only one model was tested. Recall@10 saturates at this scale, which hides differences that would appear at hundreds of thousands of documents. Latency and memory were not measured in the local run, so every cost figure above comes from Qdrant’s study. The next step is the same comparison on a larger, domain-specific corpus with a few hundred queries, with p50 and p99 latency recorded for each strategy.</p><h3>What the 32K window is actually for</h3><p>The interesting part of UltraBERT is not that it ends chunking. It is that chunk size no longer has to be set by the encoder. A team can now choose 256 tokens for fact-heavy material, a whole section for policy documents, and a whole document for routing, all from one model, and decide by measuring rather than by limit.</p><p>That shifts the real question. It is no longer “how small must the pieces be for the model to read them?” It is “how much text should one vector be responsible for, for this kind of question?” Those two questions have different answers, and most retrieval pipelines were built while they were forced to be the same.</p><h3>References</h3><p>• <a href="https://qdrant.tech/blog/ultrabert-embed/">Qdrant: UltraBERT Fits 32K Tokens in One Vector. RIP Chunking? (Oct 2026)</a></p><p>• <a href="https://huggingface.co/dmis-lab/UltraBERT-Embed-150M">DMIS Lab: UltraBERT-Embed-150M model card</a></p><p>• <a href="https://huggingface.co/datasets/dwzhu/LongEmbed">LongEmbed benchmark</a></p><p>• <a href="https://huggingface.co/datasets/Shitao/MLDR">MLDR dataset</a></p><p>• <a href="https://qdrant.tech/documentation/manage-data/quantization/">Qdrant documentation: Quantization (TurboQuant)</a></p><p>• <a href="https://qdrant.tech/documentation/search/hybrid-queries/">Qdrant documentation: Hybrid queries</a></p><p>• <a href="https://qdrant.tech/documentation/manage-data/vectors/">Qdrant documentation: Named vectors and multivectors</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b66d7816f45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Question That Names Nothing: Robot Memory with Reachy Mini and Qdrant Edge]]></title>
            <link>https://medium.com/@parichaydas/the-question-that-names-nothing-robot-memory-with-reachy-mini-and-qdrant-edge-654020b79f1f?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/654020b79f1f</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 17:28:08 GMT</pubDate>
            <atom:updated>2026-10-31T17:28:08.492Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A close reading of Qdrant’s Reachy Mini memory demo, the retrieval decisions behind it, and a small local replication of its recall logic.</em></p><p>Ask a robot “Did you see a bottle?” and vector search does exactly what it was built for. Ask it “What did you see today?” and the same search quietly falls apart. The question contains no object. It matches every stored frame almost equally, on the verb alone, and the top results come back as whatever happens to score a few thousandths higher. Usually that means four near-copies of the last thing the camera looked at.</p><p>That failure is the most instructive part of Qdrant’s Reachy Mini demo. The headline numbers, sub-millisecond search on a Raspberry Pi and memory that survives a full context window, are real and worth noting. Speed is not where on-device memory gets difficult, though. The difficult part is deciding when a result counts as a memory, and what to return when nothing does.</p><p>This article walks through the architecture Qdrant published, the retrieval decisions that make it work, and a small local replication of the recall logic. The replication ran against a Qdrant server, not Qdrant Edge. That distinction matters later.</p><h3>The setup</h3><p>Reachy Mini is an open-source desktop robot from Pollen Robotics and Hugging Face, driven by a Raspberry Pi with 4 GB of RAM. Qdrant Edge is the embedded form of Qdrant: a library that runs inside the application process, keeps each shard as a directory on local disk, and answers queries as function calls instead of network requests.</p><p>The memory budget shapes everything else. According to Qdrant’s write-up, the Gemma 4 dialog model alone needs about 2.5 GB before its KV cache, more than the Pi has free once the operating system and robot daemon are running. So the demo splits the system. Memory lives on the robot. The language model, speech recognition, detection and, by default, the embedding models run on a laptop on the same local network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dQ3-U24bbRQ-309g_g90A.png" /><figcaption><em>Figure 1. Reference architecture as described by Qdrant. Memory stays on the robot; compute that does not fit on the Pi runs on a nearby laptop.</em></figcaption></figure><p>Read the trust boundary carefully. Vectors and payloads are stored only on the robot, and nothing is sent to the internet. Recalled text and images do cross the LAN to the laptop, because the dialog model needs them to answer. “Private” here means private to the local network, not private to the device. For a home robot that is a reasonable line to draw. For a wearable in a shared office it may not be.</p><h3>Three shards, three kinds of memory</h3><p>In Qdrant Edge a shard is the unit of storage, a directory the application opens. The demo uses three of them, and the split follows access pattern more than data type.</p><p>• <strong>memory/</strong> holds conversation exchanges and camera frames. An indexed kind payload field separates the two and acts as a tenant key. Exchanges carry one text vector. Frames carry two named vectors, an image vector from SigLIP2 and a text vector from bge-small built from detection labels and the robot’s own comments, plus a pointer to the JPEG.</p><p>• <strong>people/</strong> holds one point per person. Every face shot of that person goes into a single multivector, compared with MaxSim, so a new angle only has to match one stored shot.</p><p>• <strong>knowledge/</strong> holds 62 facts about Qdrant and the robot, each stored with the questions it answers as a multivector. It is read-only on the device and restored at startup from a 0.7 MB snapshot.</p><p>The knowledge shard is the quietly important choice. It is authored centrally and shipped as a snapshot, so the robot gets curated facts and has no way to corrupt them. That is the pattern a fleet of devices would need, and it is the part of the design most likely to survive contact with production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qsbp3bVhP-Pcd0JdacfxBA.png" /><figcaption><em>Dimensions are taken from the replication later in this article. Qdrant’s write-up does not state them, and SigLIP2 variants differ.</em></figcaption></figure><h3>Writing memory without asking</h3><p>The language model never decides what to store. Exchanges are written when the context fills. Frames are written when the detected objects change or when someone asks the robot to look. Faces are written when a name is learned. All of these are side effects of the robot’s loop, not tool calls.</p><p>This keeps the write path deterministic and cheap, and leaves the model’s tool budget for reading. The cost is that nothing filters for importance at write time. Every changed scene becomes a frame. Over a long deployment that pushes the hard problems onto retrieval and retention, and the demo does not address retention.</p><p>Context overflow follows the same rule. The demo caps context at 1,000 tokens. When it fills, the oldest half moves into memory/ instead of being dropped, and the conversation can still reach it through the remember tool. It is a small amount of code with a large behavioral effect. Working memory stays bounded while accessible memory keeps growing.</p><h3>The question that names nothing</h3><p>Recall goes through one tool, remember, which takes a query and an about label. The label picks shards: seen searches frames, anything searches exchanges, frames and facts. Each shard has its own score gate.</p><p>The static gate is where the first failure showed up. Qdrant reports that “What did you see?” scored about 0.70 against frames described as “I saw …”, above a frame gate of 0.66. The match was real and meaningless. The question and the frame descriptions shared a verb and nothing else.</p><p>Raising the gate does not fix this. Push it high enough to reject “What did you see?” and it starts rejecting genuine matches that happen to land in the low 0.70s. The demo uses a baseline instead: a synthetic frame description, “I saw something”, scored against the same question. A real frame counts only if it beats both the gate and the baseline. A question that names an object pulls that object’s frames above the baseline. A question that names nothing leaves every frame at or below it, since the baseline is the purest possible verb-only match.</p><p>The threshold becomes adaptive per query, set to whichever is higher: the static gate, or the question’s score against an empty description. It costs one extra vector comparison, and it turns an absolute similarity score into a relative one. That is the real idea in the demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zoJo3yscL4-6l4cHK08w1Q.png" /><figcaption><em>Figure 2. Frame recall. The baseline decides which path a question takes. Example outputs are from the local replication.</em></figcaption></figure><p>When nothing clears the threshold, returning nothing would be wrong. The person asked a real question. The demo samples the day instead. It starts with the frame whose image vector is nearest the question, then repeatedly adds the frame least similar to those already chosen, using the stored image vectors. That is greedy farthest-point sampling, close to maximal marginal relevance with the relevance term mostly switched off.</p><p>It guarantees spread, not importance. A day with one interesting event and forty frames of an empty desk will still hand back some empty desk.</p><h3>Faces: two thresholds and a gap</h3><p>Face matching uses a different rule. Above 0.35 the robot greets the person by name. Below 0.25 it asks who they are. In between it waits for a better view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4yXUAQydL1OCcV9R2UasQ.png" /><figcaption><em>Figure 3. Face decision bands as reported by Qdrant.</em></figcaption></figure><p>The gap is the useful part. A single threshold forces the system to act on every borderline frame, and the errors here are asymmetric. Greeting someone by the wrong name is worse than a second of hesitation. Multivector storage helps from the other side, because each confirmed shot can be appended to the person’s point, widening the set of angles that will match next time.</p><p>Two cautions belong next to this. The thresholds were tuned in a demo with a handful of people, and face similarity distributions shift with lighting, camera and population. A gap tuned on three people says little about thirty. And face embeddings are biometric data. Consent, deletion on request and local regulation are design inputs, not something to bolt on later.</p><h3>Tool selection is a retrieval problem too</h3><p>The robot has three tools: remember, camera and move. Early on, “What did you see?” often triggered camera, because the phrasing sounds like a request to look. The fix was to rewrite the remember tool description so it states that past-tense questions belong to memory, with example questions. Correct tool selection went from 23 to 26 out of 26 test questions, with no loss on camera.</p><p>The tool description is the model’s only routing signal, and it deserves the same scrutiny as any prompt. The limitation generalizes as well. Twenty-six questions is a smoke test. A rephrased question set, or a second language, could move that number in either direction.</p><h3>What Qdrant reported</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJ5IBUlqDpeXCd3PweZ7tg.png" /><figcaption><em>All figures come from Qdrant’s published write-up. None were reproduced in the replication below.</em></figcaption></figure><p>One note on latency. Half a millisecond over 500 points says very little about the index, since at that size almost any approach is fast. What it does show is the absence of network and serialization overhead, which is exactly what in-process storage buys.</p><h3>A local replication of the recall logic</h3><p>To look at the recall logic in isolation, the same pattern was reproduced on a laptop with Python, a local Qdrant server, six synthetic frames, and the two embedding models loaded through FastEmbed.</p><pre>python -m pip install -U qdrant-client fastembed pillow numpy</pre><p>• The client connects to a Qdrant server at localhost:16333, read from the QDRANT_URL environment variable. The server was exposed on 16333 rather than the default 6333, so anyone following along should set QDRANT_URL to match their own port mapping.</p><p>• The collection is memory, with two named vectors: text (384-dim, cosine) and image (512-dim, cosine). Payloads are stored on disk.</p><ul><li>The static gate is 0.60, marked in the code as a value to tune on real questions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xj7HPWOGwXfdGi2PymGJEg.png" /><figcaption><em>Client setup. The gate is a starting point, not a tuned constant.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XiwdNSvc-eantRrCJFuxSA.png" /><figcaption><em>Collection info in the Qdrant Web UI (v1.16.3): two named vectors, six points, payload on disk.</em></figcaption></figure><p>Each frame is a single point carrying both vectors and a payload with kind, a text description, the image path and a timestamp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-zE6vufTdsYOUQYKQjS8A.png" /><figcaption><em>One frame point: payload plus the text (384) and image (512) vectors.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aly7RNJTOvTx_R16XITFZQ.png" /><figcaption><em>Filtering on kind in the Console. It is the same field that separates frames from exchanges in Qdrant’s design.</em></figcaption></figure><h3>The decision logic</h3><p>The core of the recall path fits in a few lines. The sketch below is simplified for reading and is not the full replication code.</p><pre>def recall_frames(question, k=4):<br>    q = text_model.embed(question)<br>    base = cosine(q, BASELINE_VEC)          # &quot;I saw something&quot;<br>    threshold = max(GATE, base)<br>    hits = client.query_points(<br>        COLLECTION, query=q, using=&quot;text&quot;,<br>        query_filter=frames_only, score_threshold=threshold, limit=k,<br>    ).points<br>    return hits if hits else sample_day(question, k)<br> <br>def sample_day(question, k):<br>    frames = all_frames(with_vectors=[&quot;image&quot;])<br>    q_img = siglip_text.embed(question)      # same space as image vectors<br>    picked = [max(frames, key=lambda f: cosine(q_img, f.vector[&quot;image&quot;]))]<br>    while len(picked) &lt; min(k, len(frames)):<br>        rest = [f for f in frames if f not in picked]<br>        picked.append(min(rest, key=lambda f: max(<br>            cosine(f.vector[&quot;image&quot;], p.vector[&quot;image&quot;]) for p in picked)))<br>    return picked</pre><h3>What came back</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qe1i1AawMBRX23fj9yxBEQ.png" /><figcaption><em>Recall output. A question that names nothing triggers sampling; a question that names an object takes the normal search path.</em></figcaption></figure><p>What did you see today?” scored 0.715 against the baseline. No frame cleared it, so the system reported that the question named nothing and sampled the day. It returned four different frames: a person, a bottle, a plant, and a person with a laptop.</p><p>“Did you see a bottle?” scored 0.735 against the baseline. The bottle frame cleared it, the system took the normal search path, and only that frame came back.</p><p>In both runs the printed threshold equals the baseline score, not the 0.60 gate. That is consistent with the effective threshold being the higher of the two, which matches Qdrant’s description. On these questions the baseline did all the work. Worth knowing before spending an afternoon tuning the static gate.</p><h3>What the replication does not show</h3><p>• The frames are synthetic, not footage from Reachy Mini’s camera, and nothing is connected to the physical robot.</p><p>• It runs on a Qdrant server, not Qdrant Edge. There is no in-process storage, no shard directories and no snapshot sync, so it says nothing about on-device latency or footprint.</p><p>• With six points, no HNSW index was built (indexed_vectors_count is 0 because the collection sits below full_scan_threshold), so every search was exact.</p><p>• Faces, tool calling and context overflow were not reproduced.</p><p>• Two questions are a demonstration of the mechanism, not an evaluation of it.</p><h3>Moving the replication to Edge</h3><p>The storage binding is the only part that has to change. The client stops pointing at a URL and opens a local shard instead. There is no port, no server process and no network hop. One collection becomes three shard directories, and the knowledge shard is restored from a snapshot at startup.</p><p>Everything else is application code and carries over unchanged: the named vectors, the kind field, the gate and baseline check, and the diversity sampler. That portability is the most practical argument for the design. Recall behavior can be developed and debugged against a server with a web UI, then moved onto the device.</p><h3>Where this design breaks</h3><p>• <strong>Retention.</strong> Nothing in the demo forgets. Every changed scene is a frame, and a month on a busy desk changes both the storage budget and what the diversity sampler returns. Decay, summarization or tiering is needed, and Qdrant’s write-up does not cover it.</p><p>• <strong>Baseline drift.</strong> The baseline sentence is tied to the description template (“I saw …”) and to the embedding model. Change either and the baseline has to be checked again. Another language needs its own.</p><p>• <strong>Diversity is not importance.</strong> Spread across the day is a decent default for “what did you see” and a poor one for “anything unusual today?”</p><p>• <strong>Split compute.</strong> The robot depends on the laptop to talk. Lose the LAN and it keeps storing memories it cannot discuss. The repository allows speech, detection, faces and embedding to move onto the robot. The language model cannot.</p><p>• <strong>Raw media on disk.</strong> Frame payloads point at JPEGs on the robot’s storage. Disk encryption and physical access now belong in the threat model.</p><h3>When not to use it</h3><p>If the device always has a reliable network and the data is not sensitive, a server or managed collection is simpler to operate, back up and query across devices. If memory will never grow past a few hundred items, a NumPy array and brute-force cosine will do the job and save a dependency. If several devices need one shared memory in real time, an embedded shard per device means building synchronization, which is a server’s job.</p><h3>Where the pattern transfers</h3><p>The same structure, local shards plus calibrated recall, fits other devices. The table lists design sketches, not built systems, and what each would need to change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-L_FmDb9JsDgYCJ3j7vfQQ.png" /></figure><h3>Something to think about</h3><p>The baseline works because it changes the question asked of a similarity score. Instead of “how close is this?” it asks “how much closer is this than an empty answer?” Plenty of retrieval pipelines still set one absolute threshold, or none, and return top-k regardless.</p><p>A small robot needed a per-query baseline to know when it had nothing specific to say. What would the equivalent be for a document assistant that always returns five chunks, whether or not any of them answers the question?</p><h3>References</h3><p>• Qdrant blog, Reachy Mini memory with Qdrant Edge: <a href="https://qdrant.tech/blog/reachy-robot-memory-qdrant-edge/">https://qdrant.tech/blog/reachy-robot-memory-qdrant-edge/</a></p><p>• qdrant-labs/reachy-edge-memory (source code): <a href="https://github.com/qdrant-labs/reachy-edge-memory">https://github.com/qdrant-labs/reachy-edge-memory</a></p><p>• Medium post by @denisov.shureg on robotic memory and Qdrant Edge: <a href="https://medium.com/@denisov.shureg/robotic-memory-and-qdrant-edge-efe223ac442b">https://medium.com/@denisov.shureg/robotic-memory-and-qdrant-edge-efe223ac442b</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=654020b79f1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Incident Diagnosis Search on Qdrant 1.20]]></title>
            <link>https://medium.com/@parichaydas/code-tokenizer-48bb32982e42?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/48bb32982e42</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 18:22:09 GMT</pubDate>
            <atom:updated>2026-10-31T18:09:37.960Z</atom:updated>
            <content:encoded><![CDATA[<p>Native BM25, the code tokenizer and hybrid retrieval for on-call knowledge</p><h3>1. The problem</h3><p>Incident knowledge lives in four shapes: prose (postmortems, runbooks), log signatures, stack traces, and file paths. An alert arrives as a mix of all four. A useful search has to match the meaning of the prose, the exact tokens in an error string, and identifiers that the code base spells three different ways.</p><p>Dense retrieval alone is weak on identifiers and rare tokens. Lexical retrieval alone misses paraphrase. Teams therefore run hybrid search, and before 1.20 the lexical half in Qdrant meant a sparse BM25 vector per document, produced by an inference step at ingest and again at query time, with the average document length baked into every stored vector.</p><p>Qdrant 1.20 changes the lexical half. BM25 is computed directly on a full-text payload index, Qdrant derives the corpus statistics itself, and a new code tokenizer splits identifiers on underscores and case changes. The lexical leg of a hybrid query becomes an index setting plus a text query, with no sparse-vector pipeline to run or keep in sync.</p><h3>2. Features used</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNRb6EciqKyP6fCO1CllmQ.png" /></figure><h3>3. Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lCo-6cHHOR8L4bhU9Pw-4A.png" /><figcaption><em>Figure 1. Ingest and query paths. Raw text stays in the payload; the text indexes, not an inference service, supply BM25.</em></figcaption></figure><p>There are three interfaces worth naming. The ingest worker writes one point per knowledge item with a dense vector and the raw body, code, service and path fields. The query API takes one request that fans out into three prefetches and fuses them. The consumer is either a responder reading ranked results or an LLM that summarises them; in the second case retrieval quality is the ceiling for answer quality, so the lexical legs matter more, not less.</p><p>What disappears from the diagram is the point. There is no sparse encoder at ingest, none at query time, and no offline job that recomputes average document length when the corpus grows. Those statistics now live inside the index.</p><h3>4. Collection and index design</h3><h3>4.1 Start the server</h3><pre>docker run -d --name qdrant-120-demo \<br>  -p 16335:6333 -p 16336:6334 \<br>  -v qdrant_120_demo_data:/qdrant/storage \<br>  qdrant/qdrant:v1.20.0<br> <br>export QDRANT_URL=http://localhost:16335<br>pip install &quot;qdrant-client==1.20.0&quot; numpy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*q2QnzRwUiuBanvr65KPLHA.png" /><figcaption><em>Figure 2. The local qdrant-1.20-demo server answering on port 16335: version 1.20.0, commit 222b2e4.</em></figcaption></figure><h3>4.2 Create indexes before ingest</h3><p>Payload indexes should exist before data arrives, so the filterable HNSW graph gets its extra edges. Two text indexes are used because prose and code want different tokenization: stemming helps timeouts match timeout, and it would damage identifiers.</p><pre>client.create_collection(COL, vectors_config={<br>    &quot;dense&quot;: models.VectorParams(size=DIM, distance=models.Distance.COSINE)})<br> <br># prose: word tokenizer + English stemmer + BM25<br>client.create_payload_index(COL, &quot;body&quot;, field_schema=models.TextIndexParams(<br>    type=models.TextIndexType.TEXT, tokenizer=models.TokenizerType.WORD,<br>    lowercase=True,<br>    stemmer=models.SnowballParams(type=models.Snowball.SNOWBALL,<br>                                  language=models.SnowballLanguage.ENGLISH),<br>    scoring=models.TextScoringParams(type=models.TextScoringType.BM25)))<br> <br># stack traces and identifiers: code tokenizer + BM25, no stemming<br>client.create_payload_index(COL, &quot;code&quot;, field_schema=models.TextIndexParams(<br>    type=models.TextIndexType.TEXT, tokenizer=models.TokenizerType.CODE,<br>    lowercase=True,<br>    scoring=models.TextScoringParams(type=models.TextScoringType.BM25)))<br> <br>client.create_payload_index(COL, &quot;service&quot;, field_schema=models.PayloadSchemaType.KEYWORD)<br>client.create_payload_index(COL, &quot;path&quot;, field_schema=models.KeywordIndexParams(<br>    type=models.KeywordIndexType.KEYWORD, prefix=True))  # prefix also speeds substring</pre><p><em>Set the tokenizer explicitly on any text index used for BM25. The Qdrant JS client release notes record that the server rejects a BM25 text index without one, and the Python client now defaults it to word. Being explicit removes the ambiguity across clients.</em></p><h3>4.3 Ingest</h3><p>Each point carries the dense vector and the untouched text. Nothing lexical is precomputed.</p><pre>client.upsert(COL, points=[<br>    models.PointStruct(id=i + 1,<br>                       vector={&quot;dense&quot;: embed(d[&quot;title&quot;] + &quot; &quot; + d[&quot;body&quot;])},<br>                       payload=d)<br>    for i, d in enumerate(DOCS)])</pre><h3>5. Queries</h3><h3>5.1 BM25 over prose</h3><pre>client.query_points(COL, query=models.TextQuery(text=&quot;acquirer timeout retry&quot;),<br>                    using=&quot;body&quot;, limit=3)</pre><p>using names the payload field, not a vector. This is the detail most people miss on first read: the same Query API slot that used to select a named vector now selects a text index.</p><h3>5.2 Identifier search with the code tokenizer</h3><pre>for q in [&quot;getUserName&quot;, &quot;user name&quot;, &quot;hashmap&quot;, &quot;xml http request&quot;]:<br>    client.query_points(COL, query=models.TextQuery(text=q), using=&quot;code&quot;, limit=3)</pre><h3>5.3 Hybrid: dense + prose BM25 + code BM25, fused</h3><pre>alert = &quot;card payments failing with timeouts, retries exhausted, chargeWithRetry errors&quot;<br>client.query_points(COL,<br>    prefetch=[<br>        models.Prefetch(query=embed(alert), using=&quot;dense&quot;, limit=20),<br>        models.Prefetch(query=models.TextQuery(text=alert), using=&quot;body&quot;, limit=20),<br>        models.Prefetch(query=models.TextQuery(text=alert), using=&quot;code&quot;, limit=20),<br>    ],<br>    query=models.FusionQuery(fusion=models.Fusion.RRF),<br>    query_filter=models.Filter(must=[models.FieldCondition(<br>        key=&quot;service&quot;, match=models.MatchValue(value=&quot;payments&quot;))]),<br>    limit=3)</pre><h3>5.4 Per-query BM25 parameters</h3><p>k and b are query-time parameters, so a short-document query and a long-postmortem query can be tuned differently against the same index.</p><pre>client.query_points(COL, query=models.TextQuery(text=models.TextQueryInput(<br>        query=&quot;cache heap memory&quot;,<br>        scoring=models.Bm25Scoring(bm25=models.Bm25Params(k=1.2, b=0.3)))),<br>    using=&quot;body&quot;, limit=3)</pre><h3>5.5 Path narrowing with substring match</h3><pre>client.scroll(COL, scroll_filter=models.Filter(must=[models.FieldCondition(<br>    key=&quot;path&quot;, match=models.MatchSubstring(substring=&quot;/ledger/&quot;))]))</pre><h3>6. Observed results</h3><p>The reference script in Appendix A was run against a local Qdrant 1.20.0 server with an eight-document knowledge base. The dense leg uses a deterministic hashing embedder so the script runs offline. That stand-in is close to lexical, so the dense results below say nothing about a real embedding model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAF5M6atTBWGH8u-uzByEg.png" /></figure><p>The code tokenizer behaved as documented: a camelCase query found a snake_case trace, a lowercase hashmap found HashMap through the joined token, and an acronym-led identifier split correctly. The hybrid query, filtered to payments, ranked the brownout postmortem first (RRF 1.50). The ledger lock-contention postmortem came second, above the acquirer runbook. That ordering comes from the hashing stand-in rewarding shared words like <em>payment</em>, and it is a reminder that fusion inherits the weaknesses of every leg.</p><h3>Screenshots from the local qdrant-1.20-demo run</h3><p>A separate feature demo, run on Windows against the Docker container from section 4.1, exercised the same 1.20 features with its own small collections (books, code, products and others). Its collections differ from the reference script in Appendix A, so the screenshots show the features working, not the eight-document knowledge base above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFG3dZDyJjzkUihLPxNH7w.png" /><figcaption><em>Figure 3. Demo summary: every step reported OK, including BM25 on a full-text index, per-query k and b, hybrid RRF, substring match and the code tokenizer. Step 6 (cluster security) only printed settings and was not executed.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRLU-Wuo6_lfbf-6u-_Uaw.png" /><figcaption><em>Figure 4. Web UI collection list from the demo. books holds the BM25 title search, code the code-tokenizer test.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wv3qttq7R69HA_1tGPJUrQ.png" /><figcaption><em>Figure 5. Points in the books collection. The BM25 leg reads title straight from the payload; the only vector stored is the 4-dimensional dense one.</em></figcaption></figure><h3>7. Failure modes and limits</h3><p>• <strong>Local mode is narrower.</strong> qdrant-client local mode supports TextQuery only with default tokenization. The code tokenizer path needs a real server, so tests that run in local mode will not exercise it.</p><p>• <strong>Index rebuilds.</strong> Enabling or disabling scoring on an existing text index rebuilds it from stored payload. No re-upload is needed, but on a large collection the rebuild takes time and should be scheduled.</p><p>• <strong>Memory.</strong> A scoring-enabled text index stores document lengths and term frequencies, so it is larger than a filter-only text index. Budget for it.</p><p>• <strong>One tokenizer per index.</strong> Prose and code in one field forces a bad compromise. Split the fields, or accept that stemming will mangle identifiers.</p><p>• <strong>RRF hides score scale.</strong> RRF fuses ranks, not scores. A strong BM25 hit and a weak one count the same if they share a rank. Where calibrated scores matter, evaluate DBSF or a reranker.</p><p>• <strong>Lexical drift.</strong> BM25 statistics now follow the data. That is correct behaviour, and it also means scores for the same query change as postmortems are added. Do not hard-code BM25 score thresholds.</p><h3>8. When not to use this design</h3><p>• When the lexical leg needs learned term weighting (SPLADE, miniCOIL). Native BM25 replaces BM25 sparse vectors, not learned sparse models.</p><p>• When text arrives in many languages with no clean field separation. The multilingual tokenizer helps, but per-language fields are usually cleaner.</p><p>• When the knowledge base is a few hundred documents. A single BM25 leg over a text index is often enough, and the dense leg adds an embedding dependency for little gain.</p><h3>9. Production checklist</h3><p>1. Create text indexes with an explicit tokenizer and scoring before ingest; keep prose and code in separate fields.</p><p>2. Migrating from sparse BM25: keep the same text processing (tokenizer, lowercasing, stemmer, stopwords) on the new index, then replace sparse queries with text queries. The payload does not need to be re-uploaded.</p><p>3. Build a small labelled set of past alerts and the documents that resolved them; measure recall@k per leg and after fusion before and after any tokenizer or k/b change.</p><p>4. Clusters with an api_key: 1.20 enforces it on internal peer traffic by default. Clusters with only read_only_api_key must set api_key (or enforce_internal_auth: false) before upgrading. Bind the internal port to a private address with cluster.p2p.host.</p><p>5. Ship audit logs to stdout or stderr if the platform collects container output.</p><p>6. Upgrade one minor version at a time (1.18.x → 1.19.x → 1.20.0).</p><p><strong>The on-call engineer typed getUserName. The postmortem says get_user_name.</strong></p><p><em>What native BM25 and a code-aware tokenizer in Qdrant 1.20 change for incident search, and what they do not.</em></p><p>Ask an on-call engineer how they search for prior incidents at 3 a.m. and the honest answer is: they paste the error. Not a question. Not a description. A fragment of a stack trace, a function name, maybe a service name. Then they scroll.</p><p>Most retrieval systems built for this are optimised for the opposite input. They embed the query, compare meaning, and do well on “payments failing during a card network outage.” They do badly on chargeWithRetry or KeyError: ‘display_name’, because identifiers and rare error strings are exactly what dense embeddings compress away.</p><p>So teams bolt on keyword search. And here is the part that rarely gets said out loud: the keyword half of a hybrid system has usually been the more fragile half.</p><h3>The quiet cost of sparse BM25</h3><p>Until now, getting BM25 ranking into a vector database meant converting text into sparse vectors. Every document went through an encoder at ingest. Every query went through the same encoder at search time. The average document length, a term in the BM25 formula, had to be computed by the team and was then frozen inside every stored vector.</p><p>That last detail is easy to skim past. It means the lexical scores were tied to the corpus as it looked on the day of encoding. An incident knowledge base is the opposite of static. Postmortems get longer after review, runbooks get rewritten, new services appear. Either the sparse vectors were periodically rebuilt, or the scoring slowly drifted from what BM25 is supposed to compute. Most teams, in practice, chose drift without knowing they had chosen it.</p><p>There was also the operational cost: one more model to version, one more service on the query path, one more place where ingest and query could disagree about tokenization.</p><h3>What 1.20 moves into the index</h3><p>Qdrant 1.20 computes BM25 directly on a full-text payload index. You create a text index on the field with scoring enabled, then query it with a text query and name the field in using. Qdrant derives the corpus statistics, including average document length, from the data itself. Text already in the payload becomes searchable once indexed, with no embedding step.</p><pre>PUT /collections/incident_kb/index<br>{ &quot;field_name&quot;: &quot;code&quot;,<br>  &quot;field_schema&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;tokenizer&quot;: &quot;code&quot;, &quot;scoring&quot;: { &quot;type&quot;: &quot;bm25&quot; } } }<br> <br>POST /collections/incident_kb/points/query<br>{ &quot;query&quot;: { &quot;text&quot;: &quot;getUserName&quot; }, &quot;using&quot;: &quot;code&quot;, &quot;limit&quot;: 5 }</pre><p>The BM25 parameters k and b move to the query. That sounds minor. It is not. It means a query against short log signatures and a query against long postmortems can use different length normalisation on the same index, and tuning stops being a reindexing exercise.</p><p>Because a text query is a first-class query, it slots into prefetch next to a dense vector query. Hybrid search becomes one request: dense, BM25 over prose, BM25 over code, fused with RRF.</p><h3>The tokenizer is the real story for this use case</h3><p>BM25 is only as good as the tokens it counts. The default word tokenizer splits on spaces and punctuation, so getUserName is one token. A responder searching get_user_name or user name finds nothing.</p><p>The new code tokenizer splits identifiers on underscores and case changes, including acronyms. XMLHttpRequest becomes xml, http, request. Digits stay attached, so utf8, k8s and sha256 survive intact. For camelCase words it also indexes the joined form, so a lowercase hashmap finds HashMap.</p><p>In a small reference run against a local 1.20.0 server, those behaviours held exactly. A camelCase query ranked a snake_case Python traceback first. xml http request found a TypeScript line containing new XMLHttpRequest(). Nothing about that is impressive in isolation; grep can do it with enough regex. What matters is that it now happens inside a ranked, filterable, fusable retrieval system, which grep is not.</p><h3>Where I would be careful</h3><p>Three things deserve more attention than release notes give them.</p><p><strong>Split prose and code.</strong> One tokenizer per text index. Stemming helps runbook prose, where <em>timeouts</em> should match <em>timeout</em>, and it actively harms identifiers. Two fields, two indexes, two BM25 legs. The cost is some memory; a scoring-enabled index stores document lengths and term frequencies.</p><p><strong>Fusion inherits every leg’s mistakes.</strong> In the reference run, a payments-filtered hybrid query ranked a ledger lock-contention postmortem above the acquirer timeout runbook. The cause was the dense leg, a deliberately crude offline embedder, rewarding the shared word <em>payment</em>. With a real model the ordering would differ, but the lesson does not: RRF combines ranks, not confidence, and a weak leg can promote a weak document. Measure each leg separately before trusting the fused list.</p><p><strong>Live statistics mean moving scores.</strong> The fix for frozen average length is that scores now track the corpus. The same query will score differently next month. Any alerting logic that thresholds on a BM25 score is now quietly wrong. Use rank, or a reranker, not absolute values.</p><h3>What this does not replace</h3><p>Native BM25 replaces BM25-as-sparse-vectors. It does not replace learned sparse models such as SPLADE or miniCOIL, which weight terms using a trained model rather than corpus counts. If the lexical leg already uses a learned sparse model and it is earning its keep, nothing here obliges a change. Sparse BM25 also remains supported, and migrating to the full-text index does not require re-uploading data, only matching the text processing settings.</p><p>There is a smaller practical limit. qdrant-client’s local mode supports text queries only with default tokenization, so a test suite that runs in local mode will not exercise the code tokenizer. That gap shows up in CI, not in production, which is the worst place for it to hide.</p><h3>A question worth sitting with</h3><p>For years the industry framed hybrid search as “vectors plus a bit of keyword.” Incident data suggests the weighting is backwards. The input is mostly identifiers and error strings, and meaning is the fallback for when the exact token is not in the corpus.</p><p>If the lexical side is now the cheaper, simpler, statistically honest half of the system, it is fair to ask which leg should be the default, and which one has to prove it belongs.</p><h3>References</h3><p>• Qdrant 1.20 — Full-Text Search Improvements, Qdrant blog, 22 Oct 2026. <a href="https://qdrant.tech/blog/qdrant-1.20.x/">https://qdrant.tech/blog/qdrant-1.20.x/</a></p><p>• Qdrant documentation, Indexing: BM25 scoring, tokenizers, code tokenizer. <a href="https://qdrant.tech/documentation/manage-data/indexing/">https://qdrant.tech/documentation/manage-data/indexing/</a></p><p>• Qdrant documentation, Hybrid Search with BM25 full-text search. <a href="https://qdrant.tech/documentation/search/text-search/hybrid-search/">https://qdrant.tech/documentation/search/text-search/hybrid-search/</a></p><ul><li>qdrant-client v1.20.0 release notes. <a href="https://github.com/qdrant/qdrant-client/releases/tag/v1.20.0">https://github.com/qdrant/qdrant-client/releases/tag/v1.20.0</a></li></ul><h3>Appendix A. Reference script</h3><p>uc1_incident_search.py, run against Qdrant 1.20.0 with qdrant-client 1.20.0. Replace embed() with a real embedding model before drawing any conclusions about the dense leg.</p><pre>&quot;&quot;&quot;<br>Use case : Incident diagnosis search on Qdrant 1.20<br>- BM25 on a full-text payload index (no sparse vectors)<br>- code tokenizer for stack traces / identifiers<br>- hybrid: dense prefetch + BM25 prefetch, fused with RRF<br>- substring match on file paths<br>The dense embedder here is a deterministic hashing stand-in so the script runs<br>offline. Swap embed() for a real model in practice.<br>&quot;&quot;&quot;<br>import hashlib, re, time<br>import numpy as np<br>from qdrant_client import QdrantClient, models<br> <br>import os<br>URL = os.environ.get(&quot;QDRANT_URL&quot;, &quot;http://localhost:6333&quot;)<br>COL = &quot;incident_kb&quot;<br>DIM = 256<br> <br>def embed(text: str) -&gt; list[float]:<br>    v = np.zeros(DIM, dtype=np.float32)<br>    for tok in re.findall(r&quot;[a-z0-9]+&quot;, text.lower()):<br>        for n in (tok[:4], tok):              # crude sub-word sharing<br>            h = int(hashlib.md5(n.encode()).hexdigest(), 16)<br>            v[h % DIM] += 1.0 if (h &gt;&gt; 8) &amp; 1 else -1.0<br>    n = np.linalg.norm(v)<br>    return (v / n if n else v).tolist()<br> <br>DOCS = [<br>    dict(kind=&quot;postmortem&quot;, service=&quot;payments&quot;, path=&quot;services/payments/retry.py&quot;,<br>         title=&quot;Payment retries exhausted during card network brownout&quot;,<br>         body=&quot;Upstream card network timed out. Retry budget exhausted; customers saw duplicate charge warnings. Mitigation: circuit breaker on acquirer client.&quot;,<br>         code=&quot;def chargeWithRetry(order): raise RetryBudgetExceeded&quot;),<br>    dict(kind=&quot;runbook&quot;, service=&quot;payments&quot;, path=&quot;runbooks/payments/acquirer-timeout.md&quot;,<br>         title=&quot;Runbook: acquirer timeout spike&quot;,<br>         body=&quot;Check acquirer latency dashboard. If p99 above 2s, enable fallback acquirer and reduce retry_budget.&quot;,<br>         code=&quot;set_retry_budget(service=&#39;payments&#39;, value=2)&quot;),<br>    dict(kind=&quot;postmortem&quot;, service=&quot;auth&quot;, path=&quot;services/auth/session_store.go&quot;,<br>         title=&quot;Login failures after Redis failover&quot;,<br>         body=&quot;Session store lost connection after primary failover. Clients kept stale DNS. Fix: lower DNS TTL and add reconnect jitter.&quot;,<br>         code=&quot;func getUserSession(ctx context.Context, userID string) (*Session, error)&quot;),<br>    dict(kind=&quot;log_signature&quot;, service=&quot;auth&quot;, path=&quot;services/auth/user_lookup.py&quot;,<br>         title=&quot;KeyError in get_user_name during profile render&quot;,<br>         body=&quot;Profile page fails when legacy accounts have no display name field.&quot;,<br>         code=&quot;File &#39;user_lookup.py&#39;, line 88, in get_user_name\nKeyError: &#39;display_name&#39;&quot;),<br>    dict(kind=&quot;postmortem&quot;, service=&quot;search&quot;, path=&quot;services/search/indexer/HashMapCache.java&quot;,<br>         title=&quot;Search indexer OOM from unbounded cache&quot;,<br>         body=&quot;An unbounded in-memory cache grew until the JVM ran out of heap during reindex.&quot;,<br>         code=&quot;private final HashMap&lt;String, Doc&gt; docCache = new HashMap&lt;&gt;();&quot;),<br>    dict(kind=&quot;runbook&quot;, service=&quot;search&quot;, path=&quot;runbooks/search/reindex.md&quot;,<br>         title=&quot;Runbook: safe full reindex&quot;,<br>         body=&quot;Drain writes, snapshot the collection, run reindex job with bounded batch size, compare counts before switching alias.&quot;,<br>         code=&quot;reindex --batch-size 500 --verify-counts&quot;),<br>    dict(kind=&quot;log_signature&quot;, service=&quot;gateway&quot;, path=&quot;services/gateway/XMLHttpRequestShim.ts&quot;,<br>         title=&quot;Gateway 502 from XMLHttpRequest shim on large uploads&quot;,<br>         body=&quot;Legacy shim buffers whole body in memory; large uploads time out at the gateway.&quot;,<br>         code=&quot;const xhr = new XMLHttpRequest(); xhr.timeout = 30000;&quot;),<br>    dict(kind=&quot;postmortem&quot;, service=&quot;payments&quot;, path=&quot;services/payments/ledger/writer.py&quot;,<br>         title=&quot;Ledger writes delayed by lock contention&quot;,<br>         body=&quot;Month-end batch held row locks; real-time payment confirmations queued behind it.&quot;,<br>         code=&quot;with ledger.lock(account_id): write_entry(entry)&quot;),<br>]<br> <br>def main():<br>    c = QdrantClient(url=URL, timeout=60)<br>    if c.collection_exists(COL):<br>        c.delete_collection(COL)<br>    c.create_collection(COL, vectors_config={<br>        &quot;dense&quot;: models.VectorParams(size=DIM, distance=models.Distance.COSINE)})<br> <br>    # Payload indexes first, before ingest<br>    c.create_payload_index(COL, &quot;body&quot;, field_schema=models.TextIndexParams(<br>        type=models.TextIndexType.TEXT, tokenizer=models.TokenizerType.WORD,<br>        lowercase=True,<br>        stemmer=models.SnowballParams(type=models.Snowball.SNOWBALL,<br>                                      language=models.SnowballLanguage.ENGLISH),<br>        scoring=models.TextScoringParams(type=models.TextScoringType.BM25)), wait=True)<br>    c.create_payload_index(COL, &quot;code&quot;, field_schema=models.TextIndexParams(<br>        type=models.TextIndexType.TEXT, tokenizer=models.TokenizerType.CODE,<br>        lowercase=True,<br>        scoring=models.TextScoringParams(type=models.TextScoringType.BM25)), wait=True)<br>    c.create_payload_index(COL, &quot;service&quot;, field_schema=models.PayloadSchemaType.KEYWORD, wait=True)<br>    c.create_payload_index(COL, &quot;path&quot;, field_schema=models.KeywordIndexParams(<br>        type=models.KeywordIndexType.KEYWORD, prefix=True), wait=True)<br> <br>    c.upsert(COL, points=[models.PointStruct(<br>        id=i + 1, vector={&quot;dense&quot;: embed(d[&quot;title&quot;] + &quot; &quot; + d[&quot;body&quot;])}, payload=d)<br>        for i, d in enumerate(DOCS)], wait=True)<br> <br>    def show(label, res):<br>        print(f&quot;\n== {label}&quot;)<br>        for p in res.points:<br>            print(f&quot;  {p.score:7.4f}  [{p.payload[&#39;service&#39;]}] {p.payload[&#39;title&#39;]}&quot;)<br> <br>    # 1. BM25 over prose, straight from the payload<br>    show(&quot;BM25 body: &#39;acquirer timeout retry&#39;&quot;,<br>         c.query_points(COL, query=models.TextQuery(text=&quot;acquirer timeout retry&quot;),<br>                        using=&quot;body&quot;, limit=3, with_payload=True))<br> <br>    # 2. Code tokenizer: one spelling finds the others<br>    for q in [&quot;getUserName&quot;, &quot;user name&quot;, &quot;hashmap&quot;, &quot;xml http request&quot;]:<br>        show(f&quot;BM25 code (code tokenizer): &#39;{q}&#39;&quot;,<br>             c.query_points(COL, query=models.TextQuery(text=q), using=&quot;code&quot;,<br>                            limit=3, with_payload=True))<br> <br>    # 3. Hybrid: dense + BM25(body) + BM25(code), RRF, filtered to one service<br>    alert = &quot;card payments failing with timeouts, retries exhausted, chargeWithRetry errors&quot;<br>    show(&quot;Hybrid RRF (dense + body + code), service=payments&quot;,<br>         c.query_points(COL,<br>            prefetch=[<br>                models.Prefetch(query=embed(alert), using=&quot;dense&quot;, limit=20),<br>                models.Prefetch(query=models.TextQuery(text=alert), using=&quot;body&quot;, limit=20),<br>                models.Prefetch(query=models.TextQuery(text=alert), using=&quot;code&quot;, limit=20),<br>            ],<br>            query=models.FusionQuery(fusion=models.Fusion.RRF),<br>            query_filter=models.Filter(must=[models.FieldCondition(<br>                key=&quot;service&quot;, match=models.MatchValue(value=&quot;payments&quot;))]),<br>            limit=3, with_payload=True))<br> <br>    # 4. Per-query BM25 tuning (k1/b) without reindexing<br>    show(&quot;BM25 body with k=1.2, b=0.3&quot;,<br>         c.query_points(COL, query=models.TextQuery(text=models.TextQueryInput(<br>             query=&quot;cache heap memory&quot;,<br>             scoring=models.Bm25Scoring(bm25=models.Bm25Params(k=1.2, b=0.3)))),<br>             using=&quot;body&quot;, limit=3, with_payload=True))<br> <br>    # 5. Substring match on file paths (keyword index)<br>    res, _ = c.scroll(COL, scroll_filter=models.Filter(must=[models.FieldCondition(<br>        key=&quot;path&quot;, match=models.MatchSubstring(substring=&quot;/ledger/&quot;))]), with_payload=True)<br>    print(&quot;\n== Substring &#39;/ledger/&#39; on path&quot;)<br>    for p in res:<br>        print(&quot;  &quot;, p.payload[&quot;path&quot;])<br> <br>    info = c.get_collection(COL)<br>    print(&quot;\ncreated_at:&quot;, getattr(info, &quot;created_at&quot;, None))<br>    print(&quot;points:&quot;, info.points_count)<br> <br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48bb32982e42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-Seller Marketplace Search on Qdrant 1.20]]></title>
            <link>https://medium.com/@parichaydas/bm25-7a5d61fdf418?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a5d61fdf418</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 18:20:33 GMT</pubDate>
            <atom:updated>2026-10-31T17:59:08.006Z</atom:updated>
            <content:encoded><![CDATA[<p>Per-element nested indexes, per-offer BM25, turbo8 vectors and ID tracker tiers</p><h3>1. The problem</h3><p>A marketplace lists one product and many offers for it. Each offer has its own seller, price, stock state, condition and description. Shoppers filter on offer attributes and expect them to hold together: “new, in stock, from shop 03, under 400” means one offer that is all of those things, not a product where one offer is new and a different one is cheap.</p><p>Qdrant models this with a nested filter over an array of objects. The semantics were always correct. The cost was the problem. Regular payload indexes on offers[].shop and offers[].price record that a value occurs somewhere in a product’s offers, not which offer holds it. They can only narrow candidates. Qdrant then read each remaining candidate’s payload, often from disk, to check the conditions offer by offer.</p><p>Qdrant 1.20 adds a nested parameter to every payload index type. It creates a per-element index that stores each array element separately. When every condition in a nested filter is backed by a per-element index on the same array, the filter is answered from the indexes alone, without reading payloads.</p><h3>2. Features used</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDsjFc4Wuawi4BBuxmu7zQ.png" /></figure><h3>3. Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4KC4C9tmy94oCapfdnijQ.png" /><figcaption><em>Figure 1. Two-stage query. Stage 1 narrows by vector similarity and per-offer constraints; stage 2 ranks the survivors by per-offer BM25.</em></figcaption></figure><p>Stage 1 is a prefetch: approximate nearest-neighbour search over turbo8 vectors with the nested filter applied during traversal. Stage 2 rescores at most 50 candidates with a BM25 text query over offers[].description. The payload is read once, at the end, to render results. The ID tracker sits on the lookup path for every returned point; at about 52 bytes per point, per the release post, it becomes a real line item only at large scale.</p><h3>4. Collection and index design</h3><h3>4.1 Payload shape</h3><pre>{ &quot;title&quot;: &quot;product 13752&quot;,<br>  &quot;offers&quot;: [<br>    { &quot;shop&quot;: &quot;shop_03&quot;, &quot;price&quot;: 214.5, &quot;in_stock&quot;: true,<br>      &quot;condition&quot;: &quot;new&quot;, &quot;description&quot;: &quot;extended warranty express box&quot; },<br>    { &quot;shop&quot;: &quot;shop_17&quot;, &quot;price&quot;: 189.0, &quot;in_stock&quot;: false,<br>      &quot;condition&quot;: &quot;used&quot;, &quot;description&quot;: &quot;local pickup gift wrap&quot; } ] }</pre><h3>4.2 Collection: turbo8 vectors, ID tracker tier</h3><pre>client.create_collection(<br>    &quot;marketplace&quot;,<br>    vectors_config=models.VectorParams(size=384, distance=models.Distance.COSINE,<br>                                       datatype=models.Datatype.TURBO8),<br>    id_tracker=models.IdTrackerParams(memory=models.Memory.COLD),<br>)</pre><p>turbo8 takes regular float vectors and quantises them on the server, unlike uint8, which expects the client to supply 8-bit integers. Setting the ID tracker to cold is only worth it when RAM is the binding constraint; pinned remains the default for a reason.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ewcnIJjmPuQ6OzbVUuAAcg.png" /><figcaption><em>Figure 2. Collection info in the Qdrant 1.20 Web UI (local demo). The legacy on_disk and on_disk_payload fields are flagged as deprecated in favour of the memory tier parameter used above.</em></figcaption></figure><h3>4.3 Per-element indexes, created before ingest</h3><pre>NEST = &quot;offers&quot;<br>client.create_payload_index(&quot;marketplace&quot;, &quot;offers[].shop&quot;,<br>    field_schema=models.KeywordIndexParams(type=models.KeywordIndexType.KEYWORD, nested=NEST))<br>client.create_payload_index(&quot;marketplace&quot;, &quot;offers[].price&quot;,<br>    field_schema=models.FloatIndexParams(type=models.FloatIndexType.FLOAT, nested=NEST))<br>client.create_payload_index(&quot;marketplace&quot;, &quot;offers[].in_stock&quot;,<br>    field_schema=models.BoolIndexParams(type=models.BoolIndexType.BOOL, nested=NEST))<br>client.create_payload_index(&quot;marketplace&quot;, &quot;offers[].condition&quot;,<br>    field_schema=models.KeywordIndexParams(type=models.KeywordIndexType.KEYWORD, nested=NEST))<br>client.create_payload_index(&quot;marketplace&quot;, &quot;offers[].description&quot;,<br>    field_schema=models.TextIndexParams(type=models.TextIndexType.TEXT,<br>        tokenizer=models.TokenizerType.WORD,<br>        scoring=models.TextScoringParams(type=models.TextScoringType.BM25),<br>        nested=NEST))</pre><p><em>All conditions in the nested filter must be on fields with a per-element index on the same array, or Qdrant falls back to reading payloads. Leaving one field on a regular index silently removes most of the gain.</em></p><h3>5. Queries</h3><h3>5.1 The nested filter</h3><p>The search API does not change. Existing nested filters get faster once the per-element indexes exist.</p><pre>def offer_filter(shop, max_price, condition):<br>    return models.Filter(must=[models.NestedCondition(nested=models.Nested(<br>        key=&quot;offers&quot;, filter=models.Filter(must=[<br>            models.FieldCondition(key=&quot;shop&quot;, match=models.MatchValue(value=shop)),<br>            models.FieldCondition(key=&quot;price&quot;, range=models.Range(lt=max_price)),<br>            models.FieldCondition(key=&quot;in_stock&quot;, match=models.MatchValue(value=True)),<br>            models.FieldCondition(key=&quot;condition&quot;, match=models.MatchValue(value=condition)),<br>        ])))])</pre><h3>5.2 Vector prefetch, per-offer BM25 rescoring</h3><pre>client.query_points(&quot;marketplace&quot;,<br>    prefetch=models.Prefetch(query=query_vector,<br>                             filter=offer_filter(&quot;shop_03&quot;, 400, &quot;new&quot;), limit=50),<br>    query=models.TextQuery(text=&quot;warranty express&quot;),<br>    using=&quot;offers[].description&quot;,<br>    limit=5)</pre><h3>5.3 Keep filter and score on the same offer</h3><p>Section 6 shows why 5.2 is not enough. The fix is to put the text condition inside the nested filter, so the offer that satisfies shop, price, stock and condition must also contain the term.</p><pre>f = offer_filter(&quot;shop_03&quot;, 400, &quot;new&quot;)<br>f.must[0].nested.filter.must.append(<br>    models.FieldCondition(key=&quot;description&quot;, match=models.MatchText(text=&quot;warranty&quot;)))<br>client.query_points(&quot;marketplace&quot;,<br>    prefetch=models.Prefetch(query=query_vector, filter=f, limit=50),<br>    query=models.TextQuery(text=&quot;warranty express&quot;),<br>    using=&quot;offers[].description&quot;, limit=5)</pre><h3>6. Observed results</h3><p>The script in Appendix A was run against a local Qdrant 1.20.0 server in a single-node sandbox. Data is synthetic: 50,000 products, 1 to 6 offers each, 40 shops, 384-dimensional vectors drawn around 64 random cluster centres. Treat the numbers as a smoke test of the mechanism, not a benchmark.</p><h3>6.1 Correctness</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5zStDixyg5WzwrkoUW9_g.png" /></figure><h3>6.2 Filter latency</h3><p>Median of exact count calls over the three filters, five repetitions each after warm-up, in two separate runs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uqLnBpdngjBZFzJJAwZEtA.png" /></figure><p>Qdrant reports 7 to 38 times on 100,000 points across three nested filters, with every payload already in memory. The sandbox figure is lower and sits in a narrower setup: half the points, a warm page cache, and count queries that include HTTP round-trip time. The direction agrees. The magnitude should come from your own data.</p><p>A separate local feature demo (Docker, port 16335) ran the same 1.20 features on small hand-built collections. Its nested-filter check used a two-point products collection that appears to mirror the release post’s example, and it returned the expected product ID 9: the only product with a single offer that satisfies both conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFG3dZDyJjzkUihLPxNH7w.png" /><figcaption><em>Figure 3. Demo summary from the local run: nested filter with per-element indexes, turbo16/turbo8 datatypes, bits8 quantisation, recall check and memory tiers all reported OK.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRLU-Wuo6_lfbf-6u-_Uaw.png" /><figcaption><em>Figure 4. Demo collections in the Web UI. products holds the nested-filter test; tiers the memory-tier configuration; vec_bits8 the bits8 TurboQuant quantisation test.</em></figcaption></figure><h3>6.3 The scoring mismatch</h3><p>Query 5.2 returned five products, all with the same BM25 score of 2.503. Two of them had a shop_03 offer with no mention of warranty or express. Inspecting product 21208 showed why:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5z7fMLdvi-uErYZ8jiaepg.png" /><figcaption><em>Figure 5. The filter is satisfied by one offer; the BM25 score comes from another.</em></figcaption></figure><p>This is documented behaviour, not a bug. With BM25 on a per-element index, each element is scored separately and the point takes its best element’s score. The nested filter guarantees that some offer satisfies the constraints. Nothing ties the scored offer to the filtered one. After moving the text condition inside the nested filter (5.3), all five results had a shop_03 offer containing <em>warranty</em>.</p><p>A residual gap remains. Another offer on the same product can still contain more of the query terms and set the score. Removing that gap completely needs one point per offer, discussed in Part B.</p><h3>6.4 turbo8 recall</h3><p>Exact search on a turbo8 collection, compared with exact float32 ground truth computed in NumPy, over 100 perturbed queries: <strong>recall@10 = 0.964</strong>. Exact search was used on both sides to isolate quantisation error from HNSW error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAYCN8v7nKMqDz3GBYZc-g.png" /><figcaption><em>Figure 6. The recall-check collections from the local demo: 50 points each, 8 dimensions, one collection per datatype (float32, turbo16, turbo8).</em></figcaption></figure><p>An earlier synthetic run of the same feature recorded recall@10 of 0.80 against float32. The two figures are not in conflict. Recall on synthetic vectors depends heavily on how the vectors are generated; uniform random vectors have almost no neighbourhood structure and punish any quantiser. The demo collections in Figure 6 also explain part of the gap: with 8-dimensional vectors and 50 points, one swapped neighbour moves recall@10 by 0.1, and quantisation error weighs more on few dimensions than on several hundred. Neither number predicts recall on a real embedding model. Qdrant’s own benchmark across 11 real datasets is the better prior: turbo8 close to float16 at half the size, and higher recall than scalar quantisation with rescoring on 10 of 11 datasets.</p><h3>7. Failure modes and limits</h3><p>• <strong>One array level.</strong> nested cannot point to an array inside another array (a[].b[]). Deeper models need flattening.</p><p>• <strong>Not combinable with tenant or principal indexes.</strong> A per-element index cannot also be is_tenant or is_principal. Multi-tenant marketplaces need a separate tenant field at the point level.</p><p>• <strong>`is_empty` changes meaning.</strong> On a per-element index, is_empty matches a point if any element lacks the field, and never matches a point without elements. With a regular index it matches only if no element has the field. Audit existing filters before switching.</p><p>• <strong>Text match is per element.</strong> match: { text: “red shoes” } no longer matches a product with <em>red</em> in one offer and <em>shoes</em> in another. That is usually what a shopper means, and it can still break existing queries.</p><p>• <strong>BM25 statistics are per element.</strong> Average document length becomes average offer description length. Scores are not comparable with a product-level text index.</p><p>• <strong>Changing `nested` rebuilds the index.</strong> Plan it as a migration.</p><p>• <strong>ID tracker `cold` adds lookup I/O.</strong> Every returned point resolves through it. On slow or network storage this shows up directly in tail latency.</p><h3>8. When not to use this design</h3><p>• When offers are ranked independently, such as a price-comparison page listing offers rather than products. Model one point per offer and group by product instead; filter and score then refer to the same object by construction.</p><p>• When products rarely have more than one offer. Per-element indexes add storage for no semantic gain.</p><p>• When the collection fits comfortably in RAM. Keep the ID tracker pinned and prefer turbo16 or float32 vectors unless storage cost is the actual constraint.</p><h3>9. Production checklist</h3><p>1. Create every per-element index before ingest, on every field the nested filter touches.</p><p>2. Diff query results between the old and new indexes for any filter using is_empty or multi-word text match.</p><p>3. Put text conditions inside the nested filter when the score must describe the filtered offer.</p><p>4. Benchmark turbo8 against your own embeddings with exact search first, then with HNSW at production hnsw_ef.</p><p>5. Inline storage users: in 1.20 original vectors follow hnsw_config.memory, not vectors.memory. Set the HNSW and quantisation tiers explicitly before upgrading or expect a RAM change.</p><p>6. Move the ID tracker to cached before cold, and watch p99 lookup latency.</p><p><strong>Nested filters fixed one bug. Scoring can bring it back.</strong></p><p><em>Per-element indexes in Qdrant 1.20 make marketplace filters fast. They also make it easier to rank the wrong offer. Both facts matter.</em></p><p>Every marketplace search engineer meets the same bug early. A shopper asks for a new item under 400 from a particular seller, and the result is a product where the seller’s offer is used and a different seller’s offer is cheap. The product matches all conditions. No single offer does.</p><p>Nested filters exist to stop that. In Qdrant, a nested condition over offers checks that one element of the array satisfies every clause. The semantics have been right for a long time. Speed is what 1.20 changes.</p><h3>Why nested filters were slow</h3><p>A regular payload index on offers[].shop answers one question: which products have this shop in any offer. An index on offers[].price answers the same for prices. Neither remembers which offer a value came from. Together they can shrink the candidate set, but they cannot prove a match. Qdrant had to open each surviving product’s payload, often from disk, and walk its offers.</p><p>That made filter cost proportional to how many products loosely match, which in a marketplace is a lot. Popular shops have offers on most products. Price ranges are wide. The narrowing step barely narrows.</p><p>The 1.20 answer is the per-element index: a nested parameter on every payload index type, so each offer is indexed as its own entry. If every condition in the nested filter uses a per-element index on the same array, the filter is answered from indexes alone and payloads are never read for it. The API does not change. Existing filters speed up once the indexes are created.</p><p>Qdrant measured 7 to 38 times faster on 100,000 points with three nested filters, with payloads already in memory, which is the best case for the old path. A small sandbox run on 50,000 synthetic products came out at roughly 4.6 to 5.5 times on warm data with HTTP overhead included. Lower, same direction, and with the expected caveat that real gains depend on how selective the filters are and where payloads live.</p><h3>The part the release notes do not dramatise</h3><p>Per-element indexing also applies to full-text indexes, and those can now score with BM25. Index offers[].description with nested: “offers” and each offer description becomes its own document. A product takes the score of its best-matching offer.</p><p>Now combine the two in the obvious way. Prefetch candidates with a vector query and the nested filter. Rescore them with a BM25 query over offer descriptions. It looks correct. It is subtly not.</p><p>In the sandbox, a query for shop 03, new, in stock, under 400, rescored by <em>warranty express</em>, returned products whose shop 03 offer said “bundle shipping gift box”. The score had come from a different seller’s offer on the same product. The filter guaranteed that some offer was valid. The score described some other offer.</p><p>That is the original nested-filter bug, moved one layer up, from filtering into ranking. Nothing in the engine is wrong. Filter and score are separate operations, each correct on its own terms, and the system has no way to know you meant them to refer to the same element.</p><h3>Three ways out, with different costs</h3><p><strong>Push the text condition into the nested filter.</strong> Add a full-text match on description inside the nested clause, so the offer that satisfies seller, price, stock and condition must also contain the term. In the sandbox this turned every returned product into one with a matching shop 03 offer. The gap that remains: another offer on the same product can still have a higher BM25 score and set the product’s rank.</p><p><strong>Model offers as points.</strong> One point per offer, product ID in the payload, group by product at query time. Filter and score now refer to the same object by construction. The cost is more points, duplicated product vectors or a separate product lookup, and a grouping step.</p><p><strong>Accept product-level relevance.</strong> Sometimes “this product has a good offer and some offer mentions warranty” is the right semantics. Category pages often work like this. Make it a decision rather than an accident.</p><p>The first option is cheap and covers most cases. The second is the honest data model if offers compete on their own merits, as on a price-comparison page.</p><h3>Storage moves in the same release</h3><p>Catalogues are large, and two 1.20 changes target their memory bill.</p><p>The new turbo8 datatype stores 1 byte per dimension and accepts ordinary float vectors, quantising them server-side. Qdrant’s benchmark across 11 datasets puts its recall close to float16 at half the size, and above scalar quantisation with rescoring on 10 of 11 datasets while storing about a fifth of the bytes. The sandbox measured recall@10 of 0.964 against exact float32 on clustered synthetic data. An earlier synthetic test of the same datatype recorded 0.80. The difference is a lesson about synthetic data, not about turbo8: random vectors with weak neighbourhood structure punish any quantiser. Measure on your own embeddings.</p><p>The ID tracker, which maps each point ID to its internal location and version, can now leave RAM. Qdrant puts it at about 52 bytes per point, roughly 5 GB at 100 million points. cold keeps it on disk and reads on demand, cached warms the page cache when a segment opens. For a catalogue at that scale, 5 GB is a meaningful slice of a node. For most catalogues it is not, and pinned should stay.</p><h3>Before switching</h3><p>Per-element indexes change two behaviours that existing queries may rely on. is_empty now matches a product if any offer lacks the field, instead of only when none has it. Multi-word text matches must occur in a single offer. Both are arguably more correct for marketplaces. Both can still break a dashboard that has been quietly depending on the old semantics. Diff results before cutting over.</p><p>There are hard limits too. Only one array level is supported, and a per-element index cannot double as a tenant or principal index.</p><h3>The broader point</h3><p>Arrays of objects are where document-shaped data meets retrieval systems built for flat records. Per-element indexes close the performance gap for filtering. They do not close the semantic gap between “some element passed” and “this element is why the result ranks here.”</p><p>That gap exists in every engine that filters and scores in separate passes. Qdrant 1.20 makes it cheaper to hit, which is a good reason to decide, explicitly, which element a result is supposed to be about.</p><h3>References</h3><p>• Qdrant 1.20 — Full-Text Search Improvements, Qdrant blog, 22 Oct 2026. <a href="https://qdrant.tech/blog/qdrant-1.20.x/">https://qdrant.tech/blog/qdrant-1.20.x/</a></p><p>• Qdrant documentation, Indexing: per-element index for arrays of objects. <a href="https://qdrant.tech/documentation/manage-data/indexing/">https://qdrant.tech/documentation/manage-data/indexing/</a></p><p>• Qdrant documentation, Memory Tiers (ID tracker, inline storage). <a href="https://qdrant.tech/documentation/ops-configuration/memory-tiers/">https://qdrant.tech/documentation/ops-configuration/memory-tiers/</a></p><ul><li>qdrant-client v1.20.0 release notes. <a href="https://github.com/qdrant/qdrant-client/releases/tag/v1.20.0">https://github.com/qdrant/qdrant-client/releases/tag/v1.20.0</a></li></ul><h3>Appendix A. Reference script</h3><p>uc2_marketplace.py, run against Qdrant 1.20.0 with qdrant-client 1.20.0. Builds three collections of 50,000 synthetic products; allow several minutes.</p><pre>&quot;&quot;&quot;<br>Use case : Multi-seller marketplace catalog on Qdrant 1.20<br>- per-element (nested) payload indexes on offers[]<br>- nested filter answered from indexes vs. regular indexes + payload reads<br>- per-offer BM25 on offers[].description<br>- turbo8 datatype vs float32, id_tracker memory tier<br>Synthetic data; numbers measure this sandbox only.<br>&quot;&quot;&quot;<br>import random, statistics, time<br>import numpy as np<br>from qdrant_client import QdrantClient, models<br> <br>import os<br>URL = os.environ.get(&quot;QDRANT_URL&quot;, &quot;http://localhost:6333&quot;)<br>N = 50_000<br>DIM = 384<br>SHOPS = [f&quot;shop_{i:02d}&quot; for i in range(40)]<br>CONDITIONS = [&quot;new&quot;, &quot;refurbished&quot;, &quot;used&quot;]<br>WORDS = [&quot;fast&quot;, &quot;shipping&quot;, &quot;warranty&quot;, &quot;bundle&quot;, &quot;original&quot;, &quot;box&quot;, &quot;sealed&quot;,<br>         &quot;express&quot;, &quot;gift&quot;, &quot;wrap&quot;, &quot;extended&quot;, &quot;support&quot;, &quot;local&quot;, &quot;pickup&quot;]<br>rng = random.Random(7)<br>np_rng = np.random.default_rng(7)<br> <br>def make_offers():<br>    out = []<br>    for _ in range(rng.randint(1, 6)):<br>        out.append({<br>            &quot;shop&quot;: rng.choice(SHOPS),<br>            &quot;price&quot;: round(rng.uniform(20, 600), 2),<br>            &quot;in_stock&quot;: rng.random() &lt; 0.7,<br>            &quot;condition&quot;: rng.choice(CONDITIONS),<br>            &quot;description&quot;: &quot; &quot;.join(rng.sample(WORDS, 4)),<br>        })<br>    return out<br> <br># clustered vectors so recall is not trivially flat<br>centers = np_rng.normal(size=(64, DIM)).astype(np.float32)<br>assign = np_rng.integers(0, 64, size=N)<br>VEC = centers[assign] + 0.35 * np_rng.normal(size=(N, DIM)).astype(np.float32)<br>VEC /= np.linalg.norm(VEC, axis=1, keepdims=True)<br>PAYLOADS = [{&quot;title&quot;: f&quot;product {i}&quot;, &quot;offers&quot;: make_offers()} for i in range(N)]<br> <br>def build(c, name, nested: bool, datatype=models.Datatype.FLOAT32, id_mem=None):<br>    if c.collection_exists(name):<br>        c.delete_collection(name)<br>    c.create_collection(<br>        name,<br>        vectors_config=models.VectorParams(size=DIM, distance=models.Distance.COSINE,<br>                                           datatype=datatype),<br>        id_tracker=models.IdTrackerParams(memory=id_mem) if id_mem else None,<br>    )<br>    nest = &quot;offers&quot; if nested else None<br>    c.create_payload_index(name, &quot;offers[].shop&quot;, field_schema=models.KeywordIndexParams(<br>        type=models.KeywordIndexType.KEYWORD, nested=nest), wait=True)<br>    c.create_payload_index(name, &quot;offers[].price&quot;, field_schema=models.FloatIndexParams(<br>        type=models.FloatIndexType.FLOAT, nested=nest), wait=True)<br>    c.create_payload_index(name, &quot;offers[].in_stock&quot;, field_schema=models.BoolIndexParams(<br>        type=models.BoolIndexType.BOOL, nested=nest), wait=True)<br>    c.create_payload_index(name, &quot;offers[].condition&quot;, field_schema=models.KeywordIndexParams(<br>        type=models.KeywordIndexType.KEYWORD, nested=nest), wait=True)<br>    c.create_payload_index(name, &quot;offers[].description&quot;, field_schema=models.TextIndexParams(<br>        type=models.TextIndexType.TEXT, tokenizer=models.TokenizerType.WORD,<br>        scoring=models.TextScoringParams(type=models.TextScoringType.BM25),<br>        nested=nest), wait=True)<br>    c.upload_collection(name, vectors=VEC, payload=PAYLOADS, ids=list(range(N)),<br>                        batch_size=1000, wait=True)<br>    while c.get_collection(name).status != models.CollectionStatus.GREEN:<br>        time.sleep(1)<br> <br>def nested(shop, max_price, condition):<br>    return models.Filter(must=[models.NestedCondition(nested=models.Nested(<br>        key=&quot;offers&quot;, filter=models.Filter(must=[<br>            models.FieldCondition(key=&quot;shop&quot;, match=models.MatchValue(value=shop)),<br>            models.FieldCondition(key=&quot;price&quot;, range=models.Range(lt=max_price)),<br>            models.FieldCondition(key=&quot;in_stock&quot;, match=models.MatchValue(value=True)),<br>            models.FieldCondition(key=&quot;condition&quot;, match=models.MatchValue(value=condition)),<br>        ])))])<br> <br>def brute_force(shop, max_price, condition):<br>    return sum(1 for p in PAYLOADS if any(<br>        o[&quot;shop&quot;] == shop and o[&quot;price&quot;] &lt; max_price and o[&quot;in_stock&quot;] and o[&quot;condition&quot;] == condition<br>        for o in p[&quot;offers&quot;]))<br> <br>def time_filter(c, name, flts, reps=5):<br>    lat = []<br>    for _ in range(reps):<br>        for f in flts:<br>            t = time.perf_counter()<br>            c.count(name, count_filter=f, exact=True)<br>            lat.append((time.perf_counter() - t) * 1000)<br>    return statistics.median(lat)<br> <br>def main():<br>    c = QdrantClient(url=URL, timeout=300)<br>    print(f&quot;building collections with {N} products ...&quot;)<br>    build(c, &quot;mkt_regular&quot;, nested=False)<br>    build(c, &quot;mkt_per_element&quot;, nested=True)<br> <br>    # correctness: both answer the nested semantics; check against brute force<br>    cases = [(&quot;shop_03&quot;, 150, &quot;new&quot;), (&quot;shop_17&quot;, 300, &quot;refurbished&quot;), (&quot;shop_29&quot;, 80, &quot;used&quot;)]<br>    print(&quot;\n== nested filter correctness (count)&quot;)<br>    for s, p, cond in cases:<br>        f = nested(s, p, cond)<br>        r1 = c.count(&quot;mkt_regular&quot;, count_filter=f, exact=True).count<br>        r2 = c.count(&quot;mkt_per_element&quot;, count_filter=f, exact=True).count<br>        print(f&quot;  {s} &lt;{p} {cond}: regular={r1} per_element={r2} brute_force={brute_force(s, p, cond)}&quot;)<br> <br>    flts = [nested(s, p, cond) for s, p, cond in cases]<br>    for _ in range(2):  # warm-up<br>        time_filter(c, &quot;mkt_regular&quot;, flts, 1); time_filter(c, &quot;mkt_per_element&quot;, flts, 1)<br>    t_reg = time_filter(c, &quot;mkt_regular&quot;, flts)<br>    t_pe = time_filter(c, &quot;mkt_per_element&quot;, flts)<br>    print(f&quot;\n== median nested-filter count latency (this sandbox, {N} points)&quot;)<br>    print(f&quot;  regular indexes + payload check: {t_reg:.2f} ms&quot;)<br>    print(f&quot;  per-element indexes:             {t_pe:.2f} ms  (x{t_reg / t_pe:.1f})&quot;)<br> <br>    # filtered vector search + per-offer BM25 rescoring<br>    q = VEC[123].tolist()<br>    res = c.query_points(&quot;mkt_per_element&quot;,<br>        prefetch=models.Prefetch(query=q, filter=nested(&quot;shop_03&quot;, 400, &quot;new&quot;), limit=50),<br>        query=models.TextQuery(text=&quot;warranty express&quot;), using=&quot;offers[].description&quot;,<br>        limit=5, with_payload=True)<br>    print(&quot;\n== vector candidates (shop_03, new, &lt;400, in stock) re-scored by per-offer BM25&quot;)<br>    for p in res.points:<br>        best = [o for o in p.payload[&quot;offers&quot;] if o[&quot;shop&quot;] == &quot;shop_03&quot;]<br>        print(f&quot;  id={p.id} bm25={p.score:.3f} shop_03 offers: {[o[&#39;description&#39;] for o in best]}&quot;)<br> <br>    # same query, but the text condition goes INSIDE the nested filter,<br>    # so the matching shop_03 offer itself must mention warranty<br>    f = nested(&quot;shop_03&quot;, 400, &quot;new&quot;)<br>    f.must[0].nested.filter.must.append(models.FieldCondition(<br>        key=&quot;description&quot;, match=models.MatchText(text=&quot;warranty&quot;)))<br>    res = c.query_points(&quot;mkt_per_element&quot;,<br>        prefetch=models.Prefetch(query=q, filter=f, limit=50),<br>        query=models.TextQuery(text=&quot;warranty express&quot;), using=&quot;offers[].description&quot;,<br>        limit=5, with_payload=True)<br>    print(&quot;\n== same, with the text condition inside the nested filter&quot;)<br>    for p in res.points:<br>        best = [o for o in p.payload[&quot;offers&quot;] if o[&quot;shop&quot;] == &quot;shop_03&quot;]<br>        print(f&quot;  id={p.id} bm25={p.score:.3f} shop_03 offers: {[o[&#39;description&#39;] for o in best]}&quot;)<br> <br>    # turbo8 vs float32 recall@10 (exact search on both, so ANN error is excluded)<br>    build(c, &quot;mkt_turbo8&quot;, nested=True, datatype=models.Datatype.TURBO8,<br>          id_mem=models.Memory.COLD)<br>    qs = np_rng.choice(N, 100, replace=False)<br>    rec = []<br>    for qi in qs:<br>        qv = (VEC[qi] + 0.05 * np_rng.normal(size=DIM)).astype(np.float32)<br>        qv /= np.linalg.norm(qv)<br>        gt = set(np.argsort(-(VEC @ qv))[:10].tolist())<br>        got = c.query_points(&quot;mkt_turbo8&quot;, query=qv.tolist(), limit=10,<br>                             search_params=models.SearchParams(exact=True)).points<br>        rec.append(len(gt &amp; {p.id for p in got}) / 10)<br>    print(f&quot;\n== turbo8 recall@10 vs exact float32 ground truth (100 queries, synthetic): {np.mean(rec):.3f}&quot;)<br>    cfg = c.get_collection(&quot;mkt_turbo8&quot;).config<br>    print(&quot;  datatype:&quot;, cfg.params.vectors.datatype, &quot;| id_tracker:&quot;, cfg.params.id_tracker)<br> <br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a5d61fdf418" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Does Tenant-Aware Indexing Help? Benchmarking Multi-Tenant Filtered Search in Qdrant]]></title>
            <link>https://medium.com/@parichaydas/multi-tenancy-4fa7a84f970e?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fa7a84f970e</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 18:13:17 GMT</pubDate>
            <atom:updated>2026-10-31T16:57:32.654Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Four index layouts, two tenant distributions, three dataset sizes, and a recommended recipe put under measurement</em></p><h3>A recipe everyone copies</h3><p>Qdrant’s multitenancy guidance is unusually specific. Put every tenant in one collection. Index the tenant field with is_tenant=true. Set m=0 so no global HNSW graph is built, and set payload_m=16 so each tenant gets a graph of its own. It reads like a settled recipe, and most teams copy it and move on.</p><p>Every recipe has a cost, and the documentation mentions this one only in passing. Dropping the global graph should make indexing cheaper. It should also make any query without a tenant filter worse. How much cheaper, how much worse, and whether tenant-aware storage changes filtered latency at all depend on the shape of the data, above all on how unevenly documents are spread across tenants.</p><p>This article reports a benchmark built around one question: <strong>does tenant-aware indexing improve filtered vector search in Qdrant?</strong> Four index configurations were run against balanced and skewed tenant distributions at three scales, from 20,000 to 500,000 documents. The harness measured filtered latency, indexing time, recall, tenant isolation and what happens to queries that cross tenant boundaries.</p><p>The answer is less tidy than the recipe suggests. On evenly sized tenants, tenant-aware indexing barely moves filtered latency. Its real payoffs are faster indexing and, on skewed data, much better filtered recall for the large tenants. The price shows up in global search, which collapsed in these runs. A few numbers also need more scrutiny before anyone builds a production decision on them, and the article is explicit about which ones.</p><h3>Why filtered search is the hard part</h3><p>Qdrant’s default answer to multitenancy is payload partitioning. All tenants live in one collection, each point carries a tenant field, and every query adds a must filter on that field. The filter is what separates one tenant’s results from another’s. It is a retrieval boundary, not a security model: if the application forgets the filter, the query searches everyone.</p><p>The difficulty sits inside HNSW. A proximity graph is built over all vectors, and a tenant filter removes most of them at query time. When 99% of nodes are filtered out, the graph a query walks becomes sparse and fragmented, and the search can stall before it reaches the true nearest neighbours. Recall drops without any error being raised.</p><p>Qdrant handles this in three ways that matter for this benchmark:</p><p>1. <strong>Query planning.</strong> When the filtered candidate set is small enough, below the HNSW full_scan_threshold, the planner skips the graph and scores the tenant’s points directly through the payload index. That path is exact. Above the threshold, it searches the graph with the filter applied.</p><p>2. <strong>Payload-specific graph links (payload_m).</strong> Qdrant can build extra HNSW links among points that share a payload value, so a filtered traversal stays connected inside one tenant. With m=0, the global graph is not built at all and only these per-tenant links remain.</p><p>3. <strong>Tenant-aware storage (is_tenant=true).</strong> Available since v1.11, this flag tells Qdrant the field identifies tenants, so a tenant’s points are stored together and can be read sequentially.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLYszxqsgXglZ3rtt1cj0Q.png" /><figcaption><strong><em>Figure 1. </em></strong><em>Conceptual index layouts. Config A builds one graph across all tenants; C and D link points only within the same tenant.</em></figcaption></figure><p>Payload partitioning is one of three strategies. Qdrant 1.16 added tiered multitenancy, which keeps small tenants in a shared fallback shard and moves large tenants to dedicated shards inside the same collection. A collection per tenant remains an option when tenants need different embedding models or schemas. This benchmark covers payload partitioning only.</p><h3>Four configurations under test</h3><p>The benchmark isolates the two levers separately and then combines them, so their effects are not confounded. Configuration A is the control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvMVALtlij9CJA6u188GSA.png" /></figure><p>Configuration D matches the layout in Qdrant’s own multitenancy tutorial. With the Python client it looks like this; the collection name is illustrative, and tenant_id is the tenant field used by the harness.</p><pre>from qdrant_client import QdrantClient, models<br> <br>client = QdrantClient(host=&quot;localhost&quot;, port=6333)<br> <br>client.create_collection(<br>    collection_name=&quot;docs_config_d&quot;,<br>    vectors_config=models.VectorParams(<br>        size=128,<br>        distance=models.Distance.COSINE,<br>    ),<br>    hnsw_config=models.HnswConfigDiff(m=0, payload_m=16),<br>)<br> <br>client.create_payload_index(<br>    collection_name=&quot;docs_config_d&quot;,<br>    field_name=&quot;tenant_id&quot;,<br>    field_schema=models.KeywordIndexParams(<br>        type=models.KeywordIndexType.KEYWORD,<br>        is_tenant=True,<br>    ),<br>)</pre><p>Every tenant-scoped query carries the filter. Without it, the query silently runs across all tenants.</p><pre>hits = client.query_points(<br>    collection_name=&quot;docs_config_d&quot;,<br>    query=query_vector,<br>    query_filter=models.Filter(<br>        must=[<br>            models.FieldCondition(<br>                key=&quot;tenant_id&quot;,<br>                match=models.MatchValue(value=&quot;tenant-042&quot;),<br>            )<br>        ]<br>    ),<br>    search_params=models.SearchParams(hnsw_ef=128),<br>    limit=10,<br>)</pre><p>The distance metric in the snippet is illustrative; the configuration, filter and hnsw_ef match the harness.</p><h3>Benchmark architecture</h3><p>One CLI drives every run, so each configuration sees the same data and the same queries. The only variable is the collection layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WM08DpSUuV_hq4CPJjhWjw.png" /><figcaption><strong><em>Figure 2. </em></strong><em>Benchmark harness. The CLI generates data, loads one collection per configuration, runs identical workloads and writes metrics, plots and a report.</em></figcaption></figure><p>• <strong>Bench CLI.</strong> Selects scale, distribution, storage mode, configurations, ef and repetitions, and points at a Qdrant host and container.</p><p>• <strong>Dataset generator.</strong> Produces synthetic 128-dimensional vectors across 100 tenants with a fixed seed (42), split evenly or with a heavy skew toward a few tenants. A SHA-256 fingerprint of the vectors is printed so runs can be compared on identical data.</p><p>• <strong>Ingest and index.</strong> Creates one collection per configuration, uploads the points and waits until the optimizer reports indexing complete. Both times are recorded.</p><p>• <strong>Qdrant.</strong> A single 1.16.3 container holds the four collections. Configuration D, highlighted, is the layout Qdrant’s tutorial recommends.</p><p>• <strong>Workloads and metrics.</strong> The same query sets run against every collection. Exact search provides the reference for recall. An isolation check counts foreign-tenant results with and without the filter, and an interference test repeats filtered queries while a bulk tenant is being written.</p><p>The trust boundary worth naming is the tenant filter. Isolation depends on the application adding it to every query, which is why the harness measures what leaks when it is missing.</p><h3>Implementation, step by step</h3><p>The project ran on Windows with PowerShell, Python 3.12 in a virtual environment and Qdrant in Docker Desktop. Each step below includes the command and the output that confirmed it worked.</p><h3>Step 1: Create a virtual environment</h3><pre>python -m venv .venv<br>.\.venv\Scripts\Activate.ps1</pre><p>An isolated environment keeps the benchmark’s client version pinned and separate from anything else on the machine.</p><h3>Step 2: Install project dependencies</h3><pre>python -m pip install -r requirements.txt</pre><p>The requirements are short: the Qdrant client for all database calls, NumPy and pandas for data generation and result tables, Matplotlib for plots and pytest for the harness’s own tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27XFI5OsnAGEq2QkHLj9dQ.png" /><figcaption><strong><em>Figure 3. </em></strong><em>requirements.txt pins qdrant-client &gt;=1.12,&lt;2 alongside numpy, pandas, matplotlib and pytest.</em></figcaption></figure><h3>Step 3: Start the Qdrant server with Docker</h3><pre>docker compose up -d<br>docker ps</pre><p>Compose pulls qdrant/qdrant:v1.16.3, creates a network and starts the qdrant-bench container with ports 6333 (REST) and 6334 (gRPC) published. Pinning the image tag matters: index behaviour changes between Qdrant releases, and every result in this article belongs to 1.16.3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4UktwHQuv6MhvR3diFwSg.png" /><figcaption><strong><em>Figure 4. </em></strong><em>docker compose starts qdrant-bench on Qdrant v1.16.3; docker ps confirms the container is up on ports 6333–6334.</em></figcaption></figure><h3>Step 4: Understand and verify the four configurations</h3><p>The CLI exposes every experimental knob: dataset scale, distribution, storage mode (memory or disk), configurations, ef, repetitions and whether to run the interference test. Running its help output confirmed the interface. The configuration module behind it defines the tenant field, the three scales and the four index layouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_Ke_24oivM66h3tfQQomA.png" /><figcaption><strong><em>Figure 5. </em></strong><em>Benchmark configuration: tenant field tenant_id, three scales, and configs A to D with their is_tenant, m and payload_m values.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4OUh_rYRtu8SRpfz6uL6A.png" /></figure><p>A separate tenant, tenant_bulk, receives the bulk points during the interference test so ingestion pressure does not change the data being queried.</p><h3>Step 5: Generate the Tiny dataset</h3><pre>python -m bench.cli generate --scale tiny</pre><p>Before any indexing, the generator was checked at the smallest scale. Both datasets hold 20,000 documents across 100 tenants with seed 42:</p><p>• <strong>Balanced.</strong> Every tenant holds 200 documents. The top 10% of tenants hold 10% of the data.</p><ul><li><strong>Skewed.</strong> The largest tenant holds 4,243 documents and the smallest 50. The top 10% of tenants hold about 60% of the data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CAqZ6PfJ5VdvzQz9UW4J2w.png" /><figcaption><strong><em>Figure 6. </em></strong><em>Tiny dataset generation: balanced (200 docs per tenant) and skewed (largest tenant 4,243 docs, top 10% hold about 60%).</em></figcaption></figure><h3>Step 6: Run the Tiny smoke test</h3><p>The smoke test exercises the full pipeline once: indexing, filtered search, global search, multi-tenant search, isolation checks, interference measurement, plots and the report. Its job is to prove the pipeline works, not to produce conclusions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEVqEbV_swgSyJDJlNpwRw.png" /><figcaption><strong><em>Figure 7. </em></strong><em>Tiny smoke test log for configs A, B and C on balanced data: indexing times, latency, recall, isolation and interference per configuration.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xjxVZ9Cm1fa3aIHNIRRxQ.png" /></figure><p>The log also shows the first isolation result. With the filter applied, foreign(with filter)=0: no result came from another tenant. With the filter removed, 86% of results did. That single line is the clearest argument for treating the filter as part of the security design rather than a query option.</p><h3>Step 7: Inspect the recall calculation</h3><p>One result in the smoke test looked wrong. Configurations C and D returned a global Recall@10 of 0.0, while everything else scored 1.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcQTJnEQZJFEdWE0PckIwg.png" /></figure><p>A zero can mean two different things: the index failed to find the neighbours, or the ground truth itself is wrong. The next step separates them.</p><h3>Step 8: Diagnostic test for global recall</h3><p>The diagnostic ran the same global queries twice, once through the approximate index and once with Qdrant’s exact search, and compared both with the ground truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M5VdKYqwlh0mOMqQ42PnxQ.png" /></figure><p>Exact search matched the ground truth in every case, so the data and the scoring are correct. The loss happens on the approximate path. The diagnostic passed, and the result was recorded as a limitation of configurations C and D rather than a harness bug.</p><h3>Step 9: benchmark results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8wpx6SfpQPy-jKkRddF8w.png" /></figure><h3>Filtered search</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26WdKKlDd_PFvzahh-AJdA.png" /></figure><h3>Indexing time</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6fBE0X_HSu0ntMdNad67g.png" /></figure><h3>Ingestion interference</h3><p>Ratio of filtered p95 while the bulk tenant is being written to filtered p95 at rest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nGBOsjvBBD0d4WZRE5qqPg.png" /></figure><p>At Tiny scale all four configurations reached a filtered Recall@10 of 1.0, and none improved filtered p95 by more than 10% over the default. The lower p50 for B, C and D on balanced data is the only visible gap, and a single run cannot separate it from noise. C indexed fastest. B’s storage co-location has little to show here, because Tiny runs in memory where read locality matters least. The interference ratios show no pattern that holds across both distributions.</p><h3>Step 10: Small benchmark and the storage failure</h3><p>The first Small run (100,000 documents) produced this table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qRuztJZCdcCsZQ3OPCNXfw.png" /></figure><h3>What failed</h3><p>During indexing of balanced configuration C, Qdrant’s optimizer failed to rename a segment file to its deleted state, and the run aborted. The cause was the storage layer rather than Qdrant’s index logic. The collection lived on a Windows folder bind-mounted into the Linux container, and that mount did not give the optimizer the file-rename behaviour it relies on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU-IQgcm9fI8dO8iVd4nCQ.png" /><figcaption><strong><em>Figure 8. </em></strong><em>Root cause and fix. A Windows bind mount broke the optimizer’s segment rename; a Docker named volume removed the problem.</em></figcaption></figure><h3>The fix</h3><p>1. <strong>Create a Docker named volume</strong> so Docker manages the storage instead of a Windows folder.</p><p>2. <strong>Test the filesystem.</strong> Create a temporary file in the new volume, rename it and delete it. The test passed.</p><p>3. <strong>Run a separate Qdrant container.</strong> Start Qdrant v1.16.3 as qdrant-volume-test on ports 6335 and 6336, using the named volume, and confirm the health endpoint responds.</p><p>4. <strong>Re-run the benchmark</strong> against that container with — port 6335 — container qdrant-volume-test.</p><p>All Small and Medium results from here on come from the named-volume setup, and the first table above is superseded. Anyone benchmarking Qdrant on Docker Desktop for Windows should start with a named volume, because a bind mount can fail in ways that look like database bugs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WsDcrH1bXYOJCeJcYbKEhA.png" /><figcaption><strong><em>Figure 9. </em></strong><em>Small benchmark on the named volume: end of the balanced run and the full skewed run for configs A to D.</em></figcaption></figure><h3>Small results: balanced</h3><p>Qdrant 1.16.3, 100,000 documents, 100 tenants, disk storage, ef=128, one repetition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fzAdf3QKR28r-jwBlgcVzg.png" /></figure><p>On balanced data configuration A is the right baseline. Every configuration reached perfect filtered recall, and A had the lowest p50 and p95. C and D needed 30 to 33% less ingest and index time.</p><h3>Small results: skewed</h3><p>In the skewed set the largest tenant held 23,428 documents and the top 10 tenants held 63% of all data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JI3ZdRHYU7s5rw_dZ2T54g.png" /></figure><p>Skew changes the picture. A’s filtered recall fell to 0.9474, while C reached 0.9989 at a slightly lower p50. C is not faster at every percentile: its p95 was 0.601 ms higher than A’s. D matched C on recall, but its p50 nearly doubled in this single run.</p><p>The log in Figure 9 also records the global trade-off on skewed data. Global approximate recall was 0.998 for A and 0.987 for B, but 0.229 for C and 0.228 for D, even though exact search scored 1.0 for all four. Configurations C and D should not be chosen for a system that also needs high-recall unfiltered search, at least not without further tuning.</p><h3>Step 11: Medium benchmark</h3><p>The Medium runs use 500,000 documents on disk against the named-volume container. To keep runtimes manageable, configurations were run one at a time and the interference test was skipped. Configuration B was not run at this scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sl7Lc3BESXJJwKlEmvymjA.png" /><figcaption><strong><em>Figure 10. </em></strong><em>Medium balanced, config A: ingest 49.9 s, index wait 41.7 s, filtered recall 1.0, global approximate recall 0.916.</em></figcaption></figure><h3>11b. Configuration C, balanced</h3><pre>python -m bench.cli all --scale medium --distributions balanced `<br>  --storage disk --configs C --ef 128 --repeats 1 --skip-interference `<br>  --host localhost --port 6335 --container qdrant-volume-test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nW19FEx7muWLw5GujnrnyQ.png" /><figcaption><strong><em>Figure 11. </em></strong><em>Medium balanced, config C: index wait drops to 4.2 s; global approximate recall is 0.0 while exact search scores 1.0.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2cv3LHeopRIvferfNWsDw.png" /></figure><p>C’s main advantage is indexing. Total ingest plus index wait fell by about 53.6%. Filtered recall was 1.0 for both, and A was slightly better at p95 and p99.</p><h3>11c. Configuration A, skewed</h3><p>This run tests how the default layout copes when documents are spread unevenly between large and small tenants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqZh3SNVImTl2XLAR2kY5g.png" /><figcaption><strong><em>Figure 12. </em></strong><em>Medium skewed, config A: largest tenant 116,928 docs; filtered recall falls to 0.896.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4895I7vl6eVgnJePaM1Dw.png" /></figure><p>Skew alone raised filtered p50 and p95 and pulled filtered recall from 1.0 to 0.896. Uneven tenant sizes hurt the default layout on exactly the workload it is meant to serve.</p><h3>11d. Configuration C, skewed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QX_7LaxiDOa0PN501HtFA.png" /><figcaption><strong><em>Figure 13. </em></strong><em>Medium skewed, config C: filtered recall recovers to 0.9896; global approximate recall is 0.227.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Cwg2CnlHOtsjU3ANTVv0w.png" /></figure><h3>11e. Configuration D, skewed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxfO6hFzqb5pfi6GUpNDbA.png" /><figcaption><strong><em>Figure 14. </em></strong><em>Medium skewed, config D: lowest filtered latency of the three; global approximate recall is 0.234.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfrhxpeR9Wjzv63kDJ_o5g.png" /></figure><p>D is the strongest latency candidate on skewed, tenant-filtered search in these single runs, with the lowest p50, p95, p99 and total indexing time. C had marginally higher filtered recall. Neither is a good choice where high-recall global search is required.</p><h3>Medium balanced: A, C and D side by side</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WI1lDmyVpz7cRIIt4qPq2A.png" /></figure><p>On balanced data, C and D cut ingest plus index time by 53.6% and 52.3%, almost entirely because index wait fell from 41.7 s to 4.2 s and 5.8 s. D had the lowest median filtered latency, A had the lowest p95, and filtered recall was perfect for all three. On skewed data the indexing savings shrank</p><p>to 12.2% for C and 19.9% for D, but filtered recall for the large tenants improved from 0.896 to about 0.99.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1IschYRh6_VxUAMZ2MY1sQ.png" /><figcaption><strong><em>Figure 15. </em></strong><em>The Medium-scale trade-off. Dropping the global graph cuts indexing time and lifts filtered recall on skewed data, but global approximate recall collapses.</em></figcaption></figure><h3>Reading the results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ds-8LR5TguWtZtRQd4Z97Q.png" /></figure><h3>Why recall stayed perfect for small tenants</h3><p>The recall pattern lines up with Qdrant’s query planner. A 128-dimensional float32 vector is 512 bytes. A balanced Medium tenant of 5,000 points is about 2.5 MB of vectors, below the default full_scan_threshold of 10,000 KB, so the planner can score that tenant exactly through the payload index and never touch the graph. The largest skewed Medium tenant, at 116,928 points, is about 60 MB and must go through HNSW. That is where A’s recall fell and where per-tenant links paid off.</p><p>The same arithmetic explains the other scales. The largest Small skewed tenant, about 12 MB, sits just above the threshold, and A’s recall dipped to 0.9474. The largest Tiny tenant, about 2 MB, sits below it, and every configuration scored 1.0. The near-zero index wait for C and D on balanced Medium data fits too, if per-tenant links are only built where a tenant is large enough to need them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBcBzynGlxIvlRK54sGy0g.png" /><figcaption><strong><em>Figure 16. </em></strong><em>How a query reaches its results. Small tenants are scored exactly; large tenants and unfiltered queries depend on the graph that exists.</em></figcaption></figure><p>This explanation is an interpretation of the results against documented planner behaviour, not something the harness measured directly. Logging which search path each query took would confirm or refute it. It also has a practical edge: production embeddings of 768 to 1,536 dimensions are 6 to 12 times larger per point, so far smaller tenants will cross the threshold and depend on the graph.</p><h3>The global search cliff</h3><p>Configurations C and D returned a global approximate Recall@10 of 0.0 on balanced data at every scale, and about 0.23 on skewed Small and Medium data. The default configuration scored between 0.916 and 1.0. Exact search scored 1.0 everywhere, so the ground truth is sound.</p><p>The direction is expected. With m=0 there is no collection-wide graph, so an unfiltered query has nothing global to traverse. Two details in the logs say more about the mechanism:</p><p>• <strong>The approximate path is fast, not slow.</strong> On Medium data, C’s global approximate p95 was 24.1 ms against 49.0 ms for exact search. The query is not falling back to a scan; it returns early with the wrong points.</p><p>• <strong>Unfiltered results stay inside one tenant.</strong> For balanced configuration C, the isolation check reported foreign(no filter)=0.00: even without a filter, results came only from the query’s own tenant. For A the same figure was 0.87.</p><p>Together these suggest that an unfiltered query on C or D walks whichever tenant’s links it enters and stops there. With 100 tenants, the true global neighbours rarely sit in that one tenant, which would produce a recall at or near zero. Skewed data scores higher because a large tenant holds a bigger share of the true neighbours. This reading is a hypothesis built from the logs.</p><p>It also sits awkwardly with Qdrant’s multitenancy guidance, which describes unfiltered queries on such a collection as slower because they must scan all tenant groups. Slower and correct is not what was observed here. The result should be reproduced with a minimal script on a current Qdrant release before anyone states it as product behaviour. Until then it is an observed result of this harness on 1.16.3. The practical conclusion holds either way: if a product needs unfiltered search across tenants, such as global admin search, deduplication or analytics, C and D are not safe defaults without a separate path for those queries.</p><h3>Isolation held in every logged run</h3><p>Every run in the screenshots reports foreign(with filter)=0 and guard ok=True. Across all configurations, distributions and scales, no filtered query returned a point from another tenant. Without the filter, between 71% and 87% of results came from other tenants for configurations A and B, and up to 77% for C and D on skewed data.</p><p>That gap is the whole security story of payload partitioning. The index configuration changes speed and recall; it does not change isolation. Isolation is enforced by one line of application code, so it belongs in a shared query layer with tests, not in each caller.</p><h3>Numbers to treat with caution</h3><p>• <strong>The p95 floor.</strong> Filtered p95 sits between 24 and 30 ms in every run, while p50 ranges from 4 to 12 ms. A tail that flat across index types points to fixed overhead outside the index, plausibly client timing or Docker Desktop networking on Windows. Differences of one or two milliseconds at p95 or p99 should not drive a decision.</p><p>• <strong>One run per cell.</strong> Every number is a single repetition. Two results look like outliers: B’s balanced Small p50 of 11.551 ms and D’s skewed Small p50 of 11.285 ms, both roughly double their neighbours.</p><p>• <strong>multi_tenant_5 recall on Medium balanced data.</strong> It scored 1.0 at Tiny scale, 0.945 to 0.974 on Small skewed data and 0.729 to 0.752 on Medium skewed data, but 0.058 for A and 0.010 for C and D on Medium balanced data. A, which keeps its global graph, should not collapse like that. The pattern points to a harness or ground-truth issue specific to that case, and those two numbers should not be quoted until it is explained.</p><p>• <strong>B was not run at Medium.</strong> The effect of is_tenant on disk at 500,000 documents is untested in isolation. The only proxy is D against C, where D indexed faster and posted lower latency on skewed data.</p><p>• <strong>Synthetic data.</strong> 128-dimensional vectors and 100 tenants are a controlled setting, chosen for repeatability rather than realism.</p><h3>Choosing a configuration</h3><p>The data supports a decision by workload rather than a single winner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGtXs399fVWjeqTQ9utr-A.png" /><figcaption><strong><em>Figure 17. </em></strong><em>Decision flow for choosing an index layout, based on this benchmark’s results.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMpJLRKRx6rq8Xyeg2O63g.png" /></figure><p>Two rules sit underneath that table. First, tenant size relative to the full-scan threshold decides whether the graph matters at all. If most tenants fit under it, filtered queries are exact and the index configuration mostly changes indexing cost. Second, the recipe is a bet that cross-tenant queries are rare. Teams that cannot make that bet should keep the global graph or route global queries elsewhere.</p><h3>What comes next</h3><p>The project is functionally complete and the main experiments have run. Before the results are treated as settled, the next round should:</p><p>• Repeat every cell at least five times and report spread, not single values.</p><p>• Run B at Medium scale to isolate is_tenant on disk.</p><p>• Reproduce the 0.0 global recall with a minimal script on a current Qdrant release.</p><p>• Debug multi_tenant_5 ground truth on Medium balanced data.</p><p>• Log the search path the planner chose per query, to confirm the threshold explanation.</p><p>• Repeat on native Linux storage to remove Docker Desktop and the Windows layer from the latency tail.</p><p>• Add realistic embedding dimensions and a larger tenant count.</p><h3>Closing thought</h3><p>The documented multitenancy recipe is good advice, but it optimises something specific. It makes indexing cheaper and keeps large tenants accurate under a filter. It does very little for small tenants, because Qdrant was already answering their queries exactly. The question that should drive the choice is how large the biggest tenants will grow, and whether anything will ever need to search across all of them.</p><h3>Sources</h3><p>• Qdrant, Multitenancy with Qdrant (tutorial): <a href="https://qdrant.tech/documentation/examples/multitenancy/">https://qdrant.tech/documentation/examples/multitenancy/</a></p><p>• Qdrant, Multitenancy documentation: <a href="https://qdrant.tech/documentation/manage-data/multitenancy/">https://qdrant.tech/documentation/manage-data/multitenancy/</a></p><p>• Qdrant API reference, Create payload index (is_tenant): <a href="https://api.qdrant.tech/api-reference/indexes/create-field-index">https://api.qdrant.tech/api-reference/indexes/create-field-index</a></p><p>• Qdrant 1.11 release notes (tenant index): <a href="https://qdrant.tech/blog/qdrant-1.11.x/">https://qdrant.tech/blog/qdrant-1.11.x/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fa7a84f970e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embed Your Documents Once, Choose Your Query Encoder Later with Qdrant Constella]]></title>
            <link>https://medium.com/@parichaydas/constella-research-preview-and-qdrant-b9a44b6fcf78?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a44b6fcf78</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Tue, 29 Sep 2026 17:35:27 GMT</pubDate>
            <atom:updated>2026-10-04T09:40:51.987Z</atom:updated>
            <content:encoded><![CDATA[<p>A document embedding is computed once. A query embedding is computed every time someone searches.</p><p>That asymmetry is obvious once you say it out loud, yet most retrieval stacks are built as if it didn’t exist. We pick one embedding model, run it over the corpus, and then run the same model on every incoming query for as long as the system lives. The corpus gets encoded in a batch job someone schedules for a quiet weekend. The query encoder sits on the request path of every search, every RAG call, and every agent step that decides it needs more context.</p><p><em>So, which side of that system deserves the big model</em></p><p><a href="https://qdrant.tech/blog/constella-research-preview/">Qdrant Constella</a>, published on 29 September 2026 as a research preview, takes a clear position. It keeps a large embedding model on the document side and offers a family of smaller query encoders that search the same stored vectors. This article looks at how that works, what the published numbers do and don’t support, and where the design fits in a production semantic search system built on the Qdrant vector database.</p><h3>Key takeaways</h3><p>• Constella separates the document encoder from the query encoder. Documents are embedded once with Stella, a 400M-parameter English model, and queries can be encoded by Constella Zero, Constella Nano, or Stella itself against the same Qdrant collection.</p><p>• Constella Nano is a 34.5M-parameter query encoder distilled to reproduce Stella’s query embeddings. On Qdrant’s BEIR-15 evaluation it averages 0.508 nDCG@10 against Stella’s 0.561, roughly 91% of the reference.</p><p>• Full Stella is still the higher-quality query path in every reported dataset. Nano trades some ranking quality for a much smaller model on the request path.</p><p>• The practical shift is operational. Document embeddings become a stable asset, and query encoding becomes something you can tune per workload, or even per request, without rebuilding the index.</p><ul><li>This is a research preview. The evaluation is English-only, partly affected by training contamination, and the tooling currently lives on a FastEmbed preview branch.</li></ul><h3>The hidden cost in semantic search</h3><p>At first glance, embedding a query looks cheap next to embedding an entire corpus. A query is twenty words. A corpus is millions of passages.</p><p>The comparison flips once you count invocations instead of tokens. A document vector, once written, can serve thousands of searches. A query vector usually serves exactly one. If a collection of ten million passages takes a day to encode, that cost is paid once and amortized over the life of the index.The query encoder, by contrast, runs for every request, forever, and its latency is directly added to the user’s wait time.</p><p>That changes the optimization problem. On the document side, you care about representation quality, and you can afford to be patient. On the query side, you care about p50 and p99 latency, CPU or GPU hours per million requests, cold-start behavior, and whether the model fits on the device where the search happens.</p><p>Qdrant’s own measurements make the gap concrete. On an Apple M5 Pro CPU, with FastEmbed and ONNX Runtime at batch size one, full Stella took about 39 ms to encode a warm 20-word query. That’s before any vector search or network time. For a single search it’s tolerable. For an agent that retrieves six times before answering, or a search box that queries on every keystroke, it adds up quickly.</p><p>The usual response is to use a smaller embedding model everywhere. That brings us to the real problem.</p><h3>The conventional trade-off: change the model, rebuild the index</h3><p>In a standard dense retrieval setup, the query encoder and the document encoder are the same model, or at least a matched pair trained together. Their vectors only mean something relative to each other. Swap one side, and the cosine similarity between the two becomes noise.</p><p>So when a team wants a cheaper or faster query model, the path usually looks like this:</p><pre>Pick a new embedding model<br>  -&gt; re-encode every document<br>  -&gt; build a new collection (or a new named vector) and backfill it<br>  -&gt; re-run retrieval evaluation<br>  -&gt; dual-run or shadow traffic<br>  -&gt; cut production over and retire the old vectors</pre><p>Each step is manageable on its own. Together they turn a query-side latency question into a data migration. You pay for a full re-embedding run, you carry two copies of the vectors during the transition, and you need an evaluation set good enough to trust the new rankings.</p><p>The friction has a quieter side effect too. Because changing the model is expensive, teams stop experimenting. The embedding model chosen during the prototype often becomes the embedding model in production two years later, simply because nobody wants to own the migration.</p><h3>What is Qdrant Constella?</h3><p>Qdrant Constella is a family of English embedding models built around one fixed document embedding space. Documents are encoded by Stella (stella_en_400M_v5, a 400M-parameter model from NovaSearch), and any of three query encoders can search those vectors: Constella Zero, Constella Nano, or Stella’s own query path.The name is a small joke that also explains the design. Constella blends “constellation” and “Stella”: the document embeddings are the fixed stars, and the query encoder is whatever you use to navigate between them.</p><p>The mechanism is distillation. Zero and Nano were trained to reproduce the query embeddings that frozen Stella would produce. Because they land in the same 1024-dimensional space, a Zero vector, a Nano vector and a Stella query vector can all be compared by cosine similarity against the same stored document vectors. One document index, multiple query encoders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*4Y69QvoE7KHXGPmsy7NTiw.png" /><figcaption>Qdrant Constella architecture: one Stella document index, three query encoders. <em>Stella encodes documents once into a Qdrant collection, and Constella Zero, Constella Nano or Stella can each encode queries into the same 1024-dimensional space.</em></figcaption></figure><h3>Constella Nano searches an existing Stella index</h3><p>Yes, with one qualification. Nano searches documents encoded by Stella’s document path, which Qdrant ships as Qdrant/stella-en-400M-v5-doc-onnx. If your collection was built from that document path, Nano and Zero can query it without changingthe stored vectors. If your collection was built with a different model, it is not a Stella index, and Constella does not help until you re-embed once.</p><p>The model cards are careful on a related point, and it’s worth repeating. Compatibility means a shared vector space. It does not mean the query encoders rank equally well.</p><h3>Why does Constella avoid re-embedding documents?</h3><p>Because the query encoders are trained to target Stella’s space, and not the other way round. The document side is the anchor. Every new query encoder in the family has to earn its place by landing close to where Stella would have placed the same query, which keeps the stored vectors valid.</p><h3>How Constella Nano works</h3><p>Constella Nano is a 34.5-million-parameter English query encoder (34,540,672 parameters, to be exact) designed to search document embeddings generated by the Stella model. It outputs normalized 1024-dimensional fp32 vectors, accepts up to 512 tokens, and uses no query prefix.</p><p>The backbone is BAAI/bge-small-en-v1.5, a 12-layer BERT-style encoder. Nano doesn’t just take the last layer’s output. It taps hidden states from layers 4, 8 and 12, combines them, and passes them through a learned linear projection into Stella’s 1024-dimensional space. FastEmbed then applies attention-masked mean pooling and L2 normalization.</p><p>Why tap intermediate layers? The model card doesn’t argue the point, so treat this as my reading rather than their claim. Lower layers in BERT-style encoders tend to carry more lexical and positional detail, and upper layers more contextual meaning. A small student trying to mimic a much larger teacher can use all of it, and the projection learns how to mix those signals into the teacher’s geometry.</p><p>The training objective is plain distillation. Stella’s query embeddings are frozen targets, and Nano learns to reproduce them. The released checkpoint saw 199,999,721 training examples, in a 75% query and 25% document mix, drawn from sources including Amazon ESCI, HotpotQA, Mr. TyDi, NQ Open, SQuAD, TriviaQA and PAQ. MS MARCO was held out for validation. The <a href="https://github.com/Dylancouzon/asymmetric-dual-encoders">distillation and evaluation harness</a> is public.</p><h3>How is Constella Zero different?</h3><p>Zero drops the transformer entirely. It looks up a learned vector for each token, pools them, and normalizes the result. That’s the whole encoder.</p><p>The consequence is predictable. Zero is a learned bag of tokens, so it can’t see word order. “Dog bites man” and “man bites dog” produce the same vector. For many search queries that barely matters. For queries where meaning depends on structure, it does.</p><p>Nano is the middle option. It keeps a real transformer on the query path, which gives it context and position, while staying about one-twelfth the size of Stella.</p><h3>Constella Zero vs Constella Nano vs Stella</h3><p>There’s no overall winner here, only a trade-off curve. The table puts the three query paths side by side using the figures Qdrant has published.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DndamAWzG5eRzdCC3MjI2w.png" /></figure><p>Latency and scores are from Qdrant’s <a href="https://qdrant.tech/blog/constella-research-preview/">research preview post</a>: FastEmbed with ONNX Runtime, four CPU threads, batch size one, median of three fresh processes. They cover encoding only, not search or network time.</p><p>Two details in the published data are worth pausing on.</p><p>First, the <a href="https://huggingface.co/Qdrant/constella-nano">Nano model card</a> reports a separate run on unspecified hardware where Nano’s warm p50 was 7.25 ms and plain bge-small-en-v1.5 was 6.84 ms. So Nano costs roughly what its backbone costs. The projection into Stella’s space adds almost nothing at query time. What you are buying is Stella’s geometry at bge-small’s price.</p><p>Second, memory. On that same card, peak resident memory was 275 MiB for Zero and 281 MiB for Nano, with most of it runtime overhead. The Stella document graph, by contrast, is about 1.75 GB in fp32, and the card notes that an fp16 conversion failed its accuracy check. For a device with tight memory, that difference decides whether semantic search runs locally at all.</p><p>So the honest framing is this. Zero minimizes computation and gives up context. Nano keeps context at a small model cost and gives up some ranking quality. Stella gives the best rankings in this family and costs an order of magnitude more per query.</p><h3>What the BEIR benchmark tells us</h3><p>Qdrant evaluated all three query encoders on BEIR-15, fifteen retrieval tasks covering scientific papers, open-domain questions, fact-checking claims, forums and more. Every encoder searched the same Stella document vectors with exact (non-approximate) search, which isolates the effect of the query model.</p><p>The metric is nDCG@10. In practical terms, it asks: of the first ten results, how many are relevant, and are the most relevant ones near the top? A score of 1.0 means a perfect ranking. Position matters, so a relevant document at rank 1 counts for much more than the same document at rank 9. For a RAG system that feeds the top few chunks to a language model, that is close to the property you actually care about.</p><p>Averaged across all fifteen datasets, Zero scored 0.457, Nano 0.508 and Stella 0.561. Nano retains about 91% of Stella’s average. A few datasets tell a more useful story than the average.</p><p>On TREC-COVID, Nano scored 0.787 against Stella’s 0.823, about 96% of the reference, while Zero fell to 0.549. That’s the clearest case for context on the query side. Biomedical questions about COVID-19 depend on how terms relate to each other, and a bag of tokens loses a third of the ranking quality.</p><p>SciFact follows a similar pattern with a wider gap: 0.610 for Zero, 0.721 for Nano, 0.780 for Stella. NFCorpus is where Nano looks weakest relative to its teacher, at 0.363 against 0.413, or about 88%. SCIDOCS is hard for everyone, with Stella at only 0.240, and Nano holds about 91% of that.</p><p>On general-domain question answering the gap is steady. Natural Questions gives 0.584 for Nano against 0.637 for Stella, and MS MARCO 0.406 against 0.437, both in the 92 to 93% range. MS MARCO is a useful data point because it was used only for validation during Nano’s training, never as training data.</p><p>Then there’s the part that doesn’t fit a simple size-equals-quality story. Zero outscored Nano on FEVER (0.698 vs 0.623), Climate-FEVER (0.279 vs 0.247) and essentially tied it on HotpotQA (0.613 vs 0.610). My hypothesis, and it is only a hypothesis, is that claim verification and entity-heavy multi-hop questions reward exact term overlap, which a learned token model captures well. Qdrant’s own conclusion is more modest and more useful: the trade-off varies by workload, so test on your own data.</p><h3>Limitations worth taking seriously</h3><p>Stella reports training or evaluation exposure to FiQA, ArguAna, FEVER and Climate-FEVER. Zero and Nano learned from Stella, so scores on those four are a comparison within the family, not evidence on unseen data. The FEVER result above sits in that group.</p><p>The sources are also slightly out of step with each other. The Nano model card reports only six datasets and says broader BEIR benchmarking is still underway, while the blog post reports all fifteen. The card flags two contaminated datasets; the blog flags four. The blog appears to be the more complete evaluation, but check both before quoting numbers.</p><p>Everything here is English only, capped at 512 tokens, measured on CPU, and labeled a research preview. None of it tells you how Constella behaves on your domain, your query distribution, or under concurrent load.</p><h3>Why this matters for production RAG and search</h3><p>Here’s the central idea, stated plainly. With Constella, document embeddings become a relatively stable asset, and query encoding becomes a tunable inference component.</p><p>That sounds abstract until you map it onto systems people actually run.</p><p>In a high-volume search API, query encoding is a recurring line item that scales linearly with traffic. Being able to move some or all of that traffic from Stella to Nano, without touching the index, turns a cost decision into a configuration change. You still need to measure whether the ranking loss is acceptable. You no longer need a migration to find out.</p><p>Retrieval augmented generation systems have a different pressure. Agentic RAG pipelines often retrieve several times per answer, rewriting the query or searching sub-questions. Every one of those calls pays the query encoder. Qdrant suggests using Zero or Nano for intermediate searches, which is a reasonable pattern to test: cheap encoders for exploration, the full model when the final context is assembled.</p><p>Enterprise knowledge search and customer-support search share a property that makes Constella interesting. The corpus is expensive to re-embed, because it’s large, spread across tenants, or tied to ingestion pipelines with their own approval steps. At the same time the query side is where product teams want to iterate. Decoupling the two lets the search team experiment without scheduling a reindex. In a multi-tenant deployment, it also opens the door to giving tenants different query encoders over a shared document representation, though Qdrant hasn’t published anything on that specific pattern.</p><p>Mobile and edge retrieval is where the asymmetry is starkest. Encode a manual or knowledge base on a server with Stella, ship the vectors with Zero or Nano to the device, and search offline. The device never loads a 1.75 GB model. Qdrant lists this as a target use case, and it fits the shape of the design well.</p><p>Latency-sensitive interfaces benefit in a similar way. Qdrant’s example is search-as-you-type: Zero on every keystroke, Nano when the user pauses or submits. The two encoders produce vectors in the same space, so results from both stages are comparable without any reconciliation logic.</p><p>There’s also a quieter benefit. Because switching the query model is cheap, you can evaluate it honestly. A/B testing query encoders against the same index isolates exactly one variable, which is rare in retrieval work.</p><h3>A small Qdrant + Constella Nano experiment</h3><p>The demo below runs against a real Qdrant server in Docker, so you can open the dashboard and see what actually got stored. It’s ordinary Qdrant and FastEmbed code. The only unusual part is that two different models touch the collection: one for documents, one for queries.</p><h3>Step 1: Create a virtual environment</h3><pre>python -m venv .venv<br>.\.venv\Scripts\activate</pre><p>That’s the Windows PowerShell form. On macOS or Linux, activate with source .venv/bin/activate.</p><h3>Step 2: Start a Qdrant server</h3><pre>docker run -d --name qdrant-constella -p 16333:6333 qdrant/qdrant</pre><p>This maps Qdrant’s REST port 6333 inside the container to 16333 on the host, avoiding clashes with any Qdrant instance already running on the default port. The Web UI is then at</p><pre>http://localhost:16333/dashboard.</pre><h3>Step 3: Install dependencies</h3><p>During the preview, native FastEmbed support for Constella lives on a branch, so install from there:</p><pre>pip install &quot;fastembed @ git+https://github.com/Dylancouzon/fastembed.git@constella-research-preview&quot; qdrant-client</pre><h3>Step 4: Connect to Qdrant and define the corpus</h3><p>The corpus is eight short sentences about energy. Several are deliberately close to each other (solar panels, photosynthesis, geothermal), making ranking differences visible even at this scale.</p><pre>import time<br><br>from fastembed import TextEmbedding<br>from qdrant_client import QdrantClient, models<br><br>COLLECTION = &quot;documents&quot;<br><br>documents = [<br>    &quot;Solar panels convert sunlight into electricity.&quot;,<br>    &quot;Wind turbines generate electricity from moving air.&quot;,<br>    &quot;Hydroelectric dams produce power from flowing water.&quot;,<br>    &quot;Batteries store electrical energy for later use.&quot;,<br>    &quot;Photosynthesis lets plants turn sunlight into chemical energy.&quot;,<br>    &quot;Nuclear reactors release energy by splitting atoms.&quot;,<br>    &quot;Geothermal plants use heat from underground to make electricity.&quot;,<br>    &quot;Electric cars use rechargeable batteries instead of gasoline.&quot;,<br>]<br><br>client = QdrantClient(url=&quot;http://localhost:16333&quot;)</pre><h3>Step 5: Create the collection</h3><pre>client.create_collection(<br>    COLLECTION,<br>    vectors_config=models.VectorParams(<br>        size=1024,  # Stella / Nano / Zero all output 1024-d vectors<br>        distance=models.Distance.COSINE,<br>    ),<br>)</pre><p>One collection, one vector size, one distance function. Nothing in the configuration mentions which query encoder will be used, and that’s the point. If you re-run the script, create_collection fails once the collection exists, so delete it first or guard the call with client.collection_exists(COLLECTION).</p><h3>Step 6: Embed the documents once with Stella</h3><pre>stella_doc = TextEmbedding(&quot;Qdrant/stella-en-400M-v5-doc-onnx&quot;)<br>doc_vectors = list(stella_doc.embed(documents))</pre><p>This is the expensive side. The first run downloads the Stella document graph, about 1.75 GB, and in a real system this step belongs in an offline ingestion job, not in your API process.</p><h3>Step 7: Store the Stella vectors in Qdrant</h3><pre>client.upsert(<br>    COLLECTION,<br>    points=[<br>        models.PointStruct(id=i, vector=vec.tolist(), payload={&quot;text&quot;: text})<br>        for i, (text, vec) in enumerate(zip(documents, doc_vectors))<br>    ],<br>)<br>print(f&quot;Indexed {len(documents)} documents with Stella.\n&quot;)</pre><p>Each point carries its sentence as payload so results are readable, plus one 1024-dimensional Stella vector. The dashboard confirms it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meq6iBm-X5Jdsa8S0U56kw.png" /></figure><p>From here on, the document vectors don’t change. Everything that follows happens on the query side.</p><h3>Step 8: Load Zero and Nano as query encoders</h3><pre>query_models = {<br>    &quot;zero&quot;: TextEmbedding(&quot;Qdrant/constella-zero&quot;),<br>    &quot;nano&quot;: TextEmbedding(&quot;Qdrant/constella-nano&quot;),<br>}<br><br><br>def search(text: str, model: str = &quot;zero&quot;, limit: int = 3):<br>    &quot;&quot;&quot;Encode the query with the chosen model and search the same collection.&quot;&quot;&quot;<br>    start = time.perf_counter()<br>    query_vec = next(query_models[model].embed([text]))<br>    encode_ms = (time.perf_counter() - start) * 1000<br><br>    hits = client.query_points(<br>        COLLECTION, query=query_vec.tolist(), limit=limit<br>    ).points<br>    return hits, encode_ms</pre><p>The search function is the whole idea in a dozen lines. The model is a parameter. The collection is not. The timer wraps only the query encoding, so the number it reports excludes Qdrant’s search time.</p><p>Nothing here is Constella-specific apart from the model names. Zero and Nano each return a normalized 1024-dimensional vector, and Qdrant compares it against the Stella document vectors with cosine similarity.</p><p>One trap is worth flagging. Don’t reuse the document encoder for queries. The Stella ONNX artifact implements the document path only and applies no query prompt, and its model card explicitly warns against using it as an unprompted query encoder.</p><h3>Switching query encoders without rebuilding the collection</h3><p>This is the experiment that makes the design click. Keep the collection exactly as it is and run the same query through different encoders.</p><h3>Step 9: Run the same query through both encoders</h3><pre>query = &quot;How can we get energy from the sun?&quot;<br><br>for name in (&quot;zero&quot;, &quot;nano&quot;):<br>    hits, ms = search(query, model=name)<br>    print(f&quot;=== {name.upper()}  (query encoding: {ms:.2f} ms) ===&quot;)<br>    for rank, h in enumerate(hits, 1):<br>        print(f&quot;  {rank}. score={h.score:.4f}  {h.payload[&#39;text&#39;]}&quot;)<br>    print()</pre><h3>Step 10: Read the output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-P9tFDPq0Ejc3UrYhmNCg.png" /><figcaption><em>A local run on a Windows development machine: Constella Zero and Constella Nano query the same collection, followed by a search-as-you-type pass.</em></figcaption></figure><p>A few things in that output deserve a careful read.</p><p>Both encoders put the same two documents on top, solar panels first and photosynthesis second. The third result differs. Zero pulled in a sentence about nuclear reactors, Nano one about geothermal plants making electricity. On an eight-document corpus that’s an anecdote, not evidence, but it’s the kind of divergence the BEIR numbers describe at scale.</p><p>The raw scores differ a lot too: 0.36 for Zero’s top hit, 0.60 for Nano’s. That doesn’t mean Nano is more confident or more correct. Each encoder produces its own distribution of cosine similarities against the same document vectors, so compare rankings across encoders and compare scores only within one. If you tune a similarity threshold for one encoder, don’t reuse it for another.</p><p>The printed encoding times, 3.67 ms for Zero and 18.41 ms for Nano, are single measurements. Because `search` is called once per model, each timer wraps that model’s very first inference, in the same run that downloaded the models. They are well above Qdrant’s published warm medians (0.081 ms and 3.13 ms on an Apple M5 Pro), which is expected from one un-warmed measurement on different hardware. Read them as showing the ordering, not as a benchmark.</p><p>The last block, from an extra section of the script not shown above, follows Qdrant’s search-as-you-type pattern. Zero encodes each partial input (“sol”, “solar pan”, “solar panels electric”), and Nano runs once when the query is submitted. Zero finds the right document from a three-letter prefix here, which says more about how small the corpus is than about Zero’s recall.</p><p>No upserts. No new collection. No second set of vectors. The point count in documents never changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYEAZx1SmHA9_GjEOgRjLQ.png" /></figure><p>One field here is easy to miss. indexed_vectors_count is 0. With eight points the collection sits far below Qdrant’s indexing and full-scan thresholds (full_scan_threshold is 10,000 KB in this config), so no HNSW graph exists and every query is a full scan. That’s exact search, which is also how Qdrant evaluated Constella on BEIR. On a production-sized collection, approximate HNSW search adds its own recall loss on top of the encoder’s, and the two should be measured separately.</p><p>To complete the comparison with full Stella, you would use its prompted query path from the original model. The Stella document-encoder card points to NovaSearch’s s2p_query prompt for this. A sketch using sentence-transformers looks like the following, but check the <a href="https://huggingface.co/NovaSearch/stella_en_400M_v5">source model card</a> for the current loading instructions before relying on it:</p><pre>from sentence_transformers import SentenceTransformer<br><br>stella = SentenceTransformer(&quot;NovaSearch/stella_en_400M_v5&quot;, trust_remote_code=True)<br>qv = stella.encode([query], prompt_name=&quot;s2p_query&quot;, normalize_embeddings=True)</pre><p>An eight-document toy corpus won’t tell you which encoder is better. It only proves the mechanics. To make a real decision, run each encoder over a labelled query set from your own traffic, compute nDCG@10 or recall@k against the same collection, and put those numbers next to the per-query latency on your target hardware. Qdrant also recommends keeping each model loaded rather than instantiating it per request. Their measured load times ranged from about 0.3 seconds for Zero to 1.3 seconds for Stella, which you don’t want inside a request.</p><h3>Where the design gets interesting</h3><p>Two ideas follow naturally from a shared document space, and neither is fully demonstrated yet.</p><p>The first is hybrid search. Qdrant recommends pairing Zero with BM25, and reports that Zero gained more from that fusion than Nano did in their benchmarks. That’s a plausible fit: BM25 covers exact terms, and Zero adds learned semantic neighbours without putting a transformer on the query path. The Zero model card has recommended fusion settings, but the preview post doesn’t include the fused scores themselves, so the size of that gain is hard to judge from the outside.</p><p>The second is adaptive routing. If every encoder searches the same index, nothing stops a system from choosing the encoder per request: Zero for short keyword-like queries, Nano for natural-language questions, Stella for high-value or ambiguous ones. That’s an architectural possibility, not a documented Constella feature, and it needs a reliable way to predict which queries lose quality under the cheaper models. The FEVER and HotpotQA results suggest the answer isn’t simply “longer queries need bigger models”.</p><p>Beyond those, these are the questions I’d want answered before putting Constella on a critical path:</p><p>• Hardware spread. The published latencies are CPU-only, from two different setups. How does Nano behave on Arm server cores, mobile SoCs, and GPUs at realistic batch sizes?</p><p>• Throughput under concurrency. Warm p50 at batch size one is a single-user number. p99 under sustained load is what capacity planning needs.</p><p>• Query-length sensitivity. The benchmarks use 20-word synthetic queries for timing. Real queries range from two words to pasted paragraphs, and Zero’s bag-of-tokens behaviour may degrade differently from Nano’s as length grows.</p><p>• Domain transfer. Scientific and general QA are covered. Legal, code, e-commerce and internal enterprise jargon are not.</p><p>• Languages. The whole family is English-only today, including the Stella document encoder.</p><p>• Document-side cost. Constella makes queries cheaper, but indexing still needs the 400M-parameter Stella model and its 1.75 GB fp32 graph, with no validated fp16 version. For fast-changing corpora, ingestion cost doesn’t go away.</p><p>• Interaction with quantization. Qdrant collections are often scalar- or binary-quantized. How much of Nano’s approximation error compounds with quantization error is worth measuring.</p><p>None of these are criticisms of the preview. They’re the gap between a well-documented research result and a production dependency.</p><h3>Final takeaway</h3><p>It’s tempting to file Qdrant Constella under “another small embedding model”. Constella Nano is small, but size is the least interesting thing about it.</p><p>What Constella changes is where optimisation can happen. For years, the document encoder and the query encoder have been treated as one inseparable choice, so every attempt to make query-time semantic search cheaper ran straight into the cost of re-embedding the corpus. Constella pins the document representation to Stella and lets the query side move independently.</p><p>That makes the vector index a more reusable asset and turns query encoding into a production optimisation surface. You can trade latency for ranking quality per workload, measure the trade honestly against a fixed index, and revisit the decision later without a migration.</p><p>The evidence so far is a research preview: English only, CPU benchmarks, some contaminated datasets, and Stella still ahead on every reported task. That’s enough to justify an experiment, not a rollout. If you already run a Stella-encoded collection, or you’re about to build one, try Constella Nano and Constella Zero against your own queries in Qdrant and see where your workload sits on the curve.</p><h3>Sources</h3><p>• Qdrant, <a href="https://qdrant.tech/blog/constella-research-preview/">Constella Preview: Swap Query Models Without Re-Embedding</a>, 29 September 2026</p><p>• Hugging Face, <a href="https://huggingface.co/Qdrant/constella-nano">Qdrant/constella-nano model card</a></p><p>• Hugging Face, <a href="https://huggingface.co/Qdrant/stella-en-400M-v5-doc-onnx">Qdrant/stella-en-400M-v5-doc-onnx model card</a></p><p>• GitHub, <a href="https://github.com/Dylancouzon/asymmetric-dual-encoders">asymmetric-dual-encoders distillation and evaluation harness</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a44b6fcf78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tuning Vector Search in Qdrant]]></title>
            <link>https://medium.com/@parichaydas/tuning-vector-search-in-qdrant-918486bd24f2?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/918486bd24f2</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 17:54:55 GMT</pubDate>
            <atom:updated>2026-10-04T19:46:38.227Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Most relevance problems get blamed on the wrong knob. A twenty-point local collection and Qdrant’s own five-dataset study show where to look first.</em></p><p>Search works. Queries return in a few milliseconds and the results are mostly right. Then a bug report lands. A document that clearly exists comes back at rank 40, or not at all.</p><p>The usual reaction is to open the configuration reference and raise hnsw_ef. It feels like the right lever. It controls how hard the index searches, so searching harder should find more.</p><p>Qdrant’s search team tested that instinct on five public datasets ranging from 5,183 documents to 4.6 million. Raising hnsw_ef moved the final nDCG@10 by at most 0.0022. Pushing the candidate limit from 10 to 500 lifted the best achievable score by up to 0.28, yet the score users actually saw moved by about 0.01. The relevant documents were already in the candidate list. Ranking was burying them.</p><p>That gap is what this article is about. Tuning vector search is mostly the work of finding which stage failed before changing anything. Once the failing stage is known, the right setting is usually obvious.</p><p>The walkthrough uses a deliberately tiny Qdrant collection running locally. Twenty points. Nothing gets benchmarked at that size. Small collections make the mechanics easy to see, and they expose a couple of traps that large collections quietly hide.</p><h3>The pipeline being tuned</h3><p>Every query does two jobs. Retrieval decides what can be found. Ranking decides what the user sees first.</p><p>In dense-only search, one vector search does both. Hybrid search splits them apart. A dense prefetch and a sparse prefetch each return a candidate list, fusion merges the lists into one ranking, and an optional reranker can reorder the top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8VrK4wPQcUpDLvYjpFPHJQ.png" /><figcaption><em>The hybrid query path in Qdrant and the settings each stage owns.</em></figcaption></figure><p>The useful part of this picture is ownership. Each setting belongs to exactly one stage. limit and hnsw_ef live on the dense prefetch. The IDF modifier and BM25 average length live on the sparse side. RRF k, weights and DBSF live in fusion. Fusion can only reorder what arrived. A document missing from both prefetch lists never reaches the result, no matter how fusion is configured.</p><h3>The demo collection</h3><p>The demo is a short Python script, qdrant_tuning_example.py, talking to a local Qdrant instance exposed on port 16333. The dashboard reports Qdrant v1.19.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYgKeOnA8x7_eb2z08L2MA.png" /><figcaption><em>Sparse vectors built from hashed word counts, and the client pointed at the local instance.</em></figcaption></figure><p>The sparse side is built by hand. Each word is hashed with MD5 and reduced modulo 100,000 to get an index, and the word’s count becomes the value. That is a plain bag-of-words vector. No stemming, no stopword removal, no length normalization.</p><p>It is fine for showing mechanics. It is not BM25. A production collection should use Qdrant’s BM25 or a trained sparse model such as miniCOIL or SPLADE. Hash collisions are also possible with this scheme, though at twenty documents they are unlikely to matter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bN9NWovB_JHdIAR2lba79w.png" /><figcaption><em>Collection info for tuning_demo in the Qdrant Web UI</em></figcaption></figure><p>Figure shows the collection configuration. A 64-dimension dense vector named dense with cosine distance. A sparse vector named sparse with the idf modifier. HNSW at m=16 and ef_construct=100, with a full_scan_threshold of 10000. Status green, optimizer ok.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lAk3jIv4IpgveNS7fdxSsg.png" /><figcaption><em>The first two points, each carrying a named dense vector and a named sparse vector.</em></figcaption></figure><p>Figure is a cheap sanity check worth copying. “the quick brown fox jumps over the lazy dog” has nine words, but “the” appears twice, so its sparse vector should have eight non-zero entries. It does. “a fast red fox runs through the forest” has eight distinct words and also shows length 8. The sparse builder does what it claims. A minute spent on checks like this saves hours of tuning against broken input.</p><h3>Check the collection before touching a knob</h3><p>Qdrant’s pre-tuning guide lists settings that cap quality without raising an error. Two of them are easy to miss.</p><p>A sparse vector without the IDF modifier stops rare words from counting more than common ones. A BM25 average length left at the default of 256 misjudges every document’s length. On Qdrant’s five datasets the correct values ran from 35.3 to 151.4, measured after stemming and stopword removal. Neither mistake produces a warning. Results just get worse, and every benchmark run on top of them measures a configuration error.</p><p>The demo passes the IDF check, since Figure 2 shows modifier: “idf” on the sparse vector. With raw word counts that is the right call. With SPLADE it would be wrong, because SPLADE already bakes corpus-level weighting into its values and IDF would count rarity twice.</p><h3>Index state, and why hnsw_ef does nothing here</h3><p>Figure 2 reports points_count: 20 and indexed_vectors_count: 20. Qdrant counts each named vector separately, so a collection with one dense and one sparse vector per point can report up to twice points_count. Qdrant’s docs treat this as a rough signal rather than an equality test.</p><p>Here the signal points somewhere useful. Qdrant builds an HNSW graph only once a segment passes indexing_threshold, which defaults to 10,000 KB. Twenty 64-dimension vectors spread across six segments are nowhere close. Smaller segments are searched with an exact scan. Results stay correct, but hnsw_ef has no effect until the graph exists.</p><p>So any hnsw_ef sweep on this collection would measure noise. The same trap exists in production right after a bulk load, while the optimizer is still catching up. Check status, check the indexed count, and wait for indexing to settle before measuring latency or graph settings.</p><h3>Three more silent failures</h3><p>• A score_threshold copied from dense-only search into an RRF or DBSF query is compared against the fused score, not the dense one. It can truncate the result list or return nothing. Validate it on labels or leave it unset.</p><p>• On sharded collections, fusion at the root of the query runs once after all shards return. Fusion nested inside a prefetch runs per shard, on shard-local candidates. The ranking then shifts with shard count, silently.</p><p>• Payload indexes added after the HNSW graph was built do not add filter-aware edges on their own. The graph needs a rebuild. Create indexes for filtered fields before ingestion.</p><h3>Labels decide what can be measured</h3><p>Without labeled queries, tuning is opinion. A labeled query pairs a real user query with the documents that should come back. Qdrant’s guide goes one step further and asks how many labels it takes before a gain becomes visible.</p><p>Across their datasets, the 95% interval around an nDCG@10 gain typically extended this far on either side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLamwQ6vuF54R-WizyA38A.png" /></figure><p>Now compare that with the size of real gains. Fusion tuning on an already working collection moved nDCG@10 by 0.012 to 0.038. With 25 queries, the noise band is wider than the best gain on record. The demo script prints the same warning in Figure 1.1, and it applies with full force to a run built on one query.</p><p>The metric deserves the same care. nDCG@10 rewards relevant results near the top and suits ranked lists. MRR@10 suits queries with one right answer. Recall@k suits a first stage that feeds something else. In Qdrant’s tests these three often named different best settings, and Recall@100 disagreed with nDCG@10 on four of five datasets. Choose the metric first, because the metric picks the winner.</p><p>Two checks turn a score into a decision. First, resample the per-query gains with replacement to get a 95% interval. If the interval includes zero, the labels cannot establish a gain. Second, select the winning setting on half of the queries and measure it on the other half. In Qdrant’s runs the selected setting kept 67% to 95% of its reported gain on fresh queries. Report the fresh number.</p><h3>Missed by retrieval, or buried by ranking?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cNJQxSK9inYVFpuFvoNxg.png" /><figcaption><em>Demo output for the query “fox and dog running”: depth diagnostic, fusion comparison, and quantized search</em></figcaption></figure><p>The first block in Figure 1.1 runs the same hybrid query with a prefetch limit of 5 and then 20. Both top-5 lists hold the same five documents. Only the order changes.</p><p>At depth 5, “quarterly earnings beat analyst expectations” ranks first for a query about a fox and a dog. At depth 20, “the quick brown fox jumps over the lazy dog” moves to the top. The dense vectors in this demo do not appear to encode meaning, which is expected from a toy 64-dimension embedding, so the earnings sentence most likely reaches the top through the dense prefetch alone.</p><p>The arithmetic explains the flip. Qdrant’s default RRF scores a document at zero-based position pos as 1 / (pos + k) with k=2. If the earnings sentence is the dense prefetch’s first hit and the fox sentence is the sparse prefetch’s first hit, both score exactly 1/2. That is a tie, and Qdrant notes that tied results come back in whatever order storage produced. At depth 20 the prefetch covers the whole collection. The fox sentence now also appears somewhere in the dense list, picks up a second contribution, and breaks the tie.</p><p>Nothing new was retrieved into the top 5. More candidates changed the fusion arithmetic. That is the small-scale version of what Qdrant measured at scale, and it is why the diagnostic in Diagram 2 matters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upDUwpcSwQcWM5qs_cvLqw.png" /><figcaption><em>Separating a retrieval failure from a ranking failure before paying to fix either</em></figcaption></figure><p>Score the candidate set as if it were ordered perfectly. That is the ceiling any later ranking stage could reach. Then compare it with the score the pipeline actually returns. Qdrant’s numbers for a limit change from 10 to 500 make the point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEMqCz-aF-fiOgEjicYYsw.png" /></figure><p>A large gap means retrieval already found the documents and ranking is losing them. Fix fusion, then consider a reranker. A small gap means ranking is close to its ceiling, so the candidates themselves need to improve.</p><p>Depth is not free. In Qdrant’s single-shard tests, raising limit from 10 to 500 added 37% to 43% to median latency. Depth also applies per shard. A limit=200 on 12 shards can deliver up to 2,400 candidates to fusion or a reranker. A starting range of 100 to 200 is reasonable when a downstream stage can use the extra candidates.</p><h3>Raise hnsw_ef only while recall is still climbing</h3><p>hnsw_ef widens the set of graph nodes a search visits. It does not change how many results come back. The honest way to tune it is against exact search, not against intuition.</p><pre>truth = [top_ids(v, exact=True) for v in queries]   # full scan, run once<br> <br>for ef in (16, 64, 128, 256, 512):<br>    found = sum(len(top_ids(v, hnsw_ef=ef) &amp; t)<br>                for v, t in zip(queries, truth))<br>    print(ef, found / (LIMIT * len(queries)))</pre><p>On a one-shard SciFact collection, recall against exact search was already 0.999 at hnsw_ef=128 and flat after that, while time per query crept up. On the full 4.6 million document DBPedia-entity collection, the graph returned 0.957 of the exact top 10. Saturation is a property of each graph. Pick the lowest value that meets the recall target inside the latency budget. If no value gets there, m and ef_construct raise the ceiling, at the cost of an index rebuild.</p><h3>Fusion: the cheapest change with the largest swing</h3><p>Fusion reorders lists that were already retrieved. It needs no rebuild and no extra retrieval work, which puts it first in line for tuning.</p><p>Qdrant’s RRF defaults to k=2. The original RRF paper by Cormack and colleagues uses 60 with one-based ranks, which maps to k=61 in Qdrant’s zero-based formula. The difference is large. At k=2, rank 1 carries 5.5 times the weight of rank 10. At k=61 it carries 1.15 times, so simply being present in a list matters almost as much as position. On WANDS, switching between the two changed the top result for 202 of 480 queries.</p><p>Qdrant’s data suggests a useful heuristic. Datasets with about one relevant document per query preferred k of 2 or 5. Datasets with tens or hundreds of relevant documents per query preferred 20 or 61. Count relevant documents per query in the label set, start in that part of the range, and sweep 1, 2, 5, 20 and 61. Even steps of five waste most runs, because the curve flattens past 20.</p><p>DBSF is the other option. It rescales each list using its mean and spread, so the size of a lead carries into the fused score. It takes no parameters, and it beat default RRF on three of five datasets with intervals that excluded zero. RRF ignores score scale entirely. DBSF trusts it, which means one outlying score can move the result. Run both against labels.</p><pre>prefetches = [<br>    models.Prefetch(query=dense_q, using=&quot;dense&quot;, limit=200),<br>    models.Prefetch(query=sparse_q, using=&quot;sparse&quot;, limit=200),<br>]<br> <br># RRF with explicit k and weights (Qdrant v1.17+)<br>client.query_points(&quot;tuning_demo&quot;, prefetch=prefetches,<br>    query=models.RrfQuery(rrf=models.Rrf(k=2, weights=[1.0, 1.0])), limit=10)<br> <br># DBSF, no parameters<br>client.query_points(&quot;tuning_demo&quot;, prefetch=prefetches,<br>    query=models.FusionQuery(fusion=models.Fusion.DBSF), limit=10)</pre><p>Weights come last. A weight pair is only valid for the k it was tested with, and pairs are absolute, so (1, 2) and (2, 4) are different settings. Do not infer weights from which retriever looks stronger alone. On DBPedia-entity, dense retrieval beat sparse on its own, yet the winning pair gave sparse three times the dense weight.</p><p>The fusion block in Figure 1.1 shows RRF at k=2, RRF at k=61 and DBSF all returning the same top document. For one query, agreement proves nothing. It is an anecdote, and the script says as much.</p><p>One practical detail is worth stealing. Low k produces more tied scores, and ties come back in storage order, so the same query can return a different document at rank 10. Request more than the page size, sort client-side by score descending and ID ascending, then trim.</p><h3>Rerankers often get credit for skipped tuning</h3><p>A cross-encoder costs a forward pass per candidate on every query, for as long as it runs. Qdrant tested four rerankers. The best one beat out-of-the-box fusion on all five datasets. Against tuned fusion, most of that lift disappeared, and one win turned into a loss.</p><p>The lesson is about baselines. Compare a reranker against tuned fusion, never against defaults. Otherwise the model earns credit for work a single parameter could have done for free.</p><h3>When the collection outgrows RAM</h3><p>Quantization keeps a compressed copy of each dense vector in memory. With rescore on, Qdrant rereads the original vectors for a shortlist and reorders it at full precision. oversampling controls how big that shortlist is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBiyPZRekJ4tsVt-JAm4Aw.png" /><figcaption><em>Quantized search with rescoring, and the point where rescoring starts hitting disk.</em></figcaption></figure><p>While the originals sit in page cache, rescoring is close to free. Once they stop fitting, every rescored candidate can trigger a disk read. In Qdrant’s test on 4.6 million vectors, the same query took 4.1 ms with rescoring under a 12 GiB limit and 43.4 ms under 4 GiB. No error, no configuration change. The collection simply grew past memory.</p><p>Switching rescoring off is not a clean escape. With 1-bit TurboQuant and no rescoring, the dense stage found only 0.605 of the exact top 10. One rescoring pass at oversampling=1 brought that to 0.951. Extra oversampling beyond that added disk reads for little recall.</p><p>Qdrant v1.19 replaced the old on_disk and always_ram flags with a per-structure memory setting. cold loads lazily from disk, cached enters page cache and may be evicted, and pinned stays in RAM. The recommended pairing pins the quantized copy and leaves originals cold. On Linux, setting storage.performance.io_uring to auto lets Qdrant issue a query’s rereads in parallel. For a first sizing estimate, Qdrant’s rule of thumb is vectors × dimensions × 4 bytes × 1.5.</p><p>The quantized block in Figure 1.1 returns no fox or dog documents at all. That reflects the toy dense vectors more than quantization, and at twenty points everything fits in RAM, so latency numbers from this demo would be meaningless. The script’s own advice is the right one. Benchmark p95 with rescoring on, at the real ratio of memory to collection size.</p><h3>A tuning order that holds up</h3><p>Putting it together gives a sequence where every change is cheap to undo and easy to measure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4b1GUq7u1IEjGjOBsJ3_lw.png" /><figcaption><em>A tuning process that moves from cheap, reversible changes to rebuilds.</em></figcaption></figure><p>1. Verify the collection: status, index state, IDF modifier, BM25 average length, payload indexes, score_threshold.</p><p>2. Build a labeled set large enough to detect the gain being chased, and choose the metric up front.</p><p>3. Name the symptom. Missing documents, misordered documents, unmatched keywords, latency, or memory each point to a different stage.</p><p>4. Change one setting, starting with the cheapest tier that fits. Fusion first, then depth and hnsw_ef, then a new stage, and rebuilds last.</p><p>5. Score per-query gains with a bootstrap interval, then confirm the winner on held-out queries before shipping.</p><h3>When tuning is the wrong move</h3><p>If exact search also returns poor results, no Qdrant parameter will help. The problem sits in the embedding model, the chunking, or the data. Fix that first.</p><p>Hybrid search is not automatically better either. On DBPedia-entity, dense alone scored 0.4677 and RRF fusion scored 0.4638. The second prefetch costs a second index, a second vector per point, and 0.6 to 1.5 ms of query time on one shard. Keep it only when labels show it earns that.</p><p>And sometimes the right answer is the default. On SciFact’s 300 queries, nothing Qdrant tried produced an interval that excluded zero. Keeping the defaults was the correct decision on one of five datasets. A team that cannot show a gain on held-out queries has not found one.</p><p>The demo has its own limits, and they should be stated plainly. Twenty points, one query, toy dense vectors, and a hand-built sparse encoder. It shows how the mechanics behave. It does not measure quality or latency, and none of its outputs should be read as a benchmark.</p><h3>Worth thinking about</h3><p>Every Qdrant setting mentioned here is documented precisely. What no reference can document is the shape of a particular dataset: how many relevant documents a typical query has, how far the collection is from its memory limit, whether the graph is even built yet.</p><p>So the most useful question before any change is not “what should this value be?” It is “which stage failed, and can the labels see the fix?” Teams that answer that first tend to change fewer settings, and keep more of what they change.</p><h3>References</h3><p>• Qdrant blog, How to Tune Vector Search Without Guessing. <a href="https://qdrant.tech/blog/tuning-retrieval-which-knob-first/">https://qdrant.tech/blog/tuning-retrieval-which-knob-first/</a></p><p>• What to Check Before Tuning a Qdrant Collection. <a href="https://qdrant.tech/documentation/search-tuning/before-tuning-a-qdrant-collection/">https://qdrant.tech/documentation/search-tuning/before-tuning-a-qdrant-collection/</a></p><p>• Candidate Depth: How Much Retrieval Is Enough?. <a href="https://qdrant.tech/documentation/search-tuning/candidate-depth/">https://qdrant.tech/documentation/search-tuning/candidate-depth/</a></p><p>• How to Tune Hybrid Search in Qdrant. <a href="https://qdrant.tech/documentation/search-tuning/how-to-tune-hybrid-search/">https://qdrant.tech/documentation/search-tuning/how-to-tune-hybrid-search/</a></p><p>• When Is a Reranker Worth It?. <a href="https://qdrant.tech/documentation/search-tuning/when-a-reranker-is-worth-it/">https://qdrant.tech/documentation/search-tuning/when-a-reranker-is-worth-it/</a></p><p>• When Your Collection Outgrows RAM. <a href="https://qdrant.tech/documentation/search-tuning/when-your-collection-outgrows-ram/">https://qdrant.tech/documentation/search-tuning/when-your-collection-outgrows-ram/</a></p><p>• Hybrid Search in Qdrant. <a href="https://qdrant.tech/documentation/search-tuning/hybrid-search/">https://qdrant.tech/documentation/search-tuning/hybrid-search/</a></p><p>• Cormack, Clarke and Buettcher, Reciprocal Rank Fusion (SIGIR 2009). <a href="https://dl.acm.org/doi/10.1145/1571941.1572114">https://dl.acm.org/doi/10.1145/1571941.1572114</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=918486bd24f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prefetch Flat, Rescore Curved: Serving Hyperbolic Embeddings in Qdrant]]></title>
            <link>https://medium.com/@parichaydas/hyperbolic-embeddings-and-qdrant-960c524959c7?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/960c524959c7</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 17:54:22 GMT</pubDate>
            <atom:updated>2026-10-04T15:43:46.487Z</atom:updated>
            <content:encoded><![CDATA[<h3>The geometry nobody chose</h3><p>Most retrieval stacks make three deliberate choices. Which embedding model, how many dimensions, which index. A fourth decision, the geometry of the space those vectors live in, usually never gets made. It arrives bundled with the model as cosine on a sphere or Euclidean distance on a flat plane, and nobody questions it.</p><p>For plenty of data that default is fine. For hierarchical data it works against you, and it does so quietly.</p><p>Think about anything that branches. A product catalogue where footwear splits into boots, trainers and sandals, and boots split again into ankle, hiking and work boots. A biological taxonomy. A policy library organised by domain, then by regulation, then by clause. In each case the number of nodes multiplies at every level, and the relationship you usually care about runs vertically. What is this a kind of, and what sits underneath it?</p><p>Qdrant recently published a detailed piece by Matin Mahmood and John Kupchanko on exactly this problem, <a href="https://qdrant.tech/articles/hyperbolic-embeddings-qdrant/">Why Hyperbolic Embeddings Matter for Hierarchical Data</a> (September 2026). What follows is an engineering read of that work, paired with a small reproduction against a local Qdrant 1.19 instance that makes the mechanics visible instead of asking anyone to take them on trust. The reproduction is tiny on purpose. It is good for intuition and useless as a benchmark, and the line between the two is drawn explicitly below.</p><h3>Flat space runs out of room</h3><p>The core argument is about counting. A tree in which every node has three children holds 3ℓ nodes at depth ℓ. Ten levels down, that is 59,049 leaves. Node count grows exponentially with depth.</p><p>Euclidean space does not grow that way. In d dimensions, the volume inside radius r grows as rd, which is polynomial. You can raise d to buy more room, and that is what most teams end up doing without framing it this way, but you are paying for exponential capacity with polynomial currency. Somewhere down the tree the branches start to crowd. Crowding is what hurts retrieval, because a leaf can end up closer to a leaf in another branch than to its own grandparent.</p><p>Hyperbolic space has constant negative curvature, and its volume grows exponentially with radius. In two dimensions with curvature −1, the area of a disk of radius r is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wey9TgUBvZ8JhWTf0y_YCQ.png" /></figure><p>That is the same shape of growth as the tree itself. Fresh room keeps appearing as you move outward, so every new level gets space for its children without squeezing its neighbours.</p><p>None of this is new mathematics. Sarkar showed in 2011 that a tree can be placed in the hyperbolic plane with arbitrarily low distortion, and van Spengler and Mettes (ICML 2025) extend that construction while noting that even simple trees embed into Euclidean space with high distortion. Nickel and Kiela’s 2017 Poincaré embeddings paper turned the idea into something you can train with gradient descent, and it remains the empirical reference point.</p><p>Their WordNet result is the one people cite, and the gap is large enough to deserve it. On reconstructing the noun hierarchy, a 5-dimensional Poincaré embedding scored 0.823 mean average precision (MAP), against 0.168 for a 200-dimensional Euclidean one. Forty times fewer coordinates, and better structure.</p><p>The Qdrant authors repeated the comparison on something closer to a real application, the Google Product Taxonomy with 5,595 categories across seven levels. They trained both embeddings themselves so that data, dimension and optimiser stayed fixed and only the geometry changed. At 5 dimensions the Poincaré embedding reached 0.905 MAP. The Euclidean one reached 0.239 at the same size and only 0.658 at 50 dimensions.</p><p>There is a caveat in their own write-up that deserves more attention than it usually gets. Those scores measure relationships the embedding saw during training. Asked to find each category’s direct parent, the score dropped to 0.539 MAP. Hyperbolic geometry gives a hierarchy room to exist. It does not, by itself, make a model generalise to structure it never saw.</p><h3>The Poincaré ball and the one formula you need</h3><p>The model used throughout is the Poincaré ball. It represents hyperbolic space inside the open unit ball, so every point is still an ordinary vector with a norm below 1. Your database can store it like any other vector. What changes is the ruler. Near the centre, hyperbolic distance behaves almost like Euclidean distance. Near the boundary, the same small Euclidean step corresponds to a much larger hyperbolic one, and the boundary itself is infinitely far away.</p><p>The geodesic distance between two points u and v is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0TFsTw8O4a2bvon56V_KA.png" /></figure><p>Read it in two halves. The numerator is plain squared Euclidean distance, which every vector database already computes. The denominator is where the geometry lives. As either point approaches the rim, 1 − ‖x‖² heads towards zero and the distance blows up. Two points that look close on a flat plot can be far apart in hyperbolic terms if both sit near the edge. That is exactly the mechanism that makes room for leaves.</p><p>It also gives you something flat embeddings do not offer by default. Radius can carry meaning. Put broad concepts near the centre and specific ones near the rim, and direction separates branches while distance from the origin tracks how specific a node is. Footwear sits at the origin, boots a step out, a black Chelsea boot close to the edge.</p><p>The distance from the origin to a point at Euclidean norm r has a closed form, 2·artanh(r). Keep that in mind, because it shows up in the experiment below.</p><h3>Serving hyperbolic search from a Euclidean engine</h3><p>Qdrant does not ship a hyperbolic distance metric. You get Cosine, Dot, Euclid and Manhattan. So the engineering question is how to get correct hyperbolic rankings out of a system built around flat metrics, without bolting a second search service onto the side.</p><p>The authors first tried the textbook route. Hyperbolic distance can be rewritten as an inner product by lifting vectors into two extra dimensions. Under brute-force search in Faiss this worked well, with recall@10 of 0.986 across 82,115 WordNet nouns. Behind Faiss’s HNSW index, recall@10 collapsed to 0.020, even at ef=1024. The transformed vectors had norms spread over roughly a 600x range, which a proximity graph built on inner product handles badly, and grouping vectors by norm only lifted recall to 0.410.</p><p>Those are Faiss numbers, not Qdrant numbers. The lesson travels anyway. A transform can be mathematically exact and still be hostile to an approximate index.</p><p>So they changed the search plan instead of the vectors. The resulting architecture looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fA21RoLxfemrxNi9xumPvQ.png" /><figcaption>Write path and two-stage query path for hyperbolic search in Qdrant</figcaption></figure><p>On the write path, the raw Poincaré coordinates go into a named vector configured with Distance.EUCLID. Nothing is transformed. Each point also carries its squared norm as a float payload field called sq_norm, and the article recommends a payload index on it, since without one the rescore turns into a full scan.</p><p>On the query path, the client computes a single scalar before sending, c = 1 − ‖q‖² for the query vector. Stage one is an ordinary Euclidean prefetch over the stored coordinates with a deliberately wide limit. Stage two is a <a href="https://qdrant.tech/documentation/search/hybrid-queries/">Formula Query</a> that takes each candidate’s Euclidean distance (exposed as $score) and its sq_norm, rebuilds the argument of arcosh, and re-ranks. Both stages run server-side in one request.</p><p>One operator is missing. Formula Query has no arcosh, but it does have ln, sqrt and pow, and arcosh(x) = ln(x + √(x² − 1)). The formula returns the negated distance because Qdrant ranks higher scores first. The article’s reference list includes a Qdrant pull request that adds acosh as a native expression. Which release carries it is worth confirming in the changelog for your version before depending on it.</p><p>For the ankle_boots query in the toy collection described in the next section, the request has the shape below. The query’s squared norm is 0.4865, so c works out to 0.5135. X is a placeholder for the inner term, which you paste in at both positions.</p><pre>// X, the argument of arcosh<br>{&quot;sum&quot;: [1.0, {&quot;div&quot;: {<br>  &quot;left&quot;:  {&quot;mult&quot;: [2.0, {&quot;pow&quot;: {&quot;base&quot;: &quot;$score&quot;, &quot;exponent&quot;: 2.0}}]},<br>  &quot;right&quot;: {&quot;mult&quot;: [0.5135, {&quot;sum&quot;: [1.0, {&quot;neg&quot;: &quot;sq_norm&quot;}]}]}<br>}}]}<br><br>// The full request<br>{<br>  &quot;prefetch&quot;: [{<br>    &quot;query&quot;: [0.6554, 0.2386],<br>    &quot;using&quot;: &quot;hyperbolic&quot;,<br>    &quot;limit&quot;: 14<br>  }],<br>  &quot;query&quot;: {&quot;formula&quot;: {&quot;neg&quot;: {&quot;ln&quot;: {&quot;sum&quot;: [<br>    X,<br>    {&quot;sqrt&quot;: {&quot;sum&quot;: [{&quot;pow&quot;: {&quot;base&quot;: X, &quot;exponent&quot;: 2.0}}, -1.0]}}<br>  ]}}}},<br>  &quot;limit&quot;: 6,<br>  &quot;with_payload&quot;: true<br>}</pre><p>With 14 points, a prefetch limit of 14 simply means everything. At real scale that number becomes the most important knob in the system.</p><p>Why Euclidean for the prefetch and not cosine? Away from the rim, Euclidean distance tracks hyperbolic distance closely enough to gather the right candidates. The authors measured both. At a prefetch of 50, cosine was slightly ahead (0.505 against 0.473 recall@10). At 1,000 it fell behind (0.876 against 0.920) and never caught up, saturating near 0.875. Direction finds the right neighbourhood but cannot separate depths inside it, and depth is the whole point.</p><h3>Reproducing it on a toy catalogue</h3><p>Every stage of that pipeline can be observed on the smallest collection that still contains a hierarchy. Fourteen footwear categories, four levels deep, hand-placed in a two-dimensional Poincaré disk and loaded into Qdrant 1.19.0 running locally. It mirrors the catalogue example the Qdrant article opens with, shrunk to something you can read on one screen.</p><p>The placement is mechanical. Footwear sits at the origin. Boots, trainers and sandals sit at Euclidean radius 0.450, their children at 0.698, and the three deepest leaves at 0.834. Converted with 2·artanh(r), those rings land at hyperbolic radius 0.97, 1.73 and 2.40. Depth is written directly into distance from the centre, and direction decides the branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xmWl7RxqNC939ttFA3RFhQ.png" /><figcaption>Figure 1. The 14-node taxonomy plotted from the coordinates in the run output, with edges drawn as hyperbolic geodesics. ankle_boots, in red, is the query node used below.</figcaption></figure><h3>What the script printed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkZzAmzIZuPR9aQ0lcPEhg.png" /><figcaption>Coordinates for all 14 points, then two top-6 result lists for the query node ankle_boots.</figcaption></figure><p>The top of the output lists every node with its Euclidean radius and coordinates. Below that are two result lists for the same query.</p><p>The first list is the two-stage pipeline, a Euclidean prefetch followed by the Formula Query rescore. qdrant_score is what Qdrant returned, the negated hyperbolic distance. true_hyperbolic_dist is the same quantity recomputed in Python from the raw coordinates. They match to four decimals on every row. That is the most important thing on the screen, because it confirms that the arcosh-free formula running on the server produces the real geodesic distance.</p><p>The second list ranks by Euclidean distance alone, with the true hyperbolic distance printed beside each hit for comparison.</p><p>The first five rows agree. The query itself, its two Chelsea boot children, its parent boots, then the sibling hiking_boots. The sixth slot is where the two geometries part ways.</p><p>Euclidean distance puts waterproof_hiking_boot sixth. That node hangs under hiking_boots, a different sub-branch, and its true hyperbolic distance is 2.23. The rescored list puts footwear sixth instead, the root of the whole tree, at 1.72. Recomputing the full 14-point ranking from the printed coordinates shows how far apart the two views really are. Under Euclidean distance, footwear only comes eighth, behind sport_sandal, which lives in a different top-level branch entirely. Under hyperbolic distance, waterproof_hiking_boot drops to ninth.</p><p>In tree terms, flat geometry swapped a two-hop ancestor (ankle_boots to boots to footwear) for a three-hop cousin (ankle_boots to boots to hiking_boots to waterproof_hiking_boot). On a 14-point toy that costs one slot. On a catalogue with thousands of leaves, the same crowding is what fills a result page with near-miss siblings.</p><p>The scale of the numbers changes too. The Chelsea boots are 0.19 away in Euclidean terms and 0.93 in hyperbolic terms, almost five times larger, because both sit close to the rim. Their order barely moves. What changes is that the distance now carries depth.</p><p>The run also emitted a DeprecationWarning for recreate_collection. The fix is mechanical: call collection_exists, delete the collection if it is there, then call create_collection. Do it before publishing the script, because readers on a newer client will hit the removal rather than the warning.</p><h3>What Qdrant thinks the collection is</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QBzNMQtQgKqfzYN1SFhh9A.png" /><figcaption>Collection info for taxonomy_geometry in the Qdrant Web UI.</figcaption></figure><p>Status green, 14 points, one named vector called hyperbolic with size 2 and distance Euclid. That confirms the core design decision. Qdrant has no idea these are hyperbolic coordinates. It stores a flat 2D vector and measures it with a flat ruler, and all the curvature lives in the query.</p><p>The line that deserves attention first is indexed_vectors_count: 0. No HNSW graph exists. The collection sits far below the full_scan_threshold of 10,000 KB shown under hnsw_config, so Qdrant answers every query with an exact scan. The script labels its first list “Euclidean HNSW prefetch”, and at this size that label describes the intent rather than what ran. The same holds for the Qdrant article’s 5,595-point test, which the authors say was served by exact search. At production scale the prefetch becomes a genuinely approximate search, and its recall joins your error budget.</p><p>The m of 16 and ef_construct of 100 are Qdrant’s defaults. Nothing here was tuned, and nothing here needed to be.</p><h3>Stage one, by hand</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwwxcZ1yxHd80Ixd5sus9A.png" /><figcaption>A raw Euclidean query against the hyperbolic named vector, run from the Qdrant console.</figcaption></figure><p>This is the prefetch on its own, without the formula. A plain query with the ankle_boots coordinates against the hyperbolic vector, limit 6, payload included. The scores are raw Euclidean distances. Brown Chelsea boot at 0.19023, black at 0.19031, the same near-tie the Python output showed.</p><p>Two details are worth reading. The query point scores 0.000054 against itself instead of zero. The most likely cause is that the console query uses coordinates rounded to four decimals while the stored vector keeps full float precision, so the request lands a few hundred-thousandths away from the real point. The second detail is the payload. Each hit carries its sq_norm, 0.4865 for the query node and 0.6949 for both Chelsea boots. Those are exactly the values the formula reads in stage two. Everything the rescore needs already sits beside the vector.</p><h3>What the toy proves, and what it does not</h3><p>Here is the full ranking for the ankle_boots query, recomputed from the 14 printed coordinates. Euclidean on the left, hyperbolic on the right.</p><pre>#   Euclidean              dist   Hyperbolic             dist<br>1   ankle_boots            0.000  ankle_boots            0.000<br>2   brown_chelsea_boot     0.190  brown_chelsea_boot     0.927<br>3   black_chelsea_boot     0.190  black_chelsea_boot     0.928<br>4   boots                  0.456  boots                  1.326<br>5   hiking_boots           0.477  hiking_boots           1.661<br>6   waterproof_hiking_boot 0.539  footwear               1.725<br>7   sport_sandal           0.590  sport_sandal           1.965<br>8   footwear               0.698  sandals                2.019<br>9   sandals                0.762  waterproof_hiking_boot 2.231<br>10  work_boots             0.897  work_boots             2.648<br>11  trainers               1.131  trainers               2.669<br>12  flip_flop              1.143  flip_flop              3.080<br>13  running_shoe           1.264  running_shoe           3.266<br>14  basketball_shoe        1.390  basketball_shoe        3.443</pre><p>The screenshots support three claims. The two-stage pipeline runs end to end inside Qdrant. The Formula Query reproduces the true Poincaré distance exactly. And for at least one query, rescoring changes which nodes make the top six, in the direction the theory predicts.</p><p>They do not show that hyperbolic search retrieves better. Fourteen hand-placed points and one query cannot carry that claim. The evidence for quality is the Qdrant team’s taxonomy benchmark and the Nickel and Kiela results, not this demo.</p><p>The table also exposes something the screenshots hide. Look at work_boots. It is a sibling of ankle_boots, two hops away through boots, yet both geometries rank it tenth, behind sandals and sport_sandal, which are three and four hops away. Its hyperbolic distance of 2.65 is larger than the 2.02 to sandals.</p><p>The reason is the placement, not the metric. work_boots sits about 80 degrees around the disk from ankle_boots, exactly the same angular gap that separates ankle_boots from the sandals node. Sandals sits nearer the centre, where hyperbolic space is cheap to cross, so the geodesic to it is shorter. Hyperbolic distance faithfully measures the coordinates it is handed. It does not know the tree.</p><p>That is the practical lesson of the experiment. The geometry provides the room, and the training objective decides how well that room gets used. Hand-placed points, or embeddings trained without a hierarchy-aware loss, can sit in a perfectly good Poincaré ball and still encode the wrong neighbourhoods.</p><h3>Trade-offs and failure modes to plan for</h3><h3>Prefetch width is the real knob</h3><p>Rescoring only reorders what the prefetch hands it. A true neighbour that never enters the candidate set cannot be rescued. On the 5,595-point taxonomy, the Qdrant team measured Euclidean-only recall@10 at 0.266. With the rescore it reached 0.257 at a prefetch of 10, 0.472 at 50, 0.598 at 100, 0.783 at 300 and 0.920 at 1,000. At a prefetch of 10 the rescore does slightly worse than doing nothing.</p><p>So correctness is bought in candidates. The formula is evaluated once per candidate, which means query cost should grow with prefetch width. Neither the toy run nor the article publishes latency numbers for this setup, so measure it on your own hardware before committing to 1,000.</p><h3>A better model can need a wider prefetch</h3><p>This one is counterintuitive. In the authors’ offline comparison, the stronger embedding (0.905 MAP) recovered 0.498 of the true neighbours from a prefetch of 50. The weaker one (0.724 MAP) recovered 0.789. Better hyperbolic embeddings push more points towards the rim, and near the rim Euclidean distance stops being a reliable shortcut.</p><p>The operational consequence is easy to miss. Upgrading the embedding can quietly degrade retrieval if nobody touches the search config. Treat a model change and the prefetch limit as one change, and evaluate them together.</p><h3>The rim is numerically fragile</h3><p>As ‖x‖ approaches 1, the term 1 − ‖x‖² approaches zero, and tiny errors in stored coordinates become large errors in distance. Poincaré training code normally projects points back inside the ball with a small margin, as Nickel and Kiela do. Keep that margin at ingest time.</p><p>Vector quantization deserves caution on a collection like this. Scalar or binary quantization introduces exactly the kind of small coordinate error that the denominator amplifies near the edge. This effect has not been measured here. Treat it as a hypothesis to test before switching quantization on, not as a finding.</p><h3>sq_norm lives apart from the vector</h3><p>The squared norm is a payload field, written separately from the vector it describes. If a pipeline updates a vector and forgets the payload, every distance involving that point is wrong and nothing raises an error. Compute sq_norm in the same function that writes the vector, and add a periodic consistency check that compares the two.</p><h3>Measure the radius before building any of this</h3><p>The most useful practical test in the article is a single number. The authors measured the output of two open hyperbolic CLIP models and found every point in a thin shell close to the origin, with a median hyperbolic radius of 0.627 for HyCoCLIP-ViT-S and 0.872 for MERU-ViT-S. Near the origin hyperbolic space is almost flat. On 300 of those vectors, plain cosine reached 0.9997 recall@10 against the exact geodesic.</p><p>Their rule of thumb is to compute the median hyperbolic radius of your corpus. Below roughly 2, treat the space as flat and use an ordinary metric. Above it, prefetch and rescore earns its complexity.</p><p>Applied to the toy collection, the median radius is 1.73, just under that line. That fits what the screenshots show, with the two rankings agreeing on five of six slots. Only the outer ring at 2.40 is far enough out for the geometries to disagree sharply.</p><p>For models that live on the hyperboloid (the Lorentz model) rather than in the Poincaré ball, the authors report a cleaner route. Ranking by the Lorentz inner product matched ranking by geodesic distance exactly, with a Spearman correlation of 1.0 across 40 queries. Negate the time coordinate before storing and Distance.DOT returns hyperbolic order with no rescore at all. Their <a href="https://github.com/jkupchanko/qdrant-hyperbolic-transform">qdrant-hyperbolic-transform</a> repository packages the transform and the two-stage search.</p><h3>When not to use it</h3><p>The authors are direct that a general catalogue where people type product names is better served by a flat model, and that judgement holds up. Hyperbolic geometry earns its keep when the hierarchy is deep and parent-child structure is what the query is actually about.</p><p>Shallow hierarchies of two or three levels are weak candidates too, because there is little crowding to fix. Data where nodes have several parents, a DAG rather than a tree, is harder to place cleanly, and more distortion should be expected there. Both points are engineering judgement rather than measured results. And if you need the model to infer relationships it never saw in training, remember the drop from 0.905 to 0.539 MAP on direct-parent prediction.</p><h3>A closing thought</h3><p>For years the default answer to structure that did not fit was more dimensions. The taxonomy numbers suggest that, for deep hierarchies, many of those dimensions were paying rent on the wrong geometry. Five coordinates in the right space beat fifty in the wrong one.</p><p>The way Qdrant serves it is worth noticing too. Nobody built a hyperbolic index. The flat index keeps doing what it is good at, gathering a neighbourhood quickly, and the curved part moves into a scoring expression that runs next to the data. That pattern travels well beyond geometry. When the similarity you actually want is expensive or unusual but correlates with something cheap, a wide cheap prefetch followed by an exact rescore inside the engine deserves a try before anyone proposes a second system.</p><p>The open question comes from the prefetch data. If better hierarchical embeddings make the Euclidean proxy weaker, the proxy eventually becomes the bottleneck. At that point native hyperbolic indexing stops being an academic idea. Before anyone can argue for it, though, we need to know how close real production data actually sits to the rim, and very few teams have measured that.</p><p><em>Figures 2 to 4 are screenshots from a local run against Qdrant 1.19.0. Figure 1 is plotted from the coordinates printed in Figure 2.</em></p><h3>References</h3><p>1. Mahmood, M. and Kupchanko, J. (2026). <a href="https://qdrant.tech/articles/hyperbolic-embeddings-qdrant/">Why Hyperbolic Embeddings Matter for Hierarchical Data</a>. Qdrant.</p><p>2. Nickel, M. and Kiela, D. (2017). <a href="https://arxiv.org/abs/1705.08039">Poincaré Embeddings for Learning Hierarchical Representations</a>. NeurIPS 2017.</p><p>3. Sarkar, R. (2011). Low Distortion Delaunay Embedding of Trees in Hyperbolic Plane. Graph Drawing 2011.</p><p>4. van Spengler, M. and Mettes, P. (2025). <a href="https://arxiv.org/abs/2502.17130">Low-distortion and GPU-compatible Tree Embeddings in Hyperbolic Space</a>. ICML 2025.</p><p>5. Desai, K. et al. (2023). <a href="https://arxiv.org/abs/2304.09172">Hyperbolic Image-Text Representations (MERU)</a>.</p><p>6. Qdrant documentation. <a href="https://qdrant.tech/documentation/search/hybrid-queries/">Hybrid Queries and Formula Query</a>.</p><p>7. Kupchanko, J. <a href="https://github.com/jkupchanko/qdrant-hyperbolic-transform">qdrant-hyperbolic-transform</a>. GitHub.</p><p>8. Google. <a href="https://www.google.com/basepages/producttype/taxonomy-with-ids.en-US.txt">Google Product Taxonomy</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=960c524959c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving Vectors from pgvector to Qdrant Without Trusting the Row Count]]></title>
            <link>https://medium.com/@parichaydas/migration-to-qdrant-531c17c1f70d?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/531c17c1f70d</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Thu, 24 Sep 2026 18:23:11 GMT</pubDate>
            <atom:updated>2026-10-04T21:15:13.039Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A step-by-step local migration with the official Qdrant tool, a hand-built pipeline, forced failures, and the one verification number that should have failed.</em></p><p>A vector migration can finish green and still be wrong.</p><p>The counts match. Every check prints PASS. And the top results for the same query barely agree between the two systems.</p><p>That is what happened in this project. PostgreSQL with pgvector was the source. Qdrant was the target. A 100,000-row product table with 384-dimensional embeddings moved across with no lost points and no corrupted vectors. Then the search comparison came back with a top-10 overlap between 11 and 17 percent. The script printed “divergence is EXPECTED” and passed the run.</p><p>This article follows the migration one step at a time, using screenshots from the local run. It covers the official Qdrant migration tool, a manual pipeline built for control, the failure tests, and the verification layer. It also explains why that overlap number deserved far more suspicion than the script gave it.</p><h3>Why move vectors out of Postgres at all</h3><p>pgvector is a sensible home for embeddings. The vectors sit next to the relational data. Transactions cover both. One backup strategy, one access model, one team to page.</p><p>The pressure to move usually comes from the vector side of the workload. Search needs its own scaling. Filtered vector queries need an engine that plans around payload filters. Quantization, multi-tenancy and index tuning start to matter. At that point the vector workload has a different operational lifecycle from the transactional one.</p><p>The reverse is also true. If the vector table is small, and most queries are relational joins with a similarity clause on the side, staying on pgvector is often the better call. A migration adds a second system to run, sync, secure and observe. That cost is real and it never shows up in the migration script.</p><h3>The setup</h3><p>Everything ran locally on one Docker host. Docker Compose started PostgreSQL 17 with pgvector and Qdrant on a shared bridge network. Two migration paths wrote into the same Qdrant instance: the official migration container and a manual Python pipeline. A separate verification script read both sides and compared them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFmfWyIZRhURHkNiD0j1HA.png" /><figcaption><em>Figure 1. Local migration setup. Verification reads both databases directly instead of trusting the migrator’s own output</em></figcaption></figure><p>One detail limits what the results can say. The vectors were synthetic 384-dimensional vectors, not output from an embedding model. The project tests migration mechanics and index behavior. It says nothing about semantic search quality. That detail comes back later, because it matters more than it first appears.</p><h3>How pgvector concepts map to Qdrant</h3><p>Before running anything, it helps to know what the official tool does with each piece of the source table. The mapping below follows the Qdrant pgvector migration guide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YdNwSiHBFbW60hUvlY_0kw.png" /></figure><p>The last two rows cause most of the quiet failures. A wrong distance metric still migrates every row. Hashed IDs still give a perfect count. Neither shows up until someone queries the data.</p><h3>The migration, step by step</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*61OD611q3k2tOZtNseojVQ.png" /><figcaption><em>Figure 2. The sequence used in the project. Each stage has its own check before the next one starts.</em></figcaption></figure><h3>Step 1. Start the stack and watch the index warning</h3><p>The Compose file defines the postgres and qdrant services, two named volumes, and a bridge network called migration_network. Once the containers were up, the first SQL session created the IVFFlat index on the products table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*UFWpjIcDkBx1IbG0nC9uLw.png" /><figcaption><em>Compose file and an early CREATE INDEX on a table with almost no rows. pgvector warns that the index will have low recall</em></figcaption></figure><p>The NOTICE in that terminal is worth reading. IVFFlat learns its cluster centers from the rows present at build time. Built on an empty or tiny table, the clusters mean nothing, and recall suffers for every row inserted afterwards. The rule is simple: load the data first, then build the IVFFlat index. The seed script used later does exactly that.</p><h3>Step 2. Generate a small dataset first</h3><p>The first dataset had 10,000 rows. Small enough to rebuild in seconds, big enough to catch mapping mistakes. The generator wrote a Parquet file with 384-dimensional embeddings.</p><p>python data/generate_dataset.py — n 10000 — out data/products_10k.parquet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpbjMHwP3wxnuI2myxo9vQ.png" /><figcaption><em>10K Parquet dataset with 384-dimensional embeddings</em></figcaption></figure><p>The same generator later produced the 100,000-row file. Starting small is not a formality. Every schema or mapping bug found at 10K costs seconds. The same bug found at 100K costs a full rerun.</p><h3>Step 3. Seed pgvector and build the index after the load</h3><p>python scripts/seed_pgvector.py — parquet data/products_10k.parquet — recreate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KkxbeeTmGo7alGsWn_vrA.png" /><figcaption><em>Seeding 10K rows, building IVFFlat with lists=100 after the insert, and confirming the count from psql</em></figcaption></figure><p>The seed script recreated the products table, inserted rows in batches, built the IVFFlat index after the insert, and printed the final count. A manual SELECT COUNT(*) in psql confirmed it. The 100,000-row run followed the same path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xmd0A4ehtWzj0sN20DYFqQ.png" /><figcaption><em>The 100K seed. The script chose lists=316 for the IVFFlat index</em></figcaption></figure><p>Note the lists=316 in that run. That is the square root of 100,000. The pgvector README suggests rows/1000 as a starting point up to one million rows, and the square root above that. For 100,000 rows that points to about 100 lists. Neither value is wrong as such, but the choice affects how many vectors each IVFFlat probe looks at, and that matters in the verification section.</p><p>Use SELECT COUNT(*) for the source count, not table statistics. The Qdrant pgvector guide calls this out because n_live_tup in Postgres is an estimate, and an estimated count makes parity checks meaningless.</p><h3>Step 4. Capture the baseline before touching Qdrant</h3><p>The Qdrant migration verification guide asks for a pre-migration baseline: counts per table, a sample of payload records, the collection configuration, and a set of baseline queries with their top-k results. Without it, there is nothing to compare against once the migration finishes.</p><p>In this project, the verification script queried pgvector live at check time rather than storing a frozen snapshot. That works for a static local dataset. On a live system, the source changes during the migration, so the baseline should be captured once and stored with the migration record.</p><h3>Step 5. Run the official migration tool</h3><p>Qdrant ships the migration tool as a Docker image. It streams rows from the source in batches through the machine it runs on and upserts them into Qdrant. Source and target never connect to each other directly. The pgvector subcommand is pg.</p><pre>docker run --net=host --rm -it \<br>  registry.cloud.qdrant.io/library/qdrant-migration pg \<br>  --pg.url &#39;postgres://&lt;user&gt;:&lt;password&gt;@localhost:5432/vector_db&#39; \<br>  --pg.table &#39;products&#39; \<br>  --pg.key-column &#39;id&#39; \<br>  --qdrant.url &#39;http://localhost:6334&#39; \<br>  --qdrant.collection &#39;products_official_tool&#39;</pre><p>The command above follows the shape documented in the Qdrant pgvector guide, with local values. A few defaults are worth knowing before the first run. The tool creates the target collection for pgvector sources. Batch size defaults to 50 points per upsert. Worker count for the pg subcommand defaults to the number of CPU cores. The — net=host flag is there because a container cannot reach the host’s localhost without it. On Docker Desktop, host.docker.internal is the usual alternative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yvOjAtyex2flpMt0uVLGcw.png" /><figcaption><em>The official tool created the target collection, ran with 12 parallel workers, and reported 100,000 points in the target</em></figcaption></figure><p>The tool’s own final line, “Target collection has 100000 points”, is useful. It is not verification. It reports what the tool wrote, not whether the right thing was written.</p><h3>Step 6. Migrate a partitioned table</h3><p>Large pgvector deployments often partition their tables. The Qdrant guide lists partition structure as a known gotcha: confirm every partition arrived, not just the parent. The project built a products_partitioned table with three list partitions and pointed the tool at the parent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5UJW6dfpTboeQ5NYomESA.png" /><figcaption><em>Migrating the parent partitioned table into products_partitioned_test</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztyLJUIwL-fSlxDR5dWmJw.png" /><figcaption><em>Row counts per partition on the Postgres side</em></figcaption></figure><p>The three partitions held 9,923, 10,216 and 79,861 rows. They add up to exactly 100,000, which matches the target count. The largest share sat in the catch-all partition, which is exactly the one a careless migration tends to miss.</p><p>A matching total can still hide a partition-level swap. So the check went one level deeper, using Qdrant’s count API with a payload filter on category.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*_cPUsNyUER9nHZ6UnDYIJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*836ZCcwHrE92qy1ylFPJVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*U8kyEY4IbQAJRh1z5TQFHA.png" /><figcaption><em>Filtered point counts in Qdrant. The category counts match the per-partition counts in Postgres</em></figcaption></figure><pre>POST /collections/products_partitioned_test/points/count<br>{ &quot;filter&quot;: { &quot;must&quot;: [ { &quot;key&quot;: &quot;category&quot;,<br>                             &quot;match&quot;: { &quot;value&quot;: &quot;Toys &amp; Games&quot; } } ] } }</pre><p>The filtered counts in Qdrant, 9,923 and 10,216, match the per-partition counts on the Postgres side. Total parity plus per-segment parity is a much stronger signal than either alone.</p><h3>Step 7. Check what happened to the IDs</h3><p>Listing a few points from the migrated collection shows something the count never would.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sg38Z07HizYCnxx465eHFA.png" /><figcaption><em>Points in the target collection carry UUIDs, not the original Postgres keys</em></figcaption></figure><p>Every point ID is a UUID. This is by design. Qdrant point IDs must be unsigned integers or UUIDs, and the migration tool hashes the values of — pg.key-column into point IDs. The mapping is deterministic, which is why a rerun overwrites rather than duplicates.</p><p>The application impact is easy to miss. Any service that fetches a point by its Postgres primary key now has two options. It can reproduce the same hash, or it can filter on the original id field in the payload. Since all non-vector columns become payload, the original key should be there, but it is worth confirming explicitly and putting a payload index on it if lookups by that key are frequent. Teams that need the Qdrant ID to equal the Postgres key will need a manual pipeline that writes integer IDs directly.</p><h3>Step 8. Interrupt the migration on purpose</h3><p>A migration that only works when nothing goes wrong is not ready for real data. The resume test started a fresh migration into products_resume_test and killed it with Ctrl+C partway through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9Zo-LkhD3WIojTe3MMXxQ.png" /><figcaption><em>The run was interrupted at 60,500 of 100,000 rows and failed with a context-canceled error.</em></figcaption></figure><p>Then the exact same command ran again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygiXRd6R5ovsgQlog7Uefg.png" /><figcaption><em>The second run skipped collection creation, started from offset 60500, and finished with 100,000 points.</em></figcaption></figure><p>The tool stores its progress in a collection called _migration_offsets inside Qdrant. On the second run it found the saved offset, skipped the existing collection, and carried on. No completed batch was copied twice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWu3PO7aHAj8XBMBa1NJMA.png" /><figcaption><em>Progress state lives in the target database, so rerunning the same command is the recovery procedure.</em></figcaption></figure><p>Two operational notes follow from this. First, the — migration.restart flag discards saved progress. It belongs to deliberate restarts, such as after fixing a bad schema, not to routine reruns. Second, if several migrations run against one Qdrant instance at the same time, each needs its own — migration.offsets-collection, or they will overwrite each other’s progress.</p><h3>When the official tool is not enough: a manual pipeline</h3><p>The official tool covers the common path well. A manual pipeline earns its keep when the migration needs control the tool does not expose: custom transforms, integer IDs that match the source key, payload reshaping, embedding re-generation on the way through, or a specific checkpoint and retry policy.</p><p>The project built one in Python. It reads Postgres with psycopg2, maps each row to a Qdrant point, upserts in batches with qdrant-client, and records progress in a checkpoint file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BlP8YkAjSXwU_L2lHd0Sw.png" /><figcaption><em>Each worker owns its database connection. Failed upserts go through retry with backoff. Completed offsets go to the checkpoint.</em></figcaption></figure><h3>The concurrency bug that shaped the design</h3><p>The serial version used one server-side cursor and called fetchmany() in a loop. A server-side cursor keeps reads bounded, so the full table never lands in memory at once.</p><p>The first concurrent version reused the same read function and passed integer offsets into it. The function expected a cursor. It failed immediately:</p><p>AttributeError: ‘int’ object has no attribute ‘fetchmany’</p><p>The tempting fix was to share one cursor across threads and add locking. That would have been the wrong design. A database cursor is a stream with position. Sharing it forces every worker to wait on the same stream, which defeats the point of having workers.</p><p>The working design gives each worker its own connection and its own cursor, and each worker reads a fixed window of rows. One worker, one batch, one connection. The unit of work becomes explicit, and a failed batch can be retried without touching any other.</p><p>One caution for anyone copying this pattern at larger scale. The windows here used OFFSET and LIMIT. Postgres still has to walk past every skipped row to reach a large offset, so deep windows get slower as the table grows. Keyset pagination avoids that:</p><pre>SELECT id, embedding, category, price, rating<br>FROM products<br>WHERE id &gt; %(last_id)s<br>ORDER BY id<br>LIMIT %(batch)s; </pre><p>Keyset reads also make checkpoints cleaner. The checkpoint stores the last committed key instead of an offset, and that value stays correct even if rows are inserted elsewhere in the table during the run.</p><h3>Checkpoint and retry</h3><p>Two failure tests ran against the manual path. In the checkpoint test, the migration was stopped after about 40,000 rows. The next run read the checkpoint and migrated only the remaining 60,000 rows, reaching the full 100,000.</p><p>The retry test used a fake Qdrant client that failed twice before succeeding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*wWTSc3_1uZ3jEyXukHTkpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*9-B7Ba_Heu79aRixNwM2sQ.png" /><figcaption><em>Retry test. Two simulated failures, waits of 0.2 s and 0.4 s, success on the third attempt</em></figcaption></figure><p>The wait doubled after each failure, and the cap was five attempts. That pattern absorbs short outages, such as a Qdrant restart or a dropped connection, without restarting the job. It also avoids hammering a struggling server with immediate retries.</p><p>Retries are safe here only because upserts are idempotent. The same point ID written twice produces one point, not two. That property is what makes both resume and retry correct, and it is the reason deterministic IDs matter.</p><h3>Edge cases a row count will never show</h3><p>Small targeted tests covered the cases most likely to surprise a real workload. These were correctness probes, not load tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vfLehqTW2GtrzqtxxxMnjg.png" /></figure><p>The duplicate-ID row cuts both ways. Overwrite-on-upsert is exactly what makes retries safe. It also means a source table with a non-unique key column will lose rows silently in the target. The key column passed to the tool has to be truly unique.</p><h3>Verification: four checks, four different failures</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5_HzwAFmqOlSSBiINkWgg.png" /><figcaption><em>Each check catches something the others cannot see.</em></figcaption></figure><p>The verification script ran three of these checks directly: count parity, a vector similarity spot-check on 100 sampled IDs, and a top-10 comparison over 20 query vectors. A payload sample comparison covered the fourth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*k2wAJ3keFRM5NzQMRAlUWQ.png" /><figcaption><em>Verification after the 100K migration. Count parity and the vector spot-check pass. Top-10 overlap is 11 percent</em></figcaption></figure><p>The final state of the main collection held 100,001 points. The extra row was the NULL-metadata test fixture, inserted on both sides. It was not part of the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*s9IR2hEuyNPTmbUI2eHQ0g.png" /><figcaption><em>Collection info and final verification. 100,001 points, status green, 97,000 indexed vectors, top-10 overlap of 12.5 percent.</em></figcaption></figure><p>Two details in that last screenshot deserve a closer look.</p><p>The first is indexed_vectors_count at 97,000 against 100,001 points. That is not data loss. Qdrant builds the HNSW index per segment, and the optimizer leaves small segments unindexed because a full scan of a small segment is cheap. Those points are still searchable. It does mean the HNSW side of the comparison was partly HNSW and partly exact scan, which is one more reason the search numbers need careful reading.</p><p>The second is the overlap figure.</p><h3>The number that should have failed</h3><p>Across three runs, the top-10 overlap between pgvector and Qdrant came out at 17 percent at 10K rows, 11 percent at 100K, and 12.5 percent on the final 100,001-row state. Every run ended with “ALL CHECKS PASSED”.</p><p>Compare that with the acceptance criteria in Qdrant’s own migration verification guide. Its quick spot-check tier expects at least 70 percent top-10 overlap. Its statistical tier expects mean recall@10 of 0.85 or better. By those criteria, every run here would fail the search check and send the team to the diagnosis stage.</p><p>The same guide also says that when the source baseline came from IVFFlat, Qdrant’s HNSW may return better results, and the mismatch may be an improvement. That is plausible. But overlap alone cannot tell an improvement from a regression. Both sides are approximate. A low overlap means at least one of them is far from the true nearest neighbors. It does not say which.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzOWFHbxUkTK3eRKsT19UA.png" /><figcaption><em>Overlap between two approximate indexes mixes the errors of both. Measuring each against exact search separates them.</em></figcaption></figure><p>Several factors in this setup could push the overlap down. None of them were measured individually, so treat these as hypotheses to test, not conclusions.</p><p>• <strong>IVFFlat probes. </strong>pgvector searches one list per query by default. With 316 lists, a query at default settings looks at roughly one three-hundredth of the table. Unless the verification script raised ivfflat.probes, the pgvector side was a very narrow search.</p><p>• <strong>Synthetic vectors. </strong>Random high-dimensional vectors have little cluster structure. IVF partitioning depends on clusters. Real embeddings from a model usually cluster much better, so IVFFlat recall on this data is likely worse than it would be in production.</p><p>• <strong>Mixed indexing on the Qdrant side. </strong>Part of the collection was still in unindexed segments, so the Qdrant results combined HNSW traversal with exact scan.</p><p>The fix is a change of reference point. Compute exact top-k for the same query vectors, then measure each system against it. Qdrant supports exact search per request:</p><pre>client.query_points(<br>    collection_name=&quot;products&quot;,<br>    query=query_vector,<br>    limit=10,<br>    search_params=models.SearchParams(exact=True),<br>)</pre><p>On the Postgres side, raise the probe count for the comparison session, or compute exact results directly in Python from the stored vectors. The pgvector README suggests lists/10 probes as a starting point for tables up to one million rows.</p><pre>BEGIN;<br>SET LOCAL ivfflat.probes = 32;<br>SELECT id FROM products ORDER BY embedding &lt;=&gt; %(q)s LIMIT 10;<br>COMMIT;</pre><p>With recall-against-exact measured on both sides, the comparison finally means something. If Qdrant’s recall is high and pgvector’s is low, the low overlap was the old system’s error, and the migration improved search. If both are high, overlap will be high too. If Qdrant’s recall is low, hnsw_ef or the HNSW build parameters need attention before cutover.</p><p>The deeper problem was the verification script itself. It printed a number, attached a reassuring label, and passed regardless. A check that cannot fail is a log line. The search check needs a threshold and an exit code, and the threshold should come from the team’s own tolerance, informed by the guidance in the Qdrant docs.</p><h3>What the local project did not cover</h3><p>The bulk copy is the first stage of a production migration, not the whole of it. The local project left several pieces open, and they should be named rather than assumed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aUuJxhvtJpFcAAqJuku6iw.png" /><figcaption><em>A typical production cutover path. None of these stages beyond the bulk copy were executed in the local project</em></figcaption></figure><p>Live writes are the biggest gap. If the application keeps writing to Postgres during and after the copy, Qdrant drifts from the moment the migration finishes. Qdrant’s data synchronization guide covers the options, from dual writes in application code to batch sync and change data capture. Dual writes are simple and fragile. CDC is robust and adds infrastructure. The right answer depends on write volume and how stale search results are allowed to be.</p><p>Scale and real embeddings come next. The local runs stopped at 100,000 rows of synthetic vectors. A rerun at target size, with the production embedding model, is the only way to know how batch sizes, worker counts and recall behave on the real data.</p><p>Observability is the last piece. During a real migration, one view should show source count, target count, checkpoint position, failed batches, retry count and the latest search-check result. A migration that can only be observed by reading terminal output does not scale beyond one engineer.</p><h3>What to carry into the next migration</h3><p>The official tool did its job. It created the collection, moved every row, handled partitions, and resumed cleanly after a kill. The manual pipeline showed how to build the same guarantees by hand when more control is needed, and where the obvious design breaks.</p><p>The risk in this project never lived in the copy. It lived in the acceptance criteria. Counts passed. Vectors passed. Payloads passed. The one check that measured what users would actually experience was allowed to pass at 11 percent.</p><p>Before the next migration starts, it is worth asking a blunt question. Which check in the verification script can actually fail, and what number would make it fail?</p><h3>References</h3><p>1. Qdrant. Migrate to Qdrant (migration tool overview). <a href="https://qdrant.tech/documentation/migrate-to-qdrant/">https://qdrant.tech/documentation/migrate-to-qdrant/</a></p><p>2. Qdrant. Migrate from pgvector to Qdrant. <a href="https://qdrant.tech/documentation/migrate-to-qdrant/from-pgvector/">https://qdrant.tech/documentation/migrate-to-qdrant/from-pgvector/</a></p><p>3. Qdrant. Migration Guidance (verification framework). <a href="https://qdrant.tech/documentation/migration-guidance/">https://qdrant.tech/documentation/migration-guidance/</a></p><p>4. Qdrant. Search Quality Verification. <a href="https://qdrant.tech/documentation/migration-guidance/search-quality/">https://qdrant.tech/documentation/migration-guidance/search-quality/</a></p><p>5. Qdrant. Data Synchronization. <a href="https://qdrant.tech/documentation/data-synchronization/">https://qdrant.tech/documentation/data-synchronization/</a></p><p>6. Qdrant migration tool source. <a href="https://github.com/qdrant/migration">https://github.com/qdrant/migration</a></p><p>7. pgvector. Open-source vector similarity search for Postgres. <a href="https://github.com/pgvector/pgvector">https://github.com/pgvector/pgvector</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=531c17c1f70d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Top-5 Is Often One Result Five Times (Maximal Marginal Relevance in Qdrant)]]></title>
            <link>https://medium.com/@parichaydas/maximum-marginal-relevance-ae46933ad3f2?source=rss-4829654c8984------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae46933ad3f2</guid>
            <dc:creator><![CDATA[Parichay Das]]></dc:creator>
            <pubDate>Thu, 24 Sep 2026 18:22:10 GMT</pubDate>
            <atom:updated>2026-10-04T18:44:13.719Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Maximal Marginal Relevance in Qdrant: how it works, a faceted search experiment on a 400-item catalogue, and where it belongs in a RAG pipeline.</em></p><p>Ask a RAG system a two-part question. Something like: what changed in the refund policy, and does it apply to annual plans? Then look at the five chunks it retrieved. Quite often four of them describe the refund window in slightly different words. The clause about annual plans sits at rank nine. The model never sees it, and it answers half the question with great confidence.</p><p>Nothing is broken. The retriever did what it was asked to do. It scored each chunk against the question and returned the five best. The trouble is that “the five most similar chunks” and “the five chunks that best answer the question” are two different sets. This article is about the gap between them.</p><h3>Why similarity search repeats itself</h3><p>Top-k scores every candidate in isolation. Each chunk is compared with the query. It is never compared with the other chunks already in the result. So when five chunks sit close to the query and close to each other, all five win.</p><p>RAG pipelines create this situation by design. Overlapping chunk windows put the same sentence into two or three neighbouring chunks. Old and new versions of a document get indexed side by side. Headers and disclaimers repeat on every page. All of that lands in one tight region of the embedding space, often right where the query points.</p><p>The cost is easy to miss because nothing errors out. The context budget fills with repeats. The second half of a multi-part question goes unanswered. And the model reads one fact five times, which looks like strong agreement when it is really a single source echoed through chunking.</p><h3>What MMR actually does</h3><p>Maximal Marginal Relevance comes from a 1998 SIGIR paper by Jaime Carbonell and Jade Goldstein. The idea fits in one sentence. Build the result list one item at a time, and at each step prefer the candidate that is relevant to the query and different from what you have already picked.</p><p>Written out, the next pick is:</p><pre>MMR = argmax over d in R \ S of<br>      [ λ · sim(d, Q)  −  (1 − λ) · max over s in S of sim(d, s) ]</pre><p>R is the candidate pool. S is the set selected so far. Q is the query. The first term rewards relevance. The second term penalises a candidate by its single closest neighbour in S. That detail matters. A chunk that nearly duplicates any one selected chunk gets marked down, even if it is unlike everything else in the list.</p><p>λ sets the trade-off. At λ = 1 the penalty vanishes and you are back to plain top-k. As λ drops, redundancy costs more and the selection spreads out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfD5d9aowCpri3JjBVCyBA.png" /><figcaption><em>Figure 1. The greedy MMR loop as Qdrant runs it: preselect a pool, take the best match, then trade relevance against redundancy one pick at a time.</em></figcaption></figure><p>The toy example below makes the effect visible. Group A is a tight cluster of near-duplicates sitting closest to the query. Plain top-5 takes all five picks from group A. MMR takes the best item from A, then reaches out to C, B and D before it comes back to A for the fifth slot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AnfcnIzYKHhEk24plr9-Uw.png" /><figcaption><em>Figure 2. Plain top-k versus MMR on synthetic 2-D points. Generated for this article as an illustration, not measured on real data.</em></figcaption></figure><h3>MMR in Qdrant</h3><p>Qdrant has supported MMR natively since v1.15.0. There is no separate endpoint. It is a parameter on a nearest-neighbour query in the Query API:</p><pre>POST /collections/products/points/query<br>{<br>  &quot;query&quot;: {<br>    &quot;nearest&quot;: [0.01, 0.45, 0.67, ...],<br>    &quot;mmr&quot;: { &quot;diversity&quot;: 0.5, &quot;candidates_limit&quot;: 100 }<br>  },<br>  &quot;limit&quot;: 10<br>}</pre><p>Two parameters do the work, and both have a sharp edge.</p><p>diversity is the inverse of λ. Qdrant defines λ = 1 − diversity, so 0.0 means pure relevance and 1.0 means maximum spread. If you are porting a setting from a paper or a library that speaks in λ, flip the number before you copy it.</p><p>candidates_limit decides how many nearest neighbours MMR may choose from. This is the one people get wrong. According to Qdrant’s own course material, it defaults to the query’s limit. Ask for 10 results without setting it, and MMR receives exactly 10 candidates and has to return all 10. It can only reorder them. The output looks identical to plain search and people conclude MMR does nothing. Give it a pool several times larger than limit.</p><p>There is a third behaviour that breaks downstream code quietly. The score on each returned point is still the similarity to the query, not the MMR value. Results arrive in selection order, so the scores are not sorted. If any later step sorts by score, the ranking you tuned is gone. The set stays diverse. The order does not survive.</p><h3>The experiment</h3><p>The test runs on a local Qdrant instance at v1.19.0. The goal is simple: check the mechanics end to end before trusting MMR inside a real retrieval pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NDYO4ozh5gTnDZ2njNlhA.png" /><figcaption><em>Figure 3. Collection info in the Qdrant Web UI: 400 points, 384-dimensional vectors, Cosine distance, 6 segments, indexed_vectors_count = 0</em></figcaption></figure><p>A few fields in that panel are worth reading closely. Status is green and the optimizer reports ok. There are 400 points across 6 segments, with one shard and replication factor 1. HNSW is configured with m = 16 and ef_construct = 100.</p><p>The interesting one is indexed_vectors_count: 0. Four hundred vectors of 384 floats come to roughly 600 KB, which is well below the size at which Qdrant’s optimizer bothers to build an HNSW graph. So every query in this experiment is an exact scan, and the MMR candidate pool is exact too. In production the pool comes from HNSW and is approximate. That is one more reason to give MMR a generous pool: some of the candidates you hoped it would consider may never make it into the preselection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1xXBr8rxaG3SjaIPx0cMQ.png" /><figcaption><em>Figure 4. Sample points. Each payload carries category, name and price.</em></figcaption></figure><p>The data is synthetic. Names like audio-item-0 and accessories-item-1, a category and a price. That is fine for verifying behaviour. It says nothing about real relevance quality, a limitation that comes up again when reading the results.</p><p>Diversifying by category first requires knowing which categories exist and how they are distributed. The Facet API answers that directly. It counts distinct values of a payload field, and it needs a keyword payload index on that field. Setting exact: true asks for precise counts instead of estimates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7rxrDeq0CRnEwzwhWf5uA.png" /><figcaption><em>Figure 5. Facet request on the category field from the Web UI console. Four values, 100 points each, returned in about 26 ms locally.</em></figcaption></figure><p>Four categories, perfectly balanced: accessories, audio, smart-home and wearables. A balanced catalogue is the easy case. Real catalogues are skewed, which is exactly when the next part matters.</p><h3>Faceted MMR</h3><p>The script set itself a concrete target. Search the catalogue for “wireless headphones” and return 12 results that are relevant, are not near-duplicate listings of the same product, and visibly span several categories instead of being dominated by one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*fgq4z30jTJUUjAmzj5Q4mA.png" /><figcaption><em>Figure 6. The scenario and requirements as stated in the script: qdrant-client 1.15 or newer, a Qdrant server at v1.15.0 or newer for native MMR, and the Facet API from v1.12.0.</em></figcaption></figure><p>Why not plain MMR? Because MMR measures difference in embedding space, and embedding space knows nothing about your category tree. Two categories that sit close together in vector space look like one region to MMR. And when one category owns the neighbourhood around the query, MMR dilutes it but has no reason to guarantee the others a seat. If the business rule is “show more than one category”, a payload field enforces that far more reliably than a distance penalty does.</p><p>So the pattern combines both. The Facet API supplies the category list. One MMR query runs per category, filtered to that category, which handles near-duplicates inside each bucket. A round-robin merge then takes one result from each category per round until the list is full.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vqBqgwQMYMvtxUFYP2DLbA.png" /><figcaption><em>Figure 7. Faceted MMR. Facets decide which buckets get a slot. MMR decides what fills each slot.</em></figcaption></figure><p>A condensed version of the pattern looks like this. The embedding model is a placeholder for any 384-dimensional text model.</p><pre>from qdrant_client import QdrantClient, models<br>from fastembed import TextEmbedding<br> <br>client = QdrantClient(url=&quot;http://localhost:6333&quot;)<br>COLLECTION = &quot;products&quot;<br>encoder = TextEmbedding(&quot;BAAI/bge-small-en-v1.5&quot;)  # any 384-dim model<br> <br># Facet API needs a keyword index on the field<br>client.create_payload_index(COLLECTION, field_name=&quot;category&quot;,<br>                            field_schema=models.PayloadSchemaType.KEYWORD)<br> <br>def faceted_mmr(query, k=12, diversity=0.5, pool=50):<br>    qv = next(encoder.embed([query])).tolist()<br> <br>    # 1. Which categories exist?<br>    facets = client.facet(COLLECTION, key=&quot;category&quot;, limit=10, exact=True)<br>    cats = [hit.value for hit in facets.hits]<br>    per_cat = -(-k // len(cats))  # ceiling division<br> <br>    # 2. One MMR query per category<br>    buckets = {}<br>    for cat in cats:<br>        res = client.query_points(<br>            COLLECTION,<br>            query=models.NearestQuery(<br>                nearest=qv,<br>                mmr=models.Mmr(diversity=diversity, candidates_limit=pool),<br>            ),<br>            query_filter=models.Filter(must=[models.FieldCondition(<br>                key=&quot;category&quot;, match=models.MatchValue(value=cat))]),<br>            limit=per_cat,<br>            with_payload=True,<br>        )<br>        buckets[cat] = res.points<br> <br>    # 3. Round-robin merge, keeping MMR order inside each bucket<br>    merged = []<br>    for i in range(per_cat):<br>        for cat in cats:<br>            if i &lt; len(buckets[cat]):<br>                merged.append(buckets[cat][i])<br>    return merged[:k]</pre><p>One loop, four network calls. With a handful of categories that is fine. With dozens, send the per-category queries together through query_batch_points so they travel in a single request.</p><h3>Reading the output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*mpZJoxqSWW1_iTI4_hkgJw.png" /><figcaption><em>Figure 8. Top 12 faceted-MMR results for “wireless headphones”.</em></figcaption></figure><p>Twelve results, three per category. The order cycles accessories, audio, smart-home, wearables, and then repeats that cycle twice more. That sequence matches the facet order exactly, which is the fingerprint of round-robin merging. Inside each category the three picks came out of MMR, so they were chosen for relevance with a penalty for resembling each other.</p><p>Now the uncomfortable part. Rank 3 is a smart-home item, returned for a headphones query. It did not earn that slot on relevance. It got it because the facet exists and round-robin gives every facet a turn. Faceting guarantees coverage. It does not guarantee that the coverage makes sense. On synthetic data this is harmless. On a real catalogue it means a smart plug in the third position of a headphones search.</p><p>Three fixes are worth trying, roughly in order of effort:</p><p>• Add a relevance floor. Drop any category whose best hit falls below a similarity threshold before the merge runs.</p><p>• Choose facets from the query, not the catalogue. Run one plain search with a wide limit, collect the categories that actually appear in those candidates, and only diversify across those.</p><p>• Allocate slots by evidence. Give each category a share of the k slots in proportion to its top score, instead of an equal share.</p><p>The broader point: diversity is a constraint you add on top of relevance. If the constraint is allowed to override relevance with no floor, the results get more varied and less useful at the same time.</p><h3>Back to RAG</h3><p>The experiment uses a product catalogue, but the mechanics carry over to chunks unchanged. What a category is to a catalogue, a doc_id, a section or a source type is to a chunk store. The placement question is where most of the design work lives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khdC-g07wv7Rgj9hb76dMw.png" /><figcaption><em>Figure 9. Where MMR sits in a RAG pipeline. Preselection and MMR run inside one Qdrant query. Context assembly must preserve the order MMR produced.</em></figcaption></figure><p>MMR runs inside Qdrant, on the candidate pool, before context assembly. Which tool you reach for depends on where the redundancy comes from:</p><p>• Structural redundancy, such as one document split into overlapping chunks. Qdrant’s grouping API, grouping by doc_id to keep one slot per document, or deduplication at ingestion is cheaper and more predictable than MMR.</p><p>• Semantic redundancy, where different sources say the same thing. Plain MMR is the right tool.</p><p>• Required coverage across known buckets, such as product lines, jurisdictions or document types. Faceted MMR, with a relevance floor.</p><p>If you also run a cross-encoder reranker, think about order. A reranker scores each chunk on its own, the same way top-k does, so it can lift near-duplicates straight back to the top. One workable sequence is to use MMR to produce a diverse shortlist of, say, 20 chunks and let the reranker choose the final few from inside it. Whether that beats the reverse order depends on your data. Measure it.</p><h3>Where MMR makes things worse</h3><p>MMR is a trade, and some workloads lose on it.</p><p>Single-fact lookups are the obvious case. If one chunk holds the answer, every diversity slot is filled with weaker context that the model then has to ignore.</p><p>Corroboration is the subtle case. In compliance review, medical literature or incident analysis, three independent sources agreeing is the signal you want. MMR reads agreement as redundancy and removes it.</p><p>Embedding distance is not the same as useful difference. A chunk can sit far from the selected set simply because it is off-topic. Push diversity high and the relevance term is the only thing keeping noise out, and at high values it is a weak guard.</p><p>A thin pool limits everything. If the preselected candidates contain nothing genuinely different, MMR can only shuffle what it was given. This is the candidates_limit trap again, and it also shows up when a strict filter leaves only a few points to choose from.</p><p>Then there is cost. Each selection round compares the remaining candidates against the items already chosen, so the work grows with both the pool size and limit. For pools in the low hundreds this is usually small next to embedding and LLM latency. It is still not free, and it belongs in your latency budget, not in an assumption.</p><h3>How to tell whether it helped</h3><p>This article does not quote a RAG quality improvement. That evaluation has not been run on this dataset, and a number without it would be decoration. What to measure:</p><p>• Redundancy: the mean pairwise cosine similarity among retrieved chunks, with and without MMR. It is cheap to compute and shows immediately whether MMR is doing anything.</p><p>• Coverage: for a small labelled set of multi-part questions, the fraction of required facts that reach the context window.</p><p>• Answer quality: end-to-end evaluation on that same set, because coverage only matters if the model uses it.</p><p>• Latency: p50 and p95 at your chosen candidates_limit, with and without MMR.</p><p>Then sweep. Qdrant’s own guide suggests 0.5 as a starting value for diversity. Try values between 0.0 and about 0.7, and treat candidates_limit as a second axis, not a constant.</p><h3>A closing thought</h3><p>Top-k quietly assumes that results are independent of each other. In a chunked corpus they almost never are. MMR is one way to stop pretending, but it forces a question most retrieval stacks never ask out loud: what should “different” mean for this system? Embedding distance is one answer. Your payload structure of documents, sections and categories is often a better one. The parameter takes seconds to set. That decision takes thought, and it is the part that decides whether diversity helps your users or just reshuffles their results.</p><h3>References</h3><p>1. Carbonell, J. and Goldstein, J. (1998). The Use of MMR, Diversity-Based Reranking for Reordering Documents and Producing Summaries. SIGIR ’98. <a href="https://www.cs.cmu.edu/~jgc/publication/The_Use_MMR_Diversity_Based_LTMIR_1998.pdf">https://www.cs.cmu.edu/~jgc/publication/The_Use_MMR_Diversity_Based_LTMIR_1998.pdf</a></p><p>2. Qdrant documentation. Search Relevance: Maximal Marginal Relevance. <a href="https://qdrant.tech/documentation/search/search-relevance/">https://qdrant.tech/documentation/search/search-relevance/</a></p><p>3. Damiba, T. (2025). Balancing Relevance and Diversity with MMR Search. Qdrant blog. <a href="https://qdrant.tech/blog/mmr-diversity-aware-reranking/">https://qdrant.tech/blog/mmr-diversity-aware-reranking/</a></p><p>4. Qdrant Beginner Course, Module 6. Diversity: Maximal Marginal Relevance. <a href="https://qdrant.tech/course/beginners/module-6/diversity-mmr/">https://qdrant.tech/course/beginners/module-6/diversity-mmr/</a></p><p>5. Jain, T. Understanding Maximal Marginal Relevance (MMR). Python in Plain English. <a href="https://python.plainenglish.io/understanding-maximal-marginal-relevance-mmr-a0a7a8df0a1a">https://python.plainenglish.io/understanding-maximal-marginal-relevance-mmr-a0a7a8df0a1a</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae46933ad3f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>