Skip to content
CyriellewuPublic

About

A local-first, DuckDB-native workbench for evaluating LLMs and agents: suites, multi-model runs, pluggable scorers (incl. SQL-execution + drift), and a dashboard.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

llm-lab

A local-first, DuckDB-native workbench for evaluating LLMs and LLM-agents.

Define a suite, run it across many models in parallel, and land every prompt, output, and score in one DuckDB eval warehouse. Then get a leaderboard, a per-scorer breakdown, a per-task heatmap, model-vs-model diffs, and behavioral drift — from a single dashboard, or with your own SQL. No cloud, no accounts: your evals in a file you own.

dashboard

Why

Most eval tooling is a hosted service you send your prompts to. llm-lab is the opposite: one integrated, offline platform where the warehouse is the product. Everything — model comparison, task-fidelity scoring, judge scores, drift — is just rows you can SELECT from. It unifies a family of eval ideas into one coherent tool:

capability scorer / view
execute model code vs unit tests (pass@1) python_exec
text-to-SQL correctness (executes the SQL!) sql_exec
structured output valid + schema-conformant json_schema
model behavior comparison + semantic drift drift scorer + dashboard drift view
exact / substring / length checks exact_match, contains, length_ok
LLM-as-judge rubric scoring llm_judge
SQL-queryable results, model diffing, CI gate warehouse + lab diff + lab gate

Execution-grounded. Three scorers don't match strings — they run the output: python_exec executes model code against unit tests in an isolated subprocess (pass@1; bypass-resistant — see Security), sql_exec runs the SQL in DuckDB and compares result tables, json_schema validates against a real JSON Schema (Draft 2020-12 via jsonschema). That's what separates a real eval harness from a vibe check.

Quick start (zero config, offline)

python -m venv .venv && .venv\Scripts\pip install numpy duckdb pyyaml jsonschema
python -m llmlab run suites/general_qa.json --models "mock:strong,mock:medium,mock:weak"
python -m llmlab run suites/text_to_sql.json --models "mock:strong,mock:weak" --report
# open reports/dashboard.html

The built-in mock providers are deterministic, offline, and clearly synthetic — mock:strong / mock:medium / mock:weak are capability tiers, not real models, so the demo and CI run with no API keys and no result is mistakable for a real benchmark. Example:

=== llm-lab: ran suite 'general-qa' across 3 model(s) ===
  strong   pass 1.0    mean 1.0
  medium   pass 1.0    mean 1.0
  weak     pass 0.333  mean 0.5     <- weak tier, caught

Real model results should be recorded separately (with date, model snapshot, temperature, and commit SHA) — they are never conflated with the synthetic mock tiers above.

Evaluate real models

Any OpenAI-compatible endpoint (OpenAI, or a gateway like OpenRouter / Ollama /v1):

set LLM_LAB_API_KEY=sk-...
# set LLM_LAB_BASE_URL=https://openrouter.ai/api/v1
python -m llmlab run suites/general_qa.json --models "gpt-4o,claude-3-5-sonnet,gemini-1.5-pro" --report

Fan-out is parallel, so running a suite across your whole model fleet is one command.

Commands

lab run <suite> --models a,b,c [--report] [--judge <model>]  # run + score into warehouse
lab report [--suite NAME]                                    # (re)build the dashboard
lab leaderboard [--suite NAME]                               # print the leaderboard
lab diff <modelA> <modelB> [--suite NAME]                    # task-by-task score diff
lab reliability [--suite NAME]                               # pass@k / majority / flakiness / CI
lab pareto --suite NAME [--prices p.json] [--svg out.svg]    # cost x quality x latency frontier
lab inspect --suite NAME --task T [--model M]                # per-sample outputs + scores (why it failed)
lab gate ...                                                 # CI gate — see below
lab query "SELECT ..."                                       # raw SQL over the warehouse

Execution-grounded coding eval

python -m llmlab run suites/coding_exec.json --models "mock:strong,mock:medium,mock:weak"
#   strong  pass 1.0     (all unit-test suites passed)
#   medium  pass 0.75
#   weak    pass 0.25    <- buggy code caught by actually running the tests

