Few-Shot Examples
Ejemplos resueltos · k-shot prompting
Escrito por Darjus Kazakevic · revisado el
Show two to five. They become the rule.
At some point, longer instructions stop improving the output. Usually you have reached something easier to show than to describe: the tone, the level of detail, the ambiguous case. Two to five worked examples can replace a page of rules, because a model often copies a pattern more reliably than it follows a description.
The catch is that the model reads examples as rules. Whatever they share becomes the rule: long summaries, an always-empty field, four of five with the same label. Choosing the examples is the real work. Adding more easy ones is not.
En esencia — Examples teach format, tone and edge cases at once, which is also why a careless example becomes a rule you did not mean to write.
Cuándo recurrir a él
Recurre a él cuando
- Format or tone is easier to show than to describe
- Boundary cases that prose keeps failing to pin down
- The instructions passed a page and quality stopped improving
Reconsidéralo cuando
- A schema and one sentence fully describe the task
- The examples would be longer than the input itself
- Inputs vary so much that any fixed set biases more than it teaches
The parts
- The example
- One complete input and output pair, in the exact format of a real request. Not a shortened version and not a description of a good answer: the real thing, tags included.
- The set
- All the examples together, which is what the model actually learns from. Coverage matters more than count: which labels you show, which edge cases, and the balance between them.
- The order
- The position of each example. Models are sensitive to order and often lean toward the last example. Decide the order on purpose, and keep it fixed.
Reglas de diseño
- Show the awkward case
- The useful example is the one you would otherwise explain in a paragraph: the ambiguous input, the empty result, two labels that both look right. Examples that only repeat the instructions waste tokens.
- Two to five, chosen, not collected
- For most tasks the gains drop fast after a handful. Variety matters, not volume: ten near-copies cost tokens on every call and teach nothing the first three did not.
- Match the real format exactly
- Same tags, field names and casing as a live request. An example that is tidier than production teaches a pattern that does not match the input the model really gets.
- Review them like code
- Examples live in the template and get reviewed. Editing one changes the behaviour of every request, not only the case you were fixing. It is a common cause of "why did unrelated output change?".
Errores habituales
- Only easy examples, so the boundary stays as unclear as before
- A mistake in one example, copied into every reply
- Four of five examples share a label, and answers lean that way