[论文解读] CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Tasks
本文介绍了CodeNet,一个大规模、多样化且高质量的数据集,包含跨55种编程语言的1400万个代码样本,并带有丰富的标注,可用于评估AI模型在代码相关任务中的表现。该数据集在掩码语言建模任务中实现了91.04%的top-1准确率和99.35%的top-5准确率,展现出卓越的泛化能力与在AI for code研究中的强大实用性。
Over the last several decades, software has been woven into the fabric of every aspect of our society. As software development surges and code infrastructure of enterprise applications ages, it is now more critical than ever to increase software development productivity and modernize legacy applications. Advances in deep learning and machine learning algorithms have enabled numerous breakthroughs, motivating researchers to leverage AI techniques to improve software development efficiency. Thus, the fast-emerging research area of AI for Code has garnered new interest and gathered momentum. In this paper, we present a large-scale dataset CodeNet, consisting of over 14 million code samples and about 500 million lines of code in 55 different programming languages, which is aimed at teaching AI to code. In addition to its large scale, CodeNet has a rich set of high-quality annotations to benchmark and help accelerate research in AI techniques for a variety of critical coding tasks, including code similarity and classification, code translation between a large variety of programming languages, and code performance (runtime and memory) improvement techniques. Additionally, CodeNet provides sample input and output test sets for 98.5% of the code samples, which can be used as an oracle for determining code correctness and potentially guide reinforcement learning for code quality improvements. As a usability feature, we provide several pre-processing tools in CodeNet to transform source code into representations that can be readily used as inputs into machine learning models. Results of code classification and code similarity experiments using the CodeNet dataset are provided as a reference. We hope that the scale, diversity and rich, high-quality annotations of CodeNet will offer unprecedented research opportunities at the intersection of AI and Software Engineering.
研究动机与目标
- 通过提供一个大规模、多样化且高质量的数据集,加速AI for code领域的研究,用于模型的训练与基准测试。
- 支持广泛的编码任务,包括代码分类、相似性计算、代码翻译和性能优化。
- 通过测试输入与输出的验证,实现对AI模型的稳健评估,支持正确性验证与强化学习。
- 通过面向多样化团队(包括代表性不足群体)的竞赛,促进AI研究中的包容性。
- 提供预处理工具与标准化表示方法,以简化在机器学习流程中的直接使用。
提出的方法
- 该数据集源自两个在线判题平台AIZU与AtCoder,通过自动化测试对提交代码进行正确性自动验证。
- 代码样本按题目ID、编程语言与提交ID组织,元数据以结构化CSV与HTML文件形式存储,便于查询与选择。
- 采用多阶段清洗流程,去除重复项,过滤低质量提交,并通过自动化与人工验证确保数据质量。
- 使用自定义的400多个词元词汇表进行分词,包括关键字、标识符、函数名与标点符号,模型输入采用固定长度256个词元的序列。
- 采用类似BERT的Transformer模型进行掩码语言建模(MLM),其中15%的词元被掩码并预测,训练时使用[Mask]词元。
- 模型在10万个样本上以32为批量大小进行训练,共5个周期,使用Adam优化器,初始初始学习率为0.001,并在保留的10万个样本测试集上进行评估。
实验结果
研究问题
- RQ1大规模、多样化且高质量的代码数据集能否提升AI模型在代码相关任务中的性能与泛化能力?
- RQ2与现有数据集GCJ-297相比,CodeNet在模型泛化与鲁棒性方面表现如何?
- RQ3在CodeNet上进行的掩码语言建模在代码词元预测任务中能达到多高的准确率?
- RQ4CodeNet能否支持复杂下游任务,如代码翻译、性能预测与错误修复?
- RQ5预处理工具在将原始代码转换为适合机器学习模型的表示形式方面有多高效?
主要发现
- 在CodeNet的C++1000子集上进行的掩码语言建模任务中,top-1预测准确率达到0.9104(标准差0.002),top-5准确率达到0.9935(标准差0.0005)。
- 在CodeNet上训练的模型相比在GCJ-297上训练的模型展现出更优的泛化能力,在独立的POJ-104测试集上得分高出12%,尽管在GCJ-297上的验证性能较低。
- 该数据集包含4,053道题目与55种编程语言的13,916,868个提交,其中57%为C++代码,53.6%的提交被判定为正确。
- 98.5%的代码样本附带测试输入与输出,支持基于oracle的代码正确性评估与质量改进的强化学习。
- 清洗流程显著降低了数据偏差(特别是头部题目的主导性),使数据集相比以往基准更加均衡与具代表性。
- CodeNet中的预处理工具可将源代码一致地转换为适合深度学习模型的标记化、向量化输入,提升了可用性与可复现性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。