Free first call

AI that looks it up first.

Ask a general AI assistant about your warranty terms and it may well answer, fluently and from nowhere. It has never seen your terms. With RAG the system first searches your documents for the relevant passages and hands them to the model along with the question. The answer draws on your material and names its sources.

  • Answers from your documents, with sources
  • New knowledge without retraining the model
  • Can respect access rights at retrieval

In short

RAG, short for retrieval-augmented generation, means a language model answers from documents retrieved for the question, in addition to what it learned in training. The documents are split into chunks and indexed. For each question the most relevant chunks are found and passed to the model, which answers and cites its sources. The model itself is not retrained.

How it works, step by step

One service question, six steps.

A service technician asks the internal assistant which torque setting applies to a pump model. The answer sits in a maintenance manual and in a later service bulletin.

A simplified example for illustration.

Example · Question from the service team00 / 06
  1. Question embedded

    The question is turned into an embedding, a vector that captures its meaning. The pump's model number is kept as a keyword.

    Agent
  2. Passages found

    A hybrid search compares the vector with the stored chunks and matches the model number word for word. Hits come from the manual and the bulletin.

    Agent
  3. Rights checked

    The service team has access to both documents. A draft bulletin from engineering also matched and is filtered out, because the technician may not see it.

    Agent
  4. Results reranked

    A reranker sorts the hits by how well they answer the question. The bulletin is newer and changes the value, and both passages go to the model.

    Agent
  5. Answer written

    The model gives the value from the bulletin, points out that the manual states an older one and links both sources.

    Agent
  6. Checked by the technician

    The technician opens the bulletin, confirms the value and reports the outdated manual page to the documentation team.

    Human

How it works

  • Chunks and embeddings

    Documents are split into chunks of a few paragraphs. Each chunk becomes an embedding, a vector of numbers that captures its meaning, and is stored in a vector database such as pgvector in PostgreSQL.

  • Retrieval

    The question is embedded the same way, and the chunks closest in meaning are found. Adding a keyword search, known as hybrid search, also catches part numbers and names.

  • Reranking

    A second model sorts the hits by how well they fit the question. Only the best go on to the language model.

  • Answer with sources

    The model receives the question together with the passages and writes its answer from them. Each statement points to the document it came from.

Limits and risks

  • Retrieval sets the ceiling

    If the search misses the right passage, even the best model cannot answer well. When an answer is weak, look at the search first.

  • Old and contradictory documents

    Several versions of the same price list produce muddled answers. Someone has to own the sources and retire what is outdated.

  • Still fallible

    The model can misread a passage or combine two the wrong way. It should cite its sources and say plainly when it found nothing.

Typical building blocks

A RAG setup combines a handful of standard components.

Document sources such as file shares, wikis and ticketsText extraction and OCR for scansEmbedding modelVector database, for example pgvector in PostgreSQLKeyword search for hybrid retrievalRerankerLanguage model

What matters

  1. 01

    Start with one collection

    Pick one well-kept set of documents, the service manuals for example, and get it right before you add more sources.

  2. 02

    Prepare tables and scans

    Tables lose their structure when split carelessly, and scans need text recognition first. Look at what the system actually extracted from your most important documents.

  3. 03

    Test with real questions

    Collect questions your team really asks, together with the correct answers. Run them again after every change to documents, chunking or model.

Common questions

What is RAG?

RAG stands for retrieval-augmented generation. The language model answers a question from documents retrieved for it, in addition to its training knowledge, and cites those documents as sources.

Where does the term RAG come from?

From a 2020 research paper by Patrick Lewis and colleagues at Facebook AI Research and partner universities. It described combining a language model with a search over a document collection, and the name stuck.

How does retrieval-augmented generation work?

Documents are split into chunks, turned into embeddings and stored in a vector database. The question is embedded too, and the most similar chunks are found, often with an added keyword search and a reranking step. The model then answers from those chunks and names them.

What is the difference between RAG and fine-tuning?

Fine-tuning changes how a model behaves and writes. RAG supplies knowledge at the moment of the question. For company knowledge that changes, RAG is usually the better fit, because a new document can be searched as soon as it is indexed, with no retraining.

What is a vector database?

A vector database stores embeddings and finds those closest to the embedding of a question. pgvector, an extension for PostgreSQL, is a common choice because the vectors live next to the rest of your data.

Does RAG stop hallucinations?

No, it reduces them. With the right passages in front of it, the model has less to invent. The weak point moves to the search, which can return a wrong or outdated passage, and the model can still misread a correct one.

Can RAG respect access rights?

Yes, if the rights are applied at retrieval. Each chunk carries the permissions of its document, and the search returns only what the person asking may see. The model never receives the rest.

What does a RAG system cost?

It varies with the number of documents, their condition, the systems they come from and how many questions the system answers. Preparing scans and tables can take more effort than the search itself.

Free process check · What is RAG?

Walk us through your process.

In a 30-minute process check we go through one process with you, on screen or with a few examples. Afterwards you know which steps an agent could take over and where to start.

Prefer email?

[email protected]

Next step

What eats your time?

Pick a topic and describe the task that costs your team the most time. We send you our assessment within one working day.

Free first call