CoDesc: A Large Code-Description Parallel Dataset

Masum Hasan, Tanveer Muttaqueen, Abdullah Al Ishtiaq, Kazi Sajeed Mehrab, Md. Mahim Anjum Haque, Tahmid Hasan, Wasi Uddin Ahmad, Anindya Iqbal, Rifat Shahriyar

TL;DR

This paper introduces CoDesc, a massive new dataset of 4.2 million Java code snippets paired with natural language descriptions. This dataset significantly advances research in code summarization and code search, enabling state-of-the-art performance and paving the way for powerful pre-trained models for Java.

What Problem Does This Paper Address?

Bridging the gap between natural language and programming languages is crucial for improving software development. Tasks like automatically generating descriptions for code (code summarization) or finding relevant code snippets using natural language queries (code search) are highly desirable. However, progress in these areas has been hampered by a lack of large, high-quality parallel datasets. Existing datasets are often small, leading to inconsistent results and limiting the ability of deep learning models to learn robust mappings between code and natural language. This paper aims to solve this by creating and releasing a substantial dataset and demonstrating its effectiveness.

Methods

The core contribution is the creation of the CoDesc dataset, a large-scale parallel corpus of Java methods and their corresponding natural language descriptions. To build this dataset, the authors combined several existing datasets (CSN, DeepCom, CONCODE, FunCom) and, crucially, used the TransCoder model to translate Python code from the CSN corpus into Java, significantly increasing the dataset's size.

A key aspect of their work is a rigorous data cleaning and noise removal process. They developed a parameterized tool to identify and remove various noise patterns, including comment tags, stray characters, HTML/XML tags, non-ASCII characters, and autogenerated tags from descriptions, as well as comments and non-ASCII characters from source code. This process aims to preserve as much meaningful data as possible, unlike previous methods that might discard entire data points. They also applied subtokenization for CamelCase and snake_case, and lowercased natural language descriptions.

Datasets

The primary dataset introduced is CoDesc, a parallel corpus of 4.2 million Java method-description pairs. This dataset is built by combining and processing data from:

  • CSN (CodeSearchNet): Originally a 6-language dataset, the Java portion was used directly, and Python methods were translated to Java using TransCoder.
  • DeepCom: A dataset for code summarization.
  • CONCODE: Another dataset for code summarization.
  • FunCom: A dataset for code summarization.

The paper also uses the CSN Java test set for evaluating code search models. For code summarization, they use a combination of a smaller dataset ("train-small") and their CoDesc dataset for pre-training.

Key Insights and Ideas

  • The Power of Scale: The paper strongly emphasizes that large datasets are critical for advancing code-NL tasks. Their CoDesc dataset, at 4.2 million pairs, dwarfs previous efforts and leads to significant performance gains.
  • Data Cleaning is Paramount: Even with existing cleaned datasets, the authors found that their custom noise removal process further improved performance. This highlights the persistent challenge of noise in code-related datasets and the value of a standardized cleaning approach.
  • Translated Code is Viable: Using TransCoder to translate Python code to Java proved effective. While acknowledging minor conversion issues, they found the translated code to be human-readable and suitable for training NL-code mapping models, opening doors for cross-lingual transfer in code tasks.
  • Pre-training is Key: Pre-training models on CoDesc significantly boosts performance on downstream tasks like code summarization, providing a better initialization than random training.

Key Results

  • Code Search: Training on CoDesc improved code search models by 10% to 22% compared to baseline models trained on smaller datasets. They achieved performance comparable to state-of-the-art models with 8x fewer parameters.
  • Code Summarization: Pre-training a Transformer network on CoDesc achieved a new state-of-the-art BLEU score of 45.89. The paper also notes that the pre-trained model generates more descriptive summaries, even in cases where its BLEU score might be slightly lower (illustrated with an example).
  • Noise Removal Impact: Table 4 shows that their noise removal process consistently improved the Mean Reciprocal Rank (MRR) for individual datasets, demonstrating the effectiveness of their cleaning methodology.

Limitations and Future Work

  • TransCoder Limitations: While effective, the TransCoder translation process had some limitations, such as converting to Java library methods and handling Python-specific conventions. However, the authors found these issues not severe enough to hinder NL-code mapping learning.
  • Dataset Noise: Despite extensive cleaning, the paper acknowledges that some noise might still be present, particularly in the FunCom dataset, where identifying and removing non-English comments was challenging.
  • Future Directions: The authors suggest exploring CoDesc for other tasks like code refactoring and clone detection. They also propose investigating the potential of translating CoDesc to other programming languages and building general-purpose code synthesis models. They raise an interesting question about whether current models are fully utilizing their capacity and suggest that larger models pre-trained on CoDesc could yield even better results.

Summary updated

BibTeX
@inproceedings{hasan2021codesc,
  author = {Masum Hasan and Tanveer Muttaqueen and Abdullah Al Ishtiaq and Kazi Sajeed Mehrab and Md. Mahim Anjum Haque and Tahmid Hasan and Wasi Uddin Ahmad and Anindya Iqbal and Rifat Shahriyar},
  title = {{CoDesc: A Large Code-Description Parallel Dataset}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  url = {https://openreview.net/forum?id=PCke1cT3Dl},
}
Figure