Insights → Development
Development Sep 26, 2026 7 min read

Semantic Search with Embeddings: Architecture, Relevance and Failure Modes

A production-focused guide to semantic search with embeddings, covering ingestion, retrieval, reranking, permissions, evaluation, observability and failure handling.

Semantic Search with Embeddings: Architecture, Relevance and Failure Modes
Share LinkedIn ↗ Facebook ↗ X ↗

Semantic search with embeddings retrieves information by meaning rather than relying only on exact words. A system converts documents and queries into numerical vectors, finds content with similar representations, and returns the most relevant candidates. That approach is useful when users phrase questions differently from the source material, but embeddings alone do not guarantee accurate search.

Production quality depends on the entire retrieval system: document preparation, embedding consistency, metadata filters, access controls, ranking, evaluation, latency, cost and fallback behavior. A useful implementation may combine keyword search, vector retrieval and a reranker rather than treating one model as the complete solution.

How semantic search with embeddings works

An embedding model maps text to a vector containing many numerical dimensions. Texts with related meaning should occupy nearby regions of the model’s vector space. During indexing, an application creates embeddings for searchable content and stores them with the source text, identifiers and metadata.

At query time, the system embeds the user’s question using the same compatible model family, searches for nearby vectors, applies filters, and returns candidate passages or records. Similarity is commonly calculated with cosine similarity, dot product or another distance function supported by the storage layer.

  1. Ingest: collect source records and identify what is searchable.
  2. Normalize: remove irrelevant boilerplate, preserve headings and attach useful metadata.
  3. Chunk: divide content into units that are specific enough to retrieve but large enough to retain meaning.
  4. Embed: generate vectors for each chunk and record the model and version.
  5. Index: store vectors, text, permissions and filterable fields.
  6. Retrieve: embed the query and select a broader candidate set than the final result count.
  7. Rerank or assemble: improve ordering, remove duplicates and construct context for the application or an LLM.

The vector database is only one component. The most consequential decisions often occur before and after vector lookup.

Architecture choices that shape retrieval quality

Chunking is a product decision, not just a storage decision

Large chunks may contain enough context but dilute the specific concept that should match a query. Small chunks can improve precision while separating definitions, qualifications or table headers from the facts they explain. Useful strategies preserve document hierarchy, include headings in chunk text, and use limited overlap only where it prevents important context from being split.

Chunking should reflect how users ask questions. A policy document, source-code repository, contract, product catalog and support ticket archive may require different boundaries. Tables, lists and structured fields often need specialized handling instead of being flattened into indistinguishable prose.

Hybrid retrieval is often safer than vector-only search

Embeddings are strong at conceptual similarity, while lexical search is often better for exact identifiers, error codes, invoice numbers, product SKUs and uncommon names. A hybrid system can combine both result sets before reranking. This reduces the risk that a semantically similar passage displaces an exact match that the user actually needs.

Metadata filters are equally important. Tenant, department, document type, date, status and language can narrow the search space. Permissions should be enforced as part of retrieval, not applied casually after an LLM has already received unauthorized context.

Reranking improves ordering but adds cost and latency

Initial vector retrieval is designed for efficient candidate generation. A cross-encoder or another reranking model can then evaluate the query against each candidate more directly. Reranking is useful when the top candidates are broadly relevant but poorly ordered, especially for long documents or ambiguous terminology.

The trade-off is operational: more model calls increase latency and infrastructure cost. Candidate count, reranking thresholds, caching and selective use should be tested against actual query categories rather than assumed from a demo.

Why semantic search fails in production

Vocabulary and domain mismatch

An embedding model may understand general language while missing the meaning of internal abbreviations, product codes or specialized workflows. A query for a short acronym can retrieve generic content with similar surrounding language instead of the intended record.

Mitigations include synonym dictionaries, aliases, metadata fields, lexical retrieval, query expansion and domain-specific evaluation data. Fine-tuning may be appropriate in some cases, but it should not be the first response to an unmeasured indexing or filtering problem.

Context loss during ingestion

Extracting text from PDFs, presentations, spreadsheets and scanned documents can remove layout, headings or relationships between fields. A high-quality embedding cannot recover information that ingestion discarded. Monitor extraction failures and preserve source locations so users can inspect the original material.

Stale or duplicated content

