方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Build a multi-metric eval pipeline

Build a Multi-Metric Eval Pipeline

Production evaluation rarely relies on a single metric. A useful pipeline runs several scorers in parallel, aggregates their outputs into a composite, and flags cases that fail any individual dimension.

What to build

Implement MultiMetricPipeline:

  1. Constructor — accepts scorers: dict[str, Callable[[str, str], float]] mapping metric name to scorer function. Optionally accepts weights: dict[str, float] (default: equal weight).

  2. run(cases: list[dict]) -> list[dict] — Each case has "input", "response", and "reference". Returns per-case results: {"case_id", "scores": {metric: float}, "composite_score", "passed_all", "failed_metrics"}.

  3. aggregate(results: list[dict]) -> dict — Returns {"n", "avg_composite", "per_metric_avg": {metric: float}, "cases_failing_any": int}.

  4. worst_cases(results, n=5) -> list[dict] — Top n cases by lowest composite score, sorted ascending.

Constraints

  • Standard library only. If a scorer raises, record score 0.0 for that metric and continue.
  • Composite score = weighted average of individual metric scores.
  • passed_all = True only when every metric score >= 0.7.

Evaluation / hard / Step 27 of 36

Practice stage

Evaluation and review loops

Hint

Separate the scoring logic from the interpretation logic. Your goal is not just a number; it is a useful next action.

Success criteria
  • - Produces a useful signal, not decorative output
  • - Makes regression review easier
  • - Would support a benchmark or observability loop
Review checklist
  • - Would this output help decide what to fix next?
  • - Are important failure modes visible?
  • - Does the score hide any ambiguity I should record?

Practice

Generate a variation

Generate a new exercise variation to deepen understanding or practice a related concept.

Attempt history

Recent submissions

Before you submit, decide what a strong answer should make obvious to the reviewer.

No attempts yet.