Retrieval-Augmented Generation connects a retrieval system with a generative language model. First, documents are collected, cleaned, divided into manageable passages, and indexed. These passages may be represented using keyword-based indexes, vector embeddings, or hybrid retrieval methods. When a user submits a query, the system searches the index for relevant passages. A retrieval component selects and returns the most useful results, which are added to the language model's context along with the original question. The model then generates a response using the supplied information. A RAG system can improve access to current, private, or domain-specific knowledge without requiring the language model to be retrained whenever documents change. It can also provide source references that help users verify claims. However, retrieval quality depends on document quality, indexing, chunking, query formulation, and ranking. The generator may still misunderstand retrieved information or produce unsupported claims. Effective RAG systems therefore use source-aware prompting, relevance evaluation, access controls, and answer-grounding checks. RAG is not the same as fine-tuning: it supplies external context at inference time rather than directly updating model parameters.
Retrieval-Augmented Generation (RAG)
Retrieval-Augmented Generation (RAG) is an AI architecture that retrieves relevant information from external sources and provides it as context to a generative model before it produces a response.
P(y | x) ≈ P(y | x, R(x))
Explanation
Variables
| Symbol | Meaning |
|---|---|
x | User query or input |
y | Generated response |
R(x) | Relevant information retrieved for input x |
P(y | x, R(x)) | Response distribution conditioned on the query and retrieved information |
Example or application
A university assistant receives a question about its admission policy. The RAG system searches official university documents, retrieves relevant policy passages, and provides them to an LLM to generate an answer grounded in those documents.
Text
RAG combines information retrieval with text generation. Instead of relying only on information learned during training, a model receives relevant documents or passages retrieved from an external knowledge source.
Key Points
RAG combines retrieval with generative AI.
External documents provide additional context during response generation.
Documents can be indexed using keyword, vector, or hybrid search.
RAG can support current and organization-specific knowledge.
Retrieval does not guarantee that the final response is correct.
Applications
Enterprise knowledge assistants
University information systems
Customer-support chatbots
Document question answering
Technical documentation search
Research literature assistance
Learning Outcomes
Define Retrieval-Augmented Generation.
Describe the main stages of a RAG pipeline.
Explain the role of embeddings and vector search.
Compare RAG with fine-tuning.
Identify common retrieval and generation failures.
Practice Questions
What does RAG stand for?
Why does RAG retrieve external documents?
What is the role of a vector database in some RAG systems?
How is RAG different from fine-tuning?
Related Concepts
Large Language Models
Embeddings
Vector Databases
Semantic Search
Information Retrieval
Prompt Engineering
Common Mistakes
Assuming RAG automatically prevents hallucinations.
Confusing document retrieval with model fine-tuning.
Ignoring the quality and freshness of the indexed documents.
Failing to enforce access permissions during retrieval.
Assuming that retrieved passages are always relevant or authoritative.
Sources and verification
Sources are shown as provided in the project data. Not every source has yet been independently verified. Please report errors or missing citations.
- Lewis, P. et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Advances in Neural Information Processing Systems.
- Karpukhin, V. et al. (2020). Dense Passage Retrieval for Open-Domain Question Answering. EMNLP.
- Gao, Y. et al. (2023). Retrieval-Augmented Generation for Large Language Models: A Survey.
Suggest a correction or source · More in Artificial Intelligence & Machine Learning