What Is RAG? A Plain-Language Guide to Retrieval-Augmented Generation

What RAG (Retrieval-Augmented Generation) is and how it works, based on AWS's official explainer and the original research paper: how it addresses LLM hallucinations, the four steps using a vector database, and the benefits for business adoption.

What Is RAG? A Plain-Language Guide to Retrieval-Augmented Generation

When you try to bring generative AI into your business, you quickly hit two walls: the AI “doesn’t know your internal documents or the latest information,” and it “produces plausible but wrong answers even about things it doesn’t know.” The most widely used remedy for these problems is RAG (Retrieval-Augmented Generation).

The term shows up in nearly every product description for enterprise chatbots and document-search AI, but the mechanism itself is simple. This article organizes what RAG is, why it is needed, and how it works—for readers who are not AI specialists—based on AWS’s official explainer and the research paper where the term originated.

What Is RAG?

According to AWS’s explainer, Retrieval-Augmented Generation (RAG) is “the process of optimizing the output of a large language model,” in which the model “references an authoritative knowledge base outside of its training data sources before generating a response” 1.

Put plainly, it is a mechanism that searches for relevant material and hands it to the AI before letting it answer. In human terms, instead of answering a question from memory alone, you first pull the relevant documents off the shelf and answer while reading them. This flow—retrieve the material (Retrieval), reinforce the answer (Augmented), and generate (Generation)—is where RAG gets its name.

The term originates in the 2020 research paper “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks” (first author: Patrick Lewis) 2. The paper proposed a method that combines the knowledge a trained model holds internally (parametric memory) with external knowledge such as a document index of Wikipedia (non-parametric memory) to generate text 2. Today the word has settled into broader usage, referring not just to the paper’s specific method but to the general approach of reinforcing generative AI with retrieval.

Why RAG Is Needed: Four Known Challenges of LLMs

Because a large language model (LLM) only holds knowledge from the time it was trained, using it as-is in business raises several problems. AWS lists known challenges of LLMs: “presenting false information when it does not have the answer,” “presenting out-of-date or generic information,” “creating a response from non-authoritative sources,” and “creating inaccurate responses due to terminology confusion, wherein different training sources use the same terminology to talk about different things” 1.

The first is the problem known as hallucination—plausible misinformation. The second is knowledge freshness: the AI does not know about the internal policy that was revised yesterday. The third and fourth concern whether an answer is grounded in trustworthy sources. RAG addresses all of these with one approach: search an authoritative knowledge base and make the model answer based on its contents.

How RAG Works: Four Steps

RAG processing consists of four broad steps. Let’s walk through them following AWS’s explainer 1.

Step 1: Prepare external data. First, information such as internal documents and databases is converted into a form the AI can search. Here, “another AI technique, called embedding language models, converts data into numerical representations and stores it in a vector database1. By converting text into sequences of numbers that represent meaning (vectors), documents can be found by semantic similarity rather than keyword matching.

Step 2: Retrieve relevant information. When a user asks a question, “the user query is converted to a vector representation and matched with the vector databases” 1. Documents semantically close to the question are pulled out as relevant material.

Step 3: Augment the prompt. The RAG system “augments the user input by adding the relevant retrieved data in context” 1. In other words, the user’s question is passed to the LLM together with the search results, and the model is asked to generate an answer based on that material.

Step 4: Update the data. To keep the knowledge base current, systems “update the documents and update embedding representation of the documents” asynchronously 1. There is no need to rebuild the AI model every time a document changes—updating the database side is enough.

The Benefits: Faster, Cheaper, and Easier to Verify than Retraining

Another way to give an LLM new knowledge is additional training of the model itself (fine-tuning or retraining). But as AWS points out, retraining foundation models incurs high computational and financial costs 1. RAG supplements the model with an external knowledge base without touching the model itself, so it can be adopted at lower cost.

AWS also cites further benefits: freshness, since RAG allows developers “to provide the latest research, statistics, or news to the generative models”; source attribution, since the output can “present accurate information with source attribution”; and developer control, since developers “can control and change the information sources” to adapt to changing requirements 1. Being able to attach a citation—“based on this clause of this internal policy”—directly improves verifiability in business use.

Caveats to Know Before Adopting

That said, RAG is not a cure-all. By design, answer quality depends on the quality of the retrieved material, so if outdated or incorrect documents are mixed into the knowledge base, the answers can be expected to reflect them. Designing operations to include document maintenance and updates (Step 4 above) is key to a successful rollout.

Also, because retrieved material is added to the prompt passed to the LLM, the amount of material you can hand over at once is constrained by how much text the model can process at a time (its context window)—a concept we cover in detail in our context window explainer. And in recent years, retrieval—the core of RAG—has also become a building block of AI agents that carry out tasks autonomously. For how agents work and how they differ from generative AI chat, see our explainer on AI agents.

Sources

  1. What is RAG (Retrieval-Augmented Generation)? - AWS official explainer
  2. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks - The original research paper that coined RAG (submitted May 2020)

We publish the latest AI news every day.

Subscribe via RSS Get new posts the moment they go live.

Search other keywords →