01
What a prompt is made of
A prompt is simply the text you send to an AI. It can be a question, a request or an instruction — anything you type into the box.
Most chat AIs today run on a large language model (LLM). An LLM doesn't write its whole answer at once. It looks at the text so far, picks the next small chunk of text (called a token), adds it on, and repeats. If you've seen your phone keyboard suggest the next word, it's a much bigger version of that. Because the model keeps building on what's already there, the words in your prompt steer the words it picks next. Prompt engineering is about using that on purpose: writing your prompt so the answer you want becomes the most likely one.
If you take a good prompt apart, you'll usually find the elements below. You won't need all of them every time — pick what the task calls for.
To keep things concrete, we'll follow one example through the whole guide: asking an AI to read shop reviews and tell us whether the customer was happy, unhappy, or a bit of both. We'll start with a one-line request. Each time the answer falls short, we'll look at why and add the technique that fixes it. The right-hand column shows what each element looks like in our example.
| Element | What it does | In our review example |
|---|---|---|
| Instruction | Tells the model what task to do | Classify the sentiment of the review |
| Context | Gives background the model needs to judge well | These are reviews from an electronics store |
| Input data | The thing to work on | Review: Shipping was slow, but the product is excellent |
| Output format | The shape the answer should take | One of positive, negative or mixed, as one line of JSON |
| Examples | Sample inputs paired with the answers you want | Review: Tastes great but the portion is small → mixed |
| Constraints | What the answer should avoid | Do not add an explanation |
Every chapter comes with a 3D scene of this example. The stacked blocks on the left are what we send (the prompt), the sphere in the middle is the AI model, and the bars on the right are answers the model might give. The taller the bar, the more likely that answer. The bar heights are made-up numbers chosen to show the trend, not real measurements.
In the first scene, try adding the elements one at a time. With just the instruction and the review, the bars are all over the place. As you add more, the bar for the answer we're after — "mixed, as JSON" — climbs.
- mixed (JSON) 6%
- "Positive" 30%
- A paragraph 40%
- positive (JSON) 4%
- "Negative" 20%
Review sentiment classification — input: "Shipping was slow, but the product is excellent"
Only the instruction and the review. Nothing says what shape the answer should take or how to judge, so the answers scatter.
A few basic tips
The companies that build AI services give much the same advice in their prompt-writing guides:
- Say what you want briefly, clearly and completely.
- Put the question or instruction at the end, after the material it refers to.
- Use delimiters (such as quotes or tags) to keep instructions and data apart, and spell out the answer format.
- Tell the model what to do if it doesn't know — for example, "If you don't know, say 'I don't know.'"
- Tweak your prompt on practice data, then test it once on data you set aside.
Which elements you include is what gives each technique its name. Just an instruction and input? That's zero-shot. Add examples and it becomes few-shot. Ask for the reasoning and it's chain-of-thought. Let's start with zero-shot, the simplest of the three.
02
Asking without examples (zero-shot)
Zero-shot prompting means you describe the task without giving a single example — the "zero" is the number of examples. Most of what people type into an AI chat box is zero-shot, like this:
Classify the sentiment of the review. Review: Shipping was slow, but the product is excellent
The model has already learned from a huge amount of text, so it understands a request like this without any examples. For things models already do well — summarizing, translating, common kinds of classification — zero-shot is often all you need. There's nothing to prepare and the prompt is short, so it's also the cheapest option.
Where it falls down is the shape of the answer. Our prompt doesn't say what format to use, or what to do with a review that has both praise and complaints. So the model goes with whatever seems reasonable: "Positive" one time, a whole paragraph the next, JSON the time after that. A person can read any of those just fine, but if a program has to process the answer, that inconsistency is a real problem.
- mixed (JSON) 6%
- "Positive" 30%
- A paragraph 40%
- positive (JSON) 4%
- "Negative" 20%
Review sentiment classification — input: "Shipping was slow, but the product is excellent"
Zero-shot: with no examples, the model decides for itself what "classify" should look like. Sometimes you get one word, sometimes a whole paragraph.
If a question says… → pick this
- “Gives only a task description, with no examples”Zero-shot
- “Without sample examples or additional training data”Zero-shot
- “The answer format comes out different every time”Add examples (few-shot)
The answers wobble because the model has no idea what kind of answer we want. We could describe the format and the rules in detail, but it's usually quicker to just show it.
Advertisement
03
Showing the answer you want (one-shot, few-shot)
Few-shot prompting means adding a few examples to your prompt so the model can see what kind of answer you're after. Each example pairs an input with the answer you'd want for it. Use one example and it's called one-shot; use two or more and it's few-shot. Some exams call one-shot "single-shot".
Classify the sentiment of the review.
Review: Carefully packed
Answer: {"label":"positive"}
Review: Tastes great but the portion is small
Answer: {"label":"mixed"}
Review: Shipping was slow, but the product is excellent
Answer:Why does the model copy the examples?
Remember from chapter 1 that the model picks what comes next by looking at the text before it. In the prompt above, "a review, then one line of JSON" happens twice. So after the third review, the most natural thing to write is another line of JSON in the same shape. The model hasn't learned anything new — it's just continuing the pattern it sees. This is called in-context learning.
The name trips a lot of people up, because nothing is actually learned in the usual sense: the model itself doesn't change. Leave the examples out of your next request and it won't remember them at all. That means you have to send the examples every time, and the longer prompt costs a bit more each time.
In the scene below, raise the number of examples from 0 to 5. The JSON format falls into place after just one or two. But the rule "praise plus complaints means mixed" only sinks in once the third example — a review like that — is added. What your examples show matters more than how many you use.
- mixed (JSON) 6%
- "Positive" 30%
- A paragraph 40%
- positive (JSON) 4%
- "Negative" 20%
Review sentiment classification — input: "Shipping was slow, but the product is excellent"
Zero-shot: with no examples, the model decides for itself what "classify" should look like. Sometimes you get one word, sometimes a whole paragraph.
Picking good examples
- Choose examples that look like the reviews you'll actually get.
- Include the tricky cases. If every example is easy, the model will wobble again when a hard one shows up.
- Mix up the answers. If every example is positive, the model will lean positive too.
- Keep every example in exactly the same format. Messy examples lead to messy answers.
If a question says… → pick this
- “Shows a few examples of the desired output first”Few-shot
- “Includes exactly one example”One-shot (single-shot)
- “Includes input–output pairs in the prompt”Few-shot
- “Says adding examples retrains the model”Wrong — the model doesn't change (that would be fine-tuning)
Examples pin down the answer's shape and the rules for judging. But for problems that take several steps to work out, examples alone aren't enough. If the examples only show final answers, the model tends to skip the working and jump to a number that just looks right.
Pro only
That’s the free part of this guide
The other 5 chapters are open to Pro subscribers. Each one continues with 3D visuals and “if a question says…” tips, and the last chapter lets you check yourself with a short quiz.
- 04Chain-of-thought
- 05Negative prompts
- 06Prompt templates
- 07Choosing a technique
- 08Attacks on prompts
PasslyExam
You have read the concept. Now test it on exam questions
PasslyExam offers original practice questions, explanations and full mock exams built around each certification’s exam guide. The explanations cover why the right option is right and why the look-alike options are wrong. Sign up to practice for free every day.