← All articles

PRIVIOT BLOG

RAG explained: How AI uses your own documents

RAG lets an AI model look things up in your own documents before it answers. How it works and where its limits are.

In short: RAG (retrieval-augmented generation) is a method where an AI model receives matching passages from your documents before it answers. This lets it answer questions about content that is not in its training data.

A language model only knows what was in its training data. It does not know your contracts, notes, or internal handbooks. Retrieval-augmented generation, or RAG, closes that gap: before each answer, the model receives matching excerpts from your documents.

The principle in four steps

  1. Split: Your documents are divided into short chunks, typically a few paragraphs long.

  2. Index: Each chunk is converted into a vector of numbers, called an embedding. Similar content ends up close together.

  3. Search: When you ask a question, it is converted into a vector as well. The system looks for the chunks that match best.

  4. Answer: The retrieved chunks are passed to the language model together with your question. The model writes an answer and, ideally, cites its source.

Why not just paste everything into the chat?

That works for a few pages. With hundreds of documents, the content no longer fits into the model’s context window, and long inputs make answers slower and more expensive. RAG selects only the relevant passages.

Where RAG reaches its limits

  • Bad search, bad answer: If the search returns the wrong chunk, the model still answers, just on the wrong basis.

  • Broken context: If a table or a condition is split across two chunks, the model may miss the crucial half.

  • Hallucinations are still possible: RAG reduces the risk of invented statements but does not eliminate it. Source citations help you verify.

  • Outdated indexes: When a document changes, the index must be updated. Otherwise, the system answers with old information.

RAG and privacy

For confidential material, what matters is where the three components run: creating embeddings, the vector database, and the language model. Many online services transfer your documents to their servers and store them there. Local setups keep the index and model on your computer, with the trade-off that smaller models and limited hardware reduce quality.

Before using a RAG tool, ask: Are documents stored permanently? Who can access the index? Can individual files be removed completely?

Typical use cases

  • Questions across a large collection of manuals or policies

  • Searching your own notes and meeting minutes

  • Support answers based on a knowledge base

Frequently asked questions

Is RAG the same as fine-tuning?

No. Fine-tuning trains the model itself further. With RAG, the model stays unchanged and receives the information with each question.

Can RAG run locally?

Yes. Embeddings, the vector database, and the language model can all run on your own computer. Quality then depends on your hardware and model size.

Conclusion

RAG combines a search engine with a language model. Its quality depends more on good preparation and retrieval than on the model itself. For sensitive documents, the most important question is where the index and model run.

And Priviot?

Priviot apps run their core features locally on your device. The transparency page explains which online services are optional and which data they transfer.