CLI tools stdlib only

model-bench

Trial local models on this machine: how fast they are, how good they are, and which one is worth using.

What it does

  • Measures cold load, time-to-first-token, prefill and decode throughput at short, medium, and long prompt sizes — after a discarded warmup.
  • Runs 15 deterministic quality tasks: JSON, instruction following, Python code against unit tests, SQL against SQLite, reasoning, extraction, summarisation, and a whole-app Snake game.
  • Reports VRAM and GPU offload, marks the Pareto frontier, and scores speed vs quality with configurable weights.
  • Records model digests and environment details — Python/platform, GPU driver/CUDA, and selected OLLAMA_* variables — for reproducibility.
  • Reports within-case speed variance and an 8-gram repetition ratio, flagging outputs that are likely looping.
  • Writes report.md, results.json, report.csv, and the raw response for every task.

Requirements

  • Ollama reachable at http://localhost:11434; honours OLLAMA_HOST.
  • Python 3.10+. Standard library only — no venv, no pip install.
  • Optional: nvidia-smi for the GPU line, and ollama on PATH for --pull.

Install

curl -fsSL https://raw.githubusercontent.com/yakovkhalinsky/ai-things/main/install.sh | sh -s -- model-bench

Installs model-bench into ~/bin. Install ol separately with sh -s -- ol if you want it. From a checkout, replace model-bench with ./bench.py in the examples below.

The optional --browser checks need node and Playwright:

cd ~/.local/share/ai-things/tools/model-bench
npm install
npx playwright install chromium

Usage

model-bench --self-test                    # check graders
model-bench --list-tasks                   # tasks and suites
model-bench --suggest                      # GPU suggestions
model-bench -m qwen3:4b -m llama3.2:3b     # compare models
model-bench --installed --suite full       # full suite
model-bench --speed-only --no-think        # throughput only
model-bench --category webapp --browser    # whole-app + runtime

What you get

A console summary, plus a markdown report and machine-readable results:

model         quality  decode t/s  prefill t/s  load s  vram MiB  gpu %  trunc  score
llama3.2:1b        88%       121.1        12757    2.60      1448    100      0   89.5
qwen2.5:1.5b       75%       130.9         7902    3.26      1115    100      0   85.0

Example run on an RTX 4060 Laptop 8 GB. Your numbers will differ.

What's in the suite

Eight tasks run in --suite quick; --suite full adds seven more. Every grader is deterministic — there is no LLM judge — and code tasks are executed, not inspected.

Speed benchmark

Three prompt sizes — short (~10 tokens), medium (~500), and long (~2k) — after a cold load, a discarded warmup, and --repeats runs per case (default 3). The report shows median decode tok/s, prefill tok/s, TTFT, and the separate cold-load time. Each request is nonce-tagged so Ollama's prefix cache cannot fake prefill speed.

Quick suite (8 tasks)

TaskWhat it asksHow it is graded
json_basicFlat JSON object for Ada Lovelace: name, age=36, three fields.Parses the first JSON value; checks exact keys, types, and values.
instr_wordsExplain recursion in ≤25 words, one line, no code or list.One line, 5–25 words, mentions recursion, no fence/list.
instr_bulletsExactly three unit-test benefits, each starting - and ≤8 words.Exact line count, prefix, and per-line word cap.
instr_primeExactly two primes, comma-separated, nothing else.Full-output shape plus a primality check.
code_fizzbuzzfizzbuzz(n) returning Fizz/Buzz/FizzBuzz strings.Generated Python executed against unit tests.
reason_mathPacks of 6, buy 4, give 6 away, split three ways.Last number in the answer must be 6.
reason_mcWhich statement must be true about roses and tulips?Last standalone letter must be D.
extract_invoiceJSON fields from a messy invoice.Vendor, invoice number, total, and ISO due date checks.

Full suite adds 7 tasks

The full suite includes the quick tasks plus these. webapp_snake carries weight 2; everything else is weight 1.

