Skip to content

Guide

What RAG is

When a question comes in, the relevant passage is found in your own material first, and the answer is written from it. It answers from material the model never learned.

In short

Find it, read it, answer

A language model answers from what it learned. It does not know the staff handbook, last month's contract or your own product manual, because none of that was public.

RAG adds a lookup step in between. When a question arrives, the relevant passage is found in your material first and handed to the model together with the question. The model reads that passage and writes the answer.

That is what makes it possible to show which document and which passage the answer came from, next to the answer itself. Whoever receives it can check.

What runs

From loading the material to getting an answer

The first two steps run once when material is loaded. The last two run on every question.

01

Split it

Documents are cut into passages. Too large and unrelated content gets mixed in; too small and the thread is lost.

02

Turn it into numbers

Each passage is stored as an embedding, a block of numbers. Text with a similar meaning ends up with similar numbers.

03

Find it

The question is turned into numbers the same way and the closest passages are pulled out, then narrowed and reordered once more.

04

Write the answer

The chosen passages and the question go to the model together. The passages it read are shown with the answer.

Side by side

How this differs from retraining the model

They are often used together. RAG fits the work where the material keeps changing.

When the material changes

Retraining means running the training again. With RAG the changed document is simply loaded again.

When you need the source

A retrained model cannot say where an answer came from. RAG points at the passage it read.

Limits

Where it falls down

Adding RAG does not settle everything. Three places do the damage.

  • A wrong lookup gives a wrong answer. Pick the wrong passage and the model will faithfully write a wrong answer from it.
  • How the material is split changes the result a lot. In a document full of tables and figures, cutting out only the text throws the meaning away.
  • A source next to the answer still needs a person. Leaving the final check with a person is still the right call.

Common questions

It depends on where it runs. A setup that keeps the material in place is possible, and it is one of the first things to settle before adoption.

It runs on a handful of documents. With few candidates to choose from, though, unrelated passages surface easily, so it helps to keep the scope of the questions narrow.

Try it on your own material

With LabRAG you load the material, describe what you need in plain words, and the service that does that work gets built.