Retrieval-augmented generation (RAG)

A pattern where relevant passages are retrieved from a knowledge source and put into the prompt so the model answers from them.

Last updated: · Markdown version

How to apply it in prompts

Use this concept to reduce ambiguity and improve consistency. If you need strict formatting, combine it with a JSON guide and a per-model template.

What it means
Copy-paste example
Answer the question using only the numbered passages below.
Cite the passage number after each claim, like [2].
If the passages do not contain the answer, say so and stop.

<passages>
[1] [paste passage]
[2] [paste passage]
</passages>

Question: [question]
Opens the analyzer with the prompt prefilled.
Open in Promptea
FAQ
Is RAG the same as fine-tuning?
No. Fine-tuning changes the model's weights; RAG leaves the model alone and changes what it reads in the prompt. RAG is the usual way to give a model fresh or private facts.
Do search-based assistants use RAG?
They follow the same idea: search first, then answer from what was found and show sources. Models such as Perplexity's do this natively, so your prompt should seed a good search rather than paste the sources.