Prompt design with evaluation scaffolding
I was asked this
No reports yet. Sign in to say where you were asked it.
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
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. New accounts get 5 credits: each one unlocks a question for good.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.
