Explain zero-shot, one-shot, and few-shot prompting with examples.
Zero-shot, one-shot, and few-shot prompting explained with clear examples and when to use each. Learn the difference between asking the model directly, giving a single example, and providing a small set of examples so you can pick the right prompting pattern.

TL;DR
- Zero-shot prompting asks the model to perform a task with only instructions and no examples.
- One-shot prompting gives a single example to show format, while few-shot gives a small set of examples to teach style and edge cases.
- Examples improve structure and reduce ambiguity, but they also increase token cost and can bias the model. Key tradeoffs: clarity versus cost and generalization versus example bias.
In this question, we will learn the difference between zero-shot, one-shot, and few-shot prompting and how to choose and craft each for real tasks. We will use simple examples so you can show the interviewer you know not only definitions but also when to use each pattern.
We will cover the following:
- The intuition
- How it actually works
- Practical prompting patterns
- When to use each
- Tradeoffs and failure modes
- Questions the interviewer might ask
- What the interviewer is really testing
Direct answer: Zero-shot means asking the model to do a task with instructions only; one-shot means providing a single illustrative example plus instructions; few-shot means providing a small set of examples plus instructions. Each step adds guidance that improves output consistency at the cost of more tokens and potential example bias.
The intuition (an analogy that makes it click)
Imagine teaching a student to solve a type of math problem. Zero-shot is like telling them the rules and saying try one now. One-shot is like showing a single solved example and then giving a new problem. Few-shot is like giving a handful of solved problems that show variations and edge cases. The more examples you show, the more the student understands the expected style and edge behavior, but you also spend time writing those examples and might accidentally teach a quirk.
How it actually works (the real mechanics, with one concrete worked example)
At the core, these patterns change the context the model conditions on. A zero-shot prompt contains only instructions. A one-shot prompt concatenates one example plus instructions. A few-shot prompt concatenates several examples plus instructions. The model predicts the next tokens given that context, so examples shape the conditional distribution of outputs.
Concrete worked example: sentiment labeling for short sentences.
Zero-shot prompt example:
"Label the sentiment of the sentence as Positive, Neutral, or Negative. Sentence: 'I loved the movie, it was inspiring.'"
One-shot prompt example:
"Label the sentiment of the sentence as Positive, Neutral, or Negative. Example: Sentence: 'The food was great and service was friendly.' Label: Positive Now label: Sentence: 'I loved the movie, it was inspiring.'"
Few-shot prompt example (three examples):
"Label the sentiment of the sentence as Positive, Neutral, or Negative. Example 1: Sentence: 'The food was great and service was friendly.' Label: Positive Example 2: Sentence: 'The package arrived late and parts were missing.' Label: Negative Example 3: Sentence: 'The product is okay but not special.' Label: Neutral Now label: Sentence: 'I loved the movie, it was inspiring.'"
Compare the expected behavior in a small table.
| Pattern | Context length | Typical effect on output |
|---|---|---|
| Zero-shot | Instructions only | Can be more variable, relies on clear instruction wording |
| One-shot | Instructions + 1 example | Shows format and style, often reduces ambiguity |
| Few-shot | Instructions + multiple examples | Teaches structure, edge cases, and desired style; higher token cost |
In practice you will see fewer formatting errors and more consistent phrasing as you move from zero-shot to few-shot, especially on open-ended or ambiguous instructions.
Practical prompting patterns
- Use zero-shot when the task is simple and instruction-following is enough, for example converting a date format or asking a factual question.
- Use one-shot when you need to show the exact output format, for example a single JSON schema or a specific label layout.
- Use few-shot when the task has subtle variations or you want the model to mimic a style across several edge cases, for example legal clause rewriting or grading essays.
A few practical tips:
- Keep examples diverse but concise. Examples that are too similar do not add much value.
- Put the most representative examples first if you must limit tokens.
- Use strictly formatted examples when you care about machine parsability, for example a single-line CSV or JSON.
When to use each
Zero-shot is efficient. Use it for high-level tasks, quick checks, or when you rely on a well-tuned instruction. One-shot is a pragmatic middle ground when format demonstration is the main need. Few-shot is the best choice when the task requires handling multiple subcases or capturing a writing style.
Example decision checklist:
- Do you only need a short answer with little format constraint? Consider zero-shot.
- Do you need a guaranteed format or label layout? Consider one-shot.
- Do you need consistent handling of edge cases or style? Consider few-shot.
Tradeoffs and failure modes
Examples bias the model. If your examples contain undesirable phrasing or mistakes the model may copy them. Few-shot also increases token usage which raises latency and cost. Zero-shot can return unexpected formats if instructions are ambiguous.
Examples can teach both what you want and what you do not want. If an example contains a subtle bias, punctuation quirk, or incorrect label, the model will often replicate that behavior. Always test prompts across varied inputs and watch for copying artifacts.
Other common failures:
- Overfitting to examples: the model imitates example-specific vocabulary.
- Under-specification in zero-shot: the model returns varied formats.
- Token limits: large few-shot prompts may exceed model context and truncate examples.
Questions the interviewer might ask:
Some follow-up questions you might get:
How do you pick examples for few-shot prompting? Choose examples that highlight common cases, edge cases, and the exact output format you need. Diversity across input structure but consistency in desired output is key.
Can few-shot prompts make the model worse? Yes. Poorly chosen examples can introduce bias or weird phrasing. Examples that contradict each other confuse the model and reduce reliability.
When should you switch from few-shot to fine-tuning? If you need consistent behavior at scale and can invest in a dataset, fine-tuning or instruction tuning is preferable for production use. Few-shot is useful for prototyping and low-volume tasks.
How do you evaluate prompt quality? Measure format compliance, correctness on held-out inputs, and human assessment of style. Track token cost and latency as well.
What about chain-of-thought examples? Showing step-by-step reasoning examples can elicit more thorough chains of thought, but it also increases token use and can leak sensitive logic.
Some things to note:
- Keep prompts short and precise when possible to save tokens.
- Test with inputs the model has not seen in examples to check generalization.
What the interviewer is really testing
They want to see you understand how model conditioning works and how examples shape outputs. They also want evidence you can balance clarity, token cost, and bias risks when choosing a prompting pattern. Finally, they are checking that you can craft practical, testable prompts and reason about failure modes.
Further reading in the curriculum
Go deeper on the fundamentals behind this question.
- Prompting and Context Engineering How to structure prompts and fill the context window so models produce reliable, grounded, and cost-efficient outputs.
Related questions
How would you rate the quality of this article?
Prepare for your AI engineering interview
This is one of many detailed questions and explainers on StudyAIDesign. Browse the full set, work through the curriculum, and walk into your interview ready.