CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Tasks

Ruchir Puri, David S. Kung, Geert Janssen, Wei Zhang, Giacomo Domeniconi, Vladimir Zolotov, Julian Dolby, Jie Chen, Mihir R. Choudhury, Lindsey Decker, Veronika Thost, Luca Buratti, Saurabh Pujar, Shyam Ramji, Ulrich Finkler, Susan Malaika, Frederick Reiss

Introduction

While artificial intelligence has achieved remarkable success in computer vision and natural language processing, the "AI for Code" domain has historically been constrained by a lack of high-quality, large-scale datasets. Existing repositories were often limited in language variety or lacked the rigorous "ground truth" metadata required to verify code functionality. Project CodeNet, introduced by IBM researchers, addresses these gaps by providing a massive dataset of 14 million code samples across 55 programming languages, designed to serve as the "ImageNet" for the coding world.

Dataset Composition and Diversity

The core of Project CodeNet consists of 14,211,603 submissions distributed across 4,053 distinct programming problems. Unlike datasets scraped from general-purpose repositories like GitHub, CodeNet is sourced from online judge platforms (AIZU and AtCoder), where every submission is tied to a specific problem with known constraints and expected outputs.

Distribution of programming languages and submission statuses in Project CodeNet.

As shown in the figure above, while C++ and Python are the most prevalent languages, the dataset maintains a significant tail of 53 other languages. Crucially, the dataset includes not only "Accepted" solutions but also a vast array of "Wrong Answer," "Compile Error," and "Time Limit Exceeded" submissions. This inclusion of "failure" data is a critical asset for training models to perform automated bug fixing and error prediction.

Methodology and Technical Contributions

To ensure the dataset is "ML-ready," the researchers implemented several rigorous preprocessing steps:

  • Deduplication: Using Jaccard similarity to remove near-duplicate submissions and clustering to identify identical problems across platforms.
  • Standardized Representations: Tools are provided to convert raw source code into token streams, Simplified Parse Trees (SPT), and inter-procedural code graphs generated via the WALA framework.
  • Execution Oracle: For approximately 98.5% of the problems, the dataset includes original input and output test sets. This allows for execution-based learning and reinforcement learning (RL) approaches where an AI can receive objective feedback on code correctness.

Scale and Benchmarking

The scale of CodeNet allows for the creation of high-quality benchmarks. The authors introduced specific subsets—C++1000, C++1400, Python800, and Java250—filtered for uniqueness and quality.

Number of problems categorized by minimum submission counts, highlighting the volume of accepted vs. rejected samples.

The figure above illustrates the distribution of problems based on submission volume. Even at high thresholds (e.g., problems with at least 500 submissions), there remains a substantial number of problems available for training, ensuring that models can learn from a wide variety of coding styles and logic patterns.

Key Insights and Results

Experiments conducted on CodeNet demonstrate its superior generalization capabilities compared to smaller datasets like Google Code Jam (GCJ). Key performance baselines include:

  • Code Classification: Models like C-BERT achieved ~97% accuracy in identifying which problem a code sample solves.
  • Code Similarity: Siamese networks reached ~96% accuracy in determining functional identity between snippets.
  • Token Inference: BERT-like models achieved 91% top-1 accuracy in predicting masked code tokens, indicating a deep understanding of syntax and context.

Limitations and Future Directions

Despite its scale, CodeNet has limitations. The code is primarily algorithmic and pedagogical, lacking the architectural complexity of enterprise software systems (e.g., complex APIs or microservices). Additionally, comments are sparse and multilingual. Future work aims to leverage CodeNet for more ambitious tasks, such as automated legacy code translation (e.g., COBOL to Java) and automated performance tuning to optimize memory and CPU footprints.

Conclusion

Project CodeNet provides the necessary infrastructure to move AI for Code beyond simple completion tasks. By providing a standardized, large-scale benchmark with rich execution metadata, it paves the way for the next generation of intelligent software engineering tools.

Summary updated

BibTeX
@inproceedings{puri2021codenet,
  author = {Ruchir Puri and David S. Kung and Geert Janssen and Wei Zhang and Giacomo Domeniconi and Vladimir Zolotov and Julian Dolby and Jie Chen and Mihir R. Choudhury and Lindsey Decker and Veronika Thost and Luca Buratti and Saurabh Pujar and Shyam Ramji and Ulrich Finkler and Susan Malaika and Frederick Reiss},
  title = {{CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Tasks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=oVaBJou8j-C},
}
Figure