---
title: "HumanEval Benchmark — HumanEval 基准测试"
source: "https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95"
wiki: "systems-analysis.info/int"
article: "HumanEval_Benchmark_—_HumanEval_基准测试"
language: "zh"
categories:
  - "Category:Chinese"
  - "Category:Large language models"
  - "Category:LLM benchmarks"
  - "Category:Machine learning"
revision_id: 3013
wiki_created_at: 2026-09-06T23:14:19Z
wiki_modified_at: 2026-09-06T23:14:19Z
downloaded_at: 2026-09-07T22:54:27Z
---

# HumanEval Benchmark — HumanEval 基准测试

**HumanEval** 是一个基准数据集（基准测试），旨在根据任务的文本描述客观评估人工智能模型生成的代码质量<sup>[\[1\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_paper-1)</sup>。它由 OpenAI 的研究人员在**马克·陈**（*Mark Chen*）的带领下于2021年7月推出，并已成为衡量生成程序功能正确性的关键标准之一。

HumanEval 的开发是为了满足对可靠代码生成评估方法的需求。此前，由语言模型生成的代码质量通常通过间接指标（如 BLEU）或手动评估，这并不能保证与程序的实际功能相符。HumanEval 通过关注**功能正确性**解决了这个问题：生成的代码不是根据其与参考实现的语法相似度来评估，而是根据其成功通过一系列自动化单元测试的能力来评估<sup>[\[1\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_paper-1)</sup>。

## 任务集结构

该基准测试包含 **164 个**编程任务，这些任务均为人工编写，以确保它们不出现在模型的训练数据中。所有任务都使用 Python 语言编写，并以带有描述的代码片段形式呈现<sup>[\[2\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_hf-2)</sup>。

每个任务包括：

- **函数签名**：包含函数名称和参数的函数签名。
- **文本描述**：描述所需功能的英文文档字符串（Docstring）。
- **函数体**：一个空白区域，需要模型用生成的代码来填充。

每个任务还包含对模型隐藏的元素：

- **标准解法**：函数的正确（参考）实现。
- **单元测试集**：用于自动验证生成代码的正确性。这些测试覆盖了常规情况和边缘情况。

这些任务涵盖了广泛的主题，从基本的语言结构和算法到简单的数学问题，使得该数据集对模型来说既多样化又具有挑战性。

## 模型评估方法

HumanEval 的主要成功指标是 **pass@k**，它衡量模型在功能上正确解决的任务比例<sup>[\[1\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_paper-1)</sup>。如果生成的代码通过了某个任务的所有自动化测试，则该解决方案被认为是成功的。

- **pass@1**：最主要且最常用的指标。它表示模型在**第一次尝试**中解决的任务百分比（即为每个任务生成一个解决方案）。
- **pass@k**：在一般情况下，该指标表示模型生成的 **k 个**解决方案中**至少有一个**通过所有测试的任务比例。例如，*pass@10* 显示了如果模型对每个任务最多尝试10次，它能解决的任务比例。

由于直接计算 *pass@k* 需要大量样本，原作者提出了一种统计上正确的方法来计算该指标，从而得到无偏估计<sup>[\[1\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_paper-1)</sup>。

实际测试在专门的“沙箱”环境中进行：生成的代码被编译并在测试集上运行。这种方法可以衡量模型生成可执行且正确的代码的能力，而不仅仅是生成与参考实现语法相似的代码。

## 结果与行业影响

在 HumanEval 上的初步实验表明，通用模型与专门针对代码进行训练的模型之间存在显著差距。

- 2021年，OpenAI Codex 模型（120亿参数，在 GitHub 代码上训练）在第一次尝试中成功解决了约 **28.8%** 的任务（*pass@1*）。
- 与此同时，更大规模的、未在代码上进行训练的语言模型 GPT-3（1750亿参数）**未能正确解决任何一个任务**<sup>[\[1\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_paper-1)</sup>。

这些结果强调了在编程数据上进行专门训练对于成功生成代码的必要性。自 HumanEval 问世以来，该基准测试迅速成为比较新模型进展的标准测试。

- **GPT-3.5** 系列模型（2023年初）的 *pass@1* 达到了 **~72%**。
- GPT-4 模型（2023年）表现更佳，基础版达到了 **~67%**，经过额外微调后超过了 **85%**<sup>[\[3\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-niu_2024_efficiency-3)</sup>。
- 开源模型，如 **Code Llama**（Meta，2023年）和 **WizardCoder**（2023年），也取得了优异成绩（*pass@1* 分别约为 **53%** 和 **57%**），超越了早期的专有模型<sup>[\[4\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-lutfullaev_2023_revisited-4)</sup>。

## 基准测试的扩展与变体

HumanEval 的成功启发了多个衍生版本的创建，旨在更广泛的条件下评估模型。

- **CL-HumanEval**（*Cross-Lingual HumanEval*）：一个跨语言版本（2024年），其中原始 HumanEval 的任务被调整，用于测试模型理解不同语言（非英语）描述并生成 Python 代码的能力<sup>[\[5\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-cl_humaneval_2024-5)</sup>。
- **Multilingual HumanEval**：一个扩展版本（2023年），旨在评估基于英文描述生成 **12 种不同编程语言**（包括 Java、C#、JavaScript 等）代码的能力<sup>[\[6\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-multilingual_humaneval_2024-6)</sup>。
- **HumanEval-XL**：一个大规模基准测试（2024年），结合了上述两种方法。它包含12种编程语言的任务，以及翻译成全球23种语言（包括俄语、中文、阿拉伯语等）的文本描述。HumanEval-XL 总共包含超过 22,000 个“描述-代码”对<sup>[\[7\]](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_note-humaneval_xl_2024-7)</sup>。

## 外部链接

- <a href="https://huggingface.co/datasets/openai/openai_humaneval" class="external text" rel="nofollow">Hugging Face 上的 HumanEval</a>
- <a href="https://paperswithcode.com/dataset/humaneval" class="external text" rel="nofollow">Papers with Code 上的 HumanEval 页面</a>

## 参考文献

- Liang, P. et al. (2022). *Holistic Evaluation of Language Models (HELM)*. <a href="https://arxiv.org/abs/2211.09110" class="external text" rel="nofollow">arXiv:2211.09110</a>.
- Chang, Y. et al. (2023). *A Survey on Evaluation of Large Language Models*. <a href="https://arxiv.org/abs/2307.03109" class="external text" rel="nofollow">arXiv:2307.03109</a>.
- Ni, S. et al. (2025). *A Survey on Large Language Model Benchmarks*. <a href="https://arxiv.org/abs/2508.15361" class="external text" rel="nofollow">arXiv:2508.15361</a>.
- Biderman, S. et al. (2024). *The Language Model Evaluation Harness (lm-eval): Guidance and Lessons Learned*. <a href="https://arxiv.org/abs/2405.14782" class="external text" rel="nofollow">arXiv:2405.14782</a>.
- Kiela, D. et al. (2021). *Dynabench: Rethinking Benchmarking in NLP*. <a href="https://arxiv.org/abs/2104.14337" class="external text" rel="nofollow">arXiv:2104.14337</a>.
- Ma, Z. et al. (2021). *Dynaboard: An Evaluation‑As‑A‑Service Platform for Holistic Next‑Generation Benchmarking*. <a href="https://arxiv.org/abs/2106.06052" class="external text" rel="nofollow">arXiv:2106.06052</a>.
- Goel, K. et al. (2021). *Robustness Gym: Unifying the NLP Evaluation Landscape*. <a href="https://arxiv.org/abs/2101.04840" class="external text" rel="nofollow">arXiv:2101.04840</a>.
- Xu, C. et al. (2024). *Benchmark Data Contamination of Large Language Models: A Survey*. <a href="https://arxiv.org/abs/2406.04244" class="external text" rel="nofollow">arXiv:2406.04244</a>.
- Liu, S. et al. (2025). *A Comprehensive Survey on Safety Evaluation of LLMs*. <a href="https://arxiv.org/abs/2506.11094" class="external text" rel="nofollow">arXiv:2506.11094</a>.
- Chiang, W.-L. et al. (2024). *Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference*. <a href="https://arxiv.org/abs/2403.04132" class="external text" rel="nofollow">arXiv:2403.04132</a>.
- Boubdir, M. et al. (2023). *Elo Uncovered: Robustness and Best Practices in Language Model Evaluation*. <a href="https://arxiv.org/abs/2311.17295" class="external text" rel="nofollow">arXiv:2311.17295</a>.
- Huang, L. et al. (2023). *A Survey on Hallucination in Large Language Models*. <a href="https://arxiv.org/abs/2311.05232" class="external text" rel="nofollow">arXiv:2311.05232</a>.

## 注释

1.  <span id="cite_note-humaneval_paper-1">↑ <sup>[1.0](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_paper_1-0)</sup> <sup>[1.1](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_paper_1-1)</sup> <sup>[1.2](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_paper_1-2)</sup> <sup>[1.3](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_paper_1-3)</sup> <sup>[1.4](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_paper_1-4)</sup> Chen, M. et al. «Evaluating Large Language Models Trained on Code». *arXiv:2107.03374*, 2021. <a href="https://ar5iv.labs.arxiv.org/html/2107.03374" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-humaneval_hf-2">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_hf_2-0) «openai/openai_humaneval». *Hugging Face Datasets*. <a href="https://huggingface.co/datasets/openai/openai_humaneval" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-niu_2024_efficiency-3">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-niu_2024_efficiency_3-0) Niu, C. et al. «On Evaluating the Efficiency of Source Code Generated by LLMs». *Proceedings of the 2nd International Conference on AI-generated Content*, 2024. <a href="https://arxiv.org/html/2404.06041v1" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-lutfullaev_2023_revisited-4">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-lutfullaev_2023_revisited_4-0) Lutfullaev, J. «HumanEval on LLMs Revisited in Late 2023». *arXiv:2402.14852*, 2023. <a href="https://arxiv.org/html/2402.14852v1" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-cl_humaneval_2024-5">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-cl_humaneval_2024_5-0) Sato, M. et al. «CL-HumanEval: A Benchmark for Evaluating Cross-Lingual Transfer through Code Generation». *Proceedings of the 38th Pacific Asia Conference on Language, Information and Computation*, 2024. <a href="https://aclanthology.org/2024.paclic-1.62.pdf" class="external autonumber" rel="nofollow">[5]</a></span>
6.  <span id="cite_note-multilingual_humaneval_2024-6">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-multilingual_humaneval_2024_6-0) Athiwaratkun, B. et al. «Multilingual HumanEval: A Multilingual Code Generation Benchmark». *arXiv:2307.11892*, 2023. <a href="https://aclanthology.org/2024.lrec-main.735.pdf" class="external autonumber" rel="nofollow">[6]</a></span>
7.  <span id="cite_note-humaneval_xl_2024-7">[↑](https://systems-analysis.info/int/HumanEval_Benchmark_%E2%80%94_HumanEval_%E5%9F%BA%E5%87%86%E6%B5%8B%E8%AF%95#cite_ref-humaneval_xl_2024_7-0) Liu, J. et al. «HumanEval-XL: A Multilingual Code Generation Benchmark for Cross-lingual Natural Language Generalization». *LREC-COLING 2024*. <a href="https://aclanthology.org/2024.lrec-main.735.pdf" class="external autonumber" rel="nofollow">[7]</a></span>
