Writing
2026-09-19 · 10 min

Understanding RAG systems

Retrieval-augmented generation is often introduced as a trick to reduce hallucinations. It is more useful to treat it as a full system: an information architecture with an LLM at the end. The generation is the easy part. The retrieval — and the evaluation of the retrieval — is where the quality is actually decided.

The five stages, and where quality is won or lost

Every RAG system has the same shape: ingest, chunk, embed, retrieve, generate. Failure modes cluster around three of them.

  1. Ingest. Real corpora are messy: mixed formats, scanned PDFs, permission boundaries, near-duplicates, stale versions. The most common failure is a system that answers confidently from a document that should never have been indexed.
  2. Chunk. Fixed 512-token splits with 50-token overlap is a default, not a design. The right unit depends on the document: a policy clause, a table row, a procedure step. Chunking that ignores the document's natural structure will lose the meaning that made the passage retrievable in the first place.
  3. Embed. Model choice matters, but so does what you embed. Embedding the raw chunk alone often underperforms embedding the chunk plus a short synthetic summary or title. Hybrid retrieval (dense plus BM25) is not optional at production scale.
  4. Retrieve. Top-k is a hyperparameter, not a constant. Rerank with a cross-encoder for the queries that matter. Cache what is stable. Enforce access control at the retriever, not the generator — retrieval is the only reliable boundary.
  5. Generate. The prompt should tell the model that it must ground its answer in the retrieved passages, and that saying “I don't know” is a valid answer. Citations belong in the output. Without them, you cannot audit the system, and neither can the user.

Grounding is a system property, not a prompt trick

A single well-written prompt does not make a system grounded. Grounding is what happens when the retriever surfaces the correct passages, the generator is instructed to depend on them, and the output structure makes the dependency visible. All three have to be true. If any one of them fails, the answer will still look confident.

Evaluate the retrieval separately from the answer

The first evaluation a production RAG system needs is retriever evaluation — did the correct passages appear in the top-k, at all? Golden question-passage pairs cost very little to curate and expose the majority of quality problems. Answer-level metrics (faithfulness, groundedness, answer relevance) belong after, not before.

Traces are non-negotiable. Every request should preserve: query, retrieved passage IDs and scores, prompt version, model version, output, and citations. Without that record, every regression is a mystery.

What production teams still get wrong

  • Chasing embedding model benchmarks while ignoring chunking. The unit of retrieval matters more than the encoder.
  • Treating the vector database as the source of truth. It is a derived index. When the source changes, the index must be re-derived, and the pipeline that does that is part of the system, not an afterthought.
  • Skipping hybrid retrieval. Sparse signals catch what dense embeddings miss — exact identifiers, rare tokens, policy references.
  • Adding a reranker before the retriever is any good. A reranker on top of poor recall just makes bad answers more confident.
  • Building a chat UI before an evaluation set. A chat UI hides regressions behind good typography.

A short mental checklist

Before shipping a RAG system, I want to be able to answer these six questions in writing:

  1. What is the unit of retrieval, and why is that the right unit for this corpus?
  2. How does the retriever prove it returned the correct passages?
  3. What does the system do when the correct passages are not in the corpus at all?
  4. Which access-control decisions are enforced by the retriever, and which by the caller?
  5. How is a bad answer detected in production without a human reading every trace?
  6. When the underlying knowledge changes, what path does the change take from source to index to user?

If any of those answers is a shrug, the system is not production-ready — regardless of how good the demo looks.