ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generation

Evaluates LLMs on class-level code generation with 100 tasks constructed over 500 person-hours. The study shows that LLMs perform worse on class-level tasks compared to method-level tasks.

Overview

ClassEval is a benchmark for evaluating large language models (LLMs) on class-level code generation tasks. It contains 100 class-level Python code generation tasks, constructed over approximately 500 person-hours.

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/class_eval --model openai/gpt-5-nano

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

from inspect_ai import eval
from inspect_evals.class_eval import class_eval
eval(class_eval)

Drop uv run if you manage dependencies yourself. Log viewing (inspect view) and default-model setup are documented in the Inspect Evals README.

[!NOTE] The bash and python code is executed inside a Docker container, so you will need to install Docker Engine in order to run the evaluation.

Docker containers are also used in some challenges for auxiliary services. When you run this, the containers are pulled from a public registry. The source code is still included, however, both for your reference and because some files are copied from them into the agent’s container at runtime.

Options

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

uv run inspect eval inspect_evals/class_eval --limit 10 --sample-shuffle
uv run inspect eval inspect_evals/class_eval --max-connections 10
uv run inspect eval inspect_evals/class_eval --temperature 0.5

See uv run inspect eval --help for all available options.

Parameters

class_eval

  • few_shot (int): The number of few shots to include. (default: 1)
  • few_shot_seed (int): The seed for generating few shots. (default: 42)
  • docker_handling (DockerHandling): Docker image handling strategy. (default: <DockerHandling.DEFAULT: 'default'>)

Dataset

See https://huggingface.co/datasets/FudanSELab/ClassEval for more information.

Scoring

For each sample, the LLM-generated code is appended with test cases from the dataset, and the code is executed to check if it passes all the test cases. If all test cases pass, the sample is considered correct, and the score for the sample is 1. Otherwise, the score for the sample is 0.

The final score for the model is the average score across all samples.

Changelog

[3-C] - 2026-08-12

  • Run the dataset’s test cases. The scorer appends them to the generated class and executes the result, but the dataset’s test field only defines unittest.TestCase classes, so no assertion was evaluated and every class that imported cleanly scored 1. Feeding each sample its own skeleton back, with every method body empty, no sample failed on an assertion; 93 of the 100 do once the runner is invoked. The executed module now calls unittest.main(). Any sample whose code fails a test now scores 0 where it scored 1, so results are not comparable with earlier versions.

[2-C] - 2026-08-03

  • Pin sandbox image references to immutable tags/digests, identical to what latest resolved to at pin time, so registry pushes cannot silently change the evaluation environment (#2062).

[2-B] - 2026-04-16

  • Resolve sandbox Docker compose path explicitly so the hosted image is used regardless of working directory.

[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.