Back to notes
AI engineering•6 min

RAG without the magic: retrieve first, generate second

Why retrieval-augmented generation is really a data-flow problem, and where the interesting engineering decisions sit.

RAG gets described like a single feature: 'give the model documents'. In practice, it is a pipeline with separate failure modes.

You have a knowledge source, a way to chunk it, an embedding or retrieval strategy, a context selection step and finally a generation step. Each layer changes the quality of the answer.

Retrieval is the first quality gate

If the right information never reaches the model, a better prompt cannot repair the missing context. That is why retrieval quality deserves its own tests rather than being treated as plumbing.

The model should not be the database

A model is good at language generation. It is not your source of truth for institution-specific or frequently changing data. RAG lets an application bring external evidence into the generation step.

Context is a budget

More retrieved text is not automatically better. Context has cost, latency and attention limits. A good system retrieves enough evidence to answer the question without flooding the prompt with irrelevant material.

Then comes the agent

An agent adds another decision: which tool to call. In the admission-assistant experiment in this portfolio, the agent can use a dedicated RAG tool and a search tool, then answer under a tightly constrained response policy.

© 2026 Aaditya Hande • Self crafted