Search⌘ K
AI Features

Calibrating Categories with Few-Shot Pairs

Explore how to enhance AI workflow reliability by using targeted few-shot example pairs to calibrate category and priority classifications. Understand how carefully designed examples reduce label variability in similar inputs, maintain schema validity, and improve prompt precision. This lesson helps you implement few-shot calibration within structured output contracts to build more predictable AI-driven automation.

A model can return schema-valid output and still assign different labels to nearly identical support emails across runs. When labels vary without a runtime error, the prompt may define the classification task without showing how borderline cases should be handled. Before changing the taxonomy or adding more rules, try a small set of targeted few-shot examples. In this lesson, we will explore how targeted few-shot examples clarify the intended classification boundaries and improve consistency in category and priority across similar inputs.

The prompt skeleton, with few-shot examples optionally inserted before the instructions, after the schema, or between blocks
The prompt skeleton, with few-shot examples optionally inserted before the instructions, after the schema, or between blocks

The diagram shows where a few-shot block can be inserted, but it does not show the schema requirements that still apply to each example. Define those requirements separately before continuing, because every few-shot example must still satisfy the schema. The schema card from the original image appears separately as a JSON code block because it defines the schema rather than the workflow sequence.

{
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["billing", "bug", "account", "how_to", "other"]
},
"priority": {
"type": "string",
"enum": ["low", "normal", "high"]
},
"next_action": {
"type": "string",
"enum": ["reply", "escalate", "request_info", "close"]
},
"needs_human": {
"type": "boolean"
}
},
"required": ["category", "priority", "next_action", "needs_human"]
}
The triage output JSON schema, the same four required keys and enums used throughout the course

With the schema pinned down, here's what it looks like once real emails are dropped into the template. The two templated examples from the original image (email A and email B) each satisfy that same schema but land on a different valid answer, which is exactly the kind of variation a few-shot example is meant to guide, not ...

Two Templated Examples, Two Valid Outputs
Templated examplecategoryprioritynext_actionneeds_human

Email A ({{email_subject_A}} / {{email_body_A}})

account

normal

reply

false

Email B ({{email_subject_B}} / {{email_body_B}})

billing

high

escalate

true

Do you find this helpful?
...