← Questions

Prompt design with evaluation scaffolding

0
AnthropicAI/ML designLast asked Jan 2026

An AI/ML design interview question asked in Anthropic's system design round, last asked Jan 2026. It tests prompt engineering, evaluation and llm.

In a notebook, design prompts for a defined task and write the surrounding scaffolding that evaluates them. The exercise tests task framing and measurement more than clever phrasing.

The task used in the worked answer: route support messages to a team and extract an order id, as JSON.

def parse(text, labels):
    """Strictly parse the model's JSON reply -> (team, order_id); raise ValueError."""


def run(model, render, examples, labels):
    """model(prompt) -> text. One record per example with pred_team, pred_order, error, correct."""


def score(records, labels):
    """accuracy, parse_failures, per_class recall and precision, confusion."""


def compare(a, b, iters=2000, seed=0):
    """Paired bootstrap on per-item correctness -> (mean diff, (low, high))."""


def failures_by_cause(records): ...

Requirements

  • Functional: a prompt that turns a support message into JSON with a team and an order id; a strict parser; a runner that records predictions and errors per example; scores with per-class precision and recall and a confusion matrix; a paired bootstrap to compare two prompts; failures grouped by cause.
  • Non-functional: results reproducible from a seed, and every model failure kept as data rather than raised.

Clarifying questions

  • What is the label set, and is there a team for messages that fit none?
  • Is the order id always in a known format, and what should the output be when there isn't one?
  • How many labeled examples are there, and how were they drawn: do they match real traffic?
  • Which mistakes cost the most, for example sending billing issues to the wrong team versus missing an order id?
  • Is the model deterministic, or should each example be run several times?

What a strong answer covers

  • A prompt that defines each team with a short rule and an example, states the exact JSON shape, and says what to do when no order id is present or the message is ambiguous.
  • Parsing that rejects anything but the expected JSON object with a team from labels, counting parse failures separately from wrong answers.
  • Scoring per class, not only overall accuracy, so a rare team with poor recall is visible, plus the confusion matrix to see which teams get mixed up.
  • A paired bootstrap over the same items so the comparison between two prompts carries an interval, and the point that a small difference on a small set may not be real.
  • Grouping failures (parse error, wrong team, wrong or missing order id) and reading examples from each group to drive the next prompt change; holding out a set so prompt edits don't overfit.

Follow-ups

  • Labels are noisy: how do you find and fix label errors in the eval set?
  • Swap in a cheaper model: what evidence would you need before shipping it?
  • Add a confidence score and route low-confidence messages to a human.
  • How do you keep the eval set representative as traffic changes?

Where it's asked

  • Anthropic · System design · Last asked Jan 202655 min · Design discussion, often typed into a shared Google Doc rather than drawn; some rounds let you share any drawing tool · No AI

What it tests

prompt engineering · evaluation · llm

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing