RAG System Components: What Makes Retrieval Work

RAG System Components: What Makes Retrieval Work

What happens when a chatbot confidently invents a policy that doesn’t exist, cites a document nobody wrote, and does it in perfect grammar? That failure is exactly why retrieval-augmented generation exists. RAG gives a language model something it lacks: access to specific, current, verifiable text at the moment it answers. But “adding retrieval” is not a single switch. A working RAG system is a pipeline of distinct components, each with its own failure modes, tuning knobs, and trade-offs. Understanding those parts is the difference between a demo that impresses and a system people actually trust.

The Core Idea: Two Components, One Contract

The term was introduced in a 2020 paper by Lewis and colleagues, and the original architecture is refreshingly simple: a retriever and a generator. The retriever embeds a user query and a corpus of documents into a shared vector space, finds the nearest passages, and hands them to the generator, which produces an answer conditioned on that evidence. The original retrieval-augmented generation paper by Lewis et al. defines this retriever-generator split and is still the clearest explanation of why the design works.

Everything else in a modern RAG stack exists to make that contract more reliable. Think of it as a supply chain: the retriever supplies evidence, the generator consumes it, and every stage in between either improves or degrades the quality of what gets delivered.

Component 1: Ingestion and Chunking

Component 1: Ingestion and Chunking

Before anything can be retrieved, documents must be parsed, cleaned, and split. Chunking is the process of breaking source documents into passages small enough to embed meaningfully and large enough to answer a question. This is where many teams quietly sabotage themselves.

The practical trade-off is straightforward. Small chunks (a few sentences) retrieve precisely but often lack the surrounding context needed to answer. Large chunks carry context but dilute the embedding, so a chunk about five topics matches poorly against a query about one. Overlap between consecutive chunks helps preserve sentences that straddle a boundary.

There is no official standard for chunk size, and anyone who presents one as settled fact is overselling. What works in practice is measuring: build a small evaluation set of real questions, then test two or three chunking configurations against it. Teams that skip this step usually end up debugging retrieval quality for weeks without knowing the chunking was the culprit. A common mistake is chunking by fixed character count and shredding tables, headers, and code blocks in the process. Structure-aware splitting, which respects headings and paragraphs, almost always beats blind character windows.

Component 2: Embedding Models

An embedding model converts text into a dense vector so that semantically similar passages land near each other in vector space. The quality of this model sets a ceiling on retrieval quality that no downstream trick can fully overcome.

The Sentence-BERT work by Reimers and Gurevych established siamese BERT networks as an efficient way to compute semantic similarity, and the Sentence-BERT paper on siamese networks for semantic similarity explains the underlying method clearly. Modern embedding models vary widely in dimension, multilingual coverage, and domain fit.

Two practical rules matter here. First, the same model must embed both documents and queries; mixing models produces meaningless distances. Second, changing the embedding model means re-indexing the entire corpus. That is expensive, so choose deliberately at the start and version the index alongside the model name.

Component 3: The Vector Index and Similarity Search

At any real scale, comparing a query against millions of vectors one by one is too slow. Approximate nearest neighbour (ANN) indexes solve this by trading a small amount of recall for enormous speed gains. FAISS, an open-source library for efficient similarity search and clustering of dense vectors, is one of the most widely used tools for this job; the FAISS paper on efficient similarity search for dense vectors describes the index families and their trade-offs.

The practical point is that index choice is a tuning decision, not a checkbox. Some index types favour speed, others favour recall, and some require a training pass over representative vectors before they work well. A frequent mistake is benchmarking on a tiny dataset, picking the fastest option, and then discovering at production scale that recall has quietly dropped. Monitor retrieval recall directly rather than assuming the index behaves as advertised.

Component 4: Retrieval Strategy

Plain top-k vector search is the baseline, but it is rarely the whole answer. Several strategies are common practice:

Strategy What it adds Typical cost
Dense top-k Semantic matching Low
Keyword or hybrid search Exact terms, IDs, names Medium
Metadata filtering Scoping by date, source, tenant Low
Query rewriting Better matching on vague questions Medium
Multi-query expansion Coverage of paraphrased intents Higher latency

Hybrid search, which blends dense vectors with keyword matching, is especially valuable in practice. Vector search is famously bad at exact strings: part numbers, error codes, product SKUs, and people’s names. If a user asks about “error E-4471,” a keyword component will find it while a pure embedding search may not.

Metadata filtering deserves more attention than it usually gets. Filtering by document date, access permissions, or tenant before the vector search is both a relevance win and a security control. Applying permissions after retrieval is a classic and serious mistake.

Component 5: Reranking

Retrieval is optimized for speed across a huge corpus; it is not optimized for precision on the final shortlist. Reranking addresses this by retrieving a larger candidate set, say fifty passages, and scoring each one more carefully against the query with a cross-encoder or similar model before passing the best handful onward.

This two-stage pattern is standard in information retrieval, and it usually produces a larger quality jump per unit of engineering effort than swapping embedding models. The cost is latency, since cross-encoders are far slower than vector lookup. In practice, teams tune the candidate count until quality gains flatten, then stop.

Component 6: Context Assembly and Prompting

Retrieved chunks must be inserted into the model’s context window, and that window is finite. This stage is where good retrieval can still be wasted.

