ai-ml

Semantic Search: Moving Beyond Keywords to Meaning

Search that understands meaning and intent rather than matching exact keywords, using embedding similarity to find relevant results.

Keyword search has been the backbone of information retrieval for decades. Type some words, get back documents containing those words, rank by frequency. It works well enough for many applications, but it fails in a fundamental way: it matches text, not meaning. A user searching for 'ways to cut staff costs' will not find a document that only uses the phrase 'workforce optimisation strategies', even though the documents are about the same thing. Semantic search solves this by operating on meaning rather than tokens. It converts text into numerical vectors that represent semantic content, then finds results by measuring similarity between vectors. For AI products, semantic search is a foundational capability that enables everything from intelligent document retrieval to RAG pipelines to recommendation systems. Understanding how it works and when to use it is essential knowledge for any team building knowledge-intensive AI products. In the UK and EU context, semantic search systems that index personal data must be designed with GDPR compliance built in from the start, not bolted on later. Storing embeddings derived from personal data constitutes personal data processing under UK GDPR and EU GDPR. The right to erasure creates a specific technical challenge: deleting a person's data requires removing all embeddings derived from documents containing that person's information. For NHS Digital-connected products and FCA-regulated firms, data residency requirements may mandate that embeddings remain within UK or EU infrastructure. SpeedMVPs builds semantic search and RAG systems with GDPR-aware embedding metadata design, self-hosted options for strict data residency, and full code ownership transferred at delivery. Projects from GBP 8,000, 2-3 week delivery from Hemel Hempstead.

How Semantic Search Works

Semantic search relies on embeddings: dense numerical vectors that capture the semantic meaning of text. An embedding model processes an input text and produces a fixed-size vector, typically 768 to 3,072 dimensions depending on the model. The key property of a good embedding model is that semantically similar texts produce vectors that are close to each other in the vector space, as measured by cosine similarity or dot product, regardless of whether those texts share literal words. At query time, the user's search query is embedded using the same model, producing a query vector. The system then searches through all document vectors to find the ones closest to the query vector. This proximity reflects semantic similarity: documents that are conceptually related to the query rank highly even if they use different vocabulary. In practice, this retrieval is performed by a vector database optimised for approximate nearest-neighbour search across millions or billions of vectors efficiently. The result is a ranked list of semantically relevant documents returned in milliseconds.

Semantic Search vs Keyword Search

Keyword search, also called lexical search, matches documents that contain the exact words in the query, typically with weighting for term frequency, inverse document frequency, and other statistical signals. BM25 is the dominant keyword search algorithm underlying Elasticsearch, OpenSearch, and many other search systems. It is fast, interpretable, and excellent at exact match recall. It fails when users use different vocabulary from the documents, when the query expresses a concept not directly named in the relevant documents, or when multi-word phrases carry meaning beyond their individual words. Semantic search handles these cases because it operates on meaning, not tokens. However, it introduces its own failure modes: it can miss exact matches that the user genuinely wanted, it is sensitive to the quality and domain coverage of the embedding model, and it can retrieve topically related but factually different documents. The best production search implementations use hybrid search, combining lexical and semantic approaches and re-ranking results from both. This is now standard in production RAG systems and modern search products.

Embedding Models for Semantic Search

The quality of semantic search depends directly on the quality of the embedding model. Several factors affect model selection. Domain coverage matters: a general-purpose embedding model trained on web text may not produce well-calibrated similarity scores for highly technical content, legal documents, or medical records. Domain-specific models or models fine-tuned on in-domain data produce better recall for specialist content. The model must be the same for indexing and querying: documents and queries must be embedded by the same model for vector similarity to be meaningful. Switching models requires re-embedding your entire document corpus. Dimension size is a practical consideration: higher-dimension embeddings capture more nuance but cost more to store and search. Leading options in 2025 include OpenAI's text-embedding-3-large (3,072 dimensions, excellent general-purpose performance), Cohere Embed v3 (strong multilingual capability and domain adaptation support), and open-source options like E5-large and BAAI/bge-large that can be self-hosted to keep data within UK or EU infrastructure, relevant for GDPR compliance.

Semantic Search in RAG Systems

