Retrieval-augmented generation (RAG)

Retrieval-augmented generation is a technique where an AI system retrieves relevant passages from a chosen document collection and gives them to a language model to use in its answer.

What is retrieval-augmented generation (RAG)?

Also known as: Grounding, Grounded generation, Retrieval-augmented LLM

Retrieval-augmented generation (RAG) is a way of building AI tools so that, before a language model answers, the system searches a chosen set of documents for relevant passages and hands those passages to the model along with the question. The model then writes its answer with that source material in front of it, rather than relying only on what it absorbed during training.

The term comes from a 2020 research paper by Patrick Lewis and colleagues, “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”, presented at NeurIPS 2020. The authors combined a pre-trained language model (knowledge stored in its weights, which they called parametric memory) with a separate, searchable index of Wikipedia (non-parametric memory) accessed through a neural retriever. They pointed to two open problems with language models alone: showing where an answer came from, and updating what the model knows. Today, “RAG” is used more broadly for almost any system that fetches documents at query time and passes them to a model as context.

How RAG works

Most RAG systems follow the same four steps, though the details vary by tool:

  1. Prepare the collection. Documents are split into smaller passages and indexed so they can be searched. Many systems use embeddings, numerical representations of meaning, so a search can find passages that match a question’s intent and not just its exact words.
  2. Retrieve. When someone asks a question, the system searches the index and selects the passages it judges most relevant.
  3. Augment. Those passages are added to the prompt, usually with instructions such as “answer only from the sources provided” and “cite the passage you used.”
  4. Generate. The language model writes the answer. Well-designed tools show which passages it drew on, so a person can check them.

RAG and grounding

“Grounding” is a looser term for tying an AI system’s output to a specified source of truth, such as a document set, a database or a search result. RAG is one of the most common ways to ground a model. NIST’s Generative AI Profile (NIST AI 600-1) lists grounding and retrieval-augmented generation among the techniques organizations may use to manage generative AI risk, and it suggests re-assessing model risks after implementing RAG, since adding a retrieval layer changes how the system behaves.

Why it matters for pharma marketing

Pharma marketing runs on approved sources: the prescribing information, an approved claims library, the references behind each claim, brand guidelines and past review decisions. A general-purpose model doesn’t know which of these are current for your brand, and it can’t tell approved wording from something it read on the internet. RAG lets a team point the model at the sources it should use.

Without retrieval With retrieval over approved sources
Answers come from whatever the model learned in training Answers draw on passages from a collection the team controls
Hard to tell where a statement came from The tool can show the passage behind each statement
Knowledge is fixed at the model’s training date Updating a document updates what the system can retrieve
One model serves every brand the same way Each brand can have its own collection and access rules

In practice, teams use RAG-style tools to answer questions about a brand’s guidelines, find the reference passage that supports a claim, check draft copy against approved language or brief a new team member. For agencies working across several brands, keeping each brand’s collection separate matters as much as the retrieval itself.

Limits and common misconceptions

  • “If it cites a source, it’s correct.” The model can still misread a passage, combine two passages into a statement neither supports, or add detail that isn’t there. NIST calls confidently stated but false output “confabulation,” and retrieval reduces the room for it without removing it. See AI hallucination.
  • “The collection takes care of itself.” Retrieval only finds what is in the index. Superseded labels, unapproved drafts or another brand’s documents in the collection will be retrieved just as readily as approved ones.
  • “Retrieval always finds the right passage.” Search can miss the relevant passage, rank a weaker one higher or return only part of a table or footnote. If the right text never reaches the model, the answer can’t reflect it.
  • “A sourced answer is an approved answer.” Output from a RAG tool is still draft material. Supporting evidence for a claim is a judgment for qualified reviewers, and promotional content still goes through MLR review.

Note. RAG is different from fine-tuning. Fine-tuning changes a model’s weights by training it further on examples; RAG leaves the model as it is and supplies documents at the moment of the question. Many tools combine both.

Questions to ask about a RAG-based tool

  • Which documents does it search, who decides what goes in, and how are superseded versions removed?
  • Does it show the exact passage behind each answer, with enough location detail to find it in the source?
  • Are collections separated by brand or client, and who can see each one?
  • What does it do when nothing relevant is found: say so, or answer anyway?
  • How has it been tested on your own material? See AI evaluation for what a useful test looks like.

References

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Lewis et al.)arXiv:2005.11401; NeurIPS 2020 · May 2020, revised April 2021
  2. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1)National Institute of Standards and Technology · July 2024

Last reviewed December 2026. This glossary explains terms in general; it isn’t legal or regulatory advice.

Frequently asked questions

Common questions about retrieval-augmented generation.

Does RAG stop AI from hallucinating?

No. It gives the model relevant source text to work from, which can make answers more accurate and easier to check, but the model can still misread, misquote or overreach beyond the passages it was given. Treat a sourced answer as something to verify, not as verified. Read more about AI hallucination.

Is RAG the same as training an AI on our documents?

No. Training or fine-tuning changes the model itself, while RAG leaves the model unchanged and supplies documents at the moment a question is asked. That is why a RAG system can reflect a label update once the new document is added to the collection and indexed, and why it matters so much which documents are in that collection.

Can a RAG tool replace our reference library?

It depends on the reference library, not the other way round. A RAG system can only be as current and as approved as the documents it searches, so most teams still need a curated, versioned library behind it. See what a reference library involves.

Ready to make the shift?

Let's talk about your goals and how we can help.