Search⌘ K
AI Features

Calibrating Categories with Few-Shot Pairs

Explore how to use few-shot example pairs to refine AI model categories and priorities for support emails. Learn to calibrate classification boundaries with schema-compliant JSON, enhancing consistency across similar inputs and reducing unpredictable label variations.

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 ...