Retrieval-augmented generation systems use semantic search as the retrieval component. When a user asks a question, the question is embedded and used to retrieve the most semantically relevant chunks from a document corpus. These chunks are then included in the LLM's context as grounding material. The quality of the semantic search directly determines what information the LLM has available when generating its response. Poor retrieval means the LLM lacks the right context and either hallucinates or produces generic responses. Strong retrieval ensures the model has exactly the information it needs. Chunking strategy, the way documents are split before embedding, significantly affects retrieval quality. Chunks must be long enough to carry sufficient semantic meaning for accurate embedding but short enough that a retrieved chunk is tightly relevant to the query rather than containing mostly unrelated content. Typical chunk sizes range from 256 to 1,024 tokens, with 512 being a common starting point. Overlapping chunks, where consecutive chunks share a small boundary, improve recall of information that falls near chunk boundaries.

GDPR and Data Residency Considerations

Semantic search systems that index personal data carry GDPR compliance obligations. Under UK GDPR and EU GDPR, embedding personal data and storing those embeddings in a vector database constitutes processing personal data. The same rules apply as for any personal data: you need a lawful basis for processing, data must be retained only as long as necessary, and individuals have rights including the right to erasure. The right to erasure creates a specific technical challenge: deleting a person's data requires finding and removing all embeddings derived from documents containing that person's data. This is more complex than deleting a database row. Vector databases vary in their support for targeted deletion. Architecture decisions made at MVP stage, such as tagging embeddings with a user or data subject identifier, significantly reduce the effort required to fulfil erasure requests later. For NHS Digital connected products handling patient data, or products handling financial data subject to FCA oversight, data residency requirements may mandate that embeddings are stored within UK or EU infrastructure, which affects the choice between cloud-hosted vector databases and self-hosted alternatives.

Implementing Semantic Search with SpeedMVPs

SpeedMVPs builds semantic search and RAG systems as part of AI MVP delivery. A typical implementation includes embedding model selection matched to the client's content domain, vector database setup using Pinecone, Weaviate, or pgvector depending on scale and infrastructure preferences, chunking strategy design and testing, and hybrid search combining BM25 and vector retrieval with a re-ranking step where accuracy requirements are high. GDPR considerations are built in from the start: embedding metadata design includes the fields needed for efficient data subject request handling. For NHS Digital and healthcare clients, self-hosted embedding models and UK-region vector database instances are standard. All code and infrastructure configuration are transferred to the client on delivery. Projects from GBP 8,000, 2-3 week delivery from our Hemel Hempstead team.

Frequently Asked Questions

When should I use semantic search instead of regular keyword search?+

Use semantic search when your users search using natural language queries rather than exact terms, when your documents use varied vocabulary to describe the same concepts, when you are building a question-answering or RAG system over a knowledge base, or when you want to find similar documents or items by meaning rather than shared words. Keep keyword search when users routinely search for specific exact terms (product codes, names, technical identifiers), when domain vocabulary is highly standardised, or when you need high precision on exact match recall. Hybrid search is the pragmatic default for most production systems.

What is the best vector database for a UK-based AI startup?+

It depends on your scale, infrastructure preference, and GDPR requirements. Pinecone is the simplest managed option with a generous free tier, but data is stored in US or EU regions with limited UK-specific residency guarantees. Weaviate offers both managed cloud and self-hosted options, with EU deployment available. pgvector, the PostgreSQL extension for vector search, is excellent for products that already use Postgres and have modest scale requirements, since it avoids a separate infrastructure component entirely. For strict UK data residency, a self-hosted Weaviate or pgvector on UK-region cloud infrastructure is the most straightforward path.

How do I handle multilingual content in semantic search?+

Use a multilingual embedding model trained on multiple languages, such as Cohere Embed v3 multilingual or the multilingual E5 variants. These models produce embeddings in a shared vector space across languages, meaning an English query can retrieve semantically relevant French or German documents. The alternative, running separate monolingual models per language and searching each index separately, is operationally more complex and produces worse cross-lingual retrieval. For EU-facing products serving multiple language markets, multilingual embedding support is a day-one architectural decision.

How does semantic search affect GDPR compliance?+

Embedding personal data creates a new form of processed personal data: the vector representation. This must be treated with the same care as the source data. You need a lawful basis for creating and storing embeddings from personal data, a retention period aligned with your privacy policy, and a technical mechanism to delete embeddings when a data subject exercises their right to erasure under GDPR. If you send text containing personal data to a third-party embedding API, a data processing agreement with that provider is required. The ICO's guidance on AI and data protection covers these obligations for UK-based organisations.

Need semantic search or a RAG system built into your AI product? SpeedMVPs delivers production-ready retrieval systems with GDPR-aware design in 2-3 weeks from GBP 8,000. Get a free consultation at speedmvps.co.uk

Get a Free Quote