TL;DR: RAG consists of three phases: indexing (converting texts into vectors), retrieval (finding the most similar texts) and augmentation (passing the retrieved texts to the LLM as context).
For everyone
How the pipeline works
RAG is like a research assistant: before the LLM answers, a system searches a knowledge base for the most relevant documents and hands them over as a "cheat sheet". The LLM then combines its general knowledge with the fresh information.
For nerds
The three phases
1. Indexing
Documents are split into chunks and converted into high-dimensional vectors by an embedding model. These vectors represent the semantic meaning and are stored in a vector database (e.g. Pinecone, Weaviate, ChromaDB).
2. Retrieval
The user's query is converted into a vector as well. A nearest-neighbor search (cosine similarity or dot product) then fetches the most similar chunks from the database. Typically: the top 5 to top 20 results.
3. Augmentation
The retrieved texts are inserted into the LLM's prompt, and the model then answers using its internal knowledge plus the external documents. Prompt template: "Based on the following sources: [CHUNKS]… Answer: [QUESTION]"
Challenges
Chunking strategy (too large = noisy, too small = missing context), embedding quality, retrieval precision vs. recall, and costs for large knowledge bases.
Why it matters in 2026
RAG is the enterprise standard for knowledge-based AI. The challenges are shifting from "whether to use RAG" to "how good is your RAG": better chunking strategies, hybrid search and multi-step retrieval.