RAG (Retrieval-Augmented Generation)
Inject external knowledge into an LLM at query time.
/ quick answer
Retrieval-Augmented Generation is a pattern where relevant documents are retrieved from a vector store and inserted into the model's context before generation, grounding answers in source material. Inject external knowledge into an LLM at query time.
What does RAG stand for?
Retrieval-Augmented Generation. The model retrieves relevant documents at query time and generates an answer grounded in them.
When should I use RAG instead of fine-tuning?
Use RAG for factual, changing or private knowledge — docs, tickets, product data. Use fine-tuning for consistent style, format or a narrow behaviour that prompting cannot reach.
Do I always need a vector database for RAG?
No. For small corpora, in-memory search or keyword search (BM25) can outperform a naive vector setup. Vector DBs shine when you have thousands+ documents and need semantic recall.
How does RAG reduce hallucinations?
By passing the retrieved passages into the prompt and asking the model to answer only from them (with citations), the surface area for fabrication drops sharply — though prompt design and reranking still matter.