Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

What is the difference between an LLM's training data, its context, and retrieval-augmented generation? Why does a model sometimes state wrong facts confidently?

Training data is what the model learned from before release; it shaped the model's weights, has a cutoff date, and cannot be looked up as documents. The context is the text we send in the current request, and the model can only use its weights and that context. Retrieval-augmented generation (RAG) fetches relevant documents at request time and puts them into the context, so answers can be grounded and cited. Models still state wrong facts confidently because they generate likely text, not verified facts.

Why this question is asked

A common first reaction to an LLM is to treat it like a database that knows everything. Then it confidently invents a refund policy, quotes a Java API that does not exist, or gets last month's price wrong, and the team is confused. Interviewers ask this question to check whether we understand where a model's knowledge actually comes from, because that decides how we design every feature that depends on facts. In this answer, we will separate training data from context, see how RAG connects the two, understand why hallucinations happen, and look at the practical ways to reduce them.

1Training Data: What the Model Learned Before We Met It

A model is trained on a very large collection of text: web pages, books, code, documentation and more. Training does not store those documents somewhere the model can open later. Instead, it adjusts billions of numbers, the weights, so that the model gets better at predicting the next token. Whatever the model knows from training is spread across those weights, a bit like what we remember from books we read years ago: general patterns are strong, specific details are fuzzy.

Training also has a cutoff date. A model trained on data up to some month knows nothing about events, releases or prices after it. And it has never seen our company's private documents unless they were somehow public. So when we ask about our own refund rules, the weights simply do not contain the answer.

2Context: The Only Other Thing the Model Can Use

The context is everything we send in the current request: the system prompt, the user's message, earlier turns of the conversation and any documents we paste in. At answer time, the model has exactly two sources: its weights and this context. It cannot browse, query our database or remember yesterday's request unless our code puts that information into the context or gives it a tool to fetch it.

This is the key idea. If we want an answer based on our refund policy, the policy text has to be in the context. The model is very good at reading what we give it and answering from it, and much less reliable when it has to recall details from training.

Java
// Without context: the model can only guess from its weights
chatClient.prompt().user("How many days do customers have to request a refund?").call().content();
// "Most companies allow 30 days..." (plausible, but not our policy)
// With context: the answer comes from text we supplied
chatClient.prompt()
.system("Answer only from the policy below. If it does not say, answer: not stated.")
.user("POLICY:\n" + refundPolicyText + "\n\nQUESTION: How many days do customers have to request a refund?")
.call().content();
// "14 days from delivery (section 3.2)."

3RAG: Putting the Right Documents Into the Context

We cannot paste every company document into every request; it would not fit in the context window, and it would be slow and expensive. Retrieval-augmented generation solves this. Ahead of time, we split documents into chunks, turn each chunk into an embedding (a list of numbers that captures its meaning) and store them in a vector store. At request time, we embed the user's question, find the few chunks whose embeddings are closest, and put only those chunks into the context with the question.

So RAG does not change the model at all. It changes what the model sees. That gives it two big advantages: the answer can cite the chunk it came from, so a user can check it, and updating knowledge is just re-indexing the changed documents, with no training involved.

Java
List<Document> chunks = vectorStore.similaritySearch(
SearchRequest.builder().query(question).topK(4).build()); // 4 most similar chunks
String sources = chunks.stream()
.map(d -> "[" + d.getMetadata().get("source") + "] " + d.getText())
.collect(Collectors.joining("\n\n"));
String answer = chatClient.prompt()
.system("Answer from the sources only and cite them in brackets. If they do not answer it, say so.")
.user("SOURCES:\n" + sources + "\n\nQUESTION: " + question)
.call().content();
// "Refunds can be requested within 14 days of delivery [refund-policy.pdf]."
Step throughA RAG request
  1. User asks a question
  2. Embed the questionthe same embedding model used for the documents
  3. Search the vector storetop 4 closest chunks
  4. Build the promptinstructions + chunks with sources + question
  5. Model answers from the contextand cites the chunks it used
  6. Do the sources answer it?
    YesAnswer with citationsNoSay the documents do not cover it

6 steps in order. Play them, or step through them one at a time.

The model is unchanged; only what it sees in the context changes.

Spring AI also provides advisors that do this retrieval automatically around a ChatClient call; the manual version above just makes each step visible.

4Why Models State Wrong Facts Confidently

A model generates the most likely continuation of the text, one token at a time. It has no separate step that checks a fact against a source, and no built-in sense of how sure it is. When it knows a fact well from training, the likely continuation is the true fact. When the fact is rare, recent or missing, the likely continuation is something that sounds right: a realistic policy, a plausible method name, a believable citation. The tone is equally confident in both cases, because confidence is a style of writing, not a measure of truth. This is what we call a hallucination.

Hallucinations are most common for rare details (a small library's API), recent facts after the cutoff, exact numbers and dates, and questions that assume something false (asking for the 2019 version of a document that never existed). They also happen with RAG when retrieval returns the wrong chunks, because the model will answer from whatever it was given.

5How We Reduce Hallucinations

We cannot remove them completely, but we can make them rare and visible. Grounding is the main tool: retrieve the right sources and instruct the model to answer only from them, with permission to say the answer is not there. Asking for citations makes answers checkable, and our code can verify that each cited source was actually in the context. Constraining the output, for example to a fixed list of categories or a JSON schema, leaves less room to invent. Finally, we evaluate: we keep a set of questions with known correct answers and measure how often the feature is right, before launch and after every prompt or model change.

Where an answer can come from
SourceWhen it is setFresh?Can it cite?
Training data (weights)Before the model was releasedNo, has a cutoff dateNo
Context we sendIn each requestAs fresh as our dataYes, if we label it
RAGRetrieved at request time into the contextYes, after re-indexingYes, chunk sources

6Follow-up questions

If we fine-tune the model on our documents, will it stop hallucinating about them?

Usually not. Fine-tuning adjusts the weights and is good at teaching a style or a format, but it stores facts in the same fuzzy way as pre-training, so the model can still mix them up, and every policy change would need another training run. For facts that change and must be cited, RAG is the better tool.

Why does a RAG system still give wrong answers sometimes?

Most often because retrieval failed: the right chunk was not among the top results, chunks were split in the middle of a rule, or an old version of a document was indexed. The model then answers from the wrong text. We evaluate retrieval separately, checking whether the correct chunk was returned, before blaming the model.

Does a model know what its own training cutoff is?

Not reliably. It may state a date it saw in training text, but it has no clock and no record of its own training. If the current date matters, our code should put it in the system prompt.

7Conclusion

In this answer, we saw that training data shaped the model's weights before release, has a cutoff, and cannot be looked up as documents. The context is what we send in each request, and together with the weights it is all the model can use. RAG retrieves relevant chunks at request time and places them in the context, so answers are grounded, fresh after re-indexing and citable. Models hallucinate because they generate likely text rather than verified facts, and we reduce that with grounding, citations, constrained outputs and evaluation on known questions.

What to say in the interviewAbout 90 seconds aloud

Open with

I separate three things. Training data is what the model learned from before release; it changed the weights, it has a cutoff date, and the model cannot open those documents later, so details are fuzzy and anything recent or private is missing.

Then, if they want more

The context is the text in the current request, the system prompt, history and anything we paste in, and at answer time the model can only use its weights plus that context. It has no memory or live access unless our code provides it.

RAG is how we get the right knowledge into the context: we chunk and embed our documents into a vector store, embed the question at request time, retrieve the closest chunks and put them in the prompt, so the answer is grounded, can cite sources, and stays current just by re-indexing.

Models state wrong facts confidently because they generate the most likely continuation, not a checked fact, and the tone is the same whether the fact is known or invented, especially for rare or recent details.

To reduce that, I ground answers in retrieved sources and allow the model to say it does not know, ask for citations and verify them, constrain outputs with schemas or fixed labels, and keep an evaluation set of questions with known answers that runs whenever the prompt or model changes.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference between an LLM's training data, its context, and...": https://scrivio-interview-library.netlify.app/spring-boot/llm-fundamentals/6362b7ea92/