Skip to main content
AI Engineering

What is RAG?

By Yohan Choi ·

Short answer

RAG (retrieval-augmented generation) is a way to make a language model answer from your own documents. Before the model writes, the system searches your documents for the passages most relevant to the question and puts them in the prompt, so the answer is grounded in that material and can cite it.

Why not just ask the model?

A model only knows what was in its training data, up to a cutoff date. It has never seen your internal wiki, your contracts or last week's meeting notes, and when it doesn't know, it may still produce a confident answer.

RAG gives the model the relevant facts at the moment it answers. The knowledge stays in your documents, where you can update it, instead of inside the model's weights.

How does a RAG pipeline work?

Most RAG systems run the same steps, whatever tools they use.

  • Chunk: split documents into passages of a few hundred words.
  • Embed: turn each passage into a vector, a list of numbers that captures its meaning.
  • Store: keep the vectors in a vector index or database.
  • Retrieve: embed the question the same way and find the passages with the closest vectors.
  • Generate: give the question and the retrieved passages to the model and ask it to answer from them, citing its sources.

What is Graph RAG?

Plain RAG finds passages that look similar to the question. It struggles with questions about relationships spread across documents, such as who worked with whom on which project.

Graph RAG also extracts entities and relationships from the documents into a knowledge graph. At question time it combines vector search with a graph query, so the model gets both the similar passages and the connections between them.

Where does RAG go wrong?

Most bad RAG answers are retrieval problems, not model problems. Check these first.

  • Chunks that cut a table or an argument in half, so no single passage holds the answer.
  • An index that was not updated after the documents changed.
  • Too many loosely related passages, which crowd out the one that matters.
  • No citations, so nobody can check where an answer came from.

RAG or fine-tuning?

Use RAG when the model needs facts that change or must be traceable to a source. Use fine-tuning when you need the model to behave differently, such as following a format or a tone. Many systems use both, but RAG is usually the cheaper place to start.