Guides · 5 min read

Chat with your own documents (local RAG)

How retrieval works, which models do the embedding, the settings that matter, and the apps that do it for you.

A model only knows what it was trained on, plus whatever fits in its context. To ask questions about your own files, you do not retrain anything. You use retrieval-augmented generation (RAG): find the passages that matter, then give them to the model with your question.

How it works

  1. Split your documents into chunks of a few paragraphs.
  2. Embed each chunk: an embedding model turns its meaning into a list of numbers.
  3. Store those vectors in a small database.
  4. Retrieve: embed your question the same way and pull the chunks whose vectors are closest.
  5. Generate: the chat model reads those chunks and your question, and answers from them.

How a question gets answered from your documents

1. Split

Your document40 pages
Chunk 1Chunk 2Chunk 3Chunk 4

Your documents are cut into chunks of a few paragraphs each.

2. Embed

Chunk 2
Embedding model
[0.12, −0.48, 0.91, …]

An embedding model turns the meaning of each chunk into a list of numbers, called a vector.

3. Store

Vector databaseone point per chunk

The vectors go into a small database on your machine. Chunks with similar meaning sit close together.

4. Retrieve

What is the notice period?
Chunk 2Chunk 4

Your question is embedded the same way, and the chunks whose vectors are closest are pulled out.

5. Generate

Chunk 2Chunk 4Your question
Chat model
Thirty days, in writing. [2] [4]

The chat model reads those chunks with your question, and answers from them.

Step 1 of 5
Two models take part: a small embedding model for steps 2 and 4, and the chat model for step 5. The document and answer here are made up for illustration.

Two models are involved. A small embedding model (a few hundred megabytes) handles steps 2 and 4, and your chat model handles step 5. Embeddings are specific to a model: if you switch embedding models you must re-embed everything.

Apps that do it for you

AnythingLLM is a desktop app with separate workspaces and visible sources. Open WebUI adds document chat to Ollama or any local API. Khoj searches your notes. GPT4All has LocalDocs built in, and PrivateGPT gives developers a ready-made document API. For your own pipelines, embedding servers such as Text Embeddings Inference and libraries such as Sentence Transformers run the embedding model.

Settings and mistakes that matter

Models tagged RAG are the ones that stick closest to the supplied text. Your documents stay on your computer throughout (privacy).

Was this guide useful?

Estimates come from published hardware specs and our open formulas, not from running the model on your machine. Real speed varies with runtime, drivers and settings. Numbers marked “Measured” come from a linked benchmark.