When an LLM in a RAG pipeline behaves differently because of the retrieved context, what is actually changing about the model?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Retrieved context changes the input the model conditions on, not its weights. Same fixed θ, different prompt, different output distribution. No parameter update happens at query time.
Think of the model as a sealed calculator. You can't open it up and rewire it, that's what training does, and it's already done. What you can do is type different numbers in. RAG doesn't rewire the calculator; it just types better numbers in by pasting relevant documents into the prompt. The calculator runs the exact same logic it always did, but because the input is now richer, the answer comes out different and more grounded. People sometimes say in-context learning 'teaches' the model on the fly. It doesn't. Nothing inside the box changes. The model is the same function before and after; only what you fed it changed. That distinction matters a lot when an interviewer asks what RAG actually does to the model.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: fixed-θ function framing, prompt-as-conditioning vs weight editing, ICL research framings, and why RAG and fine-tuning compose.
| Aspect | RAG / in-context learning | Fine-tuning |
|---|---|---|
| What changes | The prompt (conditioning input) | The parameters θ |
| Persistence | Gone when the query ends | Durable across all future queries |
| Mechanism | Forward pass only, no gradients | Gradient descent on a training set |
| Math touched | Posterior P(y|prompt;θ) | θ itself (and thus the prior) |
| Best for | Fresh, private, query specific facts | Behavior, format, domain reasoning |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying RAG or in-context learning 'updates' or 'teaches' the model. The parameters never move at query time; only the conditioning input changes.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.