Glossary
Sparse vectors
A sparse vector has a value in only a few of its many dimensions, usually one dimension per vocabulary term, which makes it the basis of keyword retrieval.
A sparse vector is a vector in which almost every value is zero, so it is stored as a short list of the positions that are not zero and their weights. In search, a sparse vector usually represents a piece of text over a vocabulary of tens of thousands of terms: each dimension stands for one word or word piece, and only the terms that appear in the text (or are judged relevant to it) get a weight. A 300-word paragraph might touch 150 of 30,000 dimensions. Sparse vectors are the basis of keyword retrieval methods such as TF-IDF and BM25, and of learned sparse models such as SPLADE. They are the counterpart to dense vectors, the embeddings produced by neural models, in which every dimension carries a value and no single dimension means anything on its own.
How a sparse vector is built
Take the sentence “Reset the router, then reset the modem.” With a vocabulary in which “reset” is dimension 18,204, “router” is 22,917 and “modem” is 17,480, a simple term-count representation has three non-zero entries: 2 for reset and 1 each for router and modem. Common words such as “the” and “then” are either dropped as stop words or given very low weights. Every other dimension is zero.
Storing all 30,000 values would waste memory, so sparse vectors are kept as pairs of index and value: [(17480, 1), (18204, 2), (22917, 1)]. Two sparse vectors are compared with a dot product, which only needs the dimensions both vectors share. If a query has no terms in common with a document, the score is zero, however close their meanings are.
The weights are where methods differ. Raw counts favour long documents and common words. TF-IDF multiplies term frequency by inverse document frequency, so rare terms count for more. BM25 adds saturation, so the tenth occurrence of a word adds less than the second, and length normalisation, so long documents do not win by size alone. Text normalisation decides what counts as the same term in the first place: lower-casing, stemming, lemmatization and tokenisation all change which dimensions light up.
Why sparse vectors search so well
Sparse vectors fit the oldest structure in search, the inverted index. For every term, the index holds a list of the documents that contain it and the weight in each. A query with five terms reads five lists, adds up the scores per document, and returns the top results. Documents that share no terms with the query are never touched. This is why full-text search engines can search billions of documents on modest hardware, and why sparse retrieval needs no special vector index of the kind that approximate nearest neighbor search relies on.
They are also interpretable. Every non-zero dimension is a term, so you can read a sparse vector and see why a document matched: it contains “router” and “reset”, weighted by how rare they are. When a result is wrong, the cause is usually visible.
And they are exact about rare tokens. Product codes, error numbers, part names, surnames, legal citations and SKUs are close to meaningless to an embedding model but highly distinctive as terms. A query for “E4021” should return the document that mentions E4021, and sparse retrieval does so reliably. The post on hybrid search in the real world goes through examples of this.
Where sparse vectors fall short
The vocabulary mismatch problem is the main weakness. A query for “laptop won’t turn on” scores zero against a support article titled “Notebook fails to power up”, because no terms overlap. Classic sparse retrieval matches words, not meaning. Partial fixes include synonym lists, query expansion and stemming, each of which helps a little and can add noise.
Sparse representations also miss word order and context. “Dog bites man” and “man bites dog” produce the same vector. Negation, comparison and intent are lost. For conversational queries and questions phrased differently from the source text, dense retrieval usually does better, which is why keyword search alone is rarely enough for an AI agent that receives natural-language questions.
Learned sparse vectors
Learned sparse models keep the sparse format and the inverted index but let a neural network choose the weights. The best known is SPLADE, which runs text through a transformer and predicts a weight for every vocabulary term, including terms that do not appear in the text. A passage about “notebook power faults” can end up with non-zero weights for “laptop” and “battery”, which closes some of the vocabulary gap while keeping exact-term matching. A regularisation step pushes most weights to zero so the vectors stay sparse enough for an inverted index.
The result sits between classic keyword retrieval and dense embeddings. Learned sparse models are more accurate than BM25 on many benchmarks, remain fairly interpretable, and keep the efficiency of term-based indexes, though they cost more to encode, produce longer posting lists, and are sensitive to the domain they were trained on. Older approaches such as doc2query, which generates likely questions for each document and indexes them as extra text, follow a similar idea of expanding documents before indexing.
Sparse vectors compared with dense vectors
Property | Sparse vectors | Dense vectors |
|---|---|---|
Dimensions | Tens of thousands, one per term | Hundreds to a few thousand |
Non-zero values | A few dozen to a few hundred | All of them |
Meaning of a dimension | One term | None on its own |
Typical index | Inverted index | HNSW, IVF or another ANN index |
Strength | Exact terms, codes, names, rare words | Paraphrase, synonyms, intent |
Weakness | Vocabulary mismatch | Exact identifiers, out-of-domain terms |
Explainability | High | Low |
Dense vectors are the embeddings produced by an embedding model, with every dimension filled. The dense vs sparse retrieval entry compares the two approaches in more depth, and BM25 vs embeddings looks at the most common pairing.
Using sparse and dense together
In practice the two are combined. Hybrid search runs a sparse and a dense query side by side and merges the results, usually with reciprocal rank fusion or a weighted sum of normalised scores. The sparse side catches exact identifiers and rare terms, and the dense side catches paraphrases. A reranking step can then reorder the merged candidates with a slower, more accurate model.
A worked example makes the split clear. A support team indexes 200,000 help articles and tickets. On a set of 1,000 real queries with known answers, BM25 alone finds the right article in the top 10 for 71% of queries and does best on error codes and product names. Dense retrieval alone reaches 76% and does best on vague, conversational questions. Fusing the two lists reaches 85%, because their failures barely overlap. Adding a reranker on the top 50 lifts it to 89%. The exact figures will differ for every corpus; the pattern of complementary failures is consistent enough that hybrid retrieval has become the default design. Hybrid search vs vector search covers when the extra complexity pays off.
Many vector databases now accept sparse vectors alongside dense ones in the same record, and search engines such as Elasticsearch combine inverted indexes with vector fields. Exabase vs Elasticsearch and the best vector databases roundup compare how different systems handle the combination.
Practical considerations
Sparse vectors need a fixed vocabulary that both indexing and querying share. Changing the tokeniser or vocabulary means re-encoding the corpus, the same as changing an embedding model for dense vectors. Learned sparse models also tie the vectors to a specific model version.
Query length matters. Short queries produce very sparse vectors, which is fast but brittle; long queries produce many terms and longer posting-list reads. Learned sparse models that expand queries can make query vectors much denser than the raw text, which raises latency, so some systems expand documents only and keep queries close to their original terms.
Multilingual corpora are harder for sparse methods, because the same idea in two languages shares no terms. Dense multilingual embeddings handle this better, and hybrid systems often lean more on the dense side for cross-language queries.
Where Exabase fits
Exabase does not ask developers to build sparse vectors, choose a tokeniser or run a separate keyword index. Content stored as Resources in a Base is extracted and indexed on arrival, and every text query to Deep Search is hybrid by default: semantic matching combined with typo-tolerant keyword matching, balanced automatically. Wrapping a phrase in double quotes forces an exact match, which covers the product-code and error-number cases where sparse retrieval shines. Results come back as passages with page numbers or timestamps, and a precision parameter between 0 and 1 controls how broad the result set is.
Exabase is the retrieval layer rather than a configurable search engine, so teams that want to tune BM25 parameters or train their own SPLADE model will still run their own stack. For teams that want hybrid retrieval without building it, the searching resources guide and the search endpoint reference are the place to start, and RAG accuracy explains why passage-level hybrid retrieval matters for answers. The customer support agents use case shows the pattern with product names and ticket numbers, and Semantic search vs keyword search for AI agents covers the trade-off from the agent’s side.
Frequently asked questions
What is the difference between sparse and dense vectors?
Sparse vectors have mostly zero values and one dimension per vocabulary term, so they match exact words. Dense vectors fill every dimension with learned values and match meaning, including paraphrases.
Is BM25 a sparse vector method?
Yes. BM25 scores documents by weighted term overlap, which is a dot product between sparse term vectors with BM25 weights. It runs on an inverted index.
What is a learned sparse vector?
A learned sparse vector is produced by a neural model that assigns weights to vocabulary terms, including related terms not in the text. SPLADE is the best-known example.
Why are sparse vectors still used if embeddings exist?
Sparse vectors are better at exact identifiers, rare terms and names, are cheap to search with an inverted index, and are easy to explain. Combining them with dense vectors in hybrid search usually beats either alone.
How are sparse vectors stored?
As lists of index and value pairs for the non-zero dimensions only, and searched through an inverted index that maps each term to the documents containing it.
Can a vector database store sparse vectors?
Many can. Several vector databases accept sparse vectors next to dense ones in the same record and support hybrid queries over both.
Do I need to create sparse vectors to use Exabase?
No. Deep Search combines keyword and semantic matching on every text query automatically, so there are no sparse or dense vectors to manage.
Related pages: Dense vectors, SPLADE, BM25, TF-IDF, Inverted index, Hybrid search, Dense vs sparse retrieval, Late interaction retrieval, Exabase vs Elasticsearch, RAG accuracy