CCA Prep

Lesson 4.2Lesson 20 of 30

Few-shot examples for consistent output

Apply few-shot prompting to improve output consistency and quality

Few-shot examples for consistent outputInstructions aloneTwo more pages of prose rules40 examples covering every caseExamples with the answer but noreasoningTargeted few-shot2–4 ambiguous cases + why this actionExact format: location · issue ·severity · fixAcceptable pattern vs genuine issueVaried document structures + whennullA rule that must always hold goes into code or a hook

Key points

  1. 1When detailed instructions still give inconsistent output, 2–4 examples of the exact output (location, issue, severity, suggested fix) are the most effective fix. The model copies what the examples show, including what they leave out.
  2. 2Spend the examples on ambiguous cases and show the reasoning: why this action beat the plausible alternatives. Reasoning lets the model generalise its judgment to new cases instead of matching only the listed ones.
  3. 3To cut false positives, pair examples: an acceptable pattern that gets no finding next to a genuine issue that does.
  4. 4In extraction, show varied structures (inline citations vs a bibliography, informal measurements) and when a field stays null. This reduces hallucinated values and empty required fields.
  5. 5Few-shot is a probabilistic aid. A rule that must hold every time belongs in code or a hook, not in examples.
What the exam guide checks here

Objective wording from the exam guide (English).

  • 4.2.K1Few-shot is the most effective way to get consistent actionable format when instructions fail
  • 4.2.K2Few-shot demonstrates handling of ambiguous cases
  • 4.2.K3Few-shot lets the model generalise judgment to novel patterns
  • 4.2.K4Few-shot reduces hallucination in extraction (informal measurements, varied structures)
  • 4.2.S1Write 2–4 targeted examples for ambiguous cases showing why one action beats alternatives
  • 4.2.S2Examples demonstrating output format (location, issue, severity, fix)
  • 4.2.S3Examples separating acceptable patterns from real issues
  • 4.2.S4Examples for varied document structures (inline citations vs bibliography)
  • 4.2.S5Examples of extraction from varied formats to fix empty/null required fields

Lock it in

Answer scenario questions on this topic. Every option comes with an explanation.

Practise 4.2 · 23 questions