TaskWhat it asksHow it is graded
json_nestedNested order object with booleans, numbers, and item arrays.Nested type, shape, and value checks.
code_slugifyslugify(s) handling punctuation, runs, and empty strings.Executed against edge-case unit tests.
code_bugfixFix unique() so it preserves first-occurrence order.Executed order-preservation tests.
reason_logicThree people, three pets: who owns the fish?Final line must name Ana and the fish.
summarize_facts≤30-word summary mentioning ARPANET and 1969.Word cap plus both required facts.
sql_top_customersTop two customers by total order amount.SQL executed against a seeded SQLite database.
webapp_snakeComplete single-file Snake game.Structure and inline JS syntax; optional headless-browser run.
Exact prompts

The literal text sent to /api/generate. Tasks with a format hint also send format=json.

JSON

json_basic quick · format=json · 200 tokens

Return ONLY a JSON object (no markdown, no prose) describing Ada Lovelace with exactly these keys: "name" (string), "age" (integer, 36), "fields" (array of exactly 3 strings).

json_nested full · format=json · 300 tokens

Return ONLY a JSON object with these keys: "order_id" (the string "A-1042"), "paid" (boolean true), "items" (array of exactly 2 objects, each with a "sku" string and a "qty" integer), and "total" (the number 59.5).

Instruction following

instr_words quick · 120 tokens

Explain what recursion is in at most 25 words. Do not use code, bullet points, or a preamble. Answer on a single line.

instr_bullets quick · 150 tokens

List exactly 3 benefits of writing unit tests. Output only three lines, each starting with '- ' and no longer than 8 words. No heading.

instr_prime quick · 60 tokens

Give exactly two examples of a prime number, separated by a comma. Output nothing else: no words, no explanation.

Code

code_fizzbuzz quick · 350 tokens

Write a Python function `fizzbuzz(n)` that returns a list of strings for the integers 1..n inclusive: "FizzBuzz" if divisible by 15, "Fizz" if divisible by 3, "Buzz" if divisible by 5, otherwise the number as a string. Return only a Python code block.

code_slugify full · 350 tokens

Write a Python function `slugify(s)` that lowercases the string, replaces every run of non-alphanumeric characters with a single '-', and strips leading/trailing '-'. Return only a Python code block.

code_bugfix full · 400 tokens

This function should return the unique items in first-occurrence order, but the order is random:

```python
def unique(items):
    return list(set(items))
```

Return only a corrected Python code block that keeps the same name and signature.

sql_top_customers full · 250 tokens

Given this SQLite schema:
  customers(id INTEGER PRIMARY KEY, name TEXT)
  orders(id INTEGER PRIMARY KEY, customer_id INTEGER, amount REAL)

Write one SQL query returning the name and total order amount for the two customers with the highest total amount, highest first. Return only the SQL query.

Reasoning

reason_math quick · 300 tokens

A shop sells pencils in packs of 6. Maya buys 4 packs and gives 6 pencils to her brother. She then splits the remaining pencils equally among herself and 2 friends. How many pencils does each person get? Answer with a single number and nothing else.

reason_mc quick · 300 tokens

All roses in the garden are red. Some red flowers are tulips. Which statement MUST be true?
A) All tulips are roses
B) Some roses are tulips
C) No roses are tulips
D) Some flowers in the garden are red
Reply with the single letter of the correct answer and nothing else.

reason_logic full · 300 tokens

Three people - Ana, Ben and Cleo - each own a different pet: a cat, a dog and a fish. Ana does not own the cat. Ben owns the dog. Who owns the fish? End your answer with one line naming the owner.

Extraction

extract_invoice quick · format=json · 250 tokens

Extract fields from the invoice below and return ONLY a JSON object with keys "vendor" (string), "invoice_no" (string), "total" (number, no currency symbol) and "due_date" (string in YYYY-MM-DD form).

INVOICE - Acme Widgets Ltd
Inv #: INV-2024-0917
Bill to: Northwind Traders
Widgets (x40) ........ $1,120.00
Shipping ............. $164.50
TOTAL DUE: $1,284.50
Payment due by 15 March 2025.

