PromptForge
AI Glossary

Retrieval & data

RAG (Retrieval-Augmented Generation)

Also known as: retrieval augmented generation, retrieval-augmented generation

Definition

RAG retrieves relevant passages from your own documents and inserts them into the prompt before the model answers. It grounds responses in your data, cuts hallucination, and needs no retraining.

A RAG pipeline has two phases. Offline: split documents into chunks, embed each chunk as a vector, store them in a vector database. At query time: embed the question, find the most similar chunks, insert them into the prompt, and ask the model to answer using only that context.

RAG is the standard answer to "make the AI know about our company." It is far cheaper and more maintainable than fine-tuning, updates instantly when documents change, and can cite its sources — which matters enormously for trust.

The single most important line in any RAG prompt is the instruction to answer only from the provided context and say so when the answer is absent. Without it, the model fills gaps with plausible invention.

Example

Prompt template: "Answer using ONLY the context below. If the context does not contain the answer, say 'Not found in the provided documents.' Context: {retrieved chunks} Question: {user question}"

Related terms

Put this into practice

Understanding the term is step one. Our free courses and tools let you actually use it.