Most LLM features don't come with an answer key. You can't write assert output == expected for a summary, a rewritten email, or a support reply, and hand-labeling a big test set is slow. Metamorphic testing, an idea borrowed from testing scientific and numerical software, gives you a way around that: instead of checking what an output is, you check how outputs should relate to each other when you change the input in a controlled way.

The question shifts from "is this answer right?" to "if I change the input like this, the output should change like that (or not at all). Did it?"

Relations that work for common LLM tasks

A metamorphic relation is a pair: a transformation you apply to an input, and a property the two outputs should share. Some that hold up well in practice:

  • Irrelevant edits should be invisible. Add a polite greeting, reorder two unrelated paragraphs in a retrieved document, rename a customer from "Priya" to "Tom". A classifier's label, an extractor's fields (other than the name), or a router's decision should not move.
  • Removing evidence should remove claims. Delete the paragraph that states a refund deadline from the source document. The summary or answer should stop mentioning that deadline, or say it isn't stated. If the deadline survives, the model is filling gaps from priors rather than reading the source.
  • Strengthening a signal shouldn't weaken the verdict. If a ticket is classified "urgent", appending "the production database is down" shouldn't make it less urgent. This monotonicity check catches classifiers that react to surface features instead of meaning.
  • Format changes shouldn't change content. Feed the same table as Markdown, CSV, and prose. Extracted values should match across all three.
  • Splitting shouldn't lose things. Extract action items from a meeting transcript, then from each half separately. The union of the halves should roughly cover the whole.

None of these need a labeled answer. They only need a way to compare two outputs, and for structured output that's usually a plain equality or set check, no judge model required.

Running it without fooling yourself

Start from real inputs, not synthetic ones. Take a few dozen production examples (scrubbed of personal data) and apply each transformation automatically. The source inputs then reflect what users actually send, and the transformation is the only variable.

Expect some disagreement even with no change at all. Run each original input twice first and measure how often the output differs from itself. If it flips 4% of the time on identical input, a relation that "fails" 5% of the time is telling you very little. Report each relation's violation rate next to that baseline, not as a bare number.

Keep relations narrow. "Renaming a person doesn't change the sentiment label" is checkable and its failures are easy to read. "Paraphrasing doesn't change anything" is vague, and the paraphrase step can introduce real meaning changes, so you'll end up arguing about the test instead of fixing the feature.

When a relation fails, save the input pair as a regular regression case. Metamorphic checks are best at finding failures. Once you've found one, a concrete example with a known correct answer is the cheaper thing to keep running.

The point

Metamorphic tests won't tell you whether your feature is good. They tell you whether it's consistent in ways you already know it has to be, and inconsistency is one of the most common failures in LLM features that a handful of hand-checked examples will never show. Write three relations for your most important feature this week. The first violation report is usually enough to pay for the effort.