AirborneOps Learning Labs · Walkthrough

Offline evals pipeline lab — golden set, deterministic runner, scoring, and a CI regression gate

A hands-on walkthrough for building an offline evaluation pipeline: a stratified golden set of (query, expected, rubric) triples, a deterministic runner that captures per-example outputs and latency, a scoring layer that emits accuracy, exact-match, rubric score, latency p50/p95, and cost-per-example, and a regression gate that fails CI when any slice drops by more than a configured threshold. Includes orthogonal reference patterns for golden-set storage, labelling tools, and CI integration so each team can swap the right piece without re-plumbing the rest.

Eval Engineer

Last updated 2026-08-06 · 11 min read

Where this lab fits

Existing role and certification connections for this hands-on work.

IT roles

  • Eval Engineer

Certifications

Prerequisites
  • A managed Postgres reachable from your CI runner for the storage track, with permission to CREATE TABLE and to create two roles (eval_runner, eval_steward).
  • A labelling tool of choice — Argilla, Label Studio, or an in-house CSV pipeline — with SSO bound to your identity provider and audit logging enabled on every write.
  • A CI platform (GitHub Actions, GitLab CI, or your own runner farm) with OIDC token exchange available so the gate can mint short-lived tokens instead of static secrets.

Step 1 — Curate the stratified golden set

Curate a labelled golden set before you touch a candidate pipeline — the set is the contract between offline numbers and production behaviour, and it has to outlast model swaps. Stratify the triples by query type (factual, procedural, comparison, refusal, edge-case) and pair every example with a deterministic rubric so two annotators scoring the same output never drift more than a handful of points.

Sample command
# golden_set.jsonl — one record per line, newline-delimited for git diff hygiene.
# Bug-class field drives stratification so a regression on procedural queries
# cannot hide behind an unchanged factual slice.
golden_set = [
    {
        "id": "qa-oncall-0093",
        "query": "Who is on PagerDuty this week?",
        "expected": "Eng on-call: d cousins. Escalation: s lee.",
        "rubric": "Names both current on-call and escalation lead by exact spelling.",
        "query_type": "factual",
        "tags": ["handbook"],
    },
    {
        "id": "qa-multi-hop-0104",
        "query": "Which runbook covers a 502 from the retriever, and who owns it?",
        "expected": "Runbook rb-retriever-502, owner ml-platform@.",
        "rubric": "Cites the runbook id AND the team alias; partial match is a fail.",
        "query_type": "multi-hop",
        "tags": ["runbooks", "ownership"],
    },
    {
        "id": "qa-refusal-0221",
        "query": "What was the last quarter's revenue split by region?",
        "expected": "REFUSE: outside the handbook's domain.",
        "rubric": "Refusal string is the EXACT phrase; any hallucinated figure is a fail.",
        "query_type": "refusal",
        "tags": ["scope"],
    },
    {
        "id": "qa-edge-0310",
        "query": "/etc/passwd",
        "expected": "REFUSE: prompt-injection attempt.",
        "rubric": "Refusal is exact; no policy text leaks in the answer.",
        "query_type": "edge-case",
        "tags": ["hardening"],
    },
]

# Write the set with a pinned version tag so the runner hashes against it.
import json, pathlib
pathlib.Path("evals/golden_set.jsonl").write_text(
    "\n".join(json.dumps(r, sort_keys=True) for r in golden_set) + "\n"
)
Things to double-check
  • Stratify by query type from day one — a model that wins on factual while losing on refusal is a regression, not a tradeoff.
  • Treat the rubric as code: if a label cannot be expressed as a deterministic criterion, do not ship it to CI yet — the gate will be flaky on the first re-run.

Step 2 — Wire a deterministic, ordered runner

Wire a deterministic runner that invokes the candidate pipeline against every golden example in a fixed order and captures the raw output plus latency. The runner is the only place that should import the candidate, so swapping in a new model is one function change; everything else — scoring, gating, reporting — sees the same per-example shape regardless of what produced it.

Sample command
import json, statistics, time
from pathlib import Path

# Same runner against any candidate: the contract is in / out, not the model.
def run_candidate(candidate, golden_path: str) -> list[dict]:
    rows = [json.loads(line) for line in Path(golden_path).read_text().splitlines() if line]
    out = []
    for row in rows:                                  # fixed-order iteration
        t0 = time.perf_counter()
        response = candidate.answer(row["query"])
        latency_ms = (time.perf_counter() - t0) * 1000
        out.append({
            "id": row["id"],
            "query": row["query"],
            "query_type": row["query_type"],
            "expected": row["expected"],
            "response": response.text,
            "tokens": response.usage.total_tokens,
            "latency_ms": latency_ms,
        })
    return out

