arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2511.00215cs.SE
收藏

DocPrism:代码与文档间错误不一致性的多语言检测

DocPrism: Multi-lingual Detection of Incorrectness Inconsistencies between Code and Documentation

University of British Columbia(不列颠哥伦比亚大学)

Xiaomeng Xu, Zahin Wahab, Reid Holmes, Caroline Lemieux

AI总结:

本文提出轻量级多语言代码-文档不一致性检测工具DocPrism,通过LCEF方法降低标记率、提升F1分数,在多语言真实场景中表现优于现有技术。

摘要:

代码与文档不一致是常见且不良的情况,会导致开发者误解和软件缺陷。本文介绍DocPrism,一款轻量级多语言代码-文档不一致性检测工具。DocPrism采用标准大语言模型(LLM)分析并解释不一致性,重点输出错误不一致性。直接用LLM完成该任务时,不一致性标记率高得不可接受——超过90%的函数被标记为与文档不一致,主要原因是LLM将高层文档与代码间的自然 gap 识别为不完整不一致性。我们引入并应用本地分类、外部过滤(LCEF)方法:LCEF利用LLM的本地补全能力而非长期推理能力,聚焦于报告错误不一致性。在 ablation 研究中,与标准提示技术相比,LCEF将DocPrism的不一致性标记率从98%降至14%,F1分数从0.22提升至0.77。在Python、TypeScript、C++和Java的广泛评估中,DocPrism在未进行任何微调的情况下,保持17%的低标记率,精度达0.63。我们还确定了四种编程语言的保守下限,表明11%的代码-文档对存在不一致性错误。此外,DocPrism在已有的合成数据集上达到与现有技术(SOTA)相当的精度,但在我们的真实Java数据集上精度大幅优于SOTA(DocPrism:0.47-0.67,SOTA:0.05-0.14)。

英文摘要:

Code-documentation inconsistencies are common and undesirable: they can lead to developer misunderstandings and software defects. This paper introduces DocPrism, a lightweight multi-language, code-documentation inconsistency detection tool. DocPrism uses a standard large language model (LLM) to analyze and explain inconsistencies, and focuses on outputting incorrectness inconsistencies. Plain use of LLMs for this task yields unacceptably high inconsistency flag rates-i.e., over 90% of functions are flagged as inconsistent with their documentation. One substantial reason is that LLMs identify natural gaps between high-level documentation and code as incompleteness inconsistencies. We introduce and apply the Local Categorization, External Filtering (LCEF) methodology: LCEF uses an LLM's local completion skills, rather than its long-term reasoning skills, to focus on reporting incorrectness inconsistencies. In our ablation study, LCEF reduces DocPrism's inconsistency flag rate from 98% to 14%, and increases F1 score from 0.22 to 0.77, compared to standard prompting techniques. On a broad evaluation across Python, TypeScript, C++, and Java, DocPrism maintains a low flag rate of 17%, and achieves a precision of 0.63 without performing any fine-tuning. We also establish a conservative lower bound across four programming languages, showing that inconsistency errors are present in 11% of code-documentation pairs. In addition, DocPrism achieves precision comparable to the state-of-the-art on an established synthetic dataset, but substantially outperforms it on our real-world Java dataset in precision (DocPrism: 0.47-0.67 vs. SOTA: 0.05-0.14).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