Three things go wrong most often. Chunks arrive in an arbitrary order, so the most relevant evidence sits buried in the middle where models attend to it least. Redundant chunks from overlapping splits crowd out diverse evidence. And the prompt gives the model no instruction about what to do when the retrieved context does not contain the answer, which invites improvisation.

The fix is unglamorous but effective: order chunks by relevance, deduplicate near-identical passages, and explicitly instruct the model to say when the evidence is insufficient. Including source identifiers alongside each chunk also makes citation possible, which is often the real point of RAG in the first place.

Component 7: The Generator

The generator is the language model that reads the assembled context and writes the answer. Its job is grounded synthesis, not recall. This distinction matters because a model with strong parametric knowledge may override retrieved evidence with its own training, producing answers that contradict the very documents you supplied.

The original RAG paper is candid on this point: retrieval reduces hallucination but does not eliminate it, and the generator can still produce content not supported by the retrieved passages. Prompt design, model choice, and explicit grounding instructions all influence how faithfully the model sticks to evidence. For teams building production systems, the broader discipline of enterprise AI systems and architecture covers how these generation-stage decisions interact with latency, cost, and compliance constraints.

Component 8: Evaluation

You cannot tune what you cannot measure, and RAG has two distinct quality surfaces: retrieval and generation. Conflating them is the single most common diagnostic error.

Retrieval quality is measured with ranking metrics such as recall@k and mean reciprocal rank. Generation quality is measured with faithfulness (is the answer supported by the retrieved context?) and answer relevance (does it address the question?). The RAGAS framework proposed reference-free metrics for exactly these dimensions, and the RAGAS evaluation metrics for RAG pipelines paper is a useful starting point for building a test suite.

In practice, a small hand-labelled set of fifty to a hundred real questions beats a large synthetic set. Synthetic questions tend to sound like the documents rather than like users, which flatters retrieval scores without improving the experience.

How the Components Fit Together

A useful way to organize the pipeline is by what each stage controls:

  • Ingestion and chunking determine what evidence exists at all.

  • Embeddings and the vector index determine what can be found.

  • Retrieval strategy and reranking determine what actually gets found.

  • Context assembly and the generator determine what gets said.

  • Evaluation determines whether any of it improved.

A 2023–2024 survey organizes RAG into naive, advanced, and modular paradigms, and the survey of retrieval-augmented generation for large language models is a good map of how the variants relate. The key insight from that framing is modularity: components can be upgraded independently, which is why incremental measurement beats wholesale rewrites.

Common Mistakes That Sink RAG Projects

A few patterns recur across teams. Chunking is treated as an afterthought and never revisited. Retrieval is evaluated with the same handful of questions used to build it, producing scores that mean nothing. Permissions filtering happens after retrieval, creating a data leak. Latency budgets are ignored until reranking and query expansion push response times past what users tolerate. And the system is launched without a way to detect when retrieval returns nothing useful, so the model fills the gap with plausible fiction.

What works in practice is unremarkable: version everything, measure retrieval and generation separately, keep a golden question set, and log the retrieved chunks alongside every answer so failures can be traced. Teams that follow a regular, disciplined review cadence tend to catch regressions early; the Sunday Systems Letter covers exactly this kind of ongoing operational practice for AI systems.

Conclusion

RAG is often described as a way to stop models from hallucinating, which sets expectations too high and too low at once. It is really a discipline of supplying evidence and then proving the evidence was used. The components are not mysterious: ingestion and chunking, embedding models, vector indexes, retrieval strategy, reranking, context assembly, the generator, and evaluation. Each one can be tuned, measured, and improved independently.

The teams that succeed treat RAG as a measurement problem rather than a model-shopping problem. They know which stage is failing before they change anything, and they keep a record of what they tried. Anyone who wants to go deeper into how these pipelines are structured in production can browse the AI systems category for related architecture discussions. Start with evaluation, work backwards through the pipeline, and the rest follows.

What are the main components of a RAG system?

The original formulation has two: a retriever that finds relevant passages and a generator that answers using them. In practice, a working system also includes ingestion and chunking, an embedding model, a vector index, a retrieval strategy, an optional reranking stage, context assembly, and an evaluation layer.

Why does chunking matter so much in RAG?

Because chunking decides what evidence exists in the first place. Chunks that are too small lack context to answer; chunks that are too large dilute their embeddings and match poorly. No amount of reranking or prompt tuning recovers evidence that was split apart badly during ingestion.

Do I need reranking if I already have good embeddings?

Not always, but it often helps. Reranking retrieves a larger candidate set and scores it more carefully, which usually improves precision on the final shortlist. The cost is added latency, so test whether the quality gain justifies it for your use case before making it standard.

How do I evaluate a RAG system properly?

Measure retrieval and generation separately. Use ranking metrics such as recall@k for retrieval, and faithfulness plus answer relevance for generation. Build a small set of real user questions rather than synthetic ones, and log the retrieved chunks with every answer so failures can be traced to a specific stage.

Does RAG eliminate hallucinations?

No. Retrieval reduces unsupported answers but does not remove them, because the generator can still produce content that is not grounded in the retrieved passages. Reducing this requires explicit grounding instructions, careful context assembly, and faithfulness checks in evaluation.

Can I change the embedding model later?

Yes, but it requires re-embedding and re-indexing the entire corpus, since documents and queries must share the same vector space. That makes the choice expensive to reverse, so decide deliberately at the start and version the index alongside the model name.

Latest articles

Scroll to Top