Search results become unreliable when old versions remain indexed, identical documents are duplicated, or deleted records persist in the vector store. Each indexed item should have a stable source identifier, version or timestamp, and an explicit update and deletion path. Reindexing should be repeatable rather than dependent on manual cleanup.

Overly broad retrieval

Returning many vaguely related chunks can overwhelm users and downstream LLMs. It also increases token usage and creates more opportunities for contradictory evidence. Candidate retrieval and final context assembly should be separate stages, with deduplication, source diversity rules and confidence thresholds where appropriate.

Security and permission leakage

Vector similarity does not understand business authorization. A private document can be semantically close to a permitted user’s question even when that user should never see it. Apply tenant and authorization constraints at query time, use defense-in-depth checks before displaying content, and log access decisions without exposing sensitive text unnecessarily.

Evaluating relevance instead of trusting similarity scores

A similarity score is a model- and data-dependent signal, not a universal probability of correctness. Teams need a representative evaluation set containing real query types, expected sources, acceptable alternatives and known hard cases.

Useful measurements include whether a relevant result appears in the top results, whether the first result is useful, how often restricted content is excluded, and how much irrelevant context reaches an answer-generation step. Review results by category: exact lookup, conceptual question, ambiguous request, newly added content, multilingual query and no-answer case.

Human review remains important for judging usefulness and risk. Reviewers should record why a result was relevant or misleading, then use those findings to improve chunking, metadata, query handling or ranking. Automated evaluations can run on every indexing or model change, while sampled production queries can reveal drift that a fixed test set misses.

Connecting retrieval to an application architecture

A common production arrangement separates application workflows from AI retrieval workloads. A Laravel or other web application can manage authentication, tenant boundaries, search interfaces, document lifecycle and audit records, while a Python service handles ingestion, embedding jobs, retrieval orchestration and evaluation pipelines. The boundary should be defined by ownership and operational needs, not by a requirement to use a particular language.

For an LLM-powered knowledge experience, retrieval should remain an explicit service step. The application can show source citations, indicate when no reliable result was found, request clarification, or route a sensitive case to a human. The model should not be allowed to invent a source merely because retrieval returned weak candidates.

Teams planning broader AI capabilities can place this work within an AI development roadmap, while application teams may use Python development for model and data services. The right design should preserve clear ownership of permissions, indexing, model configuration and user-facing behavior.

Operational controls for reliable semantic search

  • Version embeddings: record the embedding model, preprocessing rules and index build identifier for every item.
  • Separate sync from serving: use background jobs for ingestion and reindexing so user requests do not block on document processing.
  • Measure latency by stage: track query embedding, vector search, filtering, reranking and response assembly independently.
  • Control cost: cache repeated queries where privacy permits, limit unnecessary reranking, and avoid sending oversized context to an LLM.
  • Provide fallbacks: use lexical search, structured filters, a no-result response or human review when confidence is low.
  • Observe quality: log query categories, result identifiers, model versions and user feedback while minimizing sensitive payloads.
  • Plan deletion: make source deletion and permission changes propagate to every derived index and cache.

Choosing the storage layer also affects filtering, tenancy, backups, operational ownership and migration effort. A useful comparison should examine those requirements alongside vector performance; the broader trade-offs are covered in Choosing a Vector Database for RAG.

When semantic search should not be the only search method

Use structured queries for structured questions. If a user asks for orders above a specific amount, records assigned to a team, or items within a date range, a database query or search filter is more dependable than semantic similarity. Embeddings can help interpret the request, but they should not replace deterministic constraints.

For enterprise knowledge assistants, retrieval is one layer in a larger system that must manage source authority, citations, permissions and unanswered questions. The architecture described in Enterprise Knowledge Assistant provides a useful adjacent perspective.

Semantic search with embeddings is most effective when it is treated as a measurable retrieval subsystem rather than an autonomous answer engine. Start with representative content and queries, preserve authorization boundaries, combine retrieval methods where needed, and make failure visible. That approach supports maintainable custom software while leaving room to add reranking, RAG workflows, agents or human review as the product’s requirements become clearer.

For broader product architecture and delivery considerations, see custom software development.

Keep exploring

More useful thinking, less digital noise.

Uncategorized↗ SEO↗ Paid Media↗ Development↗