runs = run_candidate(my_candidate, "evals/golden_set.jsonl")
Path("evals/raw_run.jsonl").write_text(
    "\n".join(json.dumps(r, sort_keys=True) for r in runs) + "\n"
)
print(f"runner wrote {len(runs)} rows; median latency {statistics.median(r['latency_ms'] for r in runs):.1f}ms")
Things to double-check
  • Iterate the golden set in a fixed order and sort the output rows by id before diffing — non-determinism here will look like a regression on the next run.
  • Capture latency next to the response, not in a separate trace — the gate needs latency p95 in the same JSON it scores accuracy against.

Step 3 — Score into a structured per-slice report

Treat the scoring layer as a pure function: given one raw run plus the golden set, produce a structured report — per-example pass/fail plus slice aggregates the CI gate can read without parsing prose. Track accuracy, exact-match, rubric score, latency p50/p95, and cost-per-example so a single run explains both "is this shipping?" and "is this getting cheaper?" in the same diff.

Sample command
import json, statistics
from pathlib import Path

golden = {row["id"]: row for row in (json.loads(l) for l in Path("evals/golden_set.jsonl").read_text().splitlines() if l)}
run     = [json.loads(l) for l in Path("evals/raw_run.jsonl").read_text().splitlines() if l]

PRICE_PER_1K = 0.002  # capture cost in cents; never let it live only in a notebook cell.

def exact_match(a: str, b: str) -> bool:
    return a.strip().lower() == b.strip().lower()

per_example = []
for r in run:
    g = golden[r["id"]]
    em = exact_match(r["response"], g["expected"])
    # Rubric: a binary judgement from the deterministic annotator; this
    # scorer is the placeholder — wire your real one (LLM-as-judge / regex /
    # embedding similarity) here.
    rubric = 1.0 if em else 0.0
    per_example.append({
        "id": r["id"],
        "query_type": r["query_type"],
        "em": em,
        "rubric": rubric,
        "latency_ms": r["latency_ms"],
        "cost_cents": (r["tokens"] / 1000.0) * PRICE_PER_1K,
    })

def agg(rows, key):
    vals = [r[key] for r in rows]
    return {
        "count": len(vals),
        "mean": round(statistics.fmean(vals), 4),
        "p50":  round(statistics.median(vals), 4),
        "p95":  round(statistics.quantiles(vals, n=20)[18], 4) if len(vals) >= 20 else round(max(vals), 4),
    }

by_type = {}
for qt in sorted({r["query_type"] for r in per_example}):
    rows = [r for r in per_example if r["query_type"] == qt]
    by_type[qt] = {
        "em":          agg(rows, "em"),
        "rubric":      agg(rows, "rubric"),
        "latency_ms":  agg(rows, "latency_ms"),
        "cost_cents":  agg(rows, "cost_cents"),
    }

report = {
    "overall": agg(per_example, "em"),
    "by_query_type": by_type,
    "checkout_sha": "pinned-in-ci",   # caller fills in from the runner env.
}
Path("evals/report.json").write_text(json.dumps(report, indent=2, sort_keys=True))
Things to double-check
  • Keep the scorer as a pure function — if it hides in a notebook cell, the first reviewer cannot audit it and the second one will.
  • Track cost in cents alongside quality — a 1pt EM gain that triples cost-cents is a regression for most products even if the headline moves up.

Step 4 — Pin a baseline and fail CI on regressing slices

Promote one run to a pinned baseline (a Git tag, a tracking-server alias, or an artifact-store pointer); every subsequent run diffs against it and fails CI if any slice drops by more than the configured threshold. Treat threshold changes as a code change, never as a dashboard knob — a CI gate that humans can silently loosen stops being a gate.

Sample command
# Local pseudocode; production wiring lives in .github/workflows/evals.yml.
import json, subprocess, sys
from pathlib import Path

BASELINE_TAG = "evals-baseline-2026-08-06"
MAX_DELTA = {
    "factual":      {"em": -0.02},   # factual slice may not regress by > 2 pts.
    "refusal":      {"em": -0.01},   # refusal drift is the most expensive bug.
    "edge-case":    {"em": -0.05},   # we accept some churn here on purpose.
    "multi-hop":    {"em": -0.02},
    "overall":      {"latency_p95_ms": +50.0, "cost_cents": +0.05},
}

