Retrieval Augmented Generation
Retrieval-Augmented Generation (RAG) is an AI architecture that enhances a generative language model by first querying an external knowledge source-such as a document corpus or database-and injecting the retrieved passages into the model's Context Window before generation. This grounds the model's output in up-to-date, domain-specific facts rather than relying solely on knowledge baked into its parameters during Pretraining.
Think of it like an open-book exam rather than a closed-book one. Instead of answering purely from memory, the model is allowed to look up relevant pages before writing its answer-producing responses that are more accurate and easier to verify because the source material is right there.
A typical RAG pipeline converts user documents into Embeddings and stores them in a Vector Database. At query time, the user's question is also embedded, and the most semantically similar chunks are retrieved. Those chunks are prepended to the prompt alongside the question, and the LLM generates an answer grounded in that retrieved text. Optionally, a reranking step reorders the candidates before they enter the context.
RAG directly reduces Hallucination and keeps models current without expensive retraining; it combines Embedding-based retrieval, Vector Database infrastructure, and Prompt Engineering patterns. Fine-tuning and RAG are complementary strategies-fine-tuning shapes behaviour and style while RAG supplies factual grounding at runtime.
You will encounter RAG in enterprise chatbots, legal and medical document Q&A systems, customer support tools, and virtually any production LLM application that needs reliable, source-cited answers.