Testing LLM Prompts With Synthetic Data: Cases, Coverage and Scoring

Testing LLM prompts with synthetic data: build generated cases, measure coverage across intents and edge cases, and score results with promptfoo and LangSmith.

By Galactic News Editorial · Published 2026-11-27T05:06:27+00:00 · Updated 2026-11-27T05:06:27+00:00

Testing LLM prompts with synthetic data cases coverage and scoring

Testing LLM Prompts With Synthetic Data: Cases, Coverage and Scoring

Prompts break quietly. A small edit fixes one case and breaks five others. A model update changes tone on edge cases. Users find the failures first. Testing LLM prompts with synthetic data catches those failures before users do. Synthetic cases are generated test inputs, built to cover the range of real traffic. This guide covers how to build them, how to measure coverage, and how to score the results.

Testing LLM prompts synthetic data: why it matters

Hand-written test sets drift away from real use. They cover what the author thought of. They miss the failures that actually happen in production. They also change silently between runs, so a score change may reflect a different dataset rather than a better prompt.

Synthetic data fixes the volume problem. A generator can produce hundreds of cases from a small set of seeds. It varies phrasing, length, tone, and edge conditions. The result is a test set that is bigger and more diverse than any team would write by hand. The catch is quality. Generated cases need review before they become reference tests. An unreviewed synthetic case can test the wrong thing.

Building synthetic test cases

Start from real failures and real traffic. Export production traces and find the cases that failed or scored low. Those are the seeds. A generator takes each seed and produces variants: paraphrases, longer inputs, adversarial phrasings, and multilingual versions. Label every generated case as synthetic. Review it before it enters the dataset.

Promptfoo is the standard open-source tool for this workflow. It evaluates prompts from a declarative YAML config and runs every combination of prompts, providers, and test cases. It supports string, regex, and JSON schema assertions, plus LLM-judge scoring. Its red team mode generates adversarial test cases from plugins that target specific risks, such as prompt injection, PII leakage, and jailbreaks. Promptfoo is MIT licensed. It became part of OpenAI in March 2026 and remains open source.

A basic promptfoo config looks like this:

description: "Customer support prompt tests"
prompts:
  - file://prompts/support.txt
providers:
  - openai:gpt-4o-mini
tests:
  - description: "Refund question"
    vars:
      question: "How do I return an item?"
    assert:
      - type: contains
        value: "return"
      - type: not-contains
        value: "cannot help"

Run it with npx promptfoo eval. Results appear in a table and a web viewer. Promptfoo returns a CI exit code, so it can gate deployments that fall below the bar.

Coverage: what a good test set must include

Coverage is the share of real behavior the test set represents. A set with 500 paraphrases of one question has low coverage. A set with 50 questions across ten intents has high coverage. Build coverage along five dimensions.

LangSmith supports this workflow with evaluation datasets. Teams create datasets from production traces or upload them directly. The LangSmith Python SDK creates a dataset and adds examples with inputs and expected outputs. The evaluate() function runs a target against a pinned dataset version and scores each run with custom evaluators. Datasets can be split into regression, representative, edge-case, and held-out sets. Pin the dataset version for every experiment so results stay comparable.

Measure coverage regularly. Compare the intent clusters in recent production traces with the intents in the test set. Send uncovered intents to the curation queue. Retire stale examples that no longer match real traffic.

Scoring: how to grade prompt outputs

Scoring needs more than one method. Different failures need different graders.

Score each case, then aggregate. Track the pass rate per intent, not just the overall rate. An overall pass rate of 95 percent can hide a 40 percent pass rate on one intent. Track the failure list too. Every failing case should name the prompt version, the model, and the input that broke it.

Promptfoo mixes all of these in one config. Its assertions include contains, regex, similar, and llm-rubric. Its red team graders decide per case whether the target failed or passed. That makes one tool cover both regression testing and security testing.

Comparing the main tools

ToolMain jobCostBest for
PromptfooPrompt evals and red teaming from YAMLOpen source, MITCI-gated prompt regression tests
LangSmithDatasets, tracing, evaluation experimentsFree tier; paid plansDataset curation from production traces
Hand-built scriptsCustom eval harnessesEngineering timeUnusual scoring rules

A workflow that holds up

  1. Instrument the app. Trace every prompt call with metadata such as prompt version and user segment.
  2. Collect failures. Route low scores, user complaints, and errors into an annotation queue.
  3. Curate the dataset. Review candidate cases. Fix reference outputs. Scrub personal data. Never let unreviewed outputs become reference answers.
  4. Generate synthetic variants. Use reviewed failures as seeds. Label them synthetic. Review before adding.
  5. Pin the version. Tag the dataset version, such as prod-2026-w10, and reference it exactly in every experiment.
  6. Run evals in CI. Gate merges on the regression split. Compare each experiment against the baseline.
  7. Refresh on a schedule. Compare new production intents against dataset coverage. Add what is missing. Retire what is stale.

Pitfalls to avoid

Synthetic data has real failure modes. Generated cases can drift toward the generator's own style and miss real user phrasing. Synthetic reference answers can be wrong, which makes a correct prompt look broken. Personal data can leak into generated cases if seeds contain it. Always scrub seeds before generation. Always review generated cases before they enter the dataset. And always keep a held-out split that no prompt tuning ever sees, so the final score stays honest.

Bottom line

Test prompts like software. Build a dataset from real failures and synthetic variants. Cover intents, edge cases, and adversarial inputs. Score with deterministic checks and a judge. Pin the dataset version and gate merges on it. Promptfoo covers the eval and red team side. LangSmith covers dataset curation and experiments. Together they turn prompt changes from guesswork into a repeatable process.