RAG

Retrieval-augmented generation

RAG retrieves external evidence and places it in the generation context.

AppIndexLLMsearch the questiontop chunksquestion + chunksanswer with sources
RAG retrieves external evidence and places it in the generation context. Values shown in the worked visual are illustrative unless the labels state otherwise.

How it works

Retrieval supplies current or private information without changing model weights. Generation must still connect claims to the retrieved evidence.

A concrete example

Illustrative: retrieve 5 passages of 300 tokens each and add 1,500 evidence tokens to the prompt.

Do not confuse it with Fine-tuning

RAG changes context at request time; fine-tuning changes model parameters.

Study the full lesson