HumanEval Benchmark: How It Tests Whether AI Can Really Write Code

HumanEval Benchmark: How It Tests Whether AI Can Really Write Code

The HumanEval benchmark is the standard test for whether a language model can write code that actually works. It gives the model 164 hand-written Python problems, each a function signature with a docstring, and grades the result by running hidden unit tests. The central question it answers is simple: can the model turn a plain-language specification into a working function, or does it only produce code that looks right?

That question matters because code is one of the few model outputs with an objective answer. An essay can be judged many ways, but a function either passes its tests or it does not. This article explains how HumanEval works, what pass@k scoring means, why the benchmark is now saturated, and how to read its results without overstating them.

Key takeaways

  • The HumanEval benchmark contains 164 hand-written Python programming problems.
  • It grades by execution: code must pass hidden unit tests, not match a reference answer.
  • The headline metric is pass@k, the chance that at least one of k attempts passes.
  • It was introduced by OpenAI in 2021 alongside the Codex model.
  • Frontier models now score above 90% on pass@1, so the benchmark is saturated.

What is the HumanEval benchmark?

HumanEval was introduced by Mark Chen, Jerry Tworek and colleagues at OpenAI in the 2021 paper “Evaluating Large Language Models Trained on Code”, which presented the Codex model. Codex was a GPT model fine-tuned on public GitHub code, and HumanEval was built to measure whether it could actually program. The benchmark has since outlived Codex and become the shared yardstick for code generation.

Each of the 164 problems is a self-contained Python task: a function signature, a docstring describing what the function should do, and a set of hidden unit tests. The problems cover string manipulation, simple mathematics, list processing and light algorithmic reasoning. The authors described some as comparable to simple software interview questions.

The problems were written by hand for a specific reason. Models are trained on large parts of GitHub, so reusing existing programming problems would risk contamination: the model might have seen the answer during training. Hand-written problems, created specifically for the benchmark, reduced that risk. Each problem ships with a reference solution and tests, averaging about 7.7 tests per problem.

How HumanEval works

The model receives the prompt, which is the function signature plus its docstring, and must complete the function body. The completed code is then executed against the hidden tests in a sandbox. A problem counts as solved only if every test passes. There is no partial credit for code that passes most tests, and no credit for code that resembles the reference solution but fails to run correctly.

This execution-based grading is what makes HumanEval different from most language benchmarks. A model cannot earn points by writing plausible-sounding code or by matching the wording of a reference answer. The only thing that matters is functional correctness: does the program do what the specification asks? That is a stricter standard than text similarity, and it is one reason the benchmark earned trust quickly.

Because generated code is untrusted, the evaluation runs it inside a sandbox. The original paper used a gVisor sandbox, since running arbitrary model output is a security risk. Modern evaluation harnesses follow the same principle, isolating execution so that a malicious or accidental piece of generated code cannot damage the host system.

What pass@k means

The headline metric is pass@k, the estimated probability that at least one of k sampled completions passes all the tests for a problem. The most commonly reported values are pass@1, pass@10 and pass@100. Pass@1 is the share of problems solved on the first attempt, and it is the number you will see most often in model announcements.

The distinction matters. A model with a high pass@100 but a low pass@1 can produce a correct solution sometimes, but it rarely produces it first. That gap tells you something useful: the correct answer is in the model’s distribution of possible outputs, but the model does not reliably prefer it. Pass@1 is therefore the more honest measure of how the model behaves when a developer asks it for one answer.

The original paper used an unbiased estimator for pass@k, generating 200 completions per problem and computing the probability from how many of them were correct. Sampling temperature was tuned to the value of k: low temperature, around 0.2, for pass@1, and higher temperature, around 0.8, for pass@100, since the metric rewards having at least one correct sample among many. Any reported pass@k figure is only reproducible if the number of samples and the decoding settings are stated alongside it.

One practical consequence is that a single problem moves pass@1 by about 0.61 percentage points, since there are only 164 problems. Small differences between models are therefore mostly noise, and a gap of one or two points proves very little. For more on why small score differences mislead, see our guide to what LLM evaluation benchmark scores actually tell you.

What the results showed

When HumanEval was released, the results were striking. The 12-billion-parameter Codex model scored 28.8% on pass@1, and a supervised fine-tuned version reached 37.7%. GPT-3, without code fine-tuning, scored close to zero. That gap showed how much difference training on code made, and it established HumanEval as the test every code model would report.

Scores have climbed steadily since. Frontier models now score above 90% on pass@1, leaving only a handful of the 164 problems unsolved. At that level the benchmark is effectively saturated: it can no longer separate strong models from each other, and the remaining differences are within the margin of error for a 164-problem test.

Saturation has also exposed a weakness in the original tests. The test suites are thin, averaging under eight tests per problem, and deliberately wrong code can sometimes pass them all. HumanEval+, from the EvalPlus team, keeps the same 164 problems but adds far more test inputs, averaging hundreds per problem, and rejects code that the original tests accept. If you need a stricter check, HumanEval+ is the better tool.

