From Inverted Indexes to Dense Vector Retrieval: BM25, HNSW, and Hybrid RRF Architecture
Direct answer
Inverted indexes (BM25) store sparse lexical postings lists for exact keyword matching at low query latency, whereas dense vector retrieval (HNSW) embeds passages into continuous semantic spaces to resolve synonyms and conceptual intent. Hybrid search systems run both channels in parallel, merge their top-K candidates with Reciprocal Rank Fusion (RRF, commonly k = 60), and apply cross-encoder reranking before answer synthesis.
Inverted index vs dense vector retrieval is a core design choice in modern search stacks: a sparse lexical index matches the exact terms a query contains, while a dense vector index matches what the query means. This comparison sets the two channels side by side: how each one represents a document, the crawl, latency and memory limits that bound it, how reciprocal rank fusion merges their ranked lists, how each one fails, and which open standards govern the content both of them index.
Inverted Index vs Dense Vector Retrieval: How Each Channel Ranks a Query
The two indexes answer one query with different evidence. An inverted index keeps a postings list for every term: the sorted identifiers of the documents that contain it, with positions and skip pointers so that intersecting two long lists stays cheap. Scoring then considers only documents that share at least one term with the query. Because that vocabulary comes from how text is cut into terms, what is tokenisation and subword splitting decides which strings can match at all.
A dense index stores no terms. An encoder turns each passage into a fixed-length vector, the query is encoded by the same model, and the engine returns the stored vectors nearest to it, usually by walking a Hierarchical Navigable Small World (HNSW) graph instead of scanning every vector. Two texts with no word in common can still land close together, which is why the dense side is the standard answer to vocabulary mismatch and why it matters for search intent optimisation across hybrid retrieval.
A hybrid stack runs both on every request. A compound prompt may first be split by multi-branch query fanout decomposition; each branch then queries both indexes, and the lists are merged before reranking.
How the two channels score a candidate
- Lexical score. BM25 rewards a term that is rare across the collection and frequent in the document, saturates repeated occurrences and normalises for document length; and are common default settings.
- Dense score. Cosine similarity or inner product between the query vector and a passage vector. It has no notion of an exact token, only of position in the embedding space.
- Learned sparse score. Models such as SPLADE sit between the two: they still write an inverted index, but a neural model adds weighted expansion terms, so some paraphrases match without any vector graph.
- Late interaction. ColBERT (Khattab et al., ACM SIGIR 2020) stores a vector per token and matches query tokens against passage tokens one at a time, keeping some lexical precision inside a neural model. It is usually run over a short fused shortlist rather than the whole collection.
Engineering Takeaway: Write each passage to win on both scores: name the exact product, protocol or error string a searcher would type, and explain the concept in a self-contained sentence that an encoder can place near paraphrased questions.
| Question a team asks | Inverted index (BM25) | Dense vector index (HNSW) |
|---|---|---|
| What must a query share with a passage? | At least one term or stem | Nothing literal, only nearness in embedding space |
| What is stored per document? | Postings entries for the terms it contains | One fixed-width vector per passage |
| How does a brand-new rare token behave? | Matchable as soon as the document is indexed | Depends on how well the encoder represents it |
| Which tuning knobs matter most? | Term saturation and length normalisation | Graph connectivity (M) and search breadth (efSearch) |
Where Each Channel Hits Its Limits: Crawl Budget, Latency and Memory
Neither index can rank a page the crawler never fetched, so the first limit is shared. A slow origin gets fewer fetches in each crawl window, and an origin that answers a conditional request with 304 Not Modified, under the caching rules of RFC 9110, lets the crawler spend that window on pages that changed. Both effects reach the lexical and the dense side equally; the upstream sourcing questions behind them are covered in how Google sources and reconciles information.
Memory: postings compress, vectors do not
The cost profiles split after ingestion. Postings grow with the number of term occurrences and compress well, since the gaps between sorted document identifiers are small integers. A dense vector does not shrink with the text: at 1,536 dimensions and 4 bytes per float32 value, each passage costs 1,536 × 4 = 6,144 bytes before graph links are added. Product quantisation (PQ) swaps each vector for a short code and gives up some accuracy in return, and that lost accuracy is why a precise reranker usually rescores the top of the dense list.
Latency: pruning versus graph breadth
Lexical latency falls with dynamic pruning, which skips postings that cannot reach the current top-K. Dense latency depends on how much of the graph a search visits. Malkov and Yashunin (IEEE TPAMI 2020) show that a hierarchical small-world graph keeps search cost close to logarithmic in collection size while node connectivity stays bounded; in practice, raising M or efSearch buys recall with more memory or more time.
| Limit | Inverted index (BM25) | Dense vector index (HNSW) | What a hybrid inherits |
|---|---|---|---|
| Crawl and fetch | Shared upstream limit | Shared upstream limit | The same limit, once |
| Memory growth | Term occurrences, with compressible identifier gaps | Passage count times vector width | Both footprints |
| Query latency | Cut by dynamic pruning | Set by graph search breadth | The slower channel plus the merge |
| Recall knob | Depth of the candidate pool | efSearch and M | Both, plus how deep the fusion reads |
Fusing BM25 and HNSW Candidate Lists with Reciprocal Rank Fusion
A hybrid cannot simply add a BM25 score to a cosine similarity: the first is unbounded, the second is bounded between -1 and 1. Reciprocal rank fusion, introduced by Cormack et al. at ACM SIGIR 2009, throws the scores away and keeps each document's position in each list. With a lexical rank , a dense rank , channel weights and a smoothing constant :
A document missing from one list contributes no term for that channel. The constant , 60 in the original paper, narrows the gap between rank 1 and rank 5, so one list cannot settle the outcome alone.
Worked Example: an Exact Error String
Take the query "ERR_SSL_PROTOCOL_ERROR after CDN migration" with equal weights of 1.0 and . The ranks are illustrative, chosen to show the arithmetic:
- Page P, an error-code reference: first in BM25 because it contains the exact string, eighteenth in the dense list. Score: 1/61 + 1/78 = 0.01639 + 0.01282 = 0.02921.
- Page Q, a general TLS handshake explainer: fortieth in BM25, first in the dense list because it matches what the question means. Score: 1/100 + 1/61 = 0.01000 + 0.01639 = 0.02639.
- Page R, a migration troubleshooting guide that names the error and explains its cause: second in BM25, third in the dense list. Score: 1/62 + 1/63 = 0.01613 + 0.01587 = 0.03200.
R comes first without topping either list, and Q, the closest semantic match, comes last because the exact string mattered for this query. For a paraphrased query sharing no term with P or R, the lexical list would hold neither, and the dense channel alone would set the order.
The fused list is what the answer step reads. In the retrieval-augmented generation design of Lewis et al. (NeurIPS 2020), the generator is conditioned on the top retrieved passages, so a fusion step that drops the exact-match page also drops it from the grounding of the answer. The stage-by-stage levers that keep a passage in that grounding set, from self-contained answer capsules to connected JSON-LD, are benchmarked in how to optimize LLM grounding citations.
Sparse and Dense Failure Modes Compared
Each channel fails in its own way, and a hybrid earns its cost because those failures rarely coincide.
Lexical misses: vocabulary mismatch
BM25 returns nothing for a passage that answers the question in other words. A buyer who asks how to stop duplicate URLs from splitting rankings will not reach a page that only says "canonicalisation", however good that page is. Learned sparse expansion narrows the gap; a dense channel closes most of it.
Dense misses: rare tokens and domain drift
An encoder trained on general text places unfamiliar identifiers, version numbers and product codes poorly, so the passage holding the exact string can rank below loose paraphrases. Domain vocabulary the encoder never saw has the same effect, and the usual fix is to fine-tune it on in-domain query and passage pairs. Quantisation noise adds small ranking errors on top, which the reranker is there to absorb.
Shared misses: crawl, canonical and attribution failures
Some losses happen before either index sees a page or after both have ranked it. A starved crawl budget, or duplicate parameter URLs with no canonical declaration, hides or splits a page for both channels at once, and near-duplicate detection such as SimHash fingerprinting can only cluster what was fetched. A robots.txt file under RFC 9309 is advisory, so an operator who must refuse an agent enforces that at the edge, for example with a 403 Forbidden. And a page can be retrieved yet left uncited when the answer step does not attribute it. The free website SEO and GEO audit covers part of the page side: it scores Core Web Vitals, on-page structure and structured data, and flags a missing robots.txt or a blanket Disallow: /. The free AI visibility report covers attribution, counting how often ChatGPT, Google AI Overviews, and Gemini cite a brand across three buyer prompts. To keep counting after a fix ships, Quasarank pricing plans list the prompts each tier re-runs on those three engines, together with its page audits and seats.
Diagnostic Rule: If a page surfaces for its exact product name but never for a paraphrased question, suspect the dense channel; if it surfaces for paraphrases but not for its own error codes or SKUs, suspect the lexical one. Find which list drops the page before rewriting it.
| Failure mode | Channel it hits | Typical cause | Remedy |
|---|---|---|---|
| Vocabulary mismatch | Inverted index | Query and passage use different words | Add a dense or learned sparse channel |
| Rare-token drift | Dense index | Encoder represents identifiers poorly | Keep the lexical channel in the fusion |
| Domain drift | Dense index | Encoder never saw the domain's vocabulary | Fine-tune the encoder on in-domain pairs |
| Quantisation noise | Dense index | Compressed vectors lose precision | Rerank the top of the fused list |
| Crawl starvation or canonical splits | Both | Slow origin or duplicate parameter URLs | Faster responses, conditional caching, canonical tags |
| Retrieved but uncited | Both | The answer step omits attribution | Short passages that state the answer directly |
Open Standards Both Retrieval Channels Depend On
Both indexes sit on one fetch layer, and two IETF documents govern it. RFC 9309 fixes the syntax of robots.txt, so a parameter rule such as Disallow: /*?sort= keeps compliant crawlers from filling either index with near-identical URLs. RFC 9110 defines the validators (ETag with If-None-Match, and Last-Modified) that let an origin answer an unchanged page with 304 Not Modified, which keeps re-crawls cheap whichever index the content lands in. Neither standard knows whether the fetched text becomes postings or vectors.
Inverted Index (BM25) vs Dense Vector Retrieval (HNSW): Side-by-Side Architecture Matrix
Inverted indexes and dense vector graphs fail in complementary ways. Sparse BM25 postings match exact tokens, so product codes, error codes and proper nouns are found reliably, while dense HNSW graphs match meaning, so a paraphrased question still reaches the passage that answers it. Both channels sit downstream of the crawling and indexing pipeline described in how search engines work, and the matrix below compares them on the dimensions that decide which channel a query depends on.
| Architectural dimension | Sparse inverted index (BM25, Block-Max WAND) | Dense vector graph (HNSW, quantised) | Hybrid fusion (BM25 + HNSW + RRF) |
|---|---|---|---|
| Primary representation | Variable-length postings lists of document identifiers, term frequencies and positions | Fixed-width embedding vectors, one per passage (1,536 dimensions in this article's example) | Both indexes, queried in parallel, each returning its own top-K candidate list |
| Exact entity and code recall | High, because a query token either appears in the postings or it does not | Lower, because rare tokens and identifiers can drift in the embedding space | High, because the lexical list keeps exact matches in the fused pool |
| Semantic and paraphrase recall | Low, because nothing matches without a shared term or stem | High, because nearby vectors match different phrasings of the same intent | High, because the dense list adds the paraphrased matches |
| Memory for 10 million passages | Grows with total term occurrences; integer codecs such as PForDelta compress the gaps between document identifiers | 61.4 GB of raw float32 vectors, 15.4 GB at one byte per dimension, plus the graph's neighbour links | The sum of both indexes |
| Retrieval latency | Low, because dynamic pruning such as Block-Max WAND skips postings that cannot reach the top-K | Set by search breadth (efSearch): a wider search raises recall and latency together | The slower of the two channels plus a rank-only merge |
The memory figures are arithmetic, not measurements. They assume 10 million passages, 1,536 dimensions per vector and 4 bytes per float32 value: 10,000,000 × 1,536 × 4 bytes = 61.44 GB. Scalar quantisation to one byte per dimension divides that by four, to 15.36 GB. Product quantisation stores a short code per vector instead; with 64-byte codes, the same collection needs 10,000,000 × 64 bytes = 0.64 GB, at the cost of the quantisation noise described earlier. The hybrid column merges the two lists with reciprocal rank fusion using the smoothing constant k = 60 chosen by Cormack et al. (2009).
Frequently Asked Questions
When does BM25 beat dense vector retrieval?
BM25 wins when a query depends on an exact token that an embedding model has rarely seen, such as a product code, an error string, a version number or a proper noun. An inverted index matches terms literally, so a passage containing the token is found reliably, while a dense index can rank loose paraphrases above the passage that holds the exact identifier.
How much memory does a dense vector index need compared with an inverted index?
Raw dense vectors cost dimensions times bytes per value for every passage: assuming 10 million passages of 1,536 float32 dimensions, that is 61.44 GB before graph links. One byte per dimension cuts it to 15.36 GB, and 64-byte product quantisation codes to 0.64 GB. Inverted postings instead grow with term occurrences and store no per-passage vector at all.
Why fuse sparse and dense candidate lists instead of choosing one channel?
Each channel covers the other's blind spot: BM25 misses paraphrases, and dense retrieval can miss rare exact tokens. Their raw scores sit on different scales, so adding them is unstable. Reciprocal Rank Fusion uses only each document's rank in each list, plus a small smoothing constant, so a document ranked well by both channels rises above one ranked first by only one.
References
- Robots Exclusion Protocol (RFC 9309) — IETF, 2022
- HTTP Semantics (RFC 9110) — IETF, 2022
- Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods — Cormack et al., ACM SIGIR, 2009
- Efficient and Robust Approximate Nearest Neighbor Search Using HNSW Graphs — Malkov and Yashunin, IEEE TPAMI, 2020
Cite this article
@misc{quasarank2026searchengines,
author = {{Quasarank AI Research}},
title = {From Inverted Indexes to Dense Vector Retrieval: BM25, HNSW, and Hybrid RRF Architecture},
year = {2026},
howpublished = {\url{https://quasarank.com/blog/from-inverted-indexes-to-dense-vector-retrieval}},
note = {Published 2026-10-01}
}Quasarank AI Research. (2026, October 1). From Inverted Indexes to Dense Vector Retrieval: BM25, HNSW, and Hybrid RRF Architecture. Quasarank. https://quasarank.com/blog/from-inverted-indexes-to-dense-vector-retrieval