RAG stands for retrieval-augmented generation. It is a method where an AI system first searches a set of documents for relevant passages and then uses them to write an answer.
Why RAG exists
Language models only know what they were trained on and can invent facts. RAG gives them fresh, specific sources so answers can be grounded in your own data.
How RAG works step by step
Documents are split into chunks and turned into embeddings. When you ask a question, the system finds the closest chunks and adds them to the prompt before the model answers.
Quick reference
| Part | Job | Example |
|---|---|---|
| Embedding | Turn text into numbers | Vector of a paragraph |
| Vector store | Search by meaning | A database of chunks |
| Retriever | Find relevant text | Top 5 passages |
| Generator | Write the answer | The language model |
Where RAG is used
Common uses include company help bots, internal knowledge search and research tools that show sources.
Limits of RAG
If retrieval picks the wrong passage, the answer is wrong. Good chunking and clear source documents matter more than model size.
Frequently asked questions
Is RAG the same as fine-tuning?
No. RAG adds information at question time while fine-tuning changes the model itself.
Does RAG stop hallucinations?
It reduces them but does not remove them.
Do I need code for RAG?
Many tools offer it with no code.
Is RAG expensive?
Cost depends on document size and how often you query.