Validate and evaluate code-change explanations and build local-effect question artifacts
Project description
ExplainBench CLI
ExplainBench checks and evaluates explanations of code changes. It can also build the question files that are needed for a full evaluation.
The project website is explainbench.github.io.
What you can do
- Check the format of an ExplainBench submission.
- Run a lite evaluation of patch explanations.
- Run a full evaluation with effect question files.
- Build local-effect question files for a submission.
- Continue an evaluation or question build after an interruption.
Requirements
ExplainBench requires Python 3.12.
The submission checker has no extra service requirements. An evaluation needs network access and a key for the selected model provider. The local-effect question builder also needs Docker and access to the required code and data services.
Installation
Create and activate a Python 3.12 virtual environment:
python3.12 -m venv .venv
source .venv/bin/activate
On Windows PowerShell, activate it with:
.venv\Scripts\Activate.ps1
Install ExplainBench:
python -m pip install --upgrade pip
python -m pip install explainbench-cli
Check the installation:
explainbench --version
explainbench --help
Quick start
1. Create a submission file
Save this example as submission.json:
{
"submission_id": "my-run",
"instances": [
{
"instance_id": "sympy__sympy-15349",
"explanation": "The patch fixes the sign used in the rotation matrix.",
"model_patch": "diff --git a/sympy/algebras/quaternion.py b/sympy/algebras/quaternion.py\n--- a/sympy/algebras/quaternion.py\n+++ b/sympy/algebras/quaternion.py\n@@ -529,7 +529,7 @@ def to_rotation_matrix(self, v=None):\n \n m10 = 2*s*(q.b*q.c + q.d*q.a)\n m11 = 1 - 2*s*(q.b**2 + q.d**2)\n- m12 = 2*s*(q.c*q.d + q.b*q.a)\n+ m12 = 2*s*(q.c*q.d - q.b*q.a)\n \n m20 = 2*s*(q.b*q.d - q.c*q.a)\n m21 = 2*s*(q.c*q.d + q.b*q.a)\n"
}
]
}
The model_patch field is optional for a lite evaluation.
It is required for a full evaluation and for the local-effect question builder.
2. Check the submission
explainbench checker submission.json
The command prints Submission is valid when the file is ready.
If the file is not valid, the command lists each problem.
3. Run a lite evaluation
Set the key for your model provider. For an OpenAI model, use:
export OPENAI_API_KEY="your-api-key"
Then run:
explainbench evaluate submission.json \
--mode lite \
--model MODEL_ID \
--num-generations 1 \
--output results.json
Replace MODEL_ID with the model that you want to use.
This command sends the explanations to the model provider and can cause a charge.
Full evaluation
A full evaluation needs both end-to-end effect files and local-effect files. The local question builder creates the local-effect files:
explainbench question-builder local run submission.json \
--workspace .explainbench/builds/my-run \
--output question-artifacts \
--resume
Add the matching end-to-end effect files to the same output directory. See the detailed usage guide for the required file names.
Then run:
explainbench evaluate submission.json \
--mode full \
--model MODEL_ID \
--artifacts-dir question-artifacts \
--output results.json \
--resume
The question builder uses Docker, downloads data and source code, and can call a model. Read the setup steps before you run it.
Detailed guide
See the ExplainBench usage guide for:
- The full submission file format.
- Lite and full evaluation modes.
- Direct task selection.
- Configuration files.
- Resume and output behavior.
- Local-effect question builder setup.
- Common errors and fixes.
You can also add --help after any command:
explainbench evaluate --help
explainbench question-builder local run --help
Get help
Report a problem in the GitHub issue tracker.
License
ExplainBench is available under the MIT License. The distribution includes the SWE-bench notice in THIRD_PARTY_NOTICES.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file explainbench_cli-0.1.0.tar.gz.
File metadata
- Download URL: explainbench_cli-0.1.0.tar.gz
- Upload date:
- Size: 810.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2da317965c16d16b82cc04a588037314cf6e3806a9dfd258cdc2a2c829b2e0a5
|
|
| MD5 |
969a82cc76aba5f26a7ced5553cf8228
|
|
| BLAKE2b-256 |
f985b14555a21e733b74b4ad56b13fbf80cd07c789b9670ab44ed2e129d7092c
|
Provenance
The following attestation bundles were made for explainbench_cli-0.1.0.tar.gz:
Publisher:
release.yml on explainbench/explainbench-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
explainbench_cli-0.1.0.tar.gz -
Subject digest:
2da317965c16d16b82cc04a588037314cf6e3806a9dfd258cdc2a2c829b2e0a5 - Sigstore transparency entry: 2257188005
- Sigstore integration time:
-
Permalink:
explainbench/explainbench-cli@5c9a78102dadb36ef78b9860cb3ac5355940444b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/explainbench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5c9a78102dadb36ef78b9860cb3ac5355940444b -
Trigger Event:
push
-
Statement type:
File details
Details for the file explainbench_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: explainbench_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 836.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3f88a08d3cea27dd8473dba464c971717ffe5fddc5fd101b8f509f5da39e89
|
|
| MD5 |
0c07310d8016c8aaaf517f633680f159
|
|
| BLAKE2b-256 |
518f85afcd83aa472ede05abed5efcd46f1a45dba77228fb6879f589929880d2
|
Provenance
The following attestation bundles were made for explainbench_cli-0.1.0-py3-none-any.whl:
Publisher:
release.yml on explainbench/explainbench-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
explainbench_cli-0.1.0-py3-none-any.whl -
Subject digest:
1f3f88a08d3cea27dd8473dba464c971717ffe5fddc5fd101b8f509f5da39e89 - Sigstore transparency entry: 2257188008
- Sigstore integration time:
-
Permalink:
explainbench/explainbench-cli@5c9a78102dadb36ef78b9860cb3ac5355940444b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/explainbench
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5c9a78102dadb36ef78b9860cb3ac5355940444b -
Trigger Event:
push
-
Statement type: