TL;DR
Human-written code comments in open-source repositories are notoriously prone to becoming outdated and mismatched as software evolves, creating a "noisy" bottleneck for pre-training code intelligence models. This paper demonstrates that replacing human reference comments with LLM-generated ones across millions of data pairs yields cleaner, more semantically consistent datasets. Pre-training models on this LLM-rebuilt data significantly boosts their performance on downstream tasks like code summarization, generation, and translation.
What Problem Does This Paper Address?
State-of-the-art code intelligence models (like CodeBERT and CodeT5) rely heavily on bimodal pre-training datasets that pair programming language (PL) code snippets with natural language (NL) comments. Traditionally, human-written comments mined from open-source repositories have been treated as the "gold standard" for these pairs.
However, as software evolves, developers frequently update code without updating the corresponding comments. This leads to severe semantic inconsistencies—previous studies estimate that over 20% to 40% of comments in popular datasets are noisy or completely mismatched.
Compounding this issue is an evaluation paradox: traditional metrics like BLEU or ROUGE are reference-based, meaning they measure quality by comparing generated text against human references. If the human references themselves are flawed, these metrics cannot accurately diagnose the problem. The authors set out to answer a provocative question: Can we build better code intelligence models by discarding human reference comments entirely and replacing them with text generated by LLMs?
Methods
To evaluate comment quality without relying on flawed human baselines, the authors introduce a paradigm shift toward reference-free evaluation using two auxiliary tasks:
- Code-Comment Inconsistency Detection (CCID): A trained classifier evaluates how often a comment is semantically misaligned with its code snippet. A lower inconsistency rate (IncRate) signifies higher quality.
- Semantic Code Search: The comment is used as a search query to retrieve the correct code snippet from a large database. Performance is measured using Mean Reciprocal Rank (MRR); a higher MRR implies the comment is a more precise and effective descriptor of the code's functionality.
Using these reference-free metrics, the authors comprehensively evaluated comments generated by six prominent LLMs (including GPT-4, GPT-3.5, and Code Llama) against human references.
After establishing that LLM-generated comments possess superior semantic consistency, the authors scaled up the process. They utilized GPT-3.5-turbo to rewrite the comments for over 2 million code snippets in the widely used CodeSearchNet dataset. Finally, they re-pre-trained a CodeT5-base model from scratch using this newly minted, LLM-enhanced dataset to evaluate its impact on downstream tasks.
Datasets
The study leverages several benchmark datasets for evaluation, rebuilding, and downstream task testing:
- TLC Dataset: Used for the initial automated and human evaluation comparing LLM-generated comments against human references.
- CodeSearchNet (CSN): Rebuilt by the authors into cgpt-CSN, replacing human comments with GPT-3.5-generated ones across six programming languages (Java, Python, PHP, JavaScript, Go, Ruby), totaling ~2.07 million PL-NL pairs.
- Concode: Used to evaluate text-to-code generation.
- AVATAR: A parallel corpus used for Java-to-Python and Python-to-Java code translation.
- Tufano et al. Datasets & Wang et al. Dataset: Used to evaluate code refinement and clone detection, respectively.
Key Insights and Ideas
- Humans are no longer the gold standard for documentation benchmarks: Reference-free evaluations revealed that 15.05% of human-written comments in standard repositories are semantically inconsistent with the code they supposedly describe.
- The "Vocabulary Trap" of n-gram metrics: Traditional metrics like BLEU heavily penalize LLMs because LLMs utilize a much richer, more diverse vocabulary than human developers do in code repositories. Embedding-based metrics (like USE) and human judges confirm that LLM comments are actually more natural, consistent, and useful.
- Context-dependent data enhancement: Rebuilding datasets with LLMs dramatically improves tasks that rely heavily on the mapping between natural language and code (summarization, generation, translation). However, it provides no benefit for purely structural code-to-code tasks (like bug fixing or clone detection), which do not utilize natural language text.
Key Results
The reference-free metrics and human evaluations painted a clear picture: LLMs consistently generate cleaner, more accurate comments than humans. As shown in the comprehensive evaluation table, GPT-4-Turbo achieved a near-perfect inconsistency rate of just 0.52%, compared to the human error rate of 15.05%.
When the CodeT5 model was pre-trained on the LLM-rebuilt dataset (cgpt-CSN), it achieved substantial performance leaps on downstream tasks:
- Code Generation (Concode): Fine-tuning the model with LLM-enhanced data led to massive improvements, boosting CodeBLEU by 11.04%, BLEU by 11.68%, and Exact Match accuracy by 8.00% over the model trained on vanilla human data.
- Code Translation (AVATAR): Java-to-Python translation saw an increase of 4.10 CodeBLEU and 5.43 BLEU points, proving that high-quality NL alignment during pre-training improves purely code-to-code translation representations.
The practical impact of this data cleaning can be seen in individual samples, where the LLM corrects vague human descriptions into precise functional summaries:
Limitations and Future Work
While the results are promising, the authors note several limitations:
- API Cost Constraints: Due to the high cost of commercial APIs, the full 2-million-pair dataset was rebuilt using GPT-3.5-Turbo instead of the superior GPT-4-Turbo.
- Model Scope: The downstream evaluation was restricted to the CodeT5 architecture; the authors did not test how this dataset reconstruction impacts larger, open-source decoder-only models like Code Llama.
- Prompt Sensitivity: The study relied on a simple, static prompt structure. More advanced prompt engineering or iterative generation techniques might unlock even higher data quality.
Summary updated