DelegIA
Get started

What is RAG in AI?

Retrieval augmented generation (RAG) is an AI technique that searches your company's documents and uses what it finds to answer a question. It retrieves relevant passages, giving the model information beyond what it learned during training. If the system also tracks where each passage came from, it can show which document supports each piece of information.

Albert López·Founder of DelegIA·Updated

Also called
Retrieval augmented generation
Type
Technique
Reading time
7 minutes

What does RAG stand for and mean in AI and ML?

RAG is a way to give generative AI (Gen AI) systems context beyond what their large language models (LLMs) learned during training. The models behind ChatGPT, Claude, and Gemini don't know your price lists, contracts, or warehouse manual unless you give them access. Without those documents, a model relies on its training and may make up a convincing answer.

Patrick Lewis and other researchers described the RAG approach in 2020, studying a system that retrieved Wikipedia passages to answer questions. The definition of RAG in AI and machine learning (ML) follows the meaning of its full name, retrieval augmented generation. One component retrieves passages relevant to the question; the other uses them to generate an answer. A company can apply the same approach to its price lists or manuals. Lewis et al., 2020.

To give the AI access to a new document, you add it to the collection the system searches. You don't need to retrain the model. Because answers draw on specific passages, the system can cite them. Google's Gemini Notebook cites the sources you upload so you can check where the information came from. Google Help.

How does retrieval augmented generation (RAG) architecture work?

This overview follows the RAG system architecture through a three-step AI pipeline. Document preparation happens during setup and whenever the documents change; the search and answer steps run each time someone asks a question.

  1. Prepare the documents

    The system splits manuals, contracts, and product sheets into passages a few paragraphs long, called chunks. It converts each chunk into a list of numbers that represents its meaning, called an embedding. It then stores this information in an index designed to search for similarity, usually a vector database.

    Returns manualPrepared

    Chunks
    A few paragraphs each
    Each chunk
    With its embedding
    Stored in
    The index
  2. Search

    When a question comes in, the system looks for relevant chunks. A common approach converts the question into numbers too, then finds chunks with the closest meaning. This lets it find the paragraph about return terms even when someone asks, "Can I exchange a product?" and the document uses the word "returns."

    QuestionSearch by meaning

    Asked
    Can I exchange a product?
    Found
    Return terms
  3. Answer

    The model receives the question, the retrieved chunks, and instructions to use only those chunks to answer and cite the source of each piece of information.

    AnswerBased on retrieved chunks

    Answers from
    Retrieved information only
    Cites
    The source document

The RAG architecture explained here is what connects an AI model to your documents, with a vector database, a retriever, and a generator as its components. The database stores the passages, the retriever finds them, and the generator, usually an LLM, writes the answer. What makes an AI model a "RAG model" is how it uses retrieved information to answer. The term doesn't identify a particular model.

Splitting a document can separate a passage from the context it needs. A chunk that says "the deadline is 30 days" isn't useful if you can't tell which contract or product it refers to. In 2024, Anthropic published a technique that adds a short explanation of each chunk's context before storing it. In its tests, combining that context with semantic and keyword search reduced the failure rate for retrieving relevant material in the top 20 chunks from 5.7% to 2.9%. Reranking the results brought it down to 1.9%. Those were reductions of 49% and 67% in that experiment. Anthropic, 2024.

What happens when RAG cannot find the answer

We configure the system to pause when it can't find enough source material to answer. It asks for the missing information or sends the question to the right person, with a record of what it searched. The team can then see what's missing instead of receiving an answer filled in with whatever the model considers likely. Decide how it should handle these gaps before building the RAG system.

The construction estimating software we built is an example of retrieval augmented generation in applications that use data beyond text documents. The software first looks for the price of each line item in the project PDF. If the price is missing, it checks the company's previous projects, then construction pricing sources. If none of those sources has a price, it estimates the amount and flags the line item for review.

With retrieval augmented generation, the accuracy of a RAG answer also depends on the documents themselves. If there are three versions of a price list, or everyone keeps templates on their own computer, the AI may cite the wrong version. Before building a RAG system, decide which documents it should treat as authoritative.

What is a RAG agent?

In a basic RAG system, the AI follows a fixed pattern: search the documents, then answer. AI agents with RAG can decide when to search, what to look for, and whether they have enough information. Document search is one of the tools an agent can use, along with email or your business management software.

In an agentic RAG architecture, an AI agent can run several searches before its LLM writes an answer. If someone asks whether a customer can return an order, for example, the agent first looks up the order in the business management system. It then finds the return terms for that product and uses both sources to answer.

For more on how agents work, read What is an AI agent?

RAG with a private model

A RAG system sends retrieved passages to the model with each question. If you use an external provider's model, those passages go to its servers under its service terms. When contracts, patient records, or customer data must stay within the company, we propose running the entire RAG system on infrastructure dedicated to that company. This includes the documents, the index, and an open model on a company server or in a private cloud set up for it. You also need to decide where the system processes documents and stores queries.

For details on this setup, see Private AI for businesses.

RAG, fine-tuning, or pasting in the whole document

Fine-tuning or retraining a model on your texts can teach it a style or a way of working, but it doesn't give you a reliable record of specific facts that you can keep current. As documents change, you need to update the model's training too.

Pasting an entire document into a conversation works for a one-time question if it fits in the model's context window. More text can increase processing costs, depending on the service, and the model can miss information buried in a long document.

RAG is useful for repeated questions about documents that change. It searches for the chunks needed for each question and can cite its sources. To make new documents available, you add them to the collection it searches.

ApproachWhen to use itLimitations
Fine-tune or retrain the modelTeach it a style or a way of workingDoesn't reliably retain specific facts; keeping the training current requires more model updates
Paste the document into the conversationA one-time question, if the document fits in the context windowMore text can cost more to process, and the model may miss relevant information
RAGAsk frequent questions about changing documents, with source citationsDepends on the quality and organization of the documents

RAG is usually the starting point when AI needs to answer questions from a company's documents.

If you'd like your team to get answers from company documents with sources they can check, visit AI document management to see how we set it up and book a free initial call.

Sources

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, the 2020 RAG paper by Patrick Lewis et al.. Accessed November 26, 2026. Retrieval augmented generation (RAG) explained in the original paper, including the Wikipedia retrieval experiment.arxiv.org
  2. AWS, What is RAG?. Accessed November 26, 2026. Retrieval, document updates, and source attribution.aws.amazon.com
  3. IBM, What is retrieval augmented generation (RAG)?. Accessed November 26, 2026. External knowledge and the difference from relying on model training alone.www.ibm.com
  4. Anthropic, Introducing Contextual Retrieval, September 19, 2024. Accessed November 26, 2026. Chunk context, hybrid search, and reranking; the percentages are from this experiment.www.anthropic.com
  5. Google, Use chat in Gemini Notebook. Accessed November 26, 2026. Citations from uploaded sources.support.google.com
  6. Nelson F. Liu et al., Lost in the Middle: How Language Models Use Long Contexts, 2023. Accessed November 26, 2026. The models tested could miss relevant information in long contexts; the study doesn't establish how every current model performs.arxiv.org
Albert López

Albert López

Founder of DelegIA

He helps small and midsize businesses in Spain decide where AI makes sense, implements the systems they agree on, and supports the teams using them. His glossary entries draw on that work with each company.

Last reviewed: