LLM Basics
Lesson 1 of 6

How Prompts Actually Work

Back in Zero to GPT, you built self-attention from scratch: 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, because 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 is more important than the user's message because it understands hierarchy — it treats system-prompt tokens differently only because training taught it to weight them that way (the same fact the AI Security course's first lesson used to explain prompt injection — same mechanism, opposite goal here: instead of exploiting it, we're using it on purpose).

Predict before you look

Before you toggle to few-shot: 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?