AI prompting: few-shot
This course covers few-shot prompting: showing a model examples of the mapping you want instead of describing it. It starts with when examples work better than instructions and what they cost in tokens. It then covers how to build a consistent example set, how many examples to use, and how to choose them with fixed sets or dynamic vector search. Later lessons cover majority label, recency and common token biases, structured outputs that replace formatting examples, storing examples as data in Rails, and evaluation that keeps prompts from decaying.
What you'll learn
- ✓When examples work better than instructions, and their token cost
- ✓How to build a consistent example set that covers the decision boundary
- ✓How many examples to use, and fixed versus dynamic selection
- ✓How to detect and reduce majority label, recency and common token biases
- ✓When a JSON schema or strict tool definition replaces formatting examples
- ✓How to store, test and evaluate example sets in a Rails app
When examples beat instructions
You need every incoming support message classified as bug, billing, feature_request or other. You write the instruction carefully:
Read the full lesson free →Curriculum
7 lessonsWhen examples beat instructions
Shows when demonstrating output beats describing it, what examples teach well, and what they cost per request.
The anatomy of a good example set
Explains consistent formatting, XML delimiters, boundary cases, full label coverage and why a wrong example can become a rule.
How many examples, and which ones
Covers how accuracy flattens as examples grow, fixed versus dynamic selection, and the caching cost of dynamic examples.
Majority, recency, and token biases
Describes majority label, recency and common token biases, how to mitigate them, and how to test order sensitivity.
When a schema replaces examples
Shows how structured outputs and strict tool schemas handle output shape, leaving examples for judgment, tone and policy.
Examples as data in Rails
Stores examples as database rows in Rails, with separate objects for selection, rendering and the API call.
Measuring, and keeping it from rotting
Builds a held-out evaluation set, changes one thing at a time, and adds CI checks against prompt decay.