DEFINITION

Retrieval-Augmented Generation

Also known as: RAG

Retrieval-augmented generation (RAG) is a technique that improves an AI model's output by fetching relevant external documents and supplying them as context at generation time.

Retrieval-augmented generation (RAG) pairs a language model with a retrieval step: instead of relying solely on what the model learned during training, the system searches an external knowledge source — documentation, a codebase, a wiki — for passages relevant to the query and includes them in the prompt.

This grounds the model's response in specific, current, and often private information it was never trained on, which reduces hallucination and lets the same model answer accurately about a particular company's systems. In developer tooling, RAG is how an assistant can reason about your repository rather than generic patterns.

RAG's quality hinges on retrieval: if the wrong context is fetched, the model confidently generates from the wrong material. Good chunking, ranking, and relevance are as important as the model itself.

Related terms

Model Context ProtocolPrompt EngineeringContext Window

Turn shipping into understanding

Cartara measures what your team actually learns from every AI coding session.

Join the waitlist