评估与基准测试 · OpenAI

HumanEval

OpenAI's hand-crafted Python coding benchmark: 164 programming problems with function signatures, docstrings, and unit tests. Models are evaluated by Pass@k — the probability of generating at least one correct solution in k tries. The definitive benchmark for code generation ability.

加载
from datasets import load_dataset
ds = load_dataset("openai/openai_humaneval")
预览示例数据
{
  "task_id": "HumanEval/0",
  "prompt": "def has_close_elements(numbers: List[float], threshold: float) -> bool:\n    \"\"\" Check whether any two numbers in the list are closer than threshold. \"\"\"",
  "canonical_solution": "    for idx, elem in enumerate(numbers):\n        for idx2, elem2 in enumerate(numbers):\n            if idx != idx2:\n                distance = abs(elem - elem2)\n                if distance < threshold:\n                    return True\n    return False",
  "test": "assert has_close_elements([1.0, 2.0, 3.0], 0.5) == False"
}

常见问题

HumanEval 可以商用吗?

可以——HumanEval 采用 MIT 宽松许可证,允许商业使用,包括训练用于产品的模型。发布前请查看数据集卡片中的署名要求。

HumanEval 有多少数据?需要全部使用吗?

HumanEval 包含 164 Problems。它是评估基准,用于完整地衡量模型——切勿混入训练数据,否则基准分数将失去意义。

HumanEval 最适合做什么?

Benchmarking Python code generation - never train on it。它属于数据集中心的「评估与基准测试」板块,那里有替代和互补的数据集。