Skip to main content

Retrieval-augmented generation (RAG)

Retrieval-augmented generation (RAG) is how an assistant answers from your data. Before it writes an answer, it searches your Knowledge for the passages most relevant to the question, and then writes the answer from them. The answer is grounded in your content, and the assistant can show which sources it used.

Without RAG, a model can only answer from what it learned in training, which knows nothing about your products, policies or records, and stops at its knowledge cutoff.

How it works​

  1. The question is turned into an embedding, a numerical representation of its meaning.
  2. The Knowledge finds the passages whose meaning is closest to the question, even when they use different words.
  3. The best passages that fit in the model's context window are handed to the model.
  4. The model writes the answer from those passages.

Two ways to search a Knowledge​

An assistant can search a Knowledge in two ways. Both are tools you turn on for a touchpoint.

Simple RAGGraph RAG
What it findsThe passages closest in meaning to the questionThose passages, plus related ones connected to them in the Knowledge
Best forSpecific questions whose answer sits in one documentBroad questions where links between documents matter: citations, references, related products
SpeedFasterSlower
NeedsDocuments in the KnowledgeRelationships between the Knowledge's resources

For example, asked "What are the side effects of metformin?", Simple RAG returns the documents about metformin. Graph RAG also brings in what those documents are linked to, such as drug interactions or related studies.

Use Simple RAG by default. Turn on Graph RAG when your Knowledge has relationships and your users ask broad questions. See Configure RAG.

When the assistant queries a database instead​

A Knowledge can also hold structured data, such as tables of records. For questions about exact values, the assistant gets better answers by querying that data than by searching text:

  • looking something up by its ID or exact name;
  • counting, adding up or averaging ("how many orders in March?");
  • filtering by numbers ("products under 50 euros").

An assistant can do both in one answer: search to find the right items, then query the data for the exact figures. Turn on only the tools that match what your Knowledge holds: database tools when it has structured data, search tools when it has documents.


Connects to​