Solution Patterns & Playbooks

Synthetic Training Data Generation with Claude

When you need 10,000 labeled examples and have 50, Claude can manufacture the rest — if you control diversity going in and filter quality coming out.

Claude 3P 101 · Updated July 2026 · Unofficial guide

Synthetic data means model-generated examples used to train or evaluate another system: labeled utterances for an intent classifier, adversarial inputs for a safety filter, edge cases for an evaluation suite. Claude is good at this because generation is guided by instructions and seed examples rather than whatever happens to be in your logs. The failure mode is equally predictable: without deliberate controls you get 10,000 fluent variations of the same three examples. Before starting, check your platform's and provider's terms for how generated output may be used in training — this article covers the engineering, not the licensing.

The prompt template

A generation prompt has four parts, and Anthropic's prompting guidance maps onto each. Give Claude a role in the system prompt ("you generate training data for a banking intent classifier" — even one sentence focuses behavior). Explain why constraints exist ("these train a model that sees real typos, so include realistic misspellings") — the docs note Claude generalizes from the explanation. Include 3–5 seed examples wrapped in <example> tags, chosen to be relevant and deliberately diverse. Finally, structure the whole thing with XML tags so instructions, label definitions, and seeds are unambiguous.

Generate in small batches per request (say 10–20 examples), not one and not a thousand: single-example calls waste money re-reading the template, while huge generations drift and self-repeat.

Labels that parse: structured outputs

Emit examples as schema-guaranteed JSON with output_config so every record has exactly the fields your training pipeline expects — an array of {"text": ..., "label": ..., "difficulty": ...} objects with additionalProperties: false. Structured outputs are GA on the Claude API, Claude Platform on AWS, Bedrock, and Vertex AI, and beta on Microsoft Foundry. Handle stop_reason: "max_tokens" (truncated JSON — retry with a higher limit) and stop_reason: "refusal" in code.

Diversity is a prompt input, not a sampling knob

The classic trick of raising temperature is off the table on the newest models: Fable 5, Opus 4.8, and Sonnet 5 reject non-default temperature, top_p, and top_k with a 400 error. Diversity therefore comes from varying the prompt itself — which produces better-controlled variety anyway. Recommended practice: build a seed matrix in code that crosses the dimensions you care about (persona, register, length, channel, edge-case type), and render one generation request per cell, e.g. "frustrated customer, mobile chat, under 15 words, mentions a competitor." Rotate which seed examples appear per request, and tell Claude what has already been covered ("avoid these 20 phrasings") when filling gaps. Deduplication then happens downstream in code — exact and near-duplicate detection is a deterministic job, not a model call.

Quality filters on the way out

Treat generation output as a candidate pool, not a dataset. A three-stage filter is recommended practice:

1. Code checks: schema already guaranteed; enforce length bounds, label validity, dedupe, and per-label balance.

2. Model-as-grader: a second, independent pass — Haiku 4.5 at $1/$5 per million tokens keeps this cheap — labels each candidate blind, without seeing the intended label. Keep records only where grader and generator agree; route disagreements to review. This catches the most damaging failure, plausible text with the wrong label.

3. Human sample: review a fixed random percentage per run and track the error rate over time, exactly as you would for any pipeline output.

Run it at half price

Generation is the textbook batch workload. On the Claude API and Claude Platform on AWS, Anthropic's Message Batches API charges 50% of standard prices, takes up to 100,000 requests or 256 MB per batch, and usually completes within an hour — put one seed-matrix cell in each request with the cell encoded in custom_id. The Message Batches API is not available on Bedrock, Vertex AI, or Foundry; Bedrock offers its own S3-based batch inference and Vertex has BigQuery/GCS-based batch prediction at 50% batch pricing, so the pattern survives the platform change even though the mechanism differs. Wherever you run it, put the shared template and seed examples behind a prompt-cache breakpoint — with batches, use the 1-hour TTL since processing can outlive the 5-minute default.

Where to go next

See structured outputs, batch processing, and evaluation and testing — your synthetic set is only as useful as the eval it feeds.

Sources