Retrieval-augmented generation

A way to keep LLM answers accurate by connecting them to your own data.

What it is

RAG adds a search step before the LLM answers. It searches your docs for relevant parts and passes them to the LLM as context. The LLM answers from those parts only.

Why it matters

RAG keeps LLM answers accurate on your data. It cuts hallucination and lets you cite sources.

How to use

  • Break your knowledge base into small passages.
  • Convert each passage to numbers and store it.
  • At query time, convert the question to numbers, find the closest passages, and pass them to the LLM.
  • Ask the LLM to answer from those passages and cite its sources.

FAQ

  • Do I always need RAG?

    No. For general questions, a plain LLM is fine. For your own data, RAG is essential.