Skip to main content

Python Pypi Docs LOC Downloads Downloads License Forks Issues Project Status Medium Donate

localbenchmark is a Python package for local LLM evaluation: coding benchmarks, long-context stress tests, speed probes, and ranking plots — driven through LM Studio or any other OpenAI-compatible server (llama.cpp, vLLM, Ollama, ...). It answers a practical question: can this model still write correct code when the context window is large, and is it fast enough that you would actually use it? ⭐️Star it if you like it⭐️



Key Features

Feature Description
Coding benchmark HumanEval-style tasks via LM Studio or any OpenAI-compatible server; temperature 0 for comparable runs
Long context Test fixed windows (e.g. 50k–180k); optional context fill so the KV cache is exercised
Speed probe Prefill / decode tok/s at controlled tokens-in-cache levels
Resume-safe CSVs Durable results; skip finished configs; retry LLM errors
Slow-model abort Stop a config after a streak of low decode speed; ranking accounts for incomplete runs
Rank-sum plots Pass rate, decode speed, TTFT, GPU peak, context — weighted ranking (model × context and per model)
Any backend LM Studio's native API or any OpenAI-compatible server, detected automatically
Model discovery --list shows every available model; running without --models tests all of them

Installation

Install from PyPI
pip install localbenchmark
Install from GitHub
pip install git+https://github.com/erdogant/localbenchmark
Install from source
pip install git+https://github.com/erdogant/localbenchmark

Quick start — Dry run

Make a dry run. This is ideal for a fast check of model GPU requirements and their theoretical (expected) coding speed.

# Run for all models with context window 120K and quantization of Q4_K_M

localbenchmark --dry-run --contexts 120000 --quants Q4_K_M
localbenchmark --dry-run --contexts 120000 --quants Q4_K_M --models unsloth/qwen3-coder-30b-a3b-instruct openai/gpt-oss-20b

Output:

rank  model                         quant   context  total GB  headroom GB  offload %  bandwidth  decode ceiling tok/s
----------------------------------------------------------------------------------------------------------------------
1     gpt-oss-20b                   Q4_K_M  120k     13.1      4.0          0%         GPU        74
2     qwen3-coder-30b-a3b-instruct  Q4_K_M  120k     18.5      -1.4         8%         GPU+RAM    21

Quick start — coding benchmark

Start your server (for LM Studio: enable the local server), then:

# Full default suite: every available model × every context window
localbenchmark

# Full default with base URL
localbenchmark --base-url http://localhost:1234

# Subset of models/contexts
localbenchmark --models unsloth/qwen3-coder-30b-a3b-instruct openai/gpt-oss-20b --contexts 50000 80000 100000 --base-url http://localhost:1234

Backends and model discovery

localbenchmark detects which API the server speaks. LM Studio's native API is used when present; otherwise any server that exposes the OpenAI-compatible /v1/models and /v1/chat/completions endpoints works (llama.cpp, vLLM, Ollama, ...).

# List every available model and exit
localbenchmark --list
localbenchmark --list --base-url http://localhost:8080

# Other servers
localbenchmark --base-url http://localhost:8080  --models my-model
localbenchmark --base-url http://localhost:11434 --backend openai --models qwen3-coder:30b
localbenchmark --base-url https://my-server/v1   --api-key $MY_KEY

Without --models, every model the server (or, if it is not running, the local LM Studio model folders) reports is tested. Embedding models are skipped.

LM Studio Other OpenAI-compatible servers
Model loading / unloading by localbenchmark not possible: the server decides
Context window every --contexts value is loaded and tested fixed by the server; each model is tested once at that size
Context detection from the load response max_model_len (vLLM) or /props (llama.cpp); if unknown, the run is labelled with the largest --contexts value, so start the server with that size
--judge model loaded for you must be served by the same server

Run the other benchmarks:

# Different types of benchmarks

localbenchmark --benchmark humaneval --models "openai/gpt-oss-20b"
localbenchmark --benchmark mbpp      --models "openai/gpt-oss-20b"
localbenchmark --benchmark swebench  --models "openai/gpt-oss-20b" --contexts 80000 150000
Localbenchmark model ranking comparison

Results are written to CSV. Configurations already present in the summary CSV are skipped on the next run. Configurations that abort for low tok/s stay in the summary so they are not reloaded endlessly.

Useful flags

