Hybrid search
Combining keyword search (such as BM25) with vector search, so results match both exact terms and meaning.
Hybrid search runs keyword search (such as BM25) and vector search on the same query and merges the two result lists, so results match both exact terms and meaning. It is the usual starting recommendation for the retrieval step of a RAG system.
Embeddings find text with similar meaning but are weak on exact strings: product codes, invoice numbers, names, rare jargon. Keyword search is the opposite. Hybrid search runs both and merges the lists, often with reciprocal rank fusion (Cormack, Clarke and Büttcher, 2009), which scores each document by its positions in both lists, so the two incompatible score scales never need to be compared. A reranker can sort the merged result. In Anthropic’s Contextual Retrieval tests, embeddings combined with BM25 missed the right chunk less often than embeddings alone.
In many RAG systems this, not a better model, is what fixes wrong answers. Postgres, Elasticsearch, OpenSearch and many vector databases can run both searches, so it rarely needs a new product. Pure semantic search is enough only when queries are conversational and never contain codes or names.
Sources
- Cormack, Clarke, Büttcher: Reciprocal Rank Fusion (SIGIR 2009) cormack.uwaterloo.ca
- Anthropic: Contextual retrieval in AI systems anthropic.com
Related terms
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- Reranker: A model that rescores the top search results against the query, so the most relevant ones go to the language model first.
- Embeddings: Vectors of numbers that place texts with similar meaning close together.
- Vector database (pgvector and others): A database that stores embeddings and finds the nearest ones to a query vector quickly, which is the search step behind most RAG systems.
- BM25: The standard keyword-search ranking formula: it scores documents by how often query words appear, weighting rare words more.
- Semantic search: Search that matches by meaning instead of exact words, by comparing embeddings of the query and the documents.
- Query expansion: Rewriting a user’s search into several fuller queries, with synonyms and related terms, before searching, so short or vague questions still find matches.
