docent

Docent blog

What is RAG? Retrieval-augmented generation in plain language

· 5 min read

A language model knows a lot about the world, but it has never read your contracts, your policies or your meeting notes. Ask it about them and it will either say it does not know or, worse, produce something that sounds right and is not. Retrieval-augmented generation, usually shortened to RAG, is the standard fix.

The idea in one sentence

Instead of asking the model to answer from memory, you first find the passages of your documents that are relevant to the question, then hand those passages to the model and ask it to answer using only them.

How RAG works, step by step

  1. Split. Each document is cut into small passages, a few sentences or a section each. Small pieces are easier to match to a question than a whole 80-page PDF.
  2. Index. Every passage is turned into a list of numbers, called an embedding, that captures its meaning. Passages about similar things end up with similar numbers.
  3. Retrieve. When you ask a question, it gets the same treatment. The system looks for the passages whose numbers are closest to the question, so a question about "refunds after 30 days" finds the passage about refund windows even if the wording differs.
  4. Answer. The best-matching passages are given to the language model along with your question, with an instruction to answer from them and say so when they do not contain the answer.

Why not just paste the document into a chat?

For one short file you can. It stops working when you have dozens of files, when the text is longer than the model can read at once, or when several people need the same knowledge. Retrieval also keeps the cost down, because the model reads a few relevant passages instead of everything, every time.

What can still go wrong

Why citations are the part that matters

Because RAG can still be wrong, the useful question is not "is this answer correct?" but "can I check it quickly?". An answer that points to the exact passage it came from turns a leap of faith into a ten-second check. That is the idea behind Docent: every claim links to the passage it was drawn from, so you read the original before you act on it.

Try it on your own files

If you have a PDF, a Markdown file or a plain text file, you can create a free workspace, upload it and ask a question. Read the cited passage next to the answer and judge for yourself. For a deeper look at checking answers, read why every AI answer should cite its source.

Ask your own documents. Upload a PDF, Markdown or text file and get an answer with the exact passage it came from.

Create a free workspace