THUDM/humaneval-x|代码生成数据集|多语言评估数据集
收藏HumanEval-X
数据集描述
HumanEval-X 是一个用于评估代码生成模型多语言能力的基准测试。它包含 820 个高质量的人工编写数据样本(每个样本包含测试用例),涵盖 Python、C++、Java、JavaScript 和 Go 五种编程语言,可用于代码生成和翻译等多种任务。
语言
数据集包含五种编程语言的编程问题:Python、C++、Java、JavaScript 和 Go。
数据集结构
加载数据集时,需要指定五种可用语言之一 [python, cpp, go, java, js]。默认加载 python。
python from datasets import load_dataset load_dataset("THUDM/humaneval-x", "js")
DatasetDict({ test: Dataset({ features: [task_id, prompt, declaration, canonical_solution, test, example_test], num_rows: 164 }) })
python next(iter(data["test"])) {task_id: JavaScript/0, prompt: /* Check if in given list of numbers, are any two numbers closer to each other than given threshold.
hasCloseElements([1.0, 2.0, 3.0], 0.5) false hasCloseElements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) true */ const hasCloseElements = (numbers, threshold) => { , declaration: const hasCloseElements = (numbers, threshold) => { , canonical_solution: for (let i = 0; i < numbers.length; i++) { for (let j = 0; j < numbers.length; j++) { if (i != j) { let distance = Math.abs(numbers[i] - numbers[j]); if (distance < threshold) { return true; } } } } return false; }
, test: const testHasCloseElements = () => { console.assert(hasCloseElements([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) === true) console.assert( hasCloseElements([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) === false ) console.assert(hasCloseElements([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) === true) console.assert(hasCloseElements([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) === false) console.assert(hasCloseElements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1) === true) console.assert(hasCloseElements([1.1, 2.2, 3.1, 4.1, 5.1], 1.0) === true) console.assert(hasCloseElements([1.1, 2.2, 3.1, 4.1, 5.1], 0.5) === false) }
testHasCloseElements() , example_test: const testHasCloseElements = () => { console.assert(hasCloseElements([1.0, 2.0, 3.0], 0.5) === false) console.assert( hasCloseElements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) === true ) } testHasCloseElements() }
数据字段
task_id:指示目标语言和问题的ID。语言为 ["Python", "Java", "JavaScript", "CPP", "Go"] 之一。prompt:函数声明和文档字符串,用于代码生成。declaration:仅函数声明,用于代码翻译。canonical_solution:人工编写的示例解决方案。test:隐藏的测试样本,用于评估。example_test:公开的测试样本(出现在提示中),用于评估。
数据分割
每个子集有一个分割:test。




