AI · Dec 28, 2025 · 7 min read

RAG Pipelines That Don't Hallucinate: Retrieval Design for Real Products

Production retrieval design for seed-stage teams — chunking, hybrid search, re-ranking, and citation patterns that keep generated answers grounded in source material.

Most RAG tutorials stop at chunk, embed, and query. Production RAG fails when retrieval misses the right context — and the model confidently fills the gap with fiction. OpenAI's retrieval guide emphasizes hybrid search, metadata filtering, and re-ranking for a reason: naive vector-only pipelines look fine in demos and collapse on real documents. This is the retrieval architecture we ship on Sprint Pod builds before any agent layer goes live.

Hallucination is usually a retrieval problem

When users report "the AI made it up," the root cause is often empty or wrong context — not a broken model. The model is doing what it always does: completing patterns. Your job is to ensure the pattern includes authoritative source text. Measure retrieval recall@k on a golden question set before you tune prompts. If the right chunk is not in the top five results, no amount of prompt engineering fixes downstream faithfulness.

  • Low recall — wrong chunking or missing hybrid keyword search.
  • Low precision — noisy chunks pollute context and confuse generation.
  • Stale index — documents updated but embeddings not refreshed.
  • Missing metadata filters — retrieving from the wrong tenant, version, or doc type.

Chunking that respects document structure

Fixed 512-token chunks destroy tables, legal clauses, API references, and nested headings. Structure-aware chunking — split on headings, preserve table rows, keep code blocks intact — often doubles recall on technical corpora. For mixed content, use different chunk strategies per document type rather than one global setting. Anthropic's context management guidance reinforces keeping retrieved context within explicit budgets and prioritizing authoritative sources.

Hybrid retrieval and re-ranking

Pure dense vector search misses exact identifiers: SKUs, case numbers, function names, statute citations. Combine BM25 or keyword indexes with embeddings, then re-rank the union with a cross-encoder or lightweight LLM scorer. The extra latency — often 100–300ms — is worth it when precision determines whether an answer is usable. We treat re-ranking as non-optional for any product where wrong answers create liability.

  1. Retrieve top 20–50 candidates via hybrid search.
  2. Apply metadata filters (tenant, date, doc type, access level).
  3. Re-rank to top 5–8 chunks with a dedicated scorer.
  4. Pass chunks with source IDs into the generation prompt.

Citations and abstention

Every generated claim should trace to a source chunk. Surface citations in the UI, not just in logs. When retrieval confidence is low — empty results, low re-rank scores, conflicting chunks — the product should abstain or ask a clarifying question rather than guess. Users trust systems that say "I don't have that in your documents" more than systems that invent plausible answers. The OWASP LLM Top 10 insecure output handling category applies: validate that cited sources actually support generated text.

Ingestion, freshness, and access control

RAG is a data pipeline, not a one-time index build. Define how new documents enter the system, how updates propagate, and how deletes remove stale embeddings. Multi-tenant products need row-level or metadata-level isolation so retrieval never crosses customer boundaries. Operate Pod teams maintain ingestion SLAs alongside feature work — because a stale index is a silent quality regression.

The moat in domain RAG is not your embedding model. It is ingestion quality, chunking tuned to your corpus, and evals that catch recall drops before users do.

Key Services engineering practice

Eval stack for retrieval

Build a golden set of questions with expected source document IDs — not just expected answers. Track recall@k, MRR, and end-to-end faithfulness on every deploy. Regression gates on retrieval metrics prevent prompt tweaks from masking pipeline decay. Pair automated metrics with periodic human review on high-stakes queries. Stanford HAI's AI Index documents rising enterprise concern about AI reliability — retrieval evals are how you prove yours is managed.

Build sequence for seed teams

  1. Week 1: Ingest real customer documents; define chunking per doc type.
  2. Week 2: Stand up hybrid search + re-rank; baseline recall@5 on golden set.
  3. Week 3: Add generation with citations; implement abstention on low confidence.
  4. Week 4: CI gates on retrieval metrics; document pipeline for diligence.

RAG that does not hallucinate is boring engineering: good chunks, good search, good citations, good evals. That boredom is what enterprise pilots and investors expect — and what a builder-partner Sprint Pod is built to deliver before you scale sales.

Next step

Want help applying this?

Tell us what you're building — we'll tell you honestly if and how we'd help.

Start a conversation

Sources & further reading

  1. 1.Retrieval and Embeddings GuideOpenAI
  2. 2.Tool Use and Context ManagementAnthropic
  3. 3.OWASP Top 10 for LLM ApplicationsOWASP Foundation
  4. 4.Artificial Intelligence Index Report 2025Stanford HAI
  5. 5.Evals FrameworkOpenAI

Disclaimer

This article is provided for general informational purposes only. It reflects the views and experience of the Key Services team at the time of publication and is not tailored to your specific situation.

Nothing here constitutes legal, financial, tax, investment, or professional advice. Outcomes described in case examples or cited research may not apply to your company, market, or stage.

Engagement models, pricing, timelines, and recommendations should be evaluated against your own goals, constraints, and independent research — including qualified advisors where appropriate — before you make any decision.

Key Services makes no guarantees about specific business, hiring, technical, or financial results. If you choose to work with us, terms are governed by a mutually executed statement of work or services agreement, not by content on this site.