Skip to content

GlossaryFloor 2 · The Harnessthe block and its bolted-on plates: what gets added to itFloor 2 · The Harness

RAG

No. 013 · v2026-08FR: RAG

RAG means searching for the documents useful to your question, then giving them to the model to read before it answers: like a colleague who, before answering you, goes and pulls out the right binder and rereads it in front of you.

What it is not

RAG teaches the model nothing. The retrieved documents are placed before its eyes for the length of one answer, then they disappear: the model that answers is exactly the same before and after. That is what separates it from fine-tuning, which does modify the model. Nor is it a search on the web: RAG queries a corpus that you have chosen and that you maintain.

In depth

The two stages

A RAG works in two stages. Upstream, documents are cut into passages and indexed so that they can be found by meaning, and not only by the exact words they contain. At question time, the harness queries this index, selects a few passages and adds them to the context, just before the person’s request. The model reads this whole and writes its answer from what it has before its eyes, which makes it possible to require that it cite the passages it relies on.

Nothing moves in the model

All of this happens in the harness: the model’s weights never move. That is the fundamental difference with fine-tuning, which continues training and transforms the model itself. The practical consequence is clear: updating a piece of information amounts to modifying a document, and withdrawing a piece of information amounts to deleting it from the corpus, without any training being restarted. In exchange, the cost shifts onto every request, since the retrieved passages occupy the context window and are paid for at each call.

The commonest trap

The most common trap is to believe that a RAG removes hallucinations. It mainly reduces the occasions to produce them, by giving the model the material it lacked; if the search brings back the wrong passage, the model will answer with the same assurance on a false basis. The quality of a RAG is therefore played out first in the search, rarely in the choice of model: how documents are cut up, how fresh the corpus is, contradictory versions living side by side, access rights that are not carried through. A corpus that is never pruned ends up turning against the system, which then faithfully cites a superseded procedure.

Under the hood3 steps · the real shape of the objects

A RAG adds no knowledge to the model: for each question, it manufactures a piece of context. Everything that makes its quality therefore lies in three objects: what you index, how you filter, and what you finally paste before the model’s eyes.

  1. 01

    What you actually index

    An indexed passage is not a piece of text: it is a text plus what makes it possible to decide about it. The metadata weighs as much as the content, because it is the metadata that will answer the two questions that make RAG systems fail in production: who is allowed to see this, and is it still in force.

    js
    {
      id: 'contract-2024#p37',
      text: 'The annual cap is set at 2,400 euros.',
      vector: [0.021, -0.184, /* ... */],
    
      // what follows decides more often than the vector does
      source: 'contract-2024.pdf',
      page: 37,                      // so that the citation can be verified
      version: '2024-01',
      superseded_by: null,           // filled in the day a version replaces it
      rights: ['policyholder', 'case_handler'],
      indexed_on: '2026-02-11',      // to spot what has not been reindexed
    }
    

    The trapA corpus that is never pruned turns against the system: without the “superseded by” field, the 2019 procedure and the 2024 one are two equally plausible passages, and the model will faithfully cite whichever the search brought back first.

  2. 02

    Filter during, never after

    The rights filter belongs to the search itself. Filtering the results afterwards means having already read, and often already passed on, what you had no right to read: it is the most common leak in systems of this kind.

    js
    const passages = await index.search(question, {
      k: 5,
      filter: (p) =>
        p.rights.some((r) => session.roles.includes(r)) &&   // rights OF THE SESSION
        p.superseded_by === null,                            // nothing superseded
    });
    
    // the way out, as important as the search itself
    if (passages.length === 0) {
      return "I found nothing in the documents you have access to.";
    }
    // without this return, the model receives an empty context and answers anyway:
    // from memory, so beside the point, and with the same assurance.
    
    session.roles
    The rights of the person asking the question, not those of the service that did the indexing. An index built with an administration account sees everything: it is at search time that the restriction has to apply.
    k
    The number of passages retained. Raising it does not make the answer better: beyond a few passages, the useful information gets diluted and the cost rises at every turn.
  3. 03

    What the model sees in the end

    The result of all this work is a block of text, added to the context just before the question. Nothing else reaches the model: not the score, not the database, not the rights. Hence the need to write the provenance into the text itself, without which no citation is possible.

    txt
    [contract-2024.pdf · page 37 · version 2024-01]
    The annual cap is set at 2,400 euros.
    
    [leaflet-2023.pdf · page 4 · version 2023-06]
    The annual cap is set at 1,800 euros.
    
    Answer only from the passages above, citing the reference in
    brackets. If the passages contradict each other, say so.
    

    The trapTwo contradictory passages are here, and this is the most frequent real case. The model has no way of knowing which one governs: it will decide by plausibility, unless it is explicitly asked to flag the contradiction, and above all if the index had filled in “superseded by” at stage 01.

Shown elsewhere
  • embeddingthe vector held by the “vector” field, and why the nearest one is not the right one
  • contextwhere exactly this block is inserted, and what it costs at every turn

What variesThe interface names of an index vary, and document databases each expose their own vocabulary of filters and scores. What does not vary: the model’s weights never move, the access restriction has to apply during the search, the provenance has to travel inside the text to be citable, and what reaches the model is a block of text like any other.

Relations where the neighbours live

Check 3 questions · click your answer

Level 1 · Recognise

You connect a RAG to your internal procedures. What has changed in the model?

Level 2 · Distinguish

An assistant connected through RAG cites a procedure superseded last year. Where is the problem?

Level 2 · Distinguish

You want the assistant to adopt the house tone and turns of phrase. Is RAG enough?

Who works with this 1 role

The roles for which this term is part of the ordinary work.

No. 013 · v2026-08 · first written in · editorial responsibility Anthony Capirchio

Lexigraph, "RAG", v2026-08, https://www.lexigraph.org/en/rag/, CC BY 4.0.

Report

What goes with your message

Entry · RAG
No. 013 · v2026-08 · /en/rag

What is this about
0 / 600

It is used to reply to you, and for nothing else. What is recorded