Retrieval Augmented Generation (RAG)

RAG retrieves relevant text at query time and feeds it into a model's context window so the answer is grounded in real documents.

Category

Industry concept

See all terms

What is RAG?

RAG stands for retrieval-augmented generation. A retriever searches an external index, usually a vector database, for text chunks related to a question, and hands those chunks to a language model along with the prompt. The model answers using that retrieved text instead of only what it learned during training.

This solves a real gap: a model's training data has a cutoff date and never included private company documents. Retrieval lets the same model read a document it has never seen and answer with that document's content.

How does RAG differ from a context layer?

RAG reruns its search on every query, re-chunking and re-embedding the same documents each time, so nothing about one lookup carries over to the next. A context layer works before the query happens: it keeps one structured, versioned, permission-aware copy of company knowledge, and every agent reads from that same maintained state instead of rebuilding it at runtime.

RAG has no record of what changed in a document, when, or why. A context layer tracks file versions and change reviews, and applies continuous updates to keep the repository current without anyone maintaining it by hand.

How does RAG work?

A RAG system splits source documents into chunks, converts each chunk into a vector embedding, and stores those vectors in an index. At query time it embeds the question, finds the chunks whose vectors sit closest to it, and inserts them into the model's prompt before generation. Splitting documents into chunks is also RAG's main failure mode: a chunk pulled out of its surrounding document often loses the context that made it relevant, so the retriever either misses the right passage or returns one that doesn't answer the question.

Qontext skips that runtime chunking problem: agents read directly from the context repository, a copy of company knowledge that is already structured and current, instead of running a fresh retrieval guess on every call.

FAQ

Is RAG the same as a vector database?

Does RAG replace fine-tuning?

Why does RAG give wrong answers even when the right document exists?

Can RAG work without a vector database?

Is RAG still necessary if a model has a huge context window?

Make your company AI-native.