MBPP: Basic Python Coding Challenges
Measures the ability of language models to generate short Python programs from simple natural-language descriptions, testing basic coding proficiency.
Overview
MBPP is a dataset for evaluating the ability of models to synthesize short Python programs from natural language descriptions. It contains programming tasks that are designed to be solvable by entry-level programmers. Each problem comes with three test asserts; a solution is correct when all of them pass in a sandbox.
By default we evaluate on the sanitized test split, 257 problems the authors hand-verified to remove samples that lacked detail or were ambiguous. The paper’s 500-problem test split is available as -T split=full.
Configuration options
default.yaml uses Inspect’s standard react agent with a Python tool and instructions to test and revise its solution before submitting. Temperature, reasoning effort and generation token limits are unset, allowing model/provider configuration to apply. The paper finds that the best temperature depends on the number of attempts: lower is better for one attempt, higher for many (Section 4.6).
single_turn.yaml preserves the eval’s previous generation settings (task version 4-A): one generate() call on a Markdown three-shot prompt.
original.yaml provides an (almost) exact replication of the paper’s setup: the full split, the paper’s [BEGIN]/[DONE] prompt and 80 samples per problem.
The three files are in Inspect’s single-file --run-config format. original.yaml documents the paper source of each setting. default.yaml is also the source of the eval’s built-in defaults: its task.args supply mbpp()’s parameter defaults, and its generation settings, epoch count, reducers, agent token limit and sandbox are read by the task. A plain uv run inspect eval inspect_evals/mbpp therefore runs the same way as passing the file with --run-config. Command-line flags such as --temperature, -T and --epochs still override it.
Task Arguments
| Task argument | Options and default | Description |
|---|---|---|
agentic |
true (default), false |
Solve with a react agent that has a Python tool and submits its final code. When false, a single generate() call on a few-shot prompt. |
split |
sanitized (default), full |
Dataset config: the 257 hand-verified test problems, or the paper’s 500 test problems (task ids 11 to 510). |
prompt_format |
markdown (default), plain_text |
Single-turn prompt: markdown is the prompt this eval used up to version 4-A; plain_text is the paper’s prompt delimited by [BEGIN] and [DONE]. Ignored when agentic is true. |
fewshot |
{count: 3, task_ids: [2, 3, 4], shuffle: false, seed: null} (default) |
Few-shot examples from the dataset’s prompt split, the ten problems (ids 1 to 10) the authors reserved for prompting. count is the number of examples, 0 for zero-shot. task_ids restricts and orders the pool, or null for the whole split in id order; the paper used problems 2, 3 and 4. shuffle shuffles the pool with seed before taking the first count. Keys left out take default.yaml’s values. |
tool_timeout |
180 (default), null; seconds |
Time allowed per Python tool call when agentic is true. null is allowed only when agentic is false. |
verify_timeout |
30 (default); seconds |
Time allowed to run the submitted code against the sample’s tests when scoring. |
Set these arguments with -T name=value on the command line or under task.args in a run config. Few-shot settings apply to both solvers. A -T fewshot=... override replaces the whole fewshot block, so keys it leaves out come from default.yaml even when another run config is selected: -T fewshot='{count: 0}' runs zero-shot. For the paper’s setup, use run_configs/original.yaml.
Prompts and Solver
With agentic=true (the default) a react agent is given the task and its tests, a Python tool to run code in the sandbox, and a submit tool; the submitted answer is scored. The agent has a budget of 50,000 total input and output tokens per sample attempt, set in default.yaml. With agentic=false the model is prompted once and the completion is scored. All prompt texts are declared as Prompt objects with their provenance in prompts.py: the agent’s instructions and task template, the Markdown few-shot prompt this eval used up to version 4-A, and the paper’s plain-text prompt.
task:
task: inspect_evals/mbpp
args:
agentic: true
fewshot:
count: 3
task_ids: [2, 3, 4]Metrics
| Metric | What it answers | Important caveat |
|---|---|---|
accuracy, stderr |
Accuracy and its standard error across problems. | Reported for both reductions below. |
mean |
Average success rate per problem. | Equals pass@1 for binary scores. |
max |
Fraction of problems solved at least once. | Equals pass@N for N scored attempts per problem. |
Requirements
- Docker. Both the agent’s Python tool and the scorer run code in a Docker sandbox. The run configs set
sandbox: docker; pass--sandbox localonly for offline tests with a mock model. - The dataset is public and needs no Hugging Face token.
Usage
Installation
Install with pip install inspect-evals, or uv sync from a checkout of this repository.
Running evaluations
uv run inspect eval inspect_evals/mbpp --model openai/gpt-5-nanoYou can also import tasks as normal Python objects and run them from python:
from inspect_ai import eval
from inspect_evals.mbpp import mbpp
eval(mbpp)Drop uv run if you manage dependencies yourself. Log viewing (inspect view) and default-model setup are documented in the Inspect Evals README.
Options
You can control a variety of options from the command line. For example:
uv run inspect eval inspect_evals/mbpp --limit 10 --sample-shuffle
uv run inspect eval inspect_evals/mbpp --max-connections 10
uv run inspect eval inspect_evals/mbpp --temperature 0.5See uv run inspect eval --help for all available options.
Dataset Details
Here is a sample from the dataset:
Write a python function to find the volume of a triangular prism.
test_list:
```
[ "assert find_Volume(10,8,6) == 240",
"assert find_Volume(3,2,2) == 6",
"assert find_Volume(1,2,1) == 1" ]
```
The model is tasked to write Python code that will pass the assert statements in the test_list. One test problem in the full split (task 367) carries test_setup_code; it is shown in the prompt and executed before the asserts.
Scoring Details
The scorer extracts the code from the completion, preferring a python-labelled fence, then an unlabelled fence, then the whole text with a trailing [DONE] removed. It appends any dataset test setup code and the sample’s assert statements, then runs the result in the sandbox; the sample is correct when every assert passes.
The task and all run configs use mean and max. Both support any positive --epochs N override.
Parameters
mbpp
agentic(bool): Solve with a react agent that has a Python tool and submits its final code. If false, a single generate() call on a few-shot prompt. (default:True)split(Literal['sanitized', 'full']): Dataset config: “sanitized” (257 hand-verified test problems) or “full” (the paper’s 500 test problems). (default:'sanitized')prompt_format(Literal['markdown', 'plain_text']): Single-turn prompt: “markdown” (headings and code fences, the prompt this eval used before the agentic default) or “plain_text” (the paper’s plain-text prompt delimited by [BEGIN] and [DONE]). Ignored when agentic. (default:'markdown')fewshot(dict[str, Any]): Few-shot examples from the dataset’spromptsplit, with these keys:count: the number of examples in the prompt (0 for zero-shot),task_ids: restricts the pool to these ids in this order (None for the whole split in id order; the paper used [2, 3, 4]),shuffle: shuffles the pool withseedbefore taking the firstcount,seed: the shuffle seed (None for an unseeded shuffle). Keys left out take default.yaml’s values, even under another run config. (default:{'count': 3, 'task_ids': [2, 3, 4], 'shuffle': False, 'seed': None})tool_timeout(int | None): Seconds allowed per Python tool call when agentic. May be None only when not agentic. (default:180)verify_timeout(int): Seconds allowed to run the submitted code against the sample’s tests when scoring. (default:30)
Changelog
[5-B] - 2026-10-23
- BREAKING (comparability): the default solver is a react agent with a Python tool and a submit tool, limited to 50,000 tokens per sample. The previous single-turn generation settings are preserved in
run_configs/single_turn.yaml. - The default configuration leaves temperature unset, allowing model/provider configuration to apply. The historical and paper configurations retain temperature 0.5.
- The agent is instructed to include required imports, helper functions and constants, fix failing tests, and submit the same complete source that passed the supplied tests.
- BREAKING (interface): the
temperaturetask arg is removed; set it in the run config or with--temperature. - Fix
--epochs Nfailing for N below 5 (#2119) by usingmeanandmaxin the task and all run configs. Separate pass@k outputs are removed. - Run-config layout:
run_configs/default.yaml(agentic, the built-in defaults),single_turn.yaml(the eval’s previous single-turn settings) andoriginal.yaml(the paper). - New task args
agentic,split,prompt_format,fewshot(keyscount,task_ids,shuffle,seed),tool_timeout,verify_timeout. - Prompts are declared as
Promptobjects with provenance inprompts.py. - Code extraction also strips a trailing
[DONE]marker, which the paper’s prompt uses to end a completion and a model may echo. - Dataset test setup code is included in prompts and scoring for the full split.
[4-A] - 2026-10-01
- Completion extraction now also handles a
python3label, a fence that is never closed (a truncated completion), a fence after prose on the same line, a closing fence glued to the last line of code, an empty block before the real one, and a stray fence before the labelled block. Each of these used to fall back to the raw completion, Markdown included, or to an empty block. Blocks labelledpyandpythonare now taken in order of position, where apythonblock used to win wherever it was. A replay of 5,456 unique MBPP completions from 12 models extracted the same code as 3-A for all of them.
[3-A] - 2026-08-19
- Fix completion extraction so Python-labelled and unlabelled Markdown code fences are handled consistently, including case-insensitive labels and CRLF line endings. [IECQ006] (@sylvesterkaczmarek)
[2-A] - 2026-02-16
- Migrate version to new scheme. See #907.
[1.0.1] - 2025-12-18
- Adds backoff policy for functions that connect to huggingface servers.
Static checks
Results of inspect-evals-lint at the commit this documentation was built from. Rule names link to their documentation; findings link to the file at that commit. These checks describe structure and conventions, not whether the evaluation measures what it claims.
Loading lint results…