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.

Related terms

  • Embedding An embedding is a numerical vector representation of data (text, image, audio) that captures semantic meaning. Similar concepts have embeddings that are close together in vector space, enabling AI systems to measure similarity, cluster data, and retrieve relevant information.
  • Vector Database A vector database stores and retrieves high-dimensional vector embeddings efficiently. It enables semantic similarity search — finding documents, images, or records that are semantically 'nearest' to a query vector. Examples include Pinecone, Weaviate, Qdrant, and ChromaDB.
  • RAG (Retrieval-Augmented Generation) RAG is a technique that combines an LLM with an external knowledge retrieval system. Instead of relying solely on its training data, the model retrieves relevant documents at query time and uses them as context to generate more accurate, up-to-date responses.
  • Cosine Similarity Cosine similarity measures the angle between two vectors in high-dimensional space. In AI, it quantifies how semantically similar two embeddings are — a score of 1.0 means identical direction (highly similar), 0 means orthogonal (unrelated), -1 means opposite meaning.