---
title: "Write a small eval harness: load a JSONL dataset, call a model concurrently under a rate limit, apply code-based and…"
url: https://gurkanozkan.ai/learn/questions/applied-llm-evl-09/
markdown: https://gurkanozkan.ai/learn/questions/applied-llm-evl-09.md
kind: question
role: Applied LLM
stage: Coding
difficulty: Medium
json: https://gurkanozkan.ai/api/learn/questions/applied-llm-evl-09.json
robots: noindex
---

# Write a small eval harness: load a JSONL dataset, call a model concurrently under a rate limit, apply code-based and judge-based graders, cache results and print a per-slice report.

Applied LLM · Coding · Medium

Theme reported publicly: [Google DeepMind](https://www.techinterview.org/post/3233474918/deepmind-interview-process-2026/), [Mistral AI](https://www.techinterview.org/post/3233474922/mistral-interview-process-2026/)

## Answer

*Model answer, written in a candidate's voice*

### In short

- Define small interfaces: DatasetItem, ModelClient, Grader, ResultStore, and a RunConfig with model, prompt version, params, and slice
- Run async with a semaphore for concurrency plus a token bucket for the rate limit, per-call timeouts, and exponential backoff with jitter on 429/5xx
- Cache by sha256 of model, prompt version, parameters, and input hash; persist results and resume by skipping cache hits
- Keep deterministic ordering by sorting items by stable id and emitting results sorted by slice and id
- Use exact/regex/schema graders plus a judge grader that records judge model, prompt, and rationale
- Aggregate per slice with n, pass rate, mean score, and confidence intervals such as Wilson for pass rates and bootstrap/t intervals for numeric scores

### In full

I would start with narrow interfaces: a dataset loader yields DatasetItem(id, slice, input, expected, metadata), a ModelClient exposes async generate(prompt, params), a Grader exposes grade(item, output) returning score, pass, and reason, and a ResultStore persists and loads results keyed by a stable run identity. The runner sorts items by id, uses asyncio.Semaphore to cap concurrency and a small token-bucket limiter to enforce the requests-per-minute limit, wraps each call in a timeout, and retries 429/5xx with exponential backoff plus jitter and a max retry count, recording failures rather than silently dropping them. The cache key is a hash of model name, prompt version, decoding parameters, and the canonicalised input, and results are written atomically so a rerun can load prior entries and only execute misses; output is sorted by slice and id so reports are reproducible. Graders are code-based for exact match, regex, and JSON schema validation, plus a judge grader for open-ended outputs that uses a separate judge model with a fixed rubric and records judge model, prompt version, and rationale. The report groups by slice and prints n, pass rate, mean score, cache-hit rate, and confidence intervals, using Wilson intervals for pass rates and bootstrap or t-intervals for numeric scores, with enough detail to inspect failures. I would keep the harness small and explicit: no hidden retries, no unversioned prompts, and no aggregates without n and intervals.

*Corrected by an independent AI reviewer.*

## What a strong answer covers

- Clear interfaces for dataset, client, grader and result store
- Async with a semaphore; exponential backoff with jitter on 429/5xx; timeouts
- Cache keyed by model, prompt version, parameters and input hash; deterministic result ordering; resumable runs
- Graders: exact/regex/schema checks and a judge grader; per-slice aggregates with confidence intervals

## Common mistakes

- No retry/rate-limit handling so the run dies midway
- cache key without prompt version

## Topic guides

- [Coding for ML and LLM engineering](https://gurkanozkan.ai/learn/topics/coding-engineering.md)
- [Evaluation: metrics, evals for LLM systems and statistical rigour](https://gurkanozkan.ai/learn/topics/evaluation.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
