0Pricing
Claude Architect · Lesson

Few-Shot to Reduce Hallucination

Grounding extraction with concrete examples.

Why Models Hallucinate in Extraction

When you ask Claude to extract data from a messy document, the biggest risk is hallucination: the model invents a plausible value to fill a field instead of admitting the value is absent.

This happens most when your instructions are vague, when the desired output format is ambiguous, or when edge cases (missing fields, conflicting numbers) aren't addressed. A vague prompt like "extract the invoice details" leaves the model guessing.

In this lesson you'll learn to ground extraction with concrete examples so the model copies real source values instead of fabricating them.

Few-Shot: Show, Don't Just Tell

Few-shot prompting means giving Claude 2-4 targeted examples of input paired with the exact output you want. The model generalizes from these examples — it does not merely repeat them.

Few-shot is the recommended technique for four things: consistency, edge cases, output format, and reducing hallucination. Our focus today is the last one.

The key idea: a well-chosen example that shows how to behave when data is missing teaches the model far more reliably than a sentence of instruction.

All lessons in this course

  1. Why 2-4 Examples Work
  2. Examples for Format & Edge Cases
  3. Generalization vs Repetition
  4. Few-Shot to Reduce Hallucination
← Back to Claude Architect