{"slug": "what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop", "title": "What Is an LLM Eval Pipeline? Why You Need One and How to Build It on Your Laptop", "summary": "A guide published on building LLM eval pipelines recommends starting with 20 to 50 real test cases drawn from bug trackers and support messages, then running them after every change to catch regressions that public benchmarks miss. The guide cites Anthropic's finding that CPU and memory limits on the test machine alone shifted scores on the coding benchmark Terminal-Bench 2.0 by about 6 points, and notes that on the ARC Prize leaderboard GPT-6.2 Astra scored 70.3% with a basic setup versus 99.8% with a tuned one at the same reasoning level. It describes a four-part pipeline — test cases, a runner script, code-first graders with an AI model as judge when code can't decide, and a report comparing against the last run — buildable locally with Ollama and llama.cpp.", "body_md": "An eval pipeline is a set of test questions, a script that sends them to an AI model, and a way to score the answers. It works like unit tests for code, but for an AI feature. You can build a small one on your own laptop with Ollama and llama.cpp, and this story shows how.\n\nWhat an eval pipeline is\n\nAnthropic describes an eval as a test for an AI system, where you give it an input and check its output. A pipeline has four parts.\n\nTest cases are questions or tasks, each with a note on what a good answer looks like.\n\nA runner is a script that sends every case to the model and saves the answers.\n\nGraders score each answer. Simple code checks come first. Does the answer match exactly, contain the right number, or parse as valid JSON? If code can’t decide, a second AI model can act as the judge.\n\nA report shows the overall score and how it compares with the last run.\n\nA benchmark such as GSM8K is a public test set that everyone uses. A pipeline points the same idea at your own task, and you run it every time something changes.\n\nWhy you need one\n\nWithout tests, you hear about problems from your users. Anthropic describes the usual pattern. People say the AI feels worse after a change, and the team can only guess and check. Fixing one bug can break something else.\n\nA public benchmark does not tell you how your task will go. Hamel Husain, who writes about building AI products, says tests built around your users’ tasks measure something different from general benchmarks. Setup matters too. On the ARC Prize leaderboard, GPT-6.2 Astra scored 70.3% with a basic setup and 99.8% with a tuned one, at the same reasoning level.\n\nA new model is a change too. In Husain’s case study of a real estate assistant, progress stalled because fixing one problem created others, so the team built a proper way to test it. Anthropic says that when a new model comes out, an eval suite shows quickly what got better.\n\nYou need to know whether a score is real. Anthropic found that CPU and memory limits on the test machine alone moved scores on a coding benchmark, Terminal-Bench 2.0, by about 6 points. A score without a margin of error can’t tell you if a gain is real.\n\nHow to use it\n\nCollect 20 to 50 real cases. Use things that went wrong, such as your bug tracker, support messages and the checks you already do by hand. Anthropic says a small set is enough at the start, because early changes tend to have big effects.\n\nDecide how each case is scored. A good case is one where two experts would agree on pass or fail. Use a code check where you can.\n\nRun it once and save the result. That is your baseline.\n\nChange one thing. It can be the model, the prompt, a setting or the size of the model file.\n\nRun it again and compare. Look at the margin of error before you believe a difference.\n\nKeep the cases. Add a new case for every new failure, and run the set after every change.\n\nWhere this helps in practice\n\nThese situations are made up, but most people who build with AI run into one of them.\n\nYou fix one prompt problem and break another. Say a support bot sorts messages into bug, billing and feature request. Someone edits the prompt so billing questions are handled better, and bug reports start landing in the wrong group. Nobody notices until customers complain. With a saved set of cases, the next run shows which ones flipped.\n\nA new model comes out and the headlines say it is better. Better at what? Run your own cases on the old and the new model and compare them case by case. A leaderboard can’t tell you how a model does on your messages.\n\nYou want a cheaper or smaller model, maybe one that runs on your laptop so your data stays with you. Run the same cases on both. The Q4 and Q8 comparison further down is an example of this check.\n\nThe demo worked, and then real users broke it. They phrase things in ways you never tried. Each time it happens, add that message as a new case, so the same failure can’t come back unnoticed.\n\nBuild it on your laptop\n\nRunning tests locally costs only electricity, keeps your data on your machine and lets you test something that hosted APIs hide, such as which compressed version of a model you use. Quantization shrinks a model by storing its numbers with fewer bits. A Q4 file is smaller than a Q8 file and can be a little less accurate.\n\nOllama and llama.cpp are two popular programs that run models on your computer. Both can answer in the same format as the OpenAI API, so one script can test either.\n\nStep 1. Start the servers\n\nThese commands are for a Mac with Homebrew. On Linux and Windows, install both from their websites.\n\n```\nbrew install ollama llama.cppollama serve                       # leave it running, port 11434ollama pull qwen3.5:4b             # Q4_K_M, 3.3 GBollama pull qwen3.5:4b-q8_0        # the same model at Q8_0, 5.2 GB\n```\n\nllama.cpp is optional. Its server, llama-server, can download a model file from Hugging Face with -hf (the default size is Q4_K_M), and --alias sets the model name you use in requests:\n\n```\nllama-server -hf unsloth/Qwen3.5-4B-GGUF:Q4_K_M --alias qwen3.5-4b-q4 --port 8080\n```\n\nOn a 16 GB laptop, stay at 9B parameters or smaller. Ollama lists qwen3.5:9b at about 7 GB and gpt-oss:20b at 14 GB, which leaves little room for everything else.\n\nStep 2. Write the test cases\n\nEach case is one line of JSON, a plain text format for data. It has four parts. prompt is what the model sees, check is how to score the answer, expect is a correct answer and tag is a group name for the report. Two lines from the demo set, with the prompts shortened:\n\n```\n{\"id\": \"label-04\", \"tag\": \"label\", \"prompt\": \"Classify the customer message ... Message: The app crashes every time I open the settings page.\", \"check\": \"exact\", \"expect\": \"bug\"}{\"id\": \"json-01\", \"tag\": \"json\", \"prompt\": \"Extract the person, city and year ... Sentence: Grace Hopper joined the Navy Reserve in New York in 1943.\", \"check\": \"json\", \"expect\": {\"name\": \"Grace Hopper\", \"city\": \"New York\", \"year\": 1943}}\n```\n\nThe check depends on the task. Four examples:\n\nSorting support messages into groups. The expected answer is one word, such as bug, so the exact check works. It wants a word for word match.\n\nPulling facts out of text, such as a name, a city and a year. The expected answer is a small JSON object, so the json check parses the reply and compares the fields.\n\nA math or counting question. The answer is a number, so a regex check (a text pattern) looks for it in the reply.\n\nWriting a summary or setting a tone. There is no single right answer, so the judge check lets a second model decide against one clear rule, such as \"mentions the refund deadline\".\n\nHere is what happens to one case. Take label-04, where the message says the app crashes every time the settings page opens and the prompt asks for only the label. The runner sends it to the model. Say the model replies Bug. The exact check drops the final period, ignores capital letters, gets bug and finds it equal to the expected answer, so the case passes. If the model had replied This looks like a bug report, the case would fail, even though a person would accept it. The check is strict on purpose, which is why the prompt demands a single word.\n\nThe demo set has 40 cases (10 each of arithmetic word problems, JSON extraction, support ticket labels and short exact answers). It only shows how the pipeline works, and you can download all 40 cases and the script from this gist. Write your own cases from failures you have seen.\n\nStep 3. The script\n\nSave this as evals.py. It is 95 lines of standard Python, so there is nothing to install, and it works on Python 3.9 and newer (checked on 3.9 and 3.12). You can copy it as is.\n\n``` bash\n#!/usr/bin/env python3\"\"\"evals.py: a tiny eval runner for any OpenAI-compatible local server (Ollama, llama-server).\"\"\"import argparse, json, math, re, statistics, sys, time, urllib.request\npython\ndef chat(base, model, prompt, temperature=0.0, seed=0, max_tokens=1024, effort=None):    body = {\"model\": model, \"messages\": [{\"role\": \"user\", \"content\": prompt}],            \"temperature\": temperature, \"seed\": seed, \"max_tokens\": max_tokens}    if effort:        body[\"reasoning_effort\"] = effort  # \"none\" turns thinking off on Ollama models that allow it    req = urllib.request.Request(base + \"/v1/chat/completions\", json.dumps(body).encode(),                                 {\"Content-Type\": \"application/json\"})    t0 = time.time()    with urllib.request.urlopen(req, timeout=900) as r:        d = json.load(r)    text = d[\"choices\"][0][\"message\"].get(\"content\") or \"\"    text = re.sub(r\"<think>.*?</think>\", \"\", text, flags=re.S).strip()    return text, time.time() - t0, d.get(\"usage\", {}).get(\"completion_tokens\", 0)\npython\ndef grade(case, out, judge):    kind, want = case[\"check\"], case[\"expect\"]    if kind == \"exact\":        return out.strip().strip(\".\\\"'\").lower() == want.lower()    if kind == \"regex\":        return re.search(want, out, re.S | re.I) is not None    if kind == \"json\":        m = re.search(r\"\\{.*\\}\", out, re.S)        try:            got = json.loads(m.group(0))        except (AttributeError, ValueError):            return False        return all(got.get(k) == v for k, v in want.items())    if kind == \"judge\":  # last resort: a second model grades against a one-line criterion        q = (\"Question: %s\\nAnswer: %s\\nCriterion: %s\\n\"             \"Does the answer meet the criterion? Reply with exactly PASS or FAIL.\" % (case[\"prompt\"], out, want))        verdict, _, _ = chat(judge[0], judge[1], q, max_tokens=512)        return verdict.strip().upper().startswith(\"PASS\")    raise ValueError(\"unknown check: \" + kind)\npython\ndef mean_ci(xs):    se = statistics.stdev(xs) / math.sqrt(len(xs)) if len(xs) > 1 else 0.0    return statistics.fmean(xs) * 100, 1.96 * se * 100  # in percent: mean and 95% half-width\npython\ndef main():    p = argparse.ArgumentParser()    p.add_argument(\"cases\")    p.add_argument(\"--base\", default=\"http://localhost:11434\")  # llama-server: port 8080    p.add_argument(\"--models\", nargs=\"+\", required=True)    p.add_argument(\"--repeats\", type=int, default=1)    p.add_argument(\"--temperature\", type=float, default=0.0)    p.add_argument(\"--effort\")    p.add_argument(\"--judge\", help=\"BASE,MODEL of the judge server, needed only for judge cases\")    p.add_argument(\"--save\", help=\"write per-case scores to this JSON file\")    p.add_argument(\"--baseline\", help=\"JSON saved by an earlier run; exit 1 if the first model got worse\")    p.add_argument(\"--max-drop\", type=float, default=5.0, help=\"allowed drop in points\")    a = p.parse_args()    cases = [json.loads(line) for line in open(a.cases) if line.strip()]    judge = a.judge.split(\",\") if a.judge else None    scores = {}    print(\"%-26s %6s %8s %8s %7s\" % (\"model\", \"pass\", \"+/-95%\", \"tok/s\", \"sec\"))    for model in a.models:        scores[model], toks, secs = {}, 0, 0.0        for c in cases:            ok = []            for r in range(a.repeats):                out, sec, n = chat(a.base, model, c[\"prompt\"], a.temperature, r, effort=a.effort)                ok.append(grade(c, out, judge))                toks, secs = toks + n, secs + sec            scores[model][c[\"id\"]] = sum(ok) / len(ok)        mean, half = mean_ci(list(scores[model].values()))        print(\"%-26s %5.1f%% %7.1f %8.1f %7.0f\" % (model, mean, half, toks / secs if secs else 0, secs))        for tag in sorted({c[\"tag\"] for c in cases}):            xs = [scores[model][c[\"id\"]] for c in cases if c[\"tag\"] == tag]            print(\"    %-22s %5.1f%%  (%d cases)\" % (tag, statistics.fmean(xs) * 100, len(xs)))    first = a.models[0]    for m in a.models[1:]:  # paired difference: the same cases, so compare case by case        d = [scores[m][c[\"id\"]] - scores[first][c[\"id\"]] for c in cases]        mean, half = mean_ci(d)        print(\"%s minus %s: %+.1f points (+/- %.1f)\" % (m, first, mean, half))    if a.save:        json.dump(scores, open(a.save, \"w\"), indent=1)    if a.baseline:        old = json.load(open(a.baseline))[first]        before = statistics.fmean(old.values()) * 100        now = statistics.fmean(scores[first].values()) * 100        print(\"baseline %.1f%% -> now %.1f%%\" % (before, now))        if before - now > a.max_drop:            sys.exit(\"REGRESSION: dropped more than %.1f points\" % a.max_drop)\nif __name__ == \"__main__\":    main()\n```\n\nIt sends each case to the model, one at a time, and prints the score. A few details:\n\nIt sets temperature to 0, which makes the model pick its most likely words, and uses a fixed seed. Runs are then mostly repeatable, but not always. Thinking Machines asked one model the same question 1,000 times at temperature 0 and got 80 different answers, because the result depended on how many requests the server was handling at once. Treat one run as one sample. --repeats shows how stable each answer is.\n\nSome models think out loud before answering. --effort none turns that off where the model allows it (gpt-oss can't), in Ollama and llama-server. The script also strips <think> blocks.\n\nThe score is the average over all cases, with a margin of error, which is a range the true score probably falls in. Evan Miller’s paper on error bars for evals recommends reporting it.\n\nWith two or more models, the script compares each with the first on the same cases. That is fairer than comparing two separate scores.\n\n--save stores a run. --baseline compares a new run with a saved one and exits with an error if the score dropped by more than --max-drop points.\n\nStep 4. Run it\n\n```\npython3 evals.py cases.jsonl --models qwen3.5:4b qwen3.5:4b-q8_0 --effort none --save runs/today.json\n```\n\nAgainst llama-server, change the base URL and use the alias:\n\n```\npython3 evals.py cases.jsonl --base http://localhost:8080 --models qwen3.5-4b-q4 --effort none\n```\n\nThe script prints a report like this one. It comes from a fake test server that returns made-up answers, so the numbers mean nothing and only the layout matters. The fake server also answers instantly, which is why the speed looks absurd and the time is 0 seconds.\n\n```\nmodel                        pass   +/-95%    tok/s     secmodel-a                     72.5%    14.0  10552.0       0    json                    70.0%  (10 cases)    label                   60.0%  (10 cases)    math                    70.0%  (10 cases)    short                   90.0%  (10 cases)model-b                     75.0%    13.6  36698.8       0    json                    90.0%  (10 cases)    label                   90.0%  (10 cases)    math                    60.0%  (10 cases)    short                   60.0%  (10 cases)model-b minus model-a: +2.5 points (+/- 21.6)\n```\n\npass is the share of cases answered correctly, and +/-95% is the margin of error in points. tok/s is the speed in tokens (small pieces of words) per second, and sec is the total time.\n\nThe indented lines show the score for each tag, so you can see which kind of task changed. With only 10 cases per tag, treat them as hints.\n\nThe last line compares the two models on the same cases. Here model-b looks 2.5 points better, but the margin is 21.6, so this gap proves nothing.\n\nHow to read the results\n\nSay you run 40 cases and score 70%. How far can you trust that? The margin of error is about 14 points either way (1.96 times the square root of 0.7 × 0.3 ÷ 40). A 70% and an 80% can’t be told apart from numbers like these. More cases shrink the margin. Running the same 40 cases again doesn’t, because the 40 cases are your sample.\n\nA real study shows how small the differences can be. In January 2026, researchers tested Llama-3.1-8B-Instruct in different llama.cpp sizes on five public benchmarks. The average score was 69.47 at full precision, 69.41 at Q8 and 69.15 at Q4_K_M, while the files were 47% and 69% smaller. A gap of 0.3 points is far too small for 40 cases to show. Quality only dropped at 3 bits (Q3_K_S averaged 65.49). The authors also warn that small gains can be noise. It is one model, so run your own cases.\n\nWhen you need a judge\n\nSome answers can’t be checked with simple code, such as a summary, a tone or an explanation. For those, a second AI model can grade the first one (called LLM as a judge), and the script has a judge check for it. Two warnings:\n\nJudges have biases. The MT-Bench paper found they tend to favor the first answer shown, longer answers and answers written by themselves.\n\nSmall judges are worse. In a study of 13 judge models, only the best and largest agreed reasonably well with humans, and scores could be off by up to 5 points. Ranking models still worked with smaller judges.\n\nUse a different model as judge than the one you test, ask one pass or fail question per call, and read about 20 verdicts yourself.\n\nWhen to use a ready-made tool\n\nOnce your cases outgrow one file, existing tools can take over.\n\npromptfoo keeps tests in a YAML file and uses Ollama through ollama:chat:<model>. Its judge defaults to an OpenAI model, so point defaultTest.options.provider at a local one.\n\nlm-evaluation-harness runs standard public benchmarks. Use --model gguf for llama-server.\n\nInspect AI has a built-in Ollama provider, ollama/<model>.\n\nDeepEval says in its docs that any model served by Ollama can run its evals.\n\nKeep it running\n\nAfter a good run, save it. After every change (a new model file, a different size, an edited prompt), run again with --baseline so it fails if the score drops by more than 5 points. You can start it from a git hook or a CI job. One catch is that with 40 cases, 5 points is well inside the margin of error, so it can fail for no reason. Raise the limit or add cases.\n\nWhat this story does not show\n\nThe demo cases are small and simple. A score on them says nothing about your task.\n\nThe script has no retries and no parallel runs, and it treats cases as independent. Miller’s paper says related questions need a more careful margin of error.\n\nThe script has only been tested against a fake server that imitates the API, not real models. The numbers here come from the linked sources, not from my own runs. Treat your first real run as a test of the script too.\n\nFinal thoughts\n\nChoosing good cases takes more work than writing the script, and Anthropic says the same about writing good tasks. Start with 20 to 50 cases from real failures. Test two models or settings side by side, and trust a difference only when it is bigger than the margin of error.\n\nIf you enjoyed this article, I’d be grateful for your support\n\nI’m a Product Manager with an engineering background (ex SWE), focused on building, scaling and growing products. I’m especially interested in new technologies, particularly AI/ML, and how they can be applied in real workflows.", "url": "https://wpnews.pro/news/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop", "canonical_source": "https://pub.towardsai.net/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop-c7180a7559cf?source=rss----98111c9905da---4", "published_at": "2026-11-27 03:02:47+00:00", "updated_at": "2026-11-27 03:44:52.666556+00:00", "lang": "en", "topics": ["large-language-models", "ai-tools", "ai-agents", "mlops"], "entities": ["Anthropic", "Hamel Husain", "ARC Prize", "GPT-6.2 Astra", "Terminal-Bench 2.0", "GSM8K", "Ollama", "llama.cpp"], "also_reported_by": [], "takeaway": "Build a regression suite of 20-50 real user cases scored by code checks first and an LLM judge only when code can't decide, and treat score differences under roughly 6 points as noise — the margin Anthropic measured from CPU and memory limits alone on Terminal-Bench 2.0.", "recommendation": {"advice": "Start an eval set with 20-50 real failure cases from bug trackers and support messages, score them with code checks where possible, and re-run after every model, prompt or setting change before trusting any score difference.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop", "markdown": "https://wpnews.pro/news/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop.md", "text": "https://wpnews.pro/news/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop.txt", "jsonld": "https://wpnews.pro/news/what-is-an-llm-eval-pipeline-why-you-need-one-and-how-to-build-it-on-your-laptop.jsonld"}}