# GSM8K

[GSM8K](https://arxiv.org/pdf/2110.14168) is a dataset consisting of diverse grade school math word problems.

<!-- Contributors: Automatically Generated -->
Contributed by [@jjallaire](https://github.com/jjallaire)
<!-- /Contributors: Automatically Generated -->

<!-- Usage: Automatically Generated -->
## Usage

### Installation

There are two ways of using Inspect Evals, from pypi as a dependency of your own project and as a standalone checked out GitHub repository.

If you are using it from pypi, install the package and its dependencies via:

```bash
pip install inspect-evals
```

If you are using Inspect Evals in its repository, start by installing the necessary dependencies with:

```bash
uv sync
```

### Running evaluations

Now you can start evaluating models. For simplicity's sake, this section assumes you are using Inspect Evals from the standalone repo. If that's not the case and you are not using `uv` to manage dependencies in your own project, you can use the same commands with `uv run` dropped.

```bash
uv run inspect eval inspect_evals/gsm8k --model openai/gpt-5-nano
```

You can also import tasks as normal Python objects and run them from python:

```python
from inspect_ai import eval
from inspect_evals.gsm8k import gsm8k
eval(gsm8k)
```

After running evaluations, you can view their logs using the `inspect view` command:

```bash
uv run inspect view
```

For VS Code, you can also download [Inspect AI extension for viewing logs](https://inspect.ai-safety-institute.org.uk/log-viewer.html).

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:

```bash
INSPECT_EVAL_MODEL=anthropic/claude-opus-4-1-20250805
ANTHROPIC_API_KEY=<anthropic-api-key>
```
<!-- /Usage: Automatically Generated -->

<!-- Options: Automatically Generated -->
## Options

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

```bash
uv run inspect eval inspect_evals/gsm8k --limit 10
uv run inspect eval inspect_evals/gsm8k --max-connections 10
uv run inspect eval inspect_evals/gsm8k --temperature 0.5
```

See `uv run inspect eval --help` for all available options.
<!-- /Options: Automatically Generated -->

<!-- Parameters: Automatically Generated -->
## Parameters

### `gsm8k`

- `fewshot` (int): The number of few shots to include (default: `10`)
- `fewshot_seed` (int): The seed for generating few shots (default: `42`)
- `shuffle_fewshot` (bool): Whether we take the first N samples of the dataset as the fewshot examples, or randomly sample to get the examples. (default: `True`)
<!-- /Parameters: Automatically Generated -->

## Dataset

Here is an example prompt from the dataset (after it has been further processed by Inspect):

>Solve the following math problem step by step. The last line of your response should be of the form "ANSWER: $ANSWER" (without quotes) where $ANSWER is the answer to the problem.
>
>Janet’s ducks lay 16 eggs per day. She eats three for breakfast every morning and bakes muffins for her friends every day with four. She sells the remainder at the farmers' market daily for $2 per fresh duck egg. How much in dollars does she make every day at the farmers' market?
>
>Remember to put your answer on its own line at the end in the form "ANSWER: $ANSWER" (without quotes) where $ANSWER is the answer to the problem, and you do not need to use a \\boxed command.
>
>Reasoning:

The model is then expected to generate reasoning steps and provide a final answer.

## Scoring

An accuracy is calculated over the datapoints. The correctness is based on an exact-match criterion and whether the model's final answer is correct.

## Changelog

### [2-A] - 2026-02-16

- Migrate version to new scheme. See [#907](https://github.com/UKGovernmentBEIS/inspect_evals/pull/907).

### [1.0.1] - 2025-12-18

- Adds backoff policy for functions that connect to huggingface servers.