What HumanEval does not measure

HumanEval measures one narrow skill: writing a short, standalone Python function from a docstring. Real software work is much broader. It involves reading existing code, understanding a large codebase, debugging, writing tests, using libraries and APIs, and making design decisions across many files. None of that appears in HumanEval.

The benchmark is also Python-only. A model that excels at HumanEval may be weaker in other languages, and the score says nothing about that. Repository-scale benchmarks such as SWE-bench, which asks models to fix real issues in real codebases, cover far more of what developers actually do, and they are a better complement for serious evaluation.

Finally, HumanEval tests code in isolation from the tools developers use. In practice, a model writes code with an editor, a compiler, a test runner and the ability to iterate on errors. A model that writes imperfect code on the first try but fixes it quickly after seeing an error message may be more useful than one with a higher pass@1. HumanEval cannot see that difference.

How HumanEval compares with other benchmarks

Benchmark What it tests Format Scoring
HumanEval Short Python function writing 164 hand-written problems Pass@k by unit tests
HumanEval+ Same problems, stricter tests 164 problems, many more tests Pass@k by unit tests
MBPP Entry-level Python problems About 1,000 short tasks Pass@k by unit tests
SWE-bench Fixing real repository issues Real GitHub issues and tests Tests pass after patch
GSM8K Multi-step grade-school maths Word problems, free-form answer Exact match on final number

The comparison shows where HumanEval sits. MBPP is its entry-level companion, with roughly 1,000 short crowd-sourced tasks that discriminate better among weaker models. SWE-bench is the harder, more realistic test for professional use. GSM8K is included because it shares HumanEval’s spirit: an objective, automatically checkable answer rather than a judge’s opinion.

A computer screen showing a code editor with a green checkmark beside a coffee cup
HumanEval grades by execution: the generated function must pass every hidden unit test.

How to use HumanEval results in practice

Use pass@1 as your headline number, since it reflects the single-answer behaviour developers actually experience. Ask for the sampling settings behind it: how many completions were generated, what temperature was used, and which evaluation harness ran the tests. Without those details, two pass@1 figures are not comparable.

Treat HumanEval as a gate, not a ranking. A model below roughly 50% pass@1 will frustrate developers on everyday coding tasks. A model above 80% is capable, and the choice between two models in that range should be made on harder tests, on your own codebase, or on the languages you actually use.

For a serious code-model decision, combine HumanEval with a repository-scale test and a trial on your own work. Our guide to building an LLM evaluation pipeline explains how to run those checks so that they catch real failures instead of confirming what you already believed.

Also consider HumanEval+ when the original benchmark’s thin tests are a concern. If a candidate model scores well on HumanEval but drops sharply on HumanEval+, its code is likely passing weak tests rather than being genuinely correct, and that is exactly the kind of weakness you want to find before deployment. Best for: a fast, reproducible first check of whether a code model writes working Python, before you invest in harder repository-scale testing.

HumanEval checklist

  • Report pass@1 as the headline figure, and state the sampling settings behind it.
  • Check how many completions were generated per problem and at what temperature.
  • Remember that one problem moves pass@1 by about 0.61 points, so small gaps are noise.
  • Run HumanEval+ alongside the original if you need stricter test coverage.
  • Do not rank frontier models on HumanEval alone, since it is saturated above 90%.
  • Test the languages you actually use, since HumanEval is Python-only.
  • Follow up with a repository-scale test such as SWE-bench for real-world coding ability.
  • Try the model on your own codebase before making a final decision.

Frequently asked questions

How many problems are in the HumanEval benchmark?

HumanEval contains 164 hand-written Python programming problems. Each gives a function signature and a docstring, and the model must complete the function so that it passes hidden unit tests.

What is pass@k in HumanEval?

Pass@k is the estimated probability that at least one of k sampled completions passes all the tests for a problem. Pass@1 is the most reported value: the share of problems solved on the first attempt.

Who created HumanEval?

It was created by Mark Chen, Jerry Tworek and colleagues at OpenAI, and introduced in the 2021 paper “Evaluating Large Language Models Trained on Code”, which presented the Codex model.

How is HumanEval scored?

It is scored by execution. The model’s completed function is run against hidden unit tests, averaging about 7.7 tests per problem, and a problem counts as solved only if every test passes.

Is HumanEval still useful?

Yes, as a fast baseline and regression check, and for comparing weaker models. It is no longer useful for ranking frontier models, which score above 90% on pass@1, and its thin tests mean HumanEval+ is a better strict check.

What is the difference between HumanEval and HumanEval+?

HumanEval+ keeps the same 164 problems but adds far more test inputs, averaging hundreds per problem instead of under ten. It rejects incorrect code that passes the original tests, so it gives a stricter measure of functional correctness.

Latest articles

Scroll to Top