AI Agentic Handbook
Retrieval & Search

Semantic search vs similarity search

Budding levelReviewed Oct 2026In 2 interview questionsIn 1 post

Search that goes after what you meant rather than the words you typed. Usually embeddings, plus a reranker to tidy up the top.

In plain English

Semantic search is the promise users feel: ask in your own words, get results that answer you, even when the wording is nothing alike.

Underneath it is usually Dense retrieval with embeddings, often paired with keyword search (Hybrid search) and a Reranker that reads the top handful more carefully before showing them to you.

Analogy

The shop assistant who hears 'something to keep my coffee hot on the commute' and walks you to the travel mugs, even though you never said 'mug'.

Common pitfall

'Semantic' sounds like it understands conditions too, and that is the gap that catches everyone. Embeddings blur numbers, negation and attributes: 'laptop under $800, not a Chromebook' needs a parser that turns the price and the exclusion into real filters. Without one, the top results are $1,400 laptops and Chromebooks.

How it actually works

The term names an outcome, not an algorithm. A production semantic-search stack has four stages: query understanding (spell-fix, Query rewriting, Intent classification & routing), candidate retrieval (dense + BM25, 100–200 candidates), reranking (Cross-encoder on 50–100), and presentation (snippets, highlighting, facets). Most of the 'semantic' quality comes from the reranker, which reads query and document together: on MS MARCO, BERT reranking of BM25 candidates lifted MRR@10 from 0.187 to 0.365 (Nogueira & Cho 2019). Highlighting is harder than in keyword search because the matching words may not be in the text; production systems use the reranker's best-scoring sentence or an LLM-extracted span.

What I'd ship on day one

Hybrid retrieval (BM25 + bge-m3 or text-embedding-3-small) to 200 candidates, structured filters from a lightweight query parser, bge-reranker-v2-m3 on the top 50, sentence-level highlighting from the reranker's best sentence.

Worked example

E-commerce catalog, 800k products. Query 'gift for a 10-year-old who likes space'. Keyword search returns 'Space heater 1500W' first. Semantic stack: dense retrieval pulls telescopes, planetarium projectors and astronaut LEGO (200 candidates, 12 ms); a filter removes out-of-stock items; a cross-encoder reorders the top 50 (140 ms) and puts a kids' telescope first. The space heater falls to rank 180.

In the interview

Start by clarifying which layer they mean, which is a fair question rather than a dodge: 'to me semantic search is dense plus BM25 for recall, with a cross-encoder for precision — the embedding gets the right items into the top 100, the reranker gets them into the top 5.' Then volunteer the evaluation: nDCG@10 and zero-result rate on a sampled query log, rather than three anecdotes.

Catalog800,000
Hybrid recall200
In-stock filter140
Cross-encoder50
Shown10
Recall stages find candidates cheaply; the reranker supplies most of the 'understanding'.

Numbers worth knowing

BERT rerank gain over BM25
MRR@10 0.187 → 0.365MS MARCO passage dev (Nogueira & Cho 2019)
Typical end-to-end budget
150–300 ms p95hybrid recall + cross-encoder on 50 candidates, one L4

How to decide

WhenDo this
Queries carry hard constraints (price, date, size, 'not X')Parse into filters before retrieval; do not rely on embeddings.
Latency budget < 80 msSkip the cross-encoder; use a distilled reranker or a Bi-encoder fine-tuned on clicks.

Cost maths

Per query: embed (~$0.0000004 at $0.02/M tokens × 20 tokens) + ANN (fixed infra) + rerank. Self-hosted reranker on one L4 (~$0.80/hr) at ~8 queries/s with 50 candidates → $0.000028/query, ~$28 per million queries. A hosted rerank API at an assumed ~$2 per 1k searches (illustrative, Oct 2026) is ~$2,000 per million — self-host above ~1M queries/month.

Operating it

Time to scale up when…
  • Zero-result or low-CTR rate > 10% on a query class — add rewriting or synonyms for that class
  • Rerank stage > 60% of latency at p95 — distil or cut candidates to 30
What to monitor
  • Query refinement rate within 30 s — alert if > 25% for any query class
  • Zero-result rate — alert above 2%
  • Click-through at rank 1–3 vs last month — alert on −10% relative

When it goes wrong

What users saw

A product search returned premium items for 'cheap running shoes under 50'.

How it was caught

Session-level refinement rate (user re-types within 30 s) was 41% on queries containing price words vs 18% overall.

Root cause

Price constraints were left to the embedding; 'cheap' and 'premium' sit close together in vector space because both describe price.

Fix

Added a rule + small-model parser that extracts price, size and exclusions into filters before retrieval; refinement rate on price queries dropped to 21%.

Sources

  1. Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks — Reimers & Gurevych, 2019paper
  2. Passage Re-ranking with BERT — Nogueira & Cho, 2019paper

Check yourself

Three questions. Every option is explained once you answer.

1ConceptIn a production semantic-search stack, which stage supplies most of the 'understanding' that puts the right items in the top 5?
2ScenarioUsers search 'laptop under $800, not Chromebook' and results include $1,400 laptops and Chromebooks. The latency budget is generous. What is the right fix?
3CalculationA self-hosted reranker on one L4 ($0.80/hr) handles ~8 queries/s with 50 candidates. A hosted rerank API costs ~$2 per 1,000 searches. What is the cost per million queries for each?