Ego Machina
← blog

RAG · Nov 15, 2026 · 5 min

RAG explained with an archivist

Search before you answer.

Someone who read everything, except yours

Imagine someone who read an entire library. They know history, cooking and law. But they’ve never seen your company’s manual, your contracts or last week’s emails.

Ask them if you can bring your dog to the office. They don’t know the answer, and still they’ll most likely say something that sounds very sure, taken from what happens at other companies. That’s called hallucinating.

A language model is that person. It knows a lot, but it knows nothing about your documents.

Give it an archivist

The most common fix is to put an archivist next to it. Before answering, someone searches your documents and puts what they found in front of it. It’s the difference between a closed-book exam and an open-book one.

  1. You

    Can I bring my dog to the office?

  2. Model thinks

    I've never seen that manual. I'll answer with what usually happens.

  3. Answermade up

    Sure, more and more offices allow it.

The company and its manual are made up.

Behind the archivist there are three steps. Let’s go one by one.

1. Cut it into cards

The archivist doesn’t hand over the whole manual. The model works on a small desk, where only a few sheets fit at a time. So before any question, the documents are cut into pieces and each piece is filed as a card.

The size of the card matters more than it seems. Change the size and see what reaches the desk.

the manualthe model's desk

completeThe whole answer fits in one card, with a little context around it.

The highlighted lines are the answer.

2. Search by meaning

Here’s the part that feels like magic. You asked about your dog and the card says pets. They don’t share a single word, and the archivist still finds it.

It works because each card is placed on a map according to what it means. Cards about the same thing end up close together, even if they use different words. When a question arrives, it’s placed on the same map and the archivist brings back the closest cards.

officepaytime offPets1Hours3Cafeteria2PayrollBonusesExpensesVacationHolidaysSick leaveyour question

the archivist brings1 · Pets2 · Cafeteria3 · Hours

No card says dog. Pets landed closest because it means almost the same.

3. Answer with what was found

The last step is the simplest. The model gets the question together with the cards and an instruction: answer only with this and say where you got it. That’s why it can cite the card, and that’s why you can check it’s true.

The model no longer guesses: it answers with what the archivist found.

When it fails

A RAG is only as good as its archivist. If it brings the wrong card, the model answers very confidently with the wrong card. That’s why, when a RAG answers badly, the first thing you check is the search, not the model.

In short

  1. You cut your documents into cards just the right size for the answer to fit whole.
  2. You search by meaning for the cards closest to the question.
  3. You give them to the model with the question and it answers citing where it got it.