Flag Meaning
--models One or more model keys (default: all available models)
--list List all available models and exit
--base-url Server URL (default http://localhost:1234; a trailing /v1 is accepted)
--backend auto (default), lmstudio or openai: force which API is used
--api-key API key for servers that need one (default: $OPENAI_API_KEY)
--contexts Context sizes in tokens (default includes 50k, 80k, 100k, 120k, 150k, 180k). Only LM Studio can change the window; other servers are tested once at their own size
--limit Run only the first N HumanEval problems
--results Results CSV path (default depends on --benchmark)
--benchmark humaneval, mbpp, swebench or suite
--suite Suite file (.jsonl) for --benchmark suite
--docs Document folder for suite mode (default company_docs)
--docs-limit Use only the first N documents, in name order
--docs-ids Use exactly these document file names

Custom (Company) QA

Suite mode asks questions about a set of company documents. Every selected document goes into the prompt, and we score each answer. The suite includes unanswerable questions: the correct answer is to say the documents do not contain the information. An invented answer scores zero, which is the most important check for company use.

Commands

Run the suite with the server running:

Example of lines:
{"id":"ctry-01","domain":"countries","type":"short","prompt":"What is the capital of Australia?","accept":["Canberra"],"distractors":["Sydney","Melbourne"]}
{"id":"ctry-03","domain":"countries","type":"numeric","prompt":"Roughly how large is Iceland, in square kilometres?","gold":103000,"rel_tol":0.05}
{"id":"co-04","domain":"companies","type":"short","prompt":"Which company acquired LinkedIn in 2016?","accept":["Microsoft"],"distractors":["Google","Oracle"]}
{"id":"co-01","domain":"companies","type":"numeric","prompt":"In which year was Microsoft founded?","gold":1975}

localbenchmark --benchmark suite --suite general_knowledge.jsonl --models "openai/gpt-oss-20b" --contexts 120000

Run with longer/ more detailled answers

  • company_docs/: the document folder. Any .txt or .md file can be used.
  • suites/<name>.jsonl: one question per line. Each question names its source documents in context.

The demo suite (northwind_demo) is fictional: 12 documents for a company called Northwind Analytics and 40 questions, 30 answerable and 10 unanswerable.

Example of jsonl:

{"id": "nw-01", "domain": "hr", "type": "short", "prompt": "How many days of annual leave do full-time employees get per calendar year?", "accept": ["25"], "context": ["hr_leave_policy.md"]}

Commands

Run the suite with the server running:

localbenchmark --benchmark suite --suite northwind_demo.jsonl --docs path/to/company_docs \
    --models "openai/gpt-oss-20b" --contexts 120000

Use fewer documents:

# first 40 files, in name order
localbenchmark --benchmark suite --suite northwind_demo.jsonl --docs path/to/company_docs \
    --models "openai/gpt-oss-20b" --docs-limit 40

localbenchmark --benchmark suite --suite northwind_demo.jsonl --docs path/to/company_docs \
    --models "openai/gpt-oss-20b" --docs-ids hr_leave_policy.md expense_policy.md

Output

  • suite_results_<suite>.csv: one row per question, with the score (0 to 1), pass/fail, domain, item type, whether the cited documents were included, and an error label (WRONG_ANSWER, INVENTED_ANSWER, MISSING_DOC, TRUNCATED, EMPTY_RESPONSE, LLM_ERROR).
  • suite_results_<suite>_by_domain.csv: pass rate and mean score per domain. The console also shows answerable and unanswerable results separately, and the number of invented answers.

Plots and ranking

localbenchmarkplot --rank-agg sum      # default
localbenchmarkplot --rank-agg mean
localbenchmarkplot --rank-agg median

# Only large windows (context_actual >= 100000)
localbenchmarkplot --min-context 100000

Ranking metrics (lower combined score is better):

  1. Pass rate (early aborts count unfinished work against the model)
  2. Decode speed (percentage of best — large speed gaps stay large)
  3. Time to first token
  4. Peak GPU memory
  5. Context size (percentage of best)

Pass rate and decode speed are weighted. Figures include pass rate vs context, tok/s, TTFT, GPU memory, quality–speed trade-off, and rank-sum panels (model × context and per model).


What is measured

Signal Why it matters
Pass rate Generated code must pass the unit tests
Decode speed (tok/s) Inference has to be usable, not only correct
TTFT Latency before the first useful token
Peak GPU memory Whether the setup fits your hardware
Context Behaviour as the window grows

Default context grid:

50k → 80k → 100k → 120k → 150k → 180k

Any context sizes present in the results file are included in the rank plots (not limited to a hard-coded list).



Maintainer

  • Erdogan Taskesen, GitHub: erdogant
  • Contributions are welcome.
  • Yes! This library is entirely free but it runs on coffee! Feel free to support with a Coffee.

Buy me a coffee

Metadata

Release files for localbenchmark 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for localbenchmark 1.1.0
File Size Uploaded Provenance Actions
localbenchmark-1.1.0.tar.gz 78.1 kB Without provenance Details for localbenchmark-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for localbenchmark 1.1.0
File Interpreter ABI Platform Actions
localbenchmark-1.1.0-py3-none-any.whl Python 3 none any Details for localbenchmark-1.1.0-py3-none-any.whl

Total release size: 158.7 kB

Release files / localbenchmark-1.1.0.tar.gz

Download URL localbenchmark-1.1.0.tar.gz
Size 78.1 kB
Tags Source
SHA-256 checksum
How to use checksums
05a3b2185fadcd7f06e48c5d19fc878df2f200674781cdf715348929ccc5e4b2
BLAKE2b-256 checksum
How to use checksums
3b7bcfbfb9f6697c48b0364d893e7dd0796092113e3ede9933b6ca78856a42d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / localbenchmark-1.1.0-py3-none-any.whl

Download URL localbenchmark-1.1.0-py3-none-any.whl
Size 80.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
530ce9dd731b3cb68ad79ba1d8eab08a19db3c0ee849d11e42e8e2a075086141
BLAKE2b-256 checksum
How to use checksums
33f09dcd8f9a03a4f62e536da7de1649ae4d555bbd8b33b0def5a9617d62e870
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for localbenchmark 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page