RAG (2020): Retrieval-Augmented Generation
RAG retrieves relevant documents for LLMs, grounding generation in external knowledge instead of model memory alone.
The foundation: retrieve then generate
RAG retrieves relevant documents for LLMs. Introduced in the 2020 paper "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" by Patrick Lewis and colleagues, submitted to arXiv on May 22, 2020.
Before RAG, language models could only answer from training data. RAG added a retrieval step: search a document index, fetch relevant passages, and pass them to the model at inference time. That single change made LLMs usable for enterprise Q&A, support tools, and domain-specific products.
How RAG works
def rag_answer(query: str, retriever, llm):
# Step 1: Retrieve relevant documents
documents = retriever.search(query, top_k=5)
# Step 2: Build context from retrieved passages
context = "\n".join(doc.content for doc in documents)
# Step 3: Generate answer grounded in context
prompt = f"Context:\n{context}\n\nQuestion: {query}\nAnswer:"
return llm.generate(prompt)The retrieve-then-generate pattern remains the backbone of production AI today. Vector search, BM25, reranking, and chunking strategies all exist to make this retrieval step more accurate.
Why RAG still matters in 2026
Every layer that came after RAG assumes retrieval exists. LangChain wraps it in chains. LangGraph uses it inside agent nodes. GraphRAG extends what gets retrieved. But the core idea from 2020 never went away: ground the LLM in real documents before it answers.