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
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:
pip install inspect-evalsIf you are using Inspect Evals in its repository, start by installing the necessary dependencies with:
uv syncRunning 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.
uv run inspect eval inspect_evals/class_eval --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.class_eval import class_eval
eval(class_eval)After running evaluations, you can view their logs using the inspect view command:
uv run inspect viewFor VS Code, you can also download Inspect AI extension for viewing logs.
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-opus-4-1-20250805
ANTHROPIC_API_KEY=<anthropic-api-key>[!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
uv run inspect eval inspect_evals/class_eval --max-connections 10
uv run inspect eval inspect_evals/class_eval --temperature 0.5See 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)
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.