Semantic Search
Definition. Search that ranks results by meaning rather than lexical overlap, implemented by comparing query and document embeddings. It handles synonyms, paraphrase, and natural-language questions that keyword search misses, but it is weaker than lexical search on exact identifiers, rare tokens and negation. Production systems therefore almost always run hybrid search, fusing a BM25 or sparse-vector score with a dense-vector score.
How it works. Implement two retrievers, one lexical and one dense, and combine their ranked lists with reciprocal rank fusion or a weighted score. Then rerank the fused top 50 with a cross-encoder that scores query and passage jointly. Tune the fusion weight on a labelled query set, and log queries with zero results so you can see where the index has gaps.
Example. An e-commerce catalogue search for running shoes for flat feet returns nothing under keyword search because no product title contains flat feet. Dense retrieval surfaces stability shoes and motion-control models, while BM25 correctly ranks an exact model number query that dense retrieval blurs. Fusing the two lists with reciprocal rank fusion improves nDCG at ten from 0.41 to 0.63 on the team's evaluation set.
Use case. Use semantic search for knowledge bases, support deflection, catalogue discovery, and any interface where users type questions rather than keywords. Keep lexical search for SKUs, error codes, legal citations, names and anything where exactness matters.
Warnings. Semantic similarity is not relevance. A passage about the opposite policy can score highly. Always evaluate with real queries and human judgements rather than trusting cosine scores, and never ship a search change without a before-and-after metric.
Limitations. Dense retrieval requires an embedding model that handles your domain and language; a general model performs poorly on legal, medical or code corpora without adaptation. It also cannot explain its ranking, which makes debugging hard, and it degrades on very short queries where there is little semantic signal.
| Pros | Cons |
|---|---|
| Finds related passages when a query uses different words from the source. | The embedding model must represent the domain and language well. |