Each task ships hidden unit tests; the model's function is executed against them in an isolated subprocess with a timeout. Correctness = tests pass, not string similarity.

Reliability: pass@k, flakiness, confidence intervals

Single-shot eval is noisy. A model that passes a task 1-in-10 tries and one that passes 9-in-10 can both look like pass_rate=0.5 at k=1. Sample each task n times at temperature>0 and llm-lab reports the real reliability picture:

python -m llmlab run suites/coding_exec.json --models "mock:strong,mock:medium,mock:weak" \
    --samples 10 --temperature 0.8 --k 3
model      pass@1  pass@3  majority  flaky        95% CI       (n=10, temp=0.8)
strong      0.95    1.00     1.00     0.15    [0.835, 0.986]
medium      0.675   0.985    1.00     0.466   [0.520, 0.799]   <- flaky: rescued by retries
weak        0.50    0.852    0.50     0.462   [0.352, 0.648]
  • pass@k — the unbiased HumanEval estimator 1 − C(n−c,k)/C(n,k) (probability the model solves the task within k tries). medium is a coin-flip at k=1 but near-perfect at k=3 — that's a real, actionable difference.
  • majority — self-consistency: score the modal output across the n samples.
  • flakiness — std of per-sample pass; high = unstable, you can't trust one run.
  • 95% CI — Wilson interval over all n×tasks samples; how much to trust the number.

Every sample is stored per-row (samples.sample_idx), so lab query can slice any of it. lab reliability --suite S prints the table any time.

Inspect: why did it fail?

Aggregate scores tell you a model is flaky; lab inspect shows you why — every sample's actual output and per-scorer result for one task:

python -m llmlab inspect --suite coding-exec --task two-sum-indices --model weak
=== weak ===
  [ 0] python_exec:ok(1.0)   def two_sum(nums,target): seen={} ...   # correct hashmap
  [ 2] python_exec:x(0.0)    def two_sum(nums,target): for i in ...  # buggy double-loop, wrong
  [ 3] python_exec:ok(1.0)   def two_sum(nums,target): seen={} ...

You can literally see the model flip between a correct and a buggy solution across samples — the concrete cause of the flakiness the reliability view flagged.

Eval in CI — real regression gate

lab gate has two modes and exits non-zero (blocks CI) on failure:

# absolute threshold: one named model must clear a bar
lab gate --suite coding-exec --model gpt-4o --min-pass 0.9

# regression: a candidate must not drop vs a baseline (lists newly-failing tasks)
lab gate --suite coding-exec --candidate new-model --baseline prod-model --max-pass-regression 0.02
# gate [FAIL]  candidate=new-model vs baseline=prod-model
#   pass_rate  baseline 0.917 -> candidate 0.833  (drop +0.084, allowed 0.02)
#   newly FAILING tasks (1): two-sum-indices          (exit 1)

Unlike a "best of any model passed" check, this gates the specific candidate against a specific baseline — a real regression signal, not a lucky pass by some other model.

Cost × quality × latency Pareto

Picking a model by one leaderboard number leaves accuracy or money on the table. lab pareto joins quality with cost (from token counts × a price table) and latency (already recorded), then marks the non-dominated frontier:

python -m llmlab run suites/general_qa.json --models "mock:strong,mock:medium,mock:weak,mock:weak2"
python -m llmlab pareto --suite general-qa --prices suites/demo_prices.json
model         quality     cost $   p50 ms  status
strong          1.0     0.000369      0.0  FRONTIER
medium          0.875   0.000068      0.0  FRONTIER
weak            0.55    0.000018      0.0  FRONTIER
weak2           0.45    0.000251      0.0  dominated   <- worse on every axis

A model is dominated when some other model is at least as good on all three axes. The dashboard renders this as an SVG scatter with the frontier line (see the Pareto section of dashboard.html). Cost is estimated from stored tokens — bring your own --prices file; mock:* tiers are free.

Docker executor (opt-in sandbox)

