Why the Model Does Not Know Your Documents
A language model writes fluent answers about almost anything, yet it cannot tell you what your own company handbook, your notes or last week's policy change say, because it has never read them. What works is placing the right text in the request beside the question, so the model answers from it. This page explains where a model's knowledge comes from, what a single request to a model contains, and why the useful version of this idea, called retrieval-augmented generation, sends a few well-chosen passages instead of every document you own.
What a model learned, and when it stopped learning
A language model is a program trained to continue text. During training it reads a very large collection of text, mostly public: web pages, books, articles, code. Training adjusts millions or billions of internal numbers, the model's weights, until the model is good at predicting what comes next. Whatever the model "knows" about the world is stored in those weights, compressed and blended, not as a library of documents it could open and quote.
Training happens once, on text gathered up to a certain date. Model providers publish that date as the model's knowledge cutoff. After training, the weights are fixed: the model does not keep reading, and nothing written after the cutoff reaches it.
That leaves three kinds of documents outside the model's knowledge:
- Private documents, such as an internal wiki, a contract or a support handbook, were never in the training text, because nobody published them.
- Recent documents were written after the cutoff.
- Changing documents may have been seen in an older version, so what the model learned is now out of date, and it has no way of noticing.
- Training text gathered mostly public text
- Knowledge cutoff weights are fixed
- Model released
- Your policy changes never seen by the model
- You ask about it
Asked about such a document, a model does not stay silent. It has learned what answers to questions like yours usually look like, so it produces a plausible one: a typical number of leave days, a common refund rule. The answer reads as confident as a correct one, which is what makes it hard to catch.
True or false?
A model that was trained before your document was written can still answer correctly about it, as long as the document is published online.
False. Publishing it changes nothing for a model that has already been trained. Its weights hold only what was in its training text, gathered before the knowledge cutoff.
When a model has never seen the answer to a question, it often still gives an answer that sounds certain.
True. The model generates text that fits the question. Without the real fact, it fills the gap with what similar answers usually say.
One request to a model
Programs reach a language model through an API: they send it a request over the network and get a reply. Many providers accept the same request format, called Chat Completions, which OpenAI first defined, and so do local model servers that run on your own machine. The openai Python package is a client for this format. Pointing the client at a different base_url is enough to talk to another provider that implements it.
A request needs two things. The model is the name of the model to run. The messages are a list of dictionaries, each with a role (who is speaking, usually user for the text you send) and a content (the text itself). The reply comes back as generated text.
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["BASE_URL"],
api_key=os.environ["API_KEY"],
)
completion = client.chat.completions.create(
model=os.environ["MODEL"],
messages=[
{"role": "user", "content": "How many days of leave carry over to next year?"},
],
)
print(completion.choices[0].message.content)The reply can hold several alternative answers, called choices; by default there is one, so choices[0].message.content is the text. The address, the key and the model name are read from environment variables here, so the same code runs against a hosted provider or a model on your own computer. (A local server may ignore the key, but the client still requires a value.)
The most important property of this call is what it leaves out. Each request is independent and stateless: the model sees the messages in this one request and nothing else. It does not see your files, your database or your earlier requests. Even a chat that seems to remember works by sending the earlier messages again inside every new request.
- Your program
- Model API
- Your program to Model API: model + messages
- Model API to Your program: generated text
True or false?
If your program has a document open, the model can read it during the call.
False. The model receives only the request. A document reaches it only when its text is placed inside one of the messages.
To continue a conversation, the earlier messages have to be sent again in the next request.
True. Requests are stateless. A conversation exists only because the program resends its history each time.
Giving the model the page it needs
The model sees only the request, but it does see everything in the request. That is the way in. The text you send is called the prompt, and it can carry more than the question: it can carry the page that holds the answer. Text added beside the question to give the model facts at question time is called context.
The prompt below places the policy page before the question and adds an instruction: answer from this text. The instruction matters because without it the model may mix the page with what it learned in training, and you want the page to win.
with open("leave-policy.md") as f:
page = f.read()
prompt = (
"Answer the question using only the text below.\n\n"
f"Text:\n{page}\n\n"
"Question: How many days of leave carry over to next year?"
)
completion = client.chat.completions.create(
model=os.environ["MODEL"],
messages=[{"role": "user", "content": prompt}],
)The model, the question and the code are the same as before. The only difference is the text in the message, and it changes the result: where the bare question gets a guess, the question with the page gets the number the page states. The model has not learned anything new. Its weights are unchanged, and the next request without the page gets a guess again. What the model is good at, reading a passage and answering a question about it, now works on your facts.
| What the request holds | Where the answer comes from | What you get |
|---|---|---|
| The question only | Patterns learned in training | A plausible guess |
| Instruction, page and question | The page in the prompt | The answer the page gives |
True or false?
Once a model has answered correctly from a page in its prompt, it can answer the same question later without the page.
False. Putting text in a prompt does not change the weights. Every request starts from the same trained model, so the page has to be sent each time.
Retrieval-augmented generation: find first, then answer
Putting the page in the prompt works when you already know which page answers the question. In practice someone asks a question about a whole collection of documents, and the program has to find the right text by itself. Adding that search step gives the pattern called retrieval-augmented generation, or RAG, a name introduced in a 2020 research paper by Lewis and colleagues (arXiv:2005.11401).
It runs in two stages for every question:
- Retrieval: search the documents for the passages that bear on the question and keep the few that fit best.
- Generation: send those passages to the model as context, with the instruction to answer from them, and let it write the answer.
- Question
- Search the documents
- A few passages
- Prompt instruction, passages, question
- Model
- Answer with its sources
The paper describes this as combining two kinds of memory. The model's weights are its parametric memory: fixed at training time, and impossible to inspect line by line. The searchable documents are a non-parametric memory: plain text you control. That split explains what retrieval adds:
- Your facts, kept current. Editing a document changes the next answer. Nothing has to be retrained.
- A traceable answer. The program knows exactly which passages it sent, so it can show them beside the answer. A reader can open the source and check, instead of trusting the model's memory, which cannot say where its knowledge came from.
It also means an answer can go wrong in two places: the search can miss the passage that holds the answer, or the model can misread the passage it was given.
True or false?
In retrieval-augmented generation, the model is retrained on your documents so that it remembers them.
False. The model stays as it is. Your documents are searched for each question, and the passages found are sent in the prompt.
Because the program chooses the passages it sends, it can show which documents an answer was based on.
True. The passages are known before the model is called, so they can be listed as the sources of the answer.
Why a few passages beat every document
If the model reads whatever is in the prompt, why search at all? Why not send every document with every question? Today's models accept very long prompts. Models read text as tokens, small pieces of words, and providers count and bill text in tokens. The most a single request can hold, the prompt and the reply together, is called the context window, and some models accept a million tokens in it. A small handbook would fit.
It would fit, and it would still serve you worse, for three reasons that all grow with the length of the prompt:
- Cost. Providers charge per token, and every token sent in the prompt is billed as input, on every question.
- Waiting time. The model has to process the whole prompt before it writes the first word of its answer, so a long prompt delays the reply.
- Accuracy. Models get worse at finding and using a fact as the text around it grows. Anthropic's documentation calls this context rot: "As token count grows, accuracy and recall degrade." A study of long inputs found that models often miss facts placed in the middle of a long input, even models built for long inputs.
- Focused prompt about 300
- Full prompt about 113,000
In the test behind this chart, from Chroma's Context Rot report, models answered the same questions from either a short, focused prompt or the full material of about 113,000 tokens, and they did significantly better with the focused prompt. The focused prompt is also the cheaper and faster one. A small, precise context is not a compromise forced by a size limit: it is the better input. Retrieval is how you build it, by choosing the few passages that bear on this question and leaving out the rest.
True or false?
If all your documents fit in the context window, sending all of them gives the most accurate answers.
False. Accuracy and recall drop as the prompt grows, so the relevant fact is easier to miss in a long prompt. Fitting is not the same as being read well.
Sending fewer tokens per question lowers both the cost and the waiting time of each answer.
True. Input tokens are billed one by one, and the model must process the whole prompt before it starts to reply.