Glossary

What is retrieval-augmented generation (RAG)?

Retrieval-augmented generation is the pattern of finding relevant passages first and then asking a model to answer with those passages in its prompt. How the loop works, why it exists, and the ways it quietly fails.

Retrieval-augmented generation, usually shortened to RAG, is a two-step loop. When a question arrives, the system first retrieves passages that are likely to bear on it, from documents, tickets, a wiki or a database. It then puts those passages into the prompt and asks the model to answer from them. The model generates; the retrieval step decides what it has to generate from.

The idea is simple, and almost every assistant that answers questions about a company's own information uses some form of it.

Why it exists

A language model knows what was in its training data, up to a cut-off date, and nothing else. It has never seen your contracts, your support queue or last week's board pack, and it cannot know what changed this morning. There are two ways to give it that knowledge. You can train it further on your data (fine-tuning), which is slow, costs money every time the data changes, and still leaves the model unable to say where a fact came from. Or you can hand it the relevant material at the moment of asking, which is what RAG does.

Retrieval also keeps the prompt small. A context window can hold a great deal, but filling it with everything the company knows on every request is expensive and makes answers worse, because the model has to find the one relevant line among thousands of irrelevant ones.

How it is usually built

Documents are split into chunks, typically a few hundred words each, because a whole contract is too large to compare against a question and too large to paste in. Each chunk is passed through an encoder model that turns it into an embedding, a list of numbers that places it so that text with similar meaning sits close together. The embeddings go into an index.

At question time the question is embedded the same way, and a similarity search returns the chunks whose vectors are nearest to it. Many systems add a keyword search alongside, because embeddings are poor at exact strings such as invoice numbers, and some add a second, slower model that re-scores the shortlist. The top few chunks are placed in the prompt, usually with an instruction to answer only from them.

Where it goes wrong

Most disappointing RAG systems fail in the retrieval step, and the answer looks confident either way.

The wrong passage is retrieved. Similarity measures resemblance to the question, and a passage can share every word with the question while answering something else. Chunking makes this worse: the sentence that answers may be split from the sentence that says which customer it is about.

The right passage is ranked too low. It was found, but it came eleventh and only ten made it into the prompt. Follow-up questions suffer most here, because "and who does she report to?" carries almost no meaning on its own.

Two records are the same customer. A CRM calls them Acme Travel Ltd, the helpdesk calls them acmetravel.com, and an email signs off as Acme. Similarity search has no notion that these are one thing, so a question about the customer gets a third of the picture. This is the problem entity resolution exists to solve.

The passage is stale. The index holds last year's price list and this year's, both resemble the question equally, and nothing tells the model which one is current.

There is no citation. If the answer does not say which records it drew on, nobody can check it, and a wrong answer reads exactly like a right one.

Variants

GraphRAG builds a graph of the entities and relationships in the material, then retrieves through that structure as well as by similarity. It helps on questions that depend on how things connect (who owns the account that raised this ticket) and on questions that need a summary across many documents rather than one passage.

Agentic RAG hands retrieval to the model itself as a set of tools. Instead of one search before answering, the model decides what to look up, reads the results, and searches again if they were not enough. It copes better with multi-step questions and costs more per answer, since each step is another model call.

Where Memtro stands

Memtro does retrieval-augmented generation over a knowledge graph rather than a pile of chunks. Before the model sees a question, memory is searched four ways (vector similarity, full-text rank, the facts attached to the entities the question names, and one hop out to their neighbours), the lists are fused, and a cross-encoder re-scores the shortlist. Records from connected systems are resolved to one entity per customer or person, and an answer lists the records it drew on, linked into the systems that hold them. The memory documentation explains the details.

Where agents remember your company

Sign in, add a provider key, create an API key and point your tools at Memtro. It takes about five minutes.

7-day free trial · card on file, nothing charged until it ends · cancel any time