页面简介
Choose models using evidence from your application’s inputs and output formats. Run identical tasks through OpenRouter and compare graded accuracy, billed
正文摘录
How to Benchmark LLMsOpenRouter ·11/12/2026TL;DRTL;DRStep 1. Write tasks with answers a script can checkStep 2. Grade with code, and check the graderStep 3. Run the three-task Python exampleStep 4. Add your own task and graderStep 5. Compare saved runs and handle missing answersWhich model did best on our benchmark?How do public LLM benchmarks compare with your own?How many times should you run each task?FAQNext stepsChoose models using evidence from your application’s inputs and output formats. Run identical tasks through OpenRouter and compare graded accuracy, billed cost, and request time. On our 60 synthetic tasks, GPT-6.1 Sol passed 180/180 trials across three repeats under the tested contracts and settings. TL;DR Code checks measure correctness and output compliance. Sol passed 180/180 trials on our synthetic set; DeepSeek had the lowest response cost, with 157/180 passes. Agreement with the public ranking was weak, with a Spearman correlation of 0.109. Before you trust a score, check how many times each task ran, how many answers came back, and whether each bill was verified. Define the behavior first, then its checks. Step 1. Write tasks with answers a script can check A task needs an input, expected answer, and output contract. For invoices, specify included rows, rounding, and acceptable currency suffixes. We wrote all 40 baseline tasks and 20 hard tasks before the final run. CategoryExampleCheckInvoice arithmeticTotal unpaid rows after discountsDecimal total and roundingDates and schedulesConvert a timestamp or list matching datesExact instant or date listEmail extractionExtract fields into JSONKeys, types and valuesPython functionsImplement a function against hidden inputsResults in an isolated runtimeOutput constraintsProduce text within specified restrictionsLength, vocabulary and formatRefund decisionsApply a written policy at its boundariesDecision for each order Compute references independently. Separate prompt-tuning cases from final evaluation. Refund cases test written decisions, without executing transactions. Step 2. Grade with code, and check the grader Use exact matching for APPROVE, and schema/value checks for JSON. Normalize only permitted differences. Accepting prose around a number hides a failure when your consumer requires only a number. Test known-correct, wrong, and malformed responses. For a refund threshold, include exactly $200 and 30 days, then values just above each boundary. Our development checker rejected valid Python because it omitted ord and type. We corrected it before the final study, specifying CPython 3.12.10/WASI with resource limits. Otherwise, checker failures would have counted against models. The full-study runner isolates generated code and stops if sandbox setup is missing. The teaching example executes no generated code. Step 3. Run the three-task Python example Download the companion ZIP. Before extracting it, compare its SHA-256 checksum with: a38ee17a2eb7090f9f4849a605cc8214691c889ca0ae40c121259603592178e8 PowerShell: Get-FileHash .\benchmark-reader-companion.zip -Algorithm SHA256 Linux or macOS: # Linux sha256sum benchmark-reader-companion.zip # macOS shasum -a 256 benchmark-reader-companion.zip If the values differ, stop and check the download. After they match, extract the ZIP. You need Python 3.12 or later. The standard-library teaching runner, JSON example, and comparisons passed offline checks on Windows x64 and Linux. macOS remains untested. The bundled full-study sandbox and native Ori setup support Windows x64 only. From the extracted folder: python verify_package.py python three_tasks.py check The check prints OFFLINE reference and grader checks passed; zero inference calls. The complete script follows in file order. Its companion module handles requests, persistence, and reporting. """Three exact contracts; run from the extracted companion (standard library).""" import argparse from datetime import datetime, timezone from decimal import Decimal import json from pathlib import Path import re from reader_core import execute, reconcile, report, read, load_config, finish_grade TASKS = [ {"id": "invoice", "prompt": "Two unpaid lines cost 3 x 12.50 USD and 2 x 4.25 USD. Return only their total with exactly two decimal places.", "expected": "46.00"}, {"id": "utc", "prompt": "Convert 2026-10-18T10:30:00+02:00 to UTC. Return only YYYY-MM-DDTHH:MM:SSZ.", "expected": "2026-10-18T08:30:00Z"}, {"id": "refund", "prompt": "Policy: approve only if amount <= 200 USD and age <= 30 days. Amount=200 USD; age=30 days. Return only APPROVE or DENY.", "expected": "APPROVE"}, ] def refund_policy(amount, days): return "APPROVE" if Decimal(str(amount)) <= 200 and days <= 30 else "DENY" def grade(task, text, finish): terminal = finish_grade(finish) if terminal: return terminal if not isinstance(text, str) or not text.strip(): return {"passed": False, "classification": "empty"} text = text.strip() patterns = {"invoice": r"\d+\.\d{2}", "utc": r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z", "refund": r"APPROVE|DENY"} valid = bool(re.fullmatch(patterns.get(task["id"], r"\d+\.\d{2}"), text)) passed = valid and text == task["expected"] and finish == "stop" return {"passed": passed, "classification": "pass" if passed else ("incorrect" if valid else "malformed")} Before using a score, check its reference and rejection rules. These offline fixtures cover boundary decisions, invalid formats, and truncated answers without calling a model. def offline(): money = Decimal(3) * Decimal("12.50") + Decimal(2) * Decimal("4.25") assert format(money, ".2f") == TASKS[0]["expected"] utc = datetime.fromisoformat("2026-10-18T10:30:00+02:00") assert utc.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") == TASKS[1]["expected"] assert refund_policy(200, 30) == TASKS[2]["expected"] for amount, days, expected in [(200.01, 30, "DENY"), (200, 31, "DENY"), (199.99, 29, "APPROVE"), (0, 0, "APPROVE")]: assert refund_policy(amount, days) == expected for task in TASKS: assert grade(task, task["expected"], "stop")["passed"] for bad in ("wrong", None, "", '{"answer": 46}', "APPROVE please"): assert not grade(task, bad, "stop")["passed"] assert not grade(task, task["expected"], "length")["passed"] assert not grade(TASKS[0], "47.00", "stop")["passed"] assert not grade(TASKS[2], "DENY", "stop")["passed"] print("OFFLINE reference and grader checks passed; zero inference calls.") Keep checking separate from spending. The command interface defaults to offline validation and requires an explicit live option and allowance before inference. def main(tasks=None, grader=grade, default_config="demo-config.json", offline_check=None): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("operation", nargs="?", default="check", choices=["check", "plan", "run", "report", "reconcile"]) parser.add_argument("--config", default=default_config) parser.add_argument("--run-dir", type=Path, default=Path("runs/demo")) parser.add_argument("--live", action="store_true") parser.add_argument("--max-usd", default="0") parser.add_argument("--resume", action="store_true") parser.add_argument("--tasks", help="Optional exact-contract custom task JSON") args = parser.parse_args() if args.operation == "check": if args.tasks: parser.error("Use an example entry point with its own offline_check; check does not accept --tasks overrides") if offline_check is not None: offline_check() elif tasks is not None or grader is not grade or args.tasks: parser.error("Custom tasks/graders require offline_check=... for their own reference and fixture checks") else: offline() return selected = read(args.tasks) if args.tasks else (tasks if tasks is not None else TASKS) config = load_config(args.config) if args.operation == "report": print(json.dumps(report(args.run_dir), indent=2)) elif args.operation == "reconcile": reconcile(args.run_dir, live=args.live) print(json.dumps(report(args.run_dir), indent=2)) else: execute(args.run_dir, selected, config, grader, args.max_usd, live=args.live, resume=args.resume, plan=args.operation == "plan") if __name__ == "__main__": main() Configure and inspect the plan Use the supplied Luna configuration to set the model, repeat count, token allowance and provider constraints: { "models": [ "openai/gpt-6-luna" ], "repeats": 1, "max_tokens": 1024, "settings": { "openai/gpt-6-luna": { "provider": { "require_parameters": true, "allow_fallbacks": true, "max_price": { "prompt": 0.09999999999999999, "completion": 0.5, "request": 0 } }, "reasoning": { "effort": "low" } } } } Sol’s configuration preserves the repeat/token settings but uses its own price ceilings: { "models": [ "openai/gpt-6.1-sol" ], "repeats": 1, "max_tokens": 1024, "settings": { "openai/gpt-6.1-sol": { "provider": { "require_parameters": true, "allow_fallbacks": true, "max_price": { "prompt": 2.0, "completion": 10.0, "request": 0 } }, "reasoning": { "effort": "low" } } } } models selects candidates, repeats specifies requests per task, and max_tokens sets the completion allowance. Reasoning can consume that allowance before visible output. Offline checks make no API calls. Paid runs require the explicit —live flag. Length-truncated responses fail without retry. Price ceilings use USD per million tokens; Luna’s prompt ceiling is approximately $0.10. If a provider no longer supports the saved settings, the runner must stop rather than silently change them. Provider fallback doesn’t swap models or resend inference. python three_tasks.py plan --config luna-config.json Actual offline output: {"planned_calls": 3, "max_tokens": 1024, "models": ["openai/gpt-6-luna"], "repeats": 1, "estimated_reservations_usd": "0.0023543749999999999565625"} A reservation is a local cost estimate, not an account hold or guaranteed cap. Plan before choosing an allowance. Teaching selectionCallsEstimated reservationsLuna, three tasks3$0.0023544Sol, three tasks3$0.0470875Luna, JSON task below1$0.00080725Sol, JSON task below1$0.016145 Changing tasks, repeats, or tokens changes