Approximate Sparse Search in Qdrant: Speed Up Retrieval by Cutting Dimensions Qdrant will expose a new search parameter, `max_sparse_dims`, starting in version 1.21.0, letting sparse-vector queries be cut to their N most relevant dimensions to make retrieval approximate rather than exact. The feature adapts a measure from SEISMIC, proposed by the TusKANNy group (Bruch et al., 2024), and targets the main weakness of inverted indexes: long queries that traverse many posting lists, where the only remedy is to walk fewer postings. Qdrant said it adopted the approach as neural sparse embedding models such as SPLADE and SlideOn grow more popular. Back to Indexing & Storage https://qdrant.tech/articles/qdrant-internals/ Approximate Sparse Search in Qdrant: Speed Up Retrieval by Cutting Dimensions In vector search, we often talk about Approximate Nearest Neighbors Search ANN Search . While exact search needs to scan an entire collection to find the true k most similar vectors to a given query, approximate search organizes data in a way that allows us to reach most of the nearest neighbors of this query with a far smaller number of vector comparisons. We achieve this in Qdrant with an HNSW index, a graph-like structure that enables far more efficient, scalable vector search than a scan of all vectors. While we use approximate search for dense vectors, we use exact search for sparse vectors: for them, inverted indexes are much easier to scale. Yet approximate search for sparse vectors is also possible. A lot of research has gone in this direction in the last few years, mostly due to the rising popularity of neural sparse embedding models such as SPLADE https://huggingface.co/naver/splade-v3 or SlideOn https://huggingface.co/lightonai/SlideOn . One approach caught our eye: SEISMIC https://tuskanny.com/papers/Seismic-SIGIR2024.pdf , proposed by the TusKANNy group https://tuskanny.com/en/ Bruch et al., 2024 . We adopted one of its measures to make search approximate: cutting the query to its N most relevant dimensions. Starting from Qdrant 1.21.0, it will be exposed as a new search parameter, max sparse dims . In this article, we’ll briefly touch upon how exact sparse search works, and then we’ll explore how and why we introduced query cutting, the results we achieved with this new feature, and how you can try it yourself. Back to Basics Before we dive into approximate techniques, it helps to go back to basics and take a look at how exact sparse search works. First of all, let’s look at what a sparse vector is: you can think of it as a dictionary, that associates each term also referred to as dimension of its vocabulary to a value also called weight . { "we": 0.2, "love": 1.4, "qdrant": 4.3 } One important feature of sparse vectors is that most of their dimensions have a weight of 0, while only a few hundred of them carry non-zero values. This means that, if we were to search a list of vectors by comparing the query with each one of them, we would be wasting a lot of compute: there is a good chance that many vectors don’t share any non-zero terms with the query, meaning that they don’t contribute at all to the search. That’s why, in vector search engines, we use inverted indexes : instead of storing sparse vectors as-is, we store their terms, and associate with each term the ID of the vector it came from and the weight it brings. The lists associated with each term are called posting lists. { "we": "doc 1", 0.2 , "doc 2", 0.3 , "love": "doc 1", 1.4 , "qdrant": "doc 1", 4.3 , "doc 3", 3.9 } In this case, a query like {"love": 0.3, "qdrant": 5.9} is only scored against documents that share its non-zero terms doc 1 and doc 3 , and skips doc 2 . Inverted indexes scale very well: the vocabulary of a sparse vector never changes provided it always comes from the same model , and the overlap of non-zero terms across many vectors is still small there are only a few “hot terms” whose posting lists are very long , so we can stay fast even at millions of data points. The main problem, though, is that there are limited optimizations that we can add to inverted indexes to make them faster on non-optimal paths, such as long queries that traverse many posting lists: the only solution there is to actually make the query walk fewer postings, and that’s where our query cutting mechanism comes in. Want to know more about inverted indexes optimizations in Qdrant? To speed up inverted-index searches, Qdrant can skip parts of a posting list. Each entry stores, alongside its document ID and weight, the largest weight among the entries that follow it. For the posting list of one term, sorted by document ID, the look-ahead values are filled from the end of the list, one step at a time: entry d1 d2 d4 d5 weight 0.1 0.3 0.9 0.4 look-ahead 0.9 0.9 0.4 none d5: last entry, nothing follows it - none d4: only d5 follows - 0.4 d2: max weight of d4, look-ahead of d4 - max 0.9, 0.4 = 0.9 d1: max weight of d2, look-ahead of d2 - max 0.3, 0.9 = 0.9 If the best score the rest of a list could still add is not above the worst score in the current top results, the search jumps ahead instead of scoring every entry. js let max weight from list = element.weight.max element.max next weight ; let max score contribution = max weight from list longest posting iterator.query weight; if max score contribution <= min score { longest posting iterator.skip to next min id ; // jump over the points that cannot win } This optimization only works with non-negative query weights and on the mutable in-memory index: compressed read-only indexes drop look-ahead values to save space. For even more details, check out prune longest posting list and search in search context.rs https://github.com/qdrant/qdrant/blob/master/lib/sparse/src/index/search context.rs , and at the max next weight field in posting list common.rs https://github.com/qdrant/qdrant/blob/master/lib/sparse/src/index/posting list common.rs . Cutting to the Chase An approximation we consider here is keeping only the most relevant dimensions of a sparse query when searching, something we will refer to as query cutting . Concentration of Importance Sparse vectors produced by neural models present an interesting property that the authors of the SEISMIC paper call concentration of importance : “We observe that the LSR techniques place a disproportionate amount of the total L1 mass of a vector on just a small subset of the coordinates”. In simpler terms, the amount of information that a sparse vector carries is often concentrated in a few dimensions. If we sort the embedding’s dimensions by absolute weight, and we keep the top N of them, we shouldn’t lose much in terms of retrieval quality, because these top dimensions should be the ones contributing the most to the result. With fewer dimensions, a query has to walk fewer posting lists in the inverted index. Fewer lists visited = faster search. Now that we understand why this should work in theory , let’s take a look at how it holds up in practice . Speeding Up The Long Tail Since Qdrant’s exact search is already fast enough in the benchmarks here, we see p99 being between 19 and 50ms, depending on the sparse neural embedding model used for encoding , benchmarking on short queries <100 dimensions might not be the best way to see the speedup, so we look at the long tail and use long documents-as-queries. We ran benchmarks on 2M pre-computed sparse embeddings from SPLADE https://huggingface.co/naver/splade-v3 , Granite-30M https://huggingface.co/ibm-granite/granite-embedding-30m-english , SlideOn https://huggingface.co/lightonai/SlideOn , and SparseUP https://huggingface.co/Linkup-Platform/linkup-sparseup-embed-v1 , using the Natural Questions dataset and holding out 10 K of its documents to use as queries. We compare exact search with our query cutting on recall@10, MRR@10, and NDCG@10. How to interpret the results A moderate cut is nearly free. For every model, there is a cut that keeps between 50% and 80% of a typical query’s dimensions and retains 95% recall@10. At that point, the slow end of the distribution gets 1.4× to 2.6× faster. | Model | Median Query Dimensions | Dimensions Kept | Recall | Speedup p95 | Speedup p99 | |---|---|---|---|---|---| | SPLADE | 156 | 128 | 98.6% | 1.4× | 1.5× | | SlideOn | 682 | 512 | 96.2% | 1.7× | 1.7× | | SparseUP | 330 | 256 | 95.2% | 2.2× | 2.5× | | Granite-30M | 229 | 128 | 96.0% | 2.3× | 2.6× | Recall here is the share of the exact top 10 documents that approximate sparse search finds, averaged over the 10K queries. The biggest gain here is for slow searches. At p99, Granite-30M and SparseUP get up to 2.6× and 4.6× faster at 128 dimensions. Cutting down to 32 to 64 dimensions pushes this to 10–15×, but recall drops to 62–73%. Averages hide part of the story. Granite-30M with 128 dimensions finds 96% of the true top 10 on average, but if we look at median recall, it’s basically 100%. At least half of the queries lose nothing, and a few lose a lot. The best result is almost always still there: MRR, which tracks how high the first correct result ranks, stays at 0.97 or higher in every run, even at the harshest cuts. The cut mostly costs results further down the top 10. “And What If I Use Hybrid Search?” We used the same 2M Natural Questions documents and the same 10K documents-as-queries, now with dense embeddings from Cohere embed v3 https://huggingface.co/datasets/CohereLabs/beir-embed-english-v3/viewer/nq-corpus next to each sparse model. Each query runs two prefetches, one dense and one sparse 100 candidates each , and fuses them with RRF, with no rescoring. We cut only the sparse side. The ground truth is the top 10 of the same hybrid query without any cut. The same cuts work the same way. For every model, the cut we picked for sparse-only search still finds 95% or more of the true top 10, and the slow end of the distribution gets 1.4× to 2.5× faster. | Model | Median Query Dimensions | Dimensions Kept | Recall | Speedup p95 | Speedup p99 | |---|---|---|---|---|---| | SPLADE | 157 | 128 | 98.1% | 1.4× | 1.4× | | SlideOn | 682 | 512 | 96.9% | 1.7× | 1.7× | | SparseUP | 330 | 256 | 96.3% | 2.2× | 2.5× | | Granite-30M | 229 | 128 | 96.5% | 2.3× | 2.5× | Same cuts as the sparse-only table. Recall is the share of the hybrid top 10 that search still finds, averaged over the 10K queries. Hard cuts hurt less. SlideOn with 64 dimensions finds 85% of the true top 10, against 73% in sparse-only search, and SparseUP with 32 dimensions finds 80%, against 62%. Our guess is that the dense results make up for part of what the cut drops. The best result is safe. MRR stays at 0.99 or higher in every run, even at the harshest cuts. Averages still hide part of the story. Granite-30M with 128 dimensions finds 96% of the true top 10 on average, but the median query finds all ten, and 95% of queries find at least nine. “Do I Need to Cut My Sparse Queries?” Yes, and no: it mostly depends on the type of workload you’re running. If you have a few million data points and you’re running on sparse embeddings from neural sparse models like SPLADE, it definitely makes sense to try it and see if a few dimensions are really all you need for your search. If you have fewer than 1M vectors, you will probably notice a smaller speedup, or even no speedup at all if you’re under 100K points. If you’re using BM25 vectors, this is not for you: BM25 follows different assumptions, and doesn’t show the concentration of importance that is at the heart of the query cutting mechanism. Also, you might be better off with BM25-scored full-text indices https://qdrant.tech/documentation/manage-data/indexing/ bm25-scoring rather than BM25 vectors. How To Try It This feature will be stabilized with the upcoming v1.21.0 release, but, in the meantime, it is available in dev preview qdrant/qdrant:dev and supported by the dev version of the python client: uv add git+https://github.com/qdrant/qdrant-client --branch dev If you want to integrate approximate sparse search in your pipeline, you can do so using the max sparse dims search parameter in your query points calls: client.query points collection name="products-ecommerce", query=models.SparseVector indices= ... , values= ... , using="sparse", params=models.SearchParams max sparse dims=128 You can do the same with a plain HTTP call: curl -X POST ${QDRANT URL}/collections/products-ecommerce/points/query \ --header "Content-Type: application/json" \ --header "api-key: $QDRANT API KEY" \ --data-raw '{ "query": { "indices": ... , "values": ... }, "using": "sparse", "params": { "max sparse dims": 128 } }' The parameter applies per request at query time, so you can try it without re-indexing anything. It keeps the N dimensions with the highest absolute weight and drops the rest. N must be at least 1, and you cannot combine it with exact=True , because exact search reads everything by definition. Let us know how it goes