Guides

Semantic search, and why I never ship it alone

By Abdul Asim ·

What is semantic search?

Semantic search ranks results by meaning instead of by word overlap. It turns your query and your documents into vectors, lists of numbers where related meanings land close together, then returns the documents sitting nearest the query. That is why it answers a paraphrased question well even when the document never uses the asker's words.

The practitioner's version is shorter: semantic search is necessary and not sufficient. Every retrieval system I have put in front of real users combines it with keyword matching and structured lookups, because people ask several different kinds of question in the same session and one index cannot serve all of them.

How semantic search works

Three stages, and each one can be the reason your results are bad.

  1. Embedding. An embedding model reads a chunk of text and outputs a fixed-length vector. Models built for this job, in the line of work that Sentence-BERT started, are trained so that sentences with similar meanings produce similar vectors.
  2. Indexing. Those vectors go into an index built for nearest-neighbour search. Most vector stores use a graph structure based on hierarchical navigable small world graphs, which trades a little accuracy for a large gain in speed.
  3. Querying. The same model embeds the incoming question. The index returns the k nearest vectors by cosine similarity or dot product, and those chunks become the evidence for whatever happens next.

The part people underestimate is that the embedding model and the index are separate decisions with separate failure modes. A good model on a badly tuned index returns fast nonsense, and the symptoms look identical from the outside. For how the index choice plays out, see the vector database guide. For where this stage sits in a larger system, see the components of a RAG pipeline.

Where semantic search beats keyword search

Keyword search needs the asker and the author to have chosen the same words. Often they did not. A learner asks about renewing a licence, the document is headed continuing education requirements, and BM25 scores that pair near zero. An embedding model does not care which words were used.

The gain is measurable, not just plausible. The dense passage retrieval paper reported 9 to 19 percent absolute improvements in top-20 retrieval accuracy over BM25 across open-domain question answering benchmarks. That is the real case for semantic search.

In my work it earns its place on three shapes of question: paraphrase, where the wording differs from the source; concept, where the reader wants everything about a topic rather than one record; and vocabulary gaps, where the user does not know the term the document uses.

Where semantic search loses

This is the half that demos skip. Nearest-neighbour search returns the closest thing it holds, always, whether or not anything in the index actually answers the question. There is no empty result to warn you.

  • Exact identifiers. A permit number, SKU or part number has no useful meaning to embed. The nearest neighbour is a different record that merely looks similar, which is worse than returning nothing.
  • Numbers, dates and ranges. Permits filed after March is a filter, not a similarity question, and embeddings handle it badly.
  • Counts and totals. How many needs a query against structured data. No amount of retrieval tuning produces a correct count.
  • Hard constraints. State, status, entitlement and effective date have to be enforced, not approximated. A near match on the wrong state is a wrong answer delivered confidently.
  • Unfamiliar domains. The BEIR benchmark evaluated retrieval models across eighteen datasets and found BM25 a strong baseline that several dense retrievers failed to beat once they were moved outside the domain they were trained on.

That last point matters when you are costing a build. An embedding model that tops a public leaderboard on general web text can underperform plain keyword search on your contracts. Test it on your own documents before you commit to the architecture, because the architecture is expensive to change later.

Is semantic search better than keyword search?

No, and the comparison is the wrong shape. The useful question is which retriever fits which query, and the answer is usually more than one. These are the criteria I sort on when I design a retrieval layer:

What the user is askingSemanticKeyword (BM25)Structured query
Explain a policy or conceptStrongWeakNo
Find record 2024-PR-8831WeakStrongStrong
How many, totals, averagesNoNoStrong
Paraphrased or unfamiliar wordingStrongWeakNo
Filter by state, date or statusWeakPartialStrong
New domain, nothing tuned yetRiskyReliableReliable

Read down the columns and the design follows. You need all three, and you need something in front of them that decides which one to call for the question in hand.

Hybrid retrieval is what I actually ship

In Permit Signal, users ask about construction permits and properties over a documented ingestion scope of three million New Jersey permits and sixty thousand property records. Some questions are about meaning, some carry a permit number, some are about a place, and some need a count. The retriever combines semantic search, BM25 keyword retrieval, SQL and spatial lookup in PostGIS, and the agent turns each message into semantic queries plus location and property filters. Answers come back source-linked, with map pins and exportable results, so a user can check the record rather than trust the sentence. Reported usage is 1,797 users and roughly 480 messages a day.

The McKissock sales assistant runs the same idea over a different shape of data. Metadata filters, vector search and structured lookups run together, so a question about one state's licensing rule resolves against the right record instead of a nearest neighbour from an adjacent state. When the answer is a specific entitlement, similarity is not good enough.

In the Applied Optoelectronics RFP workflow, the lesson sat earlier in the pipeline. Technical documents and scanned material pass through extraction and OCR before anything is embedded, and retrieval runs per requirement rather than per document. If extraction drops a specification table, no retriever can find it, and a strong embedding model will simply return the second-best passage with no sign that the best one is missing.

If a system routes every question through one embedding index, that is usually the first thing I change. The pattern generalises: production RAG pipelines covers the failure modes this creates downstream, and agentic RAG covers letting the system choose its own retrieval route.

How to evaluate a semantic search engine

Scoring the final answer tells you almost nothing about retrieval, because a good answer can come from lucky retrieval and a bad one from a perfect retriever followed by a weak prompt. Measure the retrieval step on its own.

  1. Build a fixed question set from real traffic, and label each question by type: concept, exact identifier, filter, count.
  2. For each question, record which documents or records should come back.
  3. Measure recall at k per question type, not as one average. The average hides the fact that identifier queries are failing outright.
  4. Compare semantic, keyword and hybrid on the same set before choosing. Run that comparison on your documents, not on a public benchmark.
  5. Rerun after every change to chunking, the embedding model or the index parameters, because all three move the results.

Chunking deserves its own pass. Anthropic reports that prepending a short chunk-specific explanation before embedding and keyword indexing, which it calls contextual retrieval, cut top-20 retrieval failures by 49 percent, and by 67 percent once reranking was added. For scoring the generated answer that sits on top of retrieval, my LLM evaluation guide covers how to build and maintain those question sets.

Key takeaways

  • Semantic search ranks by meaning, using an embedding model and a nearest-neighbour index, and it fixes the vocabulary mismatch that keyword search cannot.
  • It returns the closest match whether or not the index holds an answer, so exact identifiers, filters and counts need keyword and structured retrieval alongside it.
  • Published benchmarks show dense retrievers can underperform BM25 outside their training domain, so test on your own documents before committing to an architecture.
  • Every production build in my work is hybrid: semantic, keyword and structured retrieval, with something deciding which to call.
  • Measure recall per question type rather than as a single average, and rerun whenever chunking, the model or the index changes.

Let's talk

Let's ship yours.

AI product, automation bottleneck, RAG use case, or operational workflow. Tell me what's slowing your team down, or what revenue you're leaving on the table.

Abdul Asim, AI / LLM Engineer