In this lesson
The prompt is the program
Keep every weight frozen, change the messages and examples in context, and watch the next-token distribution move.
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
- 11Promptingruntime contextNot started
- 12Reasoningthink in tokensNot started
- 13Groundingouter systemNot started
- 14Final tracewhole loopNot started
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
The toy bets 43.7% on apple. Add two examples above the same question and it bets 77.7% on orange. No training separates the two bets. What moved?
Only the text entering the model. The application assembles instructions, messages, examples, and earlier replies into runtime context. The model then bets on what follows that context.
In that sense, the prompt is a program - a probabilistic one, executed by behavior already stored in the weights.
Observe one frozen model
The instrument runs one tiny set of handcrafted weights, summarized on screen as a fingerprint: one short signature computed from every weight. It never changes.
Switch instructions and examples on or off. Only the input and the temporary numbers computed from it change. Training is locked out entirely. How far can text alone push the bet?
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?
Commit before manipulating the instrument. This choice is final.
Build the message that reaches one frozen toy model. Instructions and examples become tokens in its context; they do not rewrite its weights.
Turn on the role-formatted instruction first.
Live missions
- Flip the winner using context alone
- Bet on the examples and win the contradiction duel
Full text sent to the model
user: citrus fruit → assistant:7 tokens
weight fingerprint: fnv1a-38b2e9f9, unchangedNext-token distribution
Without guidance, the frozen toy prefers apple.
Handcrafted three-feature fixture with real logits and softmax. Effects add independently here; real prompts interact. Role markers matter because training taught the model to use them, not because “system” is magic.
Manipulate context, not weights
Start with examples set to None: the toy prefers apple. Turn on the role-formatted instruction and watch cat, the only non-fruit on the board, drop out of the running.
Now step the examples up. Does the bet flip at One example, or only at Two? Either way, the same weights processed a different sequence and produced different temporary values and logits.
Before the duel, mark the boundary: this fixture adds three authored effects. It encodes no universal hierarchy between system messages and examples.
Keep the Role-formatted instruction on, then turn on Contradictory instruction with Two examples still selected. The system line demands apple, the examples answer orange, and the bars hide until you back a winner.
After the reveal, drop to One example. Does the duel end the same way? Nothing here ranks system lines against examples in general.
Compare instruction alone with examples alone: which lever moves the odds further? Either way, you edited the program; the stored weights never moved.
Challenge Find the smallest context change that flips the winner. Name the lever you used: weights, context, or orchestration.
For a stretch, stage the duel with two examples and call the winner before the bars return. Then explain why this authored result does not establish a hierarchy for real models.
Compare your answer
The bet flips at one example, and two turn that lead into a rout. Only runtime context changed.
In this authored toy, two examples beat the contradictory instruction; a single one loses to it at 70%. Real effects interact through training and the whole prompt, so this result proves no universal hierarchy.
Explain roles and in-context learning
The role line you switched on comes from a chat template: it serializes structured messages into a token sequence, often with special tokens that mark each role.
Chapter 8’s next-token training, run over chapter 9’s mountain of text, is pretraining. Chapter 10’s later steering, including supervised fine-tuning and preference tuning, is post-training.
During post-training, the model sees formatted conversations. It learns to answer after a user marker, to give weight to whatever sits in the instruction slot, and to stop at a response boundary.
A system message is 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. You staged a harmless version of that fight yourself. When the competing instruction is hostile and planted by someone else, it is a prompt injection.
When that instruction arrives through a web page, retrieved document, or tool result, it is an indirect prompt injection. The hostile instruction travels as data inside the context.
Giving a few examples in the prompt is called few-shot prompting. The examples show a local pattern in context, and the existing network computes a new conditional distribution from parameters that stayed put.
- 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?
Pick an answer first.
Connect the model to the conversation
The assistant now has two levers. Post-training rewrites the weights. Prompting rewrites the program they execute.
In the next chapter, the model writes its intermediate work into that context. Can later tokens use it to improve the final bet?
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.
- Greshake et al. (2023) demonstrates indirect prompt injection through data retrieved by an LLM-integrated application.
- 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 28, 2026.