[Paper Review] CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Tasks
This paper introduces CodeNet, a large-scale, diverse, and high-quality dataset of 14 million code samples across 55 programming languages, with rich annotations for benchmarking AI models in code-related tasks. It enables state-of-the-art performance in code classification and similarity with top-1 accuracy of 0.9104 and top-5 accuracy of 0.9935 on masked language modeling, demonstrating strong generalization and utility for AI for code research.
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.
Motivation & Objective
- To accelerate research in AI for code by providing a large-scale, diverse, and high-quality dataset for training and benchmarking models.
- To support a wide range of coding tasks including code classification, similarity, translation, and performance optimization.
- To enable robust evaluation of AI models using test inputs and outputs for correctness validation and reinforcement learning.
- To promote inclusivity in AI research through contests targeting diverse teams, including underrepresented groups.
- To provide pre-processing tools and standardized representations to facilitate direct use in machine learning pipelines.
Proposed method
- The dataset is derived from two online judge platforms, AIZU and AtCoder, with submissions automatically validated for correctness via automated testing.
- Code samples are organized by problem ID, language, and submission ID, with metadata stored in structured CSV and HTML files for query and selection.
- A multi-stage curation pipeline removes duplicates, filters low-quality submissions, and ensures high data quality through automated and manual validation.
- Tokenization is performed using a custom vocabulary of 400+ tokens, including keywords, identifiers, functions, and punctuation, with fixed-length sequences of 256 tokens for model input.
- A masked language modeling (MLM) approach is applied using a BERT-like transformer model, where 15% of tokens are masked and predicted, with [mask] tokens used for training.
- Models are trained on 100,000 samples in batches of 32 over five epochs using Adam optimizer with a 0.001 initial learning rate, and evaluated on a held-out test set of 100,000 samples.
Experimental results
Research questions
- RQ1Can a large-scale, diverse, and high-quality code dataset improve the performance and generalization of AI models in code-related tasks?
- RQ2How does CodeNet compare to existing datasets like GCJ-297 in terms of model generalization and robustness?
- RQ3To what extent can masked language modeling on CodeNet achieve high accuracy in code token prediction?
- RQ4Can CodeNet support complex downstream tasks such as code translation, performance prediction, and bug repair?
- RQ5How effective are pre-processing tools in transforming raw code into ML-ready representations for model training?
Key findings
- The masked language modeling task on the C++1000 subset of CodeNet achieved a top-1 prediction accuracy of 0.9104 (standard deviation 0.002) and a top-5 accuracy of 0.9935 (standard deviation 0.0005).
- Models trained on CodeNet demonstrated superior generalization compared to those trained on GCJ-297, achieving a 12% higher score on the independent POJ-104 test set despite lower validation performance on GCJ-297.
- The dataset contains 13,916,868 submissions across 4,053 problems and 55 programming languages, with 57% of submissions in C++, and 53.6% of submissions accepted as correct.
- The dataset includes test inputs and outputs for 98.5% of code samples, enabling oracle-based evaluation of code correctness and reinforcement learning for quality improvement.
- The curation process significantly reduced data bias—particularly the dominance of top problems—resulting in a more balanced and representative dataset compared to prior benchmarks.
- Pre-processing tools in CodeNet enable consistent transformation of source code into tokenized, vectorized inputs suitable for deep learning models, enhancing usability and reproducibility.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.