What is RAG context? Definition of retrieval-augmented generation

RAG context is the retrieved snippets fed into a large language model at prompt time, sourced from a search step that picks the relevant material for the current question.

RAG context is the retrieved snippets fed into a large language model at prompt time, sourced from a search step that picks the relevant material for the current question.

The reason for the architecture is the gap between what the model knows from training and what the current task actually requires. The model was trained on a generic corpus a year or more ago; the user is asking about a specific codebase, document, or product as it exists now. RAG bridges that gap by searching the actual material at request time and putting the matching snippets in front of the model.

Where the technique fits

For codebases, the retrieval step searches files and indexes; the model gets the relevant functions or modules. For document Q&A, the retrieval searches a knowledge base; the model gets the matching paragraphs. For product feedback, the retrieval can pull related past reviews, design specs, or earlier conversations.

The quality bound is the quality of the retrieval. A great LLM with bad retrieval produces confident answers based on irrelevant snippets. A modest LLM with excellent retrieval often outperforms it. The shape that travels best for human-curated retrieval is the same as for human handoff: markdown documents with inline images, source URLs, and a clear topic.

Frequently asked questions

What does RAG stand for?

Retrieval-augmented generation. The model "generates" an answer, "augmented" with material a "retrieval" step pulls from outside the model's training data.

How does RAG relate to agent context?

RAG is one way to populate the context. Instead of the user manually deciding what files matter, a retrieval step searches the knowledge base for whatever looks most relevant and adds it.

Capture your first review.

About a minute from open tab to a shareable URL your agent can ingest.

Start capturing