How Prompts Actually Work
Back in Zero to GPT, you built self-attention from scratch, and the whole mechanism comes down to one fact, every token in the context window can pull information from every earlier token, weighted by relevance. That single fact explains almost everything in this course. Prompt engineering isn't a bag of magic phrases, it's the practice of deciding what text sits in the context window before the model starts generating, and that text is the only thing attention has to work with.
A model has no memory beyond its context window. It doesn't "know" your system prompt outranks the user's message because it understands hierarchy, it treats system-prompt tokens differently only because training taught it to weight them that way. This is the same fact the AI Security course's first lesson used to explain prompt injection, the same mechanism, just aimed at the opposite goal, there we were exploiting it, here we're using it on purpose.
Predict before you look
Before you toggle to few-shot, notice that the only difference between the two prompts below is three extra example lines. Do you expect that to change the model's answer, its format, both, or neither?
Toggle back and forth and notice what's actually happening. Few-shot prompting isn't teaching the model anything new in the training sense, no weights change, it's adding more tokens to the context window, and every one of those tokens is available for the attention mechanism to draw on when it generates the answer. A few-shot example showing the exact label format is mechanically no different from any other token the model attends to, it's just unusually well-placed precedent.
That's the lens for the rest of this course. Every technique below, chain-of-thought, role framing, self-consistency, chaining, is a different strategy for putting more useful tokens in front of the model before it answers.
Why does adding a few-shot example to a prompt change the model's output, even though no training happens?