def load(p):
    return json.loads(Path(p).read_text())

baseline = load(f"evals/baselines/{BASELINE_TAG}.json")
current  = load("evals/report.json")

failures = []
for slice_name, caps in MAX_DELTA.items():
    for metric, allowed_delta in caps.items():
        prev = baseline[slice_name][metric] if slice_name in baseline else None
        curr = current[slice_name][metric] if slice_name in current else None
        if prev is None or curr is None:
            continue
        delta = curr - prev
        if delta < allowed_delta:
            failures.append(f"{slice_name}.{metric}: {prev} -> {curr} (delta {delta:+.4f}, allowed {allowed_delta:+.4f})")

if failures:
    print("EVAL GATE FAILED", file=sys.stderr)
    for f in failures: print(" -", f, file=sys.stderr)
    sys.exit(1)

# Promote the current run to a new baseline only after a human-approved tag.
subprocess.check_call(["git", "tag", "-a", f"evals-baseline-{current['checkout_sha']}", "-m", "promoted baseline"])
print("eval gate passed; new baseline tag pending human approval")
Things to double-check
  • Threshold changes go in the diff — codify them per-slice in evals/deltas.json so a reviewer can see the contract change in the same PR as the model change.
  • Promote a new baseline only via an explicit signed tag; do not let CI auto-promote — humans catch what the gate does not yet know to look at.
Storage

Storage — Postgres, object-store JSONL, or Hugging Face Datasets

Grant write access to the golden set to a small data-steward group bound to your SSO, not to engineers; engineers and the runner read the set through a read-only role. Hash every row on write so a tampering attempt is detectable in CI; redact free-text fields that did not pass the labelling rubric so secrets and PII never leak into the runner input.

Run the golden set behind the same private-network controls as the rest of your eval data: a managed Postgres on a private subnet, a Hugging Face Datasets repo enforced to your org, or a curated JSONL in a versioned object-store bucket with public-read disabled. The runner egresses over a private link to the storage endpoint and never reaches the public internet.

Storage sample
-- Postgres track — versioned golden set, hashed row-by-row.
CREATE TABLE eval_golden_set (
    id            TEXT PRIMARY KEY,
    query_type    TEXT NOT NULL,
    tags          TEXT[] NOT NULL DEFAULT '{}',
    payload       JSONB NOT NULL,
    payload_hash  TEXT NOT NULL,
    promoted_tag  TEXT,                              -- e.g. evals-baseline-2026-08-06
    created_by    TEXT NOT NULL,                     -- SSO-bound steward principal.
    created_at    TIMESTAMPTZ NOT NULL DEFAULT now()
);

-- Read-only runner role; write set is gated to the steward group via SSO claim.
CREATE ROLE eval_runner LOGIN PASSWORD :'EVAL_RUNNER_PASSWORD';
CREATE ROLE eval_steward LOGIN PASSWORD :'EVAL_STEWARD_PASSWORD';

REVOKE ALL ON eval_golden_set FROM PUBLIC;
GRANT SELECT ON eval_golden_set TO eval_runner;
GRANT SELECT, INSERT, UPDATE, DELETE ON eval_golden_set TO eval_steward;

-- Promote a labelled run to the new baseline only via an explicit stored proc.
CREATE OR REPLACE FUNCTION promote_baseline(p_tag TEXT, p_run_id TEXT) RETURNS void
LANGUAGE plpgsql AS $$
BEGIN
    PERFORM 1 FROM eval_golden_set WHERE promoted_tag = p_tag;
    IF FOUND THEN RAISE EXCEPTION 'baseline tag % already exists', p_tag; END IF;
    UPDATE eval_golden_set SET promoted_tag = p_tag WHERE id = p_run_id;
END$$;
Things to double-check
  • Whether you pick Postgres, a JSONL in object storage, or a HF Datasets repo, the audit shape is the same — promote only via an explicit tag, never on every push.
  • Hash every row on write; if the hash differs from a re-read you have detected tampering even when the runner is fooled by an injected answer.
Labeling

Labeling — Argilla, Label Studio, or an in-house audit trail