The in-process python_exec harness is bypass-resistant but is isolation, not a sandbox. Set LLM_LAB_DOCKER=1 to run candidate code inside a container with --network=none, read-only FS, and memory/CPU/PID limits (builds from docker/, falls back to the in-process harness if Docker is unavailable). See docs/docker-executor.md.

Reusable GitHub Action

Drop the eval regression gate into any repo's CI — it installs llm-lab, runs the gate, fails the job on regression, and posts a PR comment with the report. See docs/github-action.md:

- uses: Cyriellewu/llm-lab@main
  with:
    suite-file: suites/coding_exec.json
    models: mock:strong,mock:medium,mock:weak
    candidate: strong
    baseline: weak
    max-pass-regression: '0.0'

lab diff output:

diff  A=strong  B=weak
task                          A      B  Δ
big-o                       1.0  0.167  -0.833  *
capital-fr                0.684  0.418  -0.266  *
math-add                    1.0    1.0     0.0

Suites

A suite is JSON or YAML: tasks + which scorers to apply (+ an optional baseline model for drift). Tasks may carry meta for scorers (e.g. a schema for sql_exec):

{
  "name": "text-to-sql",
  "scorers": ["sql_exec"],
  "tasks": [{
    "id": "total-by-region",
    "prompt": "Given sales(region, amount), total amount per region.",
    "expected": "SELECT region, SUM(amount) FROM sales GROUP BY region",
    "meta": {"schema_sql": "CREATE TABLE sales(region VARCHAR, amount INT); INSERT INTO sales VALUES ('N',100),('S',80);"}
  }]
}

The sql_exec scorer executes both the model's SQL and the gold SQL in a fresh DuckDB and compares result tables — correctness by answer, not string match.

The warehouse

Four plain tables, so any question is a SQL query:

  • models(model_id, spec, provider)
  • runs(run_id, suite, model_id, started_at, n_tasks, mean_score, pass_rate)
  • samples(run_id, task_id, prompt, output, tokens, latency_ms)
  • scores(run_id, task_id, scorer, score, passed, detail)
lab query "SELECT model_id, scorer, ROUND(AVG(score),2) FROM scores s JOIN runs r USING(run_id) GROUP BY 1,2"

Add a scorer

Write a function (task, output, ctx) -> ScoreResult and register it in llmlab/scorers/__init__.py. It's immediately usable from any suite.

Security

python_exec runs model-generated code and sql_exec runs model SQL. This is process isolation with a wall-clock timeout, NOT a security sandbox — it does not restrict filesystem, network, or CPU/memory. python_exec is hardened against the common eval-gaming tricks: the candidate code and tests run in a separate file, and a run is only scored PASS if the harness prints a per-run random nonce the candidate cannot know or forge — so print("OK"), raise SystemExit(0), or printing a guessed sentinel all fail (covered by tests). But a determined adversarial model with arbitrary code execution can still do harmful things, so run untrusted models inside a container or VM. A Docker executor is on the roadmap.

Status

v0.5 — DuckDB warehouse with per-sample storage + per-sample inspection (lab inspect — see why a model failed a task); mock (synthetic tiers) + OpenAI-compatible providers; JSON/YAML suites; execution-grounded scorers (python_exec bypass-resistant + opt-in Docker sandbox, sql_exec, json_schema Draft 2020-12) + exact_match/contains/length_ok/llm_judge + semantic drift; reliability sampling (pass@k, majority vote, flakiness, Wilson CI); cost × quality × latency Pareto; parallel runner; dashboard; a candidate-vs-baseline regression gate; a reusable GitHub Action; 29 tests + CI. Maintained project: LICENSE, CHANGELOG, CONTRIBUTING, issue/PR templates, tagged releases. Roadmap: auto-sync prices, dashboard per-sample drill-down, more executors.

MIT licensed — see CHANGELOG and CONTRIBUTING.

About

A local-first, DuckDB-native workbench for evaluating LLMs and agents: suites, multi-model runs, pluggable scorers (incl. SQL-execution + drift), and a dashboard.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages