Guide · RAG in AI

RAG in AI: how AI answers from your sources.

RAG (Retrieval-Augmented Generation) lets an AI look for information in your documents before answering. Definition, how it works step by step, differences with fine-tuning, examples and limits: the essentials for understanding and using RAG.

Definition

What is RAG
in artificial intelligence?

RAG (short for Retrieval-Augmented Generation, also called search-augmented generation) is a method that combines two steps: retrieving the useful passages in a set of documents, then generating an answer with a language model (LLM) from those passages.

In practice, when you ask a question, the system doesn’t settle for what the model learned during training: it first searches your knowledge base for the relevant extracts, adds them to the request, and the model writes its answer based on them. The answer can then cite its sources.

The term was popularised by a 2020 paper from Facebook AI Research (Lewis et al.). Today it refers to the most widespread architecture for connecting generative AI to a company’s data.

SearchContextGenerationCited sources
Why RAG

An LLM on its own knows
neither your documents nor the news.

ChatGPT, Claude, Gemini or Mistral can write and reason, but their knowledge stops at their training data. RAG fills three gaps.

Frozen knowledge

A model knows nothing of what happened after its training or of what was never public: your prices, your procedures, your contracts, your decisions.

Unverifiable answers

Without a source, there is no way to know where a claim comes from. With RAG, the answer points to the passages that fed it.

Fewer fabrications

When information is missing, a model may fill the gap with a plausible but false answer. Providing the right context reduces this risk, without removing it.

How it works

How RAG works,
in 6 steps.

The first three steps happen once, when documents are imported. The next three repeat with every question.

01

Extract the content

Documents are read: file text, web pages, transcripts of videos and audio files.

02

Split into passages

The text is split into pieces (chunks) that keep their reference to the original document.

03

Create the vector index

An embedding model translates the meaning of each passage into a numerical vector, stored in a vector database.

04

Search by meaning

For each question, the system compares the question with the index and selects the closest passages, even without the same words.

05

Augment the request

The selected passages are added to the question, with instructions: answer from the sources, say when information is missing.

06

Generate and cite

The LLM writes the answer from this context and shows the documents used, so you can check.

The model is not retrained: it is given context at the moment of answering. For details of the two approaches, see Vector RAG and LLM Wiki.
Vocabulary

RAG and LLMs: the words
to know.

RAG combines a search engine and a language model. A few concepts are enough to understand what happens under the hood and ask a provider the right questions.

See the detailed diagram
RAG glossary
EmbeddingA numerical representation of a text’s meaning

Two sentences with similar meanings have similar vectors, even with different words.

Vector databaseAn index that stores passage vectors

It finds the passages closest to a question in a few milliseconds.

ChunkAn indexed piece of a document

Too small, it loses context; too large, it drowns the useful information.

Hybrid searchMeaning + keywords

Combines vector search with exact-word search, useful for references and codes.

Augmented promptQuestion + passages + instructions

This is what the model actually receives when it answers.

Compare

RAG, fine-tuning or long context:
what is the difference?

Three ways to make an LLM work on knowledge it doesn’t have. They are often combined: fine-tuning shapes how it answers, RAG brings the facts.

Search, then answer

RAG

Knowledge stays in your documents; the model consults them for each question.

  • Ideal for: lots of information that changes often and needs sourcing
  • Updating: just add or remove a document
  • Limit: depends on the quality of the search and the sources
Retrain the model

Fine-tuning

The model’s parameters are adjusted on examples to change its behaviour.

  • Ideal for: a very specific style, format or task
  • Updating: new training with every change
  • Limit: costly, doesn’t cite sources, poorly suited to facts that change
Paste everything into the request

Long context

Whole documents are sent to the model with each question.

  • Ideal for: one-off analysis of a few documents
  • Updating: nothing to prepare
  • Limit: cost and slowness grow with volume, not suited to a large knowledge base

For a company knowledge base that evolves and whose answers must be verifiable, RAG is usually the starting point.

RAG variants

Find. Structure. Protect.

RAG is not a single technology. Depending on the need, you search for passages, structure knowledge upstream or protect data before processing. All three approaches are available in Narratheque, at the same price per knowledge base.

01 · FIND

Vector RAG

“I want to find the right information in my documents.”

The classic form: search for the passages closest to the question, then generate.

ExampleFind a returns procedure in support manuals.
Understand vector RAG
02 · STRUCTURE

LLM Wiki

“I want to connect scattered information.”

The AI organises the content upstream into linked, summarised pages; search relies on this structured knowledge.

ExampleRebuild a project’s history from several documents.
Explore the wiki approach
03 · PROTECT

RAG with anonymisation

“I want to limit the exposure of sensitive data.”

Supported identifying information is replaced or encrypted before being sent to the model.

ExampleQuery customer files without sending names.
See anonymisation
Limits and good practice

What RAG doesn’t do
for you.

Most disappointments come from the sources and governance, not the technology.

Quality sources

RAG repeats what it finds. Outdated or contradictory documents produce outdated or contradictory answers.

Good splitting

A passage cut in the wrong place loses its meaning. Preparing the documents matters as much as the model.

Consistent access rights

RAG doesn’t manage permissions for you: a knowledge base should contain what its audience is allowed to see.

Errors are always possible

RAG reduces fabrications, it doesn’t eliminate them. Answers with consequences are checked against the cited sources.

Data in transit

With an external model, the selected extracts are sent to it to produce the answer. Choose models according to sensitivity.

A knowledge base to maintain

Add, remove, update: a knowledge base lives with the organisation.

RAG and sensitive data

Where the knowledge base is stored and where the model processes it are two separate questions. Check where the extracts sent go, the provider’s reuse terms, and protect identifying information before processing when necessary.

Understand the data journey
Setting up RAG

Use RAG
without coding.

Building RAG yourself means choosing an embedding model, a vector database and a splitting strategy, and managing access rights. With Narratheque, you import your documents, web pages, videos or audio files: indexing is done for you, and you choose the model (OpenAI, Anthropic, Google, Mistral or local models) that answers.

A knowledge base starts at €29 excl. VAT per month (Simple plan: 1 knowledge base, 2 users, usage budget included).

Your first RAG
  1. Choose a precise use case.
  2. Import the useful sources.
  3. Define access and models.
  4. Test the answers and their sources.

14-day free trial, no card required →

Further reading

Going further with RAG.

Frequently asked questions

RAG in AI: your questions.

What is RAG in AI?

RAG (Retrieval-Augmented Generation) is a method that makes AI search for the useful passages in a set of documents before generating its answer. The model thus relies on your sources and can cite them, instead of being limited to its training data.

What does RAG stand for?

RAG stands for Retrieval-Augmented Generation. The term was popularised by a 2020 paper from Facebook AI Research.

What is the difference between RAG and fine-tuning?

Fine-tuning retrains the model to change its behaviour; RAG gives it documents at the moment of answering, without retraining it. RAG suits information that changes and must be sourced; fine-tuning suits a very specific style or task.

Does RAG eliminate hallucinations?

No. It reduces them by providing the right context, but an answer can still be incomplete or wrong if the search misses a passage or the sources are poor. Important information is checked in the cited documents.

Which documents can be used in RAG?

Any content from which text can be extracted: files, web pages, transcripts of videos and audio files, notes. Quality matters more than quantity: remove duplicates and obsolete versions.

Do you need to code to use RAG?

To build RAG yourself, yes: you have to assemble an embedding model, a vector database and an LLM. A platform like Narratheque does it for you: you import your documents and ask your questions.

Is RAG compatible with sensitive data?

It is possible with precautions: separate knowledge bases by audience, choose models according to sensitivity, and protect identifying information before processing. With an external model, the selected extracts are sent to it to produce the answer.

How much does RAG cost?

A custom-built RAG requires development time plus infrastructure and API costs. With Narratheque, a knowledge base usable with RAG starts at €29 excl. VAT per month, with a 14-day free trial.

Put it into practice

RAG, applied to your documents.

Let’s start from a real body of content and a few real questions to see what RAG can do for your organisation.

Prendre rendez-vous

Besoin d'aide ?