> Explore Qdrant's agent skills catalog at https://skills.qdrant.tech/
> Search the documentation at https://search.qdrant.tech/md/documentation?q=your+query+here
> Use this file for an index of the main pages: https://qdrant.tech/llms.txt
> Content inside `<only-applies-to>` tags applies only to the named products, or only as of the named version, and never to products it says it does not apply to. All other content applies to every Qdrant product. If you know which product the user is on, ignore tagged content for other products.


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).

```json
{ "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.*

```json
{
  "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. 


<div class="accordion-dark" data-shortcode="accordion">
  
    <div class="accordion-dark__item">
      <h6 class="accordion-dark__item-header">Want to know more about inverted indexes optimizations in Qdrant?</h6>
      <div class="accordion-dark__item-body">
        <div class="accordion-dark__item-body-content list">
          <p>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.</p>
<p>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:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">entry        d1     d2     d4     d5
</span></span><span class="line"><span class="cl">weight       0.1    0.3    0.9    0.4
</span></span><span class="line"><span class="cl">look-ahead   0.9    0.9    0.4    none
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">d5: last entry, nothing follows it            -&gt; none
</span></span><span class="line"><span class="cl">d4: only d5 follows                           -&gt; 0.4
</span></span><span class="line"><span class="cl">d2: max(weight of d4, look-ahead of d4)       -&gt; max(0.9, 0.4) = 0.9
</span></span><span class="line"><span class="cl">d1: max(weight of d2, look-ahead of d2)       -&gt; max(0.3, 0.9) = 0.9
</span></span></code></pre></div><p>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.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-rust" data-lang="rust"><span class="line"><span class="cl"><span class="kd">let</span><span class="w"> </span><span class="n">max_weight_from_list</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element</span><span class="p">.</span><span class="n">weight</span><span class="p">.</span><span class="n">max</span><span class="p">(</span><span class="n">element</span><span class="p">.</span><span class="n">max_next_weight</span><span class="p">);</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="kd">let</span><span class="w"> </span><span class="n">max_score_contribution</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">max_weight_from_list</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">longest_posting_iterator</span><span class="p">.</span><span class="n">query_weight</span><span class="p">;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="k">if</span><span class="w"> </span><span class="n">max_score_contribution</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">min_score</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="n">longest_posting_iterator</span><span class="p">.</span><span class="n">skip_to</span><span class="p">(</span><span class="n">next_min_id</span><span class="p">);</span><span class="w">   </span><span class="c1">// jump over the points that cannot win
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span></code></pre></div><p>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.</p>
<p>For even more details, check out <code>prune_longest_posting_list</code> and <code>search</code> in <a href="https://github.com/qdrant/qdrant/blob/master/lib/sparse/src/index/search_context.rs" target="_blank" rel="noopener nofollow">search_context.rs</a>, and at the <code>max_next_weight</code> field in <a href="https://github.com/qdrant/qdrant/blob/master/lib/sparse/src/index/posting_list_common.rs" target="_blank" rel="noopener nofollow">posting_list_common.rs</a>.</p>

        </div>
      </div>
    </div>
  
</div>
    

## 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.**

Diagram of a sparse query with five weighted terms. Keeping only the highest-weight terms means the search reads fewer posting lists.

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. 

Chart of recall against speedup for four sparse models. The tables that follow list the same values.

*Recall at 10 against speedup for sparse-only search. Each dot is one cut, and only cuts with 90% recall or more are shown. Switch between p95 and p99 to compare the slow end of the distribution.*



#### 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.

<aside role="alert">
<b>A note on SlideOn.</b> SlideOn is denser than the other models (about 600 non-zero dimensions against about 160 for SPLADE) because it is not vocabulary-based: its dimensions are learned features, not tokens. Cutting to 128 dimensions still keeps 80% of the recall, but cutting by overall vector mass may suit it better than cutting by dimensions. We plan to test this further.
</aside>

<aside role="status">
<b>And what does this mean for you?</b> Start by keeping 128 dimensions for SPLADE and Granite-30M, 256 for SparseUP, and 512 for SlideOn. You keep at least 95% of the true top 10, and your slowest queries run 1.4× to 2.6× faster. Cut harder only if you can live with lost recall: at 32 to 64 dimensions the slowest searches get 10–15× faster, but recall drops to 62–73%.
</aside>

## “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.
Chart of recall against speedup for four sparse models in hybrid search. The tables that follow list the same values.

*Recall at 10 against speedup for hybrid search with Cohere embed v3 as the dense side. Speedups cover the whole hybrid query, and only the sparse side is 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.

<aside role="status">
<b>And what does this mean for you?</b> If you run hybrid search, use the same cuts as for sparse-only. You still find 95% or more of the true top 10, the slowest queries run 1.4× to 2.5× faster, and harder cuts cost less recall because the dense side makes up for part of what is dropped.
</aside>

## “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

<!--TODO: Update these instructions to _actual_ Qdrant v1.21 once it is released-->

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:

```bash
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:

<!--TODO: Update the code snippets to show all the clients (not only python and HTTP) once Qdrant v1.21 is released-->

```python
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:

```bash
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!
