AI Model Wiki

    Skip to main content
    Back to Glossary

    Retrieval-Augmented Generation (RAG)

    Retrieval-Augmented Generation (RAG) is a technique that extends a generative language model by coupling it with a retrieval system: at inference time, relevant documents or passages are fetched from an external store and appended to the prompt, giving the model authoritative context it cannot have memorised. The approach was formalised by Lewis et al. at Meta in 2020 and has become a cornerstone of production AI applications.

    Think of it like a doctor who, before answering a patient's unusual question, quickly pulls the latest treatment guidelines off a shelf. The doctor's medical training (the model's parameters) provides reasoning ability; the guidelines (retrieved documents) supply current, specific facts. Together they produce a far better answer than either could alone.

    In a typical RAG setup, source documents are chunked, converted into Embeddings, and stored in a Vector Database such as Pinecone or pgvector. A user query is embedded the same way, the nearest chunks are retrieved-optionally reordered by a reranker-and the whole package lands in the model's Context Window before the LLM generates a response. The result is an answer with traceable citations rather than confabulated facts.

    RAG is the primary practical defence against Hallucination in production systems and works hand-in-hand with Vector Database infrastructure, Embedding models, and Prompt Engineering; it complements rather than replaces Fine-tuning, which adjusts the model's style and domain knowledge at the parameter level.

    You will encounter RAG in customer-support bots, legal research tools, internal knowledge-base assistants, and any application where factual accuracy and source attribution are non-negotiable.

    AI Terminology
    Glossary