MBPP: Mostly Basic Python Problems

Coding

Measuring the ability of these models to synthesize short Python programs from natural language descriptions. Demonstrates custom scorers and sandboxing untrusted model code.

Contributed By

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. We evaluate on the sanitized test split of the dataset, which was hand-verified to remove samples that lacked detail or were ambiguous.

Usage

First, install the inspect_ai and inspect_evals Python packages with:

pip install inspect_ai
pip install git+https://github.com/UKGovernmentBEIS/inspect_evals

Then, evaluate against one more models with:

inspect eval inspect_evals/mbpp --model openai/gpt-4o

If you don’t want to specify the --model each time you run an evaluation, create a .env configuration file in your working directory that defines the INSPECT_EVAL_MODEL environment variable along with your API key. For example:

INSPECT_EVAL_MODEL=anthropic/claude-3-5-sonnet-20240620
ANTHROPIC_API_KEY=<anthropic-api-key>

Options

You can control a variety of options from the command line. For example:

inspect eval inspect_evals/mbpp --limit 10
inspect eval inspect_evals/mbpp --max-connections 10
inspect eval inspect_evals/mbpp --temperature 0.5

See inspect eval --help for all available options.

Dataset

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.

Scoring

The model is prompted to solve the problem, given its description and test cases to pass. Additionally, few shot examples can be included in the prompt, with prompts patterned after an AgentCoder implementation which topped the leaderboard.

Evaluation metrics follow similar benchmarks such as HumanEval. The benchmark uses the \(\text{pass}@k\) metric to measure functional correctness. In brief terms, this is the per-problem probability of at least 1 correct sample generation given \(k\) generations. It is defined using the following expectation:

\[ \text{pass@}k := \underset{\text{Problems}}{\mathbb{E}}\left[1-\frac{{n-c}\choose{k}}{{n}\choose{k}}\right]\]

where we sample \(n \geq k\) generations to reduce variance. Note that the default in this benchmark implementation is \(n = 5\), and we evaluate \(\text{pass}@k\) for \(k \in \\{1, 2, 5\\}\).