In this lesson
The prompt is the program
Course
From text to chatbot
Course order, not one forward pass.
I · From text to representations
II · Inside the Transformer
III · Prediction and learning
IV · From model to chatbot
- 09Assistantchanges weightsNot started
- 10Promptingruntime contextNot started
- 11Groundingouter systemNot started
- 12Final tracewhole loopNot started
Keep every weight frozen, change the messages and examples in context, and watch the next-token distribution move.
By the end, you can
- Demonstrate that instructions and examples can change a prediction without changing model weights.
- Explain message roles as formatted context learned during post-training, not an infallible authority system.
Before you start: From raw continuer to assistant
You rarely hand a chatbot one bare sentence. The application wraps a conversation into role-formatted text: system instructions, developer instructions, user messages, examples, and earlier replies. Then the model plays the same old game from chapter 1: predict what token follows this entire context.
Observe one frozen model
The instrument has one tiny set of handcrafted weights. Its fingerprint never changes. Switch instructions and examples on or off; only the text entering the model and the temporary numbers computed from it change. This isolates prompting from training.
Predict what examples can move
Your bet
If two examples make orange the pattern for a citrus query, what must change inside the frozen toy?
Nobody grades this. Commit, and let the instrument settle it.
Build the message that reaches one frozen toy model. Instructions and examples become tokens in its context; they do not rewrite its weights.
Live missions
- Flip the winner using context alone
- Compare instruction-only with examples-only
- Make two examples beat a contradictory instruction
Full text sent to the model
user: citrus fruit → assistant:
weights: frozen-toy-v1, unchangedNext-token distribution
Without guidance, the frozen toy prefers apple.
Handcrafted three-feature fixture, real logits and softmax. Role markers matter because post-training taught the toy how to use them, not because “system” is a magical command channel. The three features are summed independently here; a real model’s instructions, examples, and their order interact non-linearly, not as separate additive terms.
Manipulate context, not weights
Start bare, examples set to None: the toy prefers apple. Switch on the role-formatted instruction and the animal option loses probability. Now step the examples radio from None to One example to Two examples and watch orange climb into first place. The same coefficients processed a different sequence, so they produced different temporary internal values and logits.
Then stage a fight. Turn on Contradictory instruction: the system line now insists outright that the fruit is always apple, straight against the citrus demonstrations. With the instruction on and two examples showing, the examples still win and orange holds the lead - that is the moment the prompt-example-beats-instruction mission fires. Compare instruction alone with examples alone (the prompt-compare-sources mission wants you to visit both) and hunt for the smallest change that flips the winner (prompt-context-flip). Prompting is not a tiny training run. It is a program written in the model’s input language and executed by the behavior already stored in its weights.
Challenge Three missions. One: find the smallest context change that flips the winner, then name the lever you used - weights, context, or orchestration. Two: compare instruction alone with examples alone, and predict which wins in this toy. Three: with the role instruction on, turn on the contradictory instruction that demands apple, then add examples until a citrus demonstration overrides the order outright. Explain why neither kind of prompt is a guarantee in a real model.
Compare your answer
Turning on the examples is enough to move orange into first place, and only runtime context changed. Instruction alone nudges the bet; two examples override even a contradictory order, because in this authored toy the demonstrations carry the largest contextual effect. A real model’s response depends on its training, the whole prompt, and how instructions and examples interact rather than add up cleanly, so no single format is an infallible command.
Explain roles and in-context learning
A chat template turns structured messages into tokens or special role markers. Time to pin down two names: what chapter 8 called simply training - the long next-token grind over a mountain of text - is pretraining; chapter 9’s finishing school, supervised fine-tuning and preference tuning together, is post-training. During post-training, the model sees many such conversations and learns regularities: continue after a user marker with an answer, treat some instruction positions as important, imitate demonstrations, stop at certain boundaries.
That makes a system message influential context, not a secure command register inside the Transformer. Its influence comes from formatting, training, and sometimes application-side enforcement. It can conflict with other context or be followed imperfectly. When a competing instruction is slipped into that context - buried in a user message, a web page, or a retrieved document - and the model follows it instead of the system message, that is prompt injection: the security hole that falls straight out of treating instructions as ordinary text.
Giving a few examples in the prompt - often called few-shot prompting - uses the same mechanism. Examples in the context show a local pattern. No parameter update occurs; the existing network computes a new conditional distribution.
- Frozen machinerysame weight fingerprint
- Different inputroles + instruction + examples
- Different temporary resultnew logits, new next-token bet
Reflect on the frozen fingerprint
Checkpoint
The prompt changes the answer while the weight fingerprint stays fixed. What happened?
Connect the model to the conversation
The assistant now has two distinct levers. Post-training changes weights. Prompting changes runtime context. The next lesson adds a third lever outside the model: an orchestrator can retrieve evidence or call a tool, then place the result back into context. That helps with truth, but it creates a new question: what happens when the evidence is missing or misleading?
Sources and scope
- Brown et al. (2020) demonstrates in-context learning from instructions and examples without gradient updates.
- Perez & Ribeiro (2022) names and demonstrates prompt injection, where instructions placed in the context override the intended ones.
- The lab’s three effects are handcrafted, while its logits and softmax are computed live. It demonstrates the boundary between frozen weights and changing context, not a universal prompt hierarchy.
- Content and claims reviewed on July 20, 2026.