该基准测试包含约 1,000 道通过众包方式收集的 Python 编程题目,旨在让初级程序员能够解答,涵盖编程基础、标准库功能等内容。每道题目包含任务描述、代码解决方案和 3 个自动化测试用例。如论文所述,我们已对其中一部分数据进行了人工验证。
作为 Program Synthesis with Large Language Models, Austin et. al., 2021 的一部分,发布于此处。
该数据集用于评估代码生成任务。
英语 - Python 代码
dataset_full = load_dataset("mbpp")
DatasetDict({
test: Dataset({
features: ['task_id', 'text', 'code', 'test_list', 'test_setup_code', 'challenge_test_list'],
num_rows: 974
})
})
dataset_sanitized = load_dataset("mbpp", "sanitized")
DatasetDict({
test: Dataset({
features: ['source_file', 'task_id', 'prompt', 'code', 'test_imports', 'test_list'],
num_rows: 427
})
}){
'task_id': 1,
'text': 'Write a function to find the minimum cost path to reach (m, n) from (0, 0) for the given cost matrix cost[][] and a position (m, n) in cost[][].',
'code': 'R = 3\r\nC = 3\r\ndef min_cost(cost, m, n): \r\n\ttc = [[0 for x in range(C)] for x in range(R)] \r\n\ttc[0][0] = cost[0][0] \r\n\tfor i in range(1, m+1): \r\n\t\ttc[i][0] = tc[i-1][0] + cost[i][0] \r\n\tfor j in range(1, n+1): \r\n\t\ttc[0][j] = tc[0][j-1] + cost[0][j] \r\n\tfor i in range(1, m+1): \r\n\t\tfor j in range(1, n+1): \r\n\t\t\ttc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j] \r\n\treturn tc[m][n]',
'test_list': [
'assert min_cost([[1, 2, 3], [4, 8, 2], [1, 5, 3]], 2, 2) == 8',
'assert min_cost([[2, 3, 4], [5, 9, 3], [2, 6, 4]], 2, 2) == 12',
'assert min_cost([[3, 4, 5], [6, 10, 4], [3, 7, 5]], 2, 2) == 16'],
'test_setup_code': '',
'challenge_test_list': []
}{
'source_file': 'Benchmark Questions Verification V2.ipynb',
'task_id': 2,
'prompt': 'Write a function to find the shared elements from the given two lists.',
'code': 'def similar_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1) & set(test_tup2))\n return (res) ',
'test_imports': [],
'test_list': [
'assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))',
'assert set(similar_elements((1, 2, 3, 4),(5, 4, 3, 7))) == set((3, 4))',
'assert set(similar_elements((11, 12, 14, 13),(17, 15, 14, 13))) == set((13, 14))'
]
}source_file: 未知text/prompt: 编程任务描述code: 编程任务的解决方案test_setup_code/test_imports: 执行测试所需的代码导入test_list: 用于验证解决方案的测试列表challenge_test_list: 更具挑战性的测试列表,用于进一步检验解决方案数据集有两个版本(完整版和净化版),每个版本包含四个划分:
prompt 划分对应用于少样本提示的样本,不用于训练。
参见原始论文第 2.1 节。
为了评估代码生成功能,需要一组简单的编程任务及其对应的解决方案,本数据集正是为此而提供。
该数据集完全从零开始手动创建。
该数据集通过 Google 内部众包方式创建。
首先创建了完整数据集,随后对其中一部分进行了第二轮标注以改进任务描述。
该数据集通过 Google 内部众包方式创建。
无。
在针对该数据集进行评估时,务必在安全环境中运行生成的 Python 代码,因为生成的代码可能存在危害。
借助该数据集,可以对代码生成模型进行更有效的评估,从而减少使用此类模型时引入的问题。
由于任务描述可能不足以充分表达解题所需的信息,sanitized 划分旨在通过引入第二轮标注者来改进数据集,以解决这一问题。
Google Research
CC-BY-4.0
@article{austin2021program,
title={Program Synthesis with Large Language Models},
author={Austin, Jacob and Odena, Augustus and Nye, Maxwell and Bosma, Maarten and Michalewski, Henryk and Dohan, David and Jiang, Ellen and Cai, Carrie and Terry, Michael and Le, Quoc and others},
journal={arXiv preprint arXiv:2108.07732},
year={2021}感谢 @lvwerra 添加了该数据集。