将代码度量纳入计算笔记本的自动化文档生成中
Integrating Code Metrics into Automated Documentation Generation for Computational Notebooks
AI总结:
本文提出利用代码度量提升计算笔记本自动化文档生成的准确性与相关性,通过两阶段方法验证了代码度量对文档质量的积极影响。
摘要:
有效的代码文档对于协作、理解和长期软件维护至关重要,但开发人员往往因为其重复性而忽视它。自动化文档生成已从启发式和基于规则的方法发展到基于神经网络和大型语言模型(LLM)的方法。然而,现有方法往往忽略了影响可读性和理解的代码结构和定量特征。先前研究表明,代码度量捕捉了与程序理解相关的信息。基于这些见解,本文研究了源代码度量作为自动化文档生成的辅助信号的作用,重点是计算笔记本,这是数据科学家中流行的介质,集成了代码、叙述和结果,但存在文档不一致的问题。我们提出了一种两阶段方法。首先,对CodeSearchNet数据集的构建过程进行了优化,以从超过1700万个代码和markdown单元格中创建专门的数据集。经过结构和语义过滤后,提取出约36734对高质量(代码,markdown)对。其次,评估了两种建模范式,即轻量级CNN-RNN架构和基于少量样本的GPT-3.5架构,在有无度量信息的情况下。结果表明,结合代码度量提高了生成文档的准确性和上下文相关性,CNN-RNN架构在BLEU-1和ROUGE-L F1上分别提高了6%和3%,LLM架构在BERTScore F1上提高了9%。这些发现表明,整合代码度量提供了有价值的整体上下文,增强了在不同模型家族中的自动化文档生成。
英文摘要:
Effective code documentation is essential for collaboration, comprehension, and long-term software maintainability, yet developers often neglect it due to its repetitive nature. Automated documentation generation has evolved from heuristic and rule-based methods to neural network-based and large language model (LLM)-based approaches. However, existing methods often overlook structural and quantitative characteristics of code that influence readability and comprehension. Prior research suggests that code metrics capture information relevant to program understanding. Building on these insights, this paper investigates the role of source code metrics as auxiliary signals for automated documentation generation, focusing on computational notebooks, a popular medium among data scientists that integrates code, narrative, and results but suffers from inconsistent documentation. We propose a two-stage approach. First, the CodeSearchNet dataset construction process was refined to create a specialized dataset from over 17 million code and markdown cells. After structural and semantic filtering, approximately 36,734 high-quality (code, markdown) pairs were extracted. Second, two modeling paradigms, a lightweight CNN-RNN architecture and a few-shot GPT-3.5 architecture, were evaluated with and without metric information. Results show that incorporating code metrics improves the accuracy and contextual relevance of generated documentation, yielding gains of 6% in BLEU-1 and 3% in ROUGE-L F1 for CNN-RNN-based architecture, and 9% in BERTScore F1 for LLM-based architecture. These findings demonstrate that integrating code metrics provides valuable structural context, enhancing automated documentation generation across diverse model families.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。