# Semantic Search

Canonical: https://aimastermindlab.com/glossary/semantic-search

---
Semantic search retrieves results based on the meaning of a query rather than exact keyword matches. Using vector embeddings, it finds content that is conceptually related to the query, even when no words overlap — solving the vocabulary mismatch problem in traditional search.

## What is Semantic Search?

Semantic search is a retrieval approach that finds documents or records based on **meaning** rather than **lexical overlap**. A keyword-based system searching for "automobile accident" won't surface documents about "car crash" unless those exact words appear. Semantic search, powered by vector embeddings, would retrieve both because they mean the same thing.

## How Semantic Search Works

1. All documents are **embedded** into vector space using an embedding model.
2. The user's query is **embedded** with the same model.
3. A vector database performs **approximate nearest-neighbour** (ANN) search to find the document vectors closest to the query vector.
4. Results are ranked by vector similarity (cosine similarity or dot product).

## Semantic vs Keyword (BM25) Search

| Aspect | Keyword (BM25) | Semantic |
|---|---|---|
| Matching basis | Exact word overlap | Conceptual meaning |
| Handles synonyms | No | Yes |
| Handles typos | Partially | Yes (embeddings are robust) |
| Domain specificity | Works immediately | Requires quality embeddings |
| Interpretability | Easy to debug | Harder to explain |

## Hybrid Search

Modern production systems combine both approaches: BM25 for lexical precision, semantic search for conceptual recall, fused via Reciprocal Rank Fusion (RRF) or similar algorithms. This outperforms either approach alone.

## Example

A user searches 'how to make code run faster'. Keyword search finds articles containing those exact words. Semantic search also surfaces articles about 'performance optimisation', 'profiling bottlenecks', and 'compiler flags' — none of which share the query's exact wording.
---

Source: https://aimastermindlab.com/glossary/semantic-search — AI Mastermind Lab (https://aimastermindlab.com)
