← AI for Professionals: Using LLMs at Work
Lesson
Lesson 1: Examples (few-shot) and step-by-step reasoning
Apply few-shot examples and chain-of-thought (step-by-step) prompting, and choose which technique fits a given task.
Few-shot and chain-of-thought: what they are and when to use them
Few-shot and chain-of-thought: what they are and when to use them
When you give the model a prompt with no examples, that is called zero-shot: you simply describe the task and let the model figure out the format and tone on its own. Zero-shot works for simple, common tasks — 'Summarize this email in one sentence.' But the moment you need a very specific format or tone, zero-shot often misses the mark.
Few-shot prompting means you include one to three completed examples inside the prompt before your actual request. Each example shows the model the input–output pattern you expect. Even one well-chosen example teaches format and tone far better than a long description. Keep examples consistent: if they vary in style, length, or structure, the model learns the wrong pattern and the results become unpredictable.
Chain-of-thought (CoT) prompting asks the model to reason through a problem step by step before giving the final answer. The simplest trigger is the phrase 'Think step by step' at the end of your prompt. This technique helps on multi-step tasks — calculations, logical puzzles, root-cause analysis, decision trees — where jumping straight to an answer increases the chance of error. For simple one-step tasks (e.g., translating a single word), CoT adds no value and just slows things down.
Here is a worked few-shot prompt for classifying customer feedback:
Example 1 — Input: 'Delivery was two days late.' → Label: COMPLAINT
Example 2 — Input: 'The packaging was beautiful.' → Label: COMPLIMENT
Now classify: Input: 'I never received a refund.' → Label:
And a worked chain-of-thought prompt:
'A project has 5 tasks. Tasks A and B must finish before C can start. Task D depends on C. Task E is independent. What is the minimum number of sequential steps to complete all tasks? Think step by step.'
Lesson notes
Few-shot and chain-of-thought: what they are and when to use them
When you give the model a prompt with no examples, that is called zero-shot: you simply describe the task and let the model figure out the format and tone on its own. Zero-shot works for simple, common tasks — 'Summarize this email in one sentence.' But the moment you need a very specific format or tone, zero-shot often misses the mark.
Few-shot prompting means you include one to three completed examples inside the prompt before your actual request. Each example shows the model the input–output pattern you expect. Even one well-chosen example teaches format and tone far better than a long description. Keep examples consistent: if they vary in style, length, or structure, the model learns the wrong pattern and the results become unpredictable.
Chain-of-thought (CoT) prompting asks the model to reason through a problem step by step before giving the final answer. The simplest trigger is the phrase 'Think step by step' at the end of your prompt. This technique helps on multi-step tasks — calculations, logical puzzles, root-cause analysis, decision trees — where jumping straight to an answer increases the chance of error. For simple one-step tasks (e.g., translating a single word), CoT adds no value and just slows things down.
Here is a worked few-shot prompt for classifying customer feedback:
Example 1 — Input: 'Delivery was two days late.' → Label: COMPLAINT
Example 2 — Input: 'The packaging was beautiful.' → Label: COMPLIMENT
Now classify: Input: 'I never received a refund.' → Label:
And a worked chain-of-thought prompt:
'A project has 5 tasks. Tasks A and B must finish before C can start. Task D depends on C. Task E is independent. What is the minimum number of sequential steps to complete all tasks? Think step by step.'