Introduction
Modern Code Intelligence (CI) models, such as CodeBERT and CodeT5, rely heavily on large-scale datasets of code-comment pairs to learn the mapping between programming logic and natural language. However, the "gold standard" human-written comments in these datasets are frequently noisy, outdated, or semantically inconsistent with the code they describe. This "garbage in, garbage out" phenomenon limits the performance of downstream tasks. This paper explores whether synthetic comments generated by Large Language Models (LLMs) like ChatGPT can serve as a superior alternative to human-written data for pre-training CI models.
Methodology: Reference-Free Evaluation and Dataset Reconstruction
To evaluate comment quality without the bias of traditional n-gram metrics (like BLEU), which penalize deviations from flawed human references, the authors introduced a reference-free evaluation framework. This framework utilizes two key metrics: IncRate (Inconsistency Rate), which uses a classifier to detect logic mismatches, and Semantic Code Search (MRR), which measures a comment's effectiveness as a search query.
The researchers then reconstructed the CodeSearchNet (CSN) dataset. They replaced over 2 million human comments across six programming languages (Java, Python, PHP, JavaScript, Go, and Ruby) with synthetic summaries generated by gpt-3.5-turbo. This process utilized specific system and task prompts to ensure the LLM acted as an expert programmer providing concise descriptions.
Finally, a CodeT5 model was re-pre-trained on this "ChatGPT-enhanced" dataset to evaluate its performance across various code intelligence benchmarks, including Concode for generation and AVATAR for translation.
Key Insights: The Superiority of Synthetic Data
The study revealed that 15.05% of human-written comments in the TLC benchmark were semantically inconsistent, whereas ChatGPT’s inconsistency rate was significantly lower at 3.65%. Interestingly, while ChatGPT performed worse on traditional BLEU scores, the reference-free metrics confirmed that its descriptions were actually more accurate. The "BLEU trap" occurs because synthetic comments are penalized for failing to replicate the noise and errors present in human "gold standards."
This process demonstrates a successful data distillation pipeline: a large, expensive LLM can be used to "clean" a massive dataset, which in turn trains a smaller, more efficient model that outperforms its predecessors.
Results and Impact
The model pre-trained on ChatGPT-enhanced data showed substantial improvements across multiple tasks:
- Code Generation: On the Concode benchmark, the model achieved an 8.0% improvement in Exact Match (EM) and an 11.7% boost in BLEU score.
- Code Summarization: The synthetic-data-trained model consistently achieved higher semantic consistency (measured by USE and MRR) across all six languages.
- Code Translation: Even for code-to-code tasks like Java-to-Python translation, the improved natural language alignment during pre-training led to a 3.7-point increase in CodeBLEU.
Conclusion
By replacing noisy human references with high-quality synthetic data, researchers can significantly enhance the capabilities of code intelligence models. This work highlights the potential of LLMs as powerful data refiners, paving the way for more robust and accurate AI-assisted software engineering tools.
Summary updated