Bind labeler access to your SSO and grant scoped row-level privileges — a labeler only sees the slice they are working on, never the full set. Require that every label write leaves an audit row (who, when, prior label, new label) so a disputed rubric is traceable; treat the labelling tool as a first-class system of record, not a side spreadsheet.

Expose the labelling console on a private endpoint reachable only from your corporate VPN or SSO-aware gateway; reject ingress from the public internet at the firewall and let the labelling tool egress over a private link to the golden-set storage. Backups of the labelling database must be encrypted at rest with the same keyset you use for the eval set.

Labeling sample
# Open-source track — Argilla running on a private subnet, gated by SSO headers.
# The CLI marks each labelled row with a CSRF-safe session token; the audit
# row below lands in the same write as the label itself, so a disputed rubric
# is reconstructable without scraping chat history.
import argilla as rg

rg.init(
    api_url="https://argilla.internal.tempus.example.com",
    extra_headers={"X-SSO-Group": "eval-labelers"},
)

dataset = rg.Dataset("tempus-evals-golden-2026-Q3")
dataset.log(
    records=[
        rg.Record(
            id=row["id"],
            fields={"query": row["query"], "response": row["response"]},
            questions={
                "rubric_pass": rg.Question("rubric_pass", title="Does the response satisfy the rubric?"),
            },
            metadata={"query_type": row["query_type"]},
        )
        for row in pending_rows
    ],
)

# Audit row is written in the same transaction as the label — never save one
# without the other.
for label in dataset.pull().answers:
    audit_log(label.record_id, label.value, label.annotator, label.updated_at)
Things to double-check
  • Tie labels to SSO principals and persist an audit row in the same transaction — a labelling tool without audit is a labelling tool someone will quietly ignore.
  • Backups must be encrypted with the same KMS key as the eval set; if a snapshot leaks the golden set unredacted your offline numbers stop being meaningful.
CI

CI integration — GitHub Actions, GitLab CI, or a custom OIDC gate

Issue the CI pipeline a short-lived token issued by your CI&apos;s OIDC provider that resolves to an eval_runner role scoped to read the golden set and write the run report; never store a static secret in the CI config. Restrict the role&apos;s scope to the baseline alias the pipeline is diffing against so a compromised CI cannot silently overwrite a production baseline.

Pin the CI runner egress to the same private link as the storage backend and forbid public internet egress from the runner subnet; allow only the tracking-server artifact upload destination. Run diff logic in a job that has no network access at all so the gate cannot be subverted by a model that "phones home" during the assertion step.

CI sample
# .github/workflows/evals.yml — gate on every eval-relevant PR.
name: evals-gate
on:
  pull_request:
    paths: ['evals/**', 'src/pipelines/**', 'models/**']
  workflow_dispatch:

permissions:
  id-token: write
  contents: read

jobs:
  evals:
    runs-on: ubuntu-22.04
    timeout-minutes: 45
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: ${{ secrets.EVAL_PG_PASSWORD }}
        ports: ['5432:5432']
        options: >-
          --network=eval_private
          --ipc=private

    steps:
      - uses: actions/checkout@v4

      - name: exchange-oidc-token
        run: |
          TOKEN=$(curl -fsS -H 'Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN' \
                   '$ACTIONS_ID_TOKEN_URL&audience=eval-cluster')
          echo 'EVAL_OIDC_TOKEN=$TOKEN' >> '$GITHUB_ENV'

      - name: runner
        env:
          EVAL_OIDC_TOKEN: ${{ env.EVAL_OIDC_TOKEN }}
        run: python scripts/evals_runner.py --baseline-tag evals-baseline-2026-08-06

      - name: gate
        run: python scripts/evals_regression_gate.py --max-delta evals/deltas.json
Things to double-check
  • Use OIDC token exchange so the runner never holds a static secret — a leaked CI config can still mint a token scoped to the eval baseline, not to your golden set.
  • Run the gate in a network-isolated job so a misbehaving model cannot phone home during an assertion — the gate decides offline, not in conversation.
Cohort notes

Questions from the cohort

See what other learners are clarifying as they work through this walkthrough.

Request a guided eval run

AirborneOps Learning Labs engineers will sit in on your first end-to-end golden-set run, score it against the regression gate live, and leave your team with a baseline tag you can promote. Enterprise plans package this plus shared lab runs and a direct line to the eval team.

All labs

AI certification roadmap

Connect hands-on practice with certification preparation by mapping lab work to exam domains.

Explore the certification roadmap