# Hybrid Retrieval Visualised

**AI Engineering Visualised** · Retrieval · Interactive explainer · Updated 2026-09-09

Hybrid retrieval runs a lexical search like BM25 and a vector search on the same query and merges the two rankings, usually with reciprocal rank fusion. Each search catches questions the other misses.

> One query, two searches, one result list. See BM25 and cosine search feed their rankings into reciprocal rank fusion.

Choose an example and press Play. BM25 looks for matching words. Cosine compares topic vectors. Both searches receive the same query, then reciprocal rank fusion (RRF) combines their rankings into one list.

The exact-identifier example shows why the searches complement each other: BM25 finds the right contract, while the topic vector also retrieves documents about related incidents. Different wording shows the opposite case: no exact words match, but the vector search still returns candidates. Combining lists can help, but does not guarantee relevance.

The demonstration uses eight fictional UK business documents. BM25 is computed from their text with k1 = 1.2 and b = 0.75, preserving identifiers such as NB-204 without stemming or stop-word removal. Cosine uses four hand-authored coordinates: incidents, billing, privacy and staff. These are teaching vectors, not model-generated embeddings. The 3D lanes separate the searches; their positions do not measure relevance. Playback illustrates the sequence, not service latency.

## The maths

### Reciprocal rank fusion

```latex
\operatorname{RRF}(d)=\sum_{L:d\in L}\frac{1}{c+\operatorname{rank}_L(d)}
```

This example keeps up to three candidates per search and fixes c at 60. A document receives 1 / (60 + rank) from each list containing it. Missing from a list means zero from that branch. Add these contributions, then sort by the total. Raw BM25 and cosine scores are not added.

## Sources

- [Elasticsearch: reciprocal rank fusion](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion)
- [Apache Lucene: BM25 similarity](https://lucene.apache.org/core/9_12_1/core/org/apache/lucene/search/similarities/BM25Similarity.html)

## Related terms

- [Hybrid search](https://understandingdata.com/context-engineering-dictionary/hybrid-search/)
- [Reranking](https://understandingdata.com/context-engineering-dictionary/reranking/)

## More visualisations

- [HNSW Visualised](https://understandingdata.com/ai-engineering-visualised/hnsw/)
- [GraphRAG Visualised](https://understandingdata.com/ai-engineering-visualised/graphrag/)
- [Embedding space](https://understandingdata.com/ai-engineering-visualised/embedding-space/)

---

Source: https://understandingdata.com/ai-engineering-visualised/vector-search/
From AI Engineering Visualised by James Phoenix, Understanding Data. Published 2026-09-09.
