Skip to content

Building an LLM Evaluation Pipeline That Outlasts Models

LLM evaluation should be durable infrastructure, not a one-time benchmark. A model-agnostic test suite with multi-dimensional scoring, automated regression detection, and human calibration loops turns model migration into a routine operation, and like a CI pipeline it needs ongoing investment as edge cases and models change.

01

What problem did this system solve?

A legal technology company built their AI-powered contract analysis product on GPT-4 in early 2024. Within little more than a year, they needed to evaluate and potentially migrate across several models: GPT-4 Turbo, Claude Sonnet, GPT-4o, and an updated Claude Sonnet. Each migration was a crisis. The team had no systematic way to evaluate whether the new model maintained the quality standards their enterprise customers depended on.

Their evaluation process for the first migration (GPT-4 to GPT-4 Turbo) took weeks: manual testing by domain experts, customer-facing beta testing, and then incident response after subtle regressions surfaced in production. The second migration was equally painful. By the time the third model option emerged, the team was paralyzed. They knew they needed to switch (the new model was cheaper with equivalent quality on general benchmarks), but they could not justify the migration cost.

I was engaged to build an evaluation pipeline that would make model migration a routine operation rather than a company-wide event.

02

How was the evaluation infrastructure designed?

The evaluation pipeline was designed around four principles: model-agnostic test cases, multi-dimensional scoring, automated regression detection, and human calibration loops.

The test suite contained over a thousand evaluation cases organized into categories aligned with the product’s core capabilities: clause extraction, risk classification, obligation identification, party detection, date parsing, defined term resolution, and further categories covering edge cases and cross-cutting concerns. Each test case specified: the input document (or document section), the task instruction, the expected output (human-judged gold standard), and a scoring rubric with weighted dimensions.

The scoring system used four dimensions for each test case: factual accuracy (whether the extracted information is correct), completeness (whether all relevant items are captured), format compliance (whether the output matches the required schema), and nuance handling (whether the output correctly handles ambiguous or conditional language). Each dimension was scored on a fixed scale by an LLM judge (a different model than the one being evaluated) using a detailed rubric with examples for each score level. The weighted composite score used weights calibrated against human expert judgments, with accuracy weighted heaviest, then completeness and nuance, then format.

I built the pipeline in Python using a custom framework (not LangSmith or Braintrust, which did not support the multi-dimensional scoring we needed at the time). The framework orchestrated: batch inference against the candidate model, parallel LLM-judge scoring across all dimensions, score aggregation by category, statistical comparison against the baseline model’s scores, and report generation with per-category breakdowns and flagged regressions.

A full evaluation run against the whole suite took hours and cost a modest amount in inference fees (for both the candidate model inference and the judge model scoring). This compared favorably to the weeks of effort and the far higher cost of manual evaluation for the first migration.

03

What were the measurable outcomes?

The pipeline’s most valuable contribution was the regressions it caught before they reached production. In the migration from GPT-4 Turbo to Claude Sonnet, the pipeline identified that Claude’s clause extraction accuracy was higher overall but noticeably lower on a specific category: indemnification clauses with nested conditions. This category contained only a small number of test cases, making it invisible in aggregate metrics. Without per-category analysis, the regression would have reached production and affected the large share of enterprise contracts that contain nested indemnification language.

The fix was straightforward: a prompt modification specific to the indemnification extraction task that included few-shot examples of nested conditional clauses. This brought Claude’s performance on that category to parity with GPT-4 Turbo. The regression was discovered, diagnosed, and fixed within days. Without the pipeline, it would have been discovered by a customer, probably weeks after migration.

04

What would I change in hindsight?

I would have invested in human calibration from the start rather than weeks in. The LLM judge’s scoring was reasonably correlated with human judgment out of the box, but there were systematic biases: the judge over-scored format compliance (because well-formatted but incorrect outputs looked good) and under-scored nuance handling (because the judge lacked the legal domain expertise to recognize subtle hedging language). The calibration process, comparing judge scores to human expert scores on a held-out calibration set and adjusting the scoring rubric, brought correlation up markedly. Those first weeks of uncalibrated evaluation produced results I later had to re-evaluate.

I also should have built A/B testing into the pipeline from the start. The ability to route a small slice of production traffic to a candidate model and compare real-user outcomes with evaluation predictions would have provided the ground truth needed to continuously improve the evaluation’s predictive validity. I added this capability later in the project. The data confirmed that the evaluation pipeline’s predictions matched production quality outcomes closely at the category level.

The fundamental lesson is that evaluation infrastructure is not a project. It is a product. It requires ongoing investment, calibration, and iteration. The test suite grew steadily as new edge cases surfaced. The scoring rubric was revised repeatedly. The judge model was changed twice (from GPT-4 to Claude 3.5 Sonnet to GPT-4o, based on which provided the most calibrated scores for legal text). Treating evaluation as a one-time effort is like treating a CI pipeline as a one-time setup. It works until the first change, and then it becomes a liability.