arXiv:2512.18748cs.SEcs.AI2025-12被引 1

构建高质量代码注释数据集,提升自动生成文档的准确性。

Code2Doc: A Quality-First Curated Dataset for Code Documentation

  • 四阶段清洗流程确保注释完整清晰,剔除重复与AI生成内容。
  • 最终保留13,358对高质量代码-注释,平均质量评分6.93/10。
  • 小规模但高质量数据显著提升模型性能,适合代码生成研究者使用。

自动代码文档生成模型的性能高度依赖训练数据质量。然而,现有数据集多通过大规模爬取公共仓库构建,缺乏质量控制,常包含噪声、重复及大量AI生成内容,削弱监督信号并干扰评估。本文提出Code2Doc,一个以质量为先的函数级代码文档数据集。该数据集包含13,358对高质量代码-文档配对,源自涵盖Python、Java、TypeScript、JavaScript和C++五种语言的广泛开源项目。从52,069个候选样本中,仅25.6%满足全部质量标准。数据集通过四阶段清洗流程:保证注释完整性与清晰度,基于结构与复杂度筛选函数,去除精确及近似重复代码,识别可能由AI生成的文档。最终数据集平均文档质量得分为6.93(满分10),86.9%样本含显式类型注解,仅2.9%被标记为潜在AI生成。基准实验显示,在Code2Doc上微调大语言模型,相较零样本性能在BLEU上提升29.47%,ROUGE-L提升24.04%。我们公开发布数据集与完整清洗流程,支持可复现的研究。

原文摘要 · Abstract (English)

The performance of automatic code documentation generation models depends critically on the quality of the training data used for supervision. However, most existing code documentation datasets are constructed through large scale scraping of public repositories with limited quality control. As a result, they often contain noisy documentation, extensive duplication, and increasing contamination from AI generated content. These issues weaken the supervision signal available to learning-based models and complicate evaluation. We introduce Code2Doc, a quality-first curated dataset for function-level code documentation generation. Code2Doc consists of 13,358 high-quality function-documentation pairs extracted from widely used open-source repositories spanning five programming languages: Python, Java, TypeScript, JavaScript, and C++. The dataset is constructed using a four-stage curation pipeline that enforces documentation completeness and clarity, filters functions based on structural and complexity criteria, removes exact and near-duplicate code, and identifies documentation likely to be AI generated. Starting from 52,069 extracted candidates, only 25.6% satisfy all quality constraints. We provide a detailed analysis of the resulting dataset, which achieves a mean documentation quality score of 6.93 out of 10. Overall, 86.9% of samples contain explicit type annotations, and only 2.9% are flagged as potentially AI generated. Baseline experiments show that fine-tuning a large language model on Code2Doc yields relative improvements of 29.47% in BLEU and 24.04% in ROUGE-L over zero shot performance, despite the modest dataset size. We release both the dataset and the full curation pipeline to support reproducible research on automatic code documentation generation.

代码生成数据集自然语言处理质量控制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。