AI / A CONCEPT NOTE
Few-Shot Prompting
providing examples to guide the model
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Injecting a few examples (inputs and expected outputs) inside the prompt template to show the model the target format and style before asking the actual question.
02 / FOLLOW THE MECHANISM
How few-shot instructs run
Pattern examples
prompt sets: 'Input: cat -> Output: feline. Input: dog -> Output: canine.'
Query link
appends the real query: 'Input: horse -> Output:'.
Prediction
LLM detects pattern matches and output format, generating: 'equine'.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
test few-shot template accuracy
promptfoo eval --config my-few-shot.yaml05 / CHECK YOURSELF
Could you explain Few-Shot Prompting to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in AI engineeringChain of Thoughtthinking step-by-step before answering