← Questions

Build an eval harness for local models served by Ollama

0
MercorSystem designLast asked Mar 2026

An AI system design interview question asked in Mercor's technical phone screen, last asked Mar 2026. It tests llm evaluation, take-home and ollama.

A take-home: write an evaluation harness for a language model served locally through Ollama. It reads a dataset of test cases, sends each prompt to the model, scores the outputs, and writes per-case results and a summary report. Then explain its design and how you made it reliable and easy to extend.

Requirements

  • Functional: read cases from a file (JSONL or CSV), each with an id, a prompt, and optionally a reference_answer or expected label; call the model through Ollama's HTTP API; capture the output, the model name, latency, errors and retry attempts.
  • Functional: compute metrics such as exact match for deterministic tasks, pass rate, average and percentile latency, and error rate; save per-case results and an aggregate summary.
  • Functional: configuration for model name, timeout, retries, temperature and concurrency.
  • Non-functional: a failed or slow call never stops the run; a re-run can resume; adding another backend (a hosted API, vLLM) needs only a new adapter.

Clarifying questions

  • What tasks are in the dataset: classification with exact labels, short answers, free-form text?
  • How should free-form answers be scored: normalized string match, a regex, a judge model?
  • How many cases and how many models per run? Is comparing models side by side a goal?
  • Must runs be reproducible (fixed seed, temperature 0, logged versions)?

What a strong answer covers

  • Components: a dataset loader with validation, a ModelBackend interface (generate(prompt, params) -> Response) with an Ollama implementation, a runner, scorers as pluggable functions, and reporters.
  • The runner: bounded concurrency (a semaphore or worker pool), a timeout per call, retries with backoff for transient errors only, and every outcome recorded, including failures.
  • Results written incrementally (one JSON line per case), so a crash loses nothing and a re-run skips finished ids.
  • Metrics computed from the stored results, so scoring can change without calling the model again; the summary records the model, its version, parameters and dataset hash.
  • Tests with a fake backend: timeouts, malformed responses, retries, and the metric math.

Follow-ups

  • Add an LLM-as-judge scorer. How do you check that the judge agrees with people?
  • Compare two models on the same cases and report whether the difference is significant.
  • Ollama runs out of memory under your concurrency setting. How does the harness notice and adapt?

Where it's asked

What it tests

llm evaluation · take-home · ollama

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