# BigCode Evaluation Harness

> Reproducible benchmarking for code-generation models across 15+ tasks

- Category: Evaluation & Production Ops / Benchmark Harnesses
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/bigcode-project/bigcode-evaluation-harness
- Canonical page: https://ai-tldr.dev/tools/bigcode-evaluation-harness/

## In short

BigCode Evaluation Harness is a framework for evaluating code-generation models on a shared set of benchmarks. It runs any autoregressive model from the Hugging Face Hub and is tuned for code models such as SantaCoder, InCoder, and CodeGen. It sits in the Benchmark Harnesses category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

BigCode Evaluation Harness is a framework for evaluating code-generation models on a shared set of benchmarks. It runs any autoregressive model from the Hugging Face Hub and is tuned for code models such as SantaCoder, InCoder, and CodeGen. The project was inspired by EleutherAI's lm-evaluation-harness and applies the same idea to code tasks.

It is aimed at researchers and engineers who want to measure how well a model writes or completes code, and who need numbers they can compare and reproduce. It ships more than 15 tasks, including HumanEval, HumanEval+, MBPP, APPS, DS-1000, MultiPL-E (HumanEval in 18 languages), and HumanEvalPack, covering both completion and fill-in-the-middle modes.

As a benchmark harness, it standardizes how prompts are built, how samples are generated, and how results are scored. It supports multi-GPU generation through Hugging Face accelerate and provides Dockerfiles so that code execution and scoring run in a contained, repeatable environment.

## What it does

- Runs any autoregressive Hugging Face model, with a focus on code models like SantaCoder, InCoder, and CodeGen
- More than 15 tasks: HumanEval, HumanEval+, InstructHumanEval, APPS, MBPP, MBPP+, DS-1000, MultiPL-E, HumanEvalPack, and more
- Covers completion (left-to-right) and fill-in-the-middle (FIM) generation modes
- MultiPL-E translates HumanEval into 18 programming languages for multilingual evaluation
- Multi-GPU text generation via accelerate, plus Dockerfiles for contained, reproducible runs
- Memory-saving options including --precision, --load_in_8bit, and --load_in_4bit

## Getting started

Clone the repo, install it as an editable package, log in to the Hub, then launch a benchmark with accelerate.

1. Clone and install

   Get the source, install torch for your device, then install the harness in editable mode.

```bash
git clone https://github.com/bigcode-project/bigcode-evaluation-harness.git
cd bigcode-evaluation-harness
pip install -e .
```

2. Log in and configure accelerate

   Make sure git-lfs is installed, log in to the Hugging Face Hub, and configure accelerate for your GPU setup.

```bash
huggingface-cli login
accelerate config
```

3. Run an evaluation

   Launch generation and scoring with accelerate launch main.py, choosing a model and task. Pass --allow_code_execution to score tasks that run unit tests.

```bash
accelerate launch main.py \
  --model <MODEL_NAME> \
  --tasks <TASK_NAME> \
  --max_length_generation <MAX_LENGTH> \
  --temperature <TEMPERATURE> \
  --do_sample True \
  --n_samples 100 \
  --batch_size 10 \
  --precision <PRECISION> \
  --allow_code_execution \
  --save_generations
```

## When to use it

- Benchmark a newly trained code model on HumanEval and MBPP to compare it against published baselines
- Measure multilingual code performance by running MultiPL-E across 18 languages
- Reproduce reported scores in a Docker container so code execution and grading stay contained
- Evaluate fill-in-the-middle (FIM) quality for editor-style code completion models