Summarisation

summarize_facts full · 150 tokens

Summarize the text below in at most 30 words. You must mention ARPANET and 1969. Output prose only, no list.

The Advanced Research Projects Agency Network (ARPANET) was the first wide-area packet-switching network. Its first successful message was sent in 1969 between two computers at UCLA and Stanford. It later became the technical foundation of the Internet.

Webapp

webapp_snake full · 8192 ctx · 4096 tokens · weight 2.0

Build a complete, playable Snake game as a single self-contained HTML file.

Requirements:
- One file: HTML with inline <style> and <script>. No external libraries, fonts, or images.
- Render the board on a <canvas> (about 400x400 pixels).
- 20x20 grid. The snake starts length 3 near the centre, moving right.
- Move on a fixed tick of about 8-10 cells per second, not on key repeat.
- Arrow keys and WASD change direction. Ignore a 180-degree reversal.
- Food appears on a random free cell. Eating it grows the snake by one cell and increments the score.
- Show the current score on the page.
- Game over when the snake hits a wall or its own body. Show a game-over message and allow restart (a button and/or a key).
- Dark theme, readable at 900x700.

Return only the complete HTML file in a single ```html code block. No explanations.

Quality is a weighted score: most tasks are pass/fail, webapp_snake earns partial credit, and a task that hits its token budget is failed. With --browser, the Snake runtime checks make up 60% of that task's score.

How the numbers work

  • Decode t/s is generation throughput; prefill t/s is prompt processing; load s is the cold load of a model that was just unloaded.
  • Each request carries a unique tag, because Ollama otherwise serves repeated identical prompts from its prefix cache and reports meaningless prefill rates.
  • Speed is normalised to the fastest model in the same run, so bench the comparison set together.
  • Quality is a weighted score. Most tasks are pass/fail; the whole-app task earns partial credit. No LLM judge; every task has a deterministic grader, and --self-test checks each grader against reference answers and rejects empty/garbage output.
  • Provenance — the report lists each model's digest, and results.json also records Python/platform, the GPU driver and CUDA version, and relevant OLLAMA_* environment variables.
  • Noise — the speed section reports within-case coefficient of variation across repeats. Treat sub-5% decode differences as noise.
  • Repetition — max rep is the highest 8-gram repetition ratio among a model's quality outputs; high values usually indicate a loop. It is diagnostic, not pass/fail.

Good to know

Code tasks execute model-generated Python in a temporary directory with a 10-second timeout. That is not a sandbox — only bench models you trust.

  • --suite quick runs 8 tasks; --suite full runs all 15.
  • --browser adds an opt-in Playwright smoke test for webapp tasks: canvas animation, wall collision, restart, and runtime errors. Without it the webapp grader is static.
  • A trunc column counts tasks that hit their token budget; those are always failed. The Snake task uses an 8k context and 4k output.
  • Cloud models work, but their speed is network-bound. Don't mix them into a local comparison.
  • Use --no-think for thinking models when you care about raw throughput.
  • models.txt carries a suggested shortlist for ~8 GB VRAM; it is a suggestion list, not an auto-install.

Source

Planned improvements

Known gaps, roughly in priority order. The partial item is partly in the current release; the rest are planned. The tool is still strongest as a per-machine triage harness.

  • partial Uncertainty — speed min/max and within-case CV are reported; quality tasks still run once each.
  • Harder coverage — repo-level and multi-file coding tasks, multi-turn conversations, tool calling, and long-context retrieval.
  • Adversarial self-test — fenced, prose-wrapped, truncated, and near-miss outputs, not just a reference answer and garbage.
  • Run comparison — a --compare results.json mode and a baseline/regression view across runs.
  • Composite semantics — make single-model scores meaningful, or require at least two models for a score.
  • Execution isolation — run generated code and browser checks in a container, and drop the headless browser's --no-sandbox.