arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2507.02182cs.SE
收藏

增强COBOL代码解释:一种使用大型语言模型的多智能体方法

Enhancing COBOL Code Explanations: A Multi-Agents Approach Using Large Language Models

Fangjian Lei, Jiawen Liu, Shayan Noei, Ying Zou, Derek Truong, William Alexander

AI总结:

本文提出一种基于大型语言模型的多智能体协作方法,通过利用代码库上下文信息为COBOL函数、文件和项目生成解释,并在14个真实开源项目上验证其显著优于基线。

摘要:

面向商业的通用语言(COBOL)是一种用于开发商业应用程序的编程语言,被金融、商业和政府机构广泛采用。由于其年代久远、复杂性高以及COBOL开发人员数量不断减少,维护COBOL代码库正变得越来越具有挑战性。特别是,文档的缺乏使得新开发人员难以有效理解和维护COBOL系统。现有研究利用大型语言模型(LLMs)来解释代码片段的功能。然而,COBOL由于其架构和语法上的差异带来了独特的挑战,这些差异常常导致其代码超出LLMs的令牌窗口大小。在这项工作中,我们提出了一种多智能体方法,利用两个基于LLM的智能体协同工作,为函数、文件以及整个项目生成解释。这些智能体通过将代码库中的上下文信息纳入代码解释提示中来实现协同。我们使用14个开源的真实世界COBOL项目评估了我们方法的有效性。我们的结果表明,我们的方法在函数代码解释方面显著优于基线,在METEOR、chrF和SentenceBERT分数上分别提高了12.67%、18.59%和0.62%。在文件层面,我们的方法能够有效解释超出LLMs令牌窗口大小的短COBOL文件和长COBOL文件,并且在解释生成解释的目的、功能和清晰度方面分别超过基线4.21%、10.72%和14.68%。在项目层面,我们的方法生成的解释传达了82%所选项目的功能和目的。

英文摘要:

Common Business Oriented Language (COBOL) is a programming language used to develop business applications that are widely adopted by financial, business, and government agencies. Due to its age, complexity, and declining number of COBOL developers, maintaining COBOL codebases is becoming increasingly challenging. In particular, the lack of documentation makes it difficult for new developers to effectively understand and maintain COBOL systems. Existing research utilizes large language models (LLMs) to explain the functionality of code snippets. However, COBOL presents unique challenges due to its architectural and syntactical differences, which often cause its code to exceed the token window size of LLMs. In this work, we propose a multi-agent approach that leverages two LLM-based agents working collaboratively to generate explanations for functions, files, and the overall project. These agents incorporate together by utilizing contextual information from the codebase into the code explanation prompts. We evaluate the effectiveness of our approach using 14 open-source, real-world COBOL projects. Our results indicate that our approach performs significantly better than the baseline in function code explanation, with improvements of 12.67%, 18.59%, and 0.62% in terms of METEOR, chrF, and SentenceBERT scores, respectively. At the file level, our approach effectively explains both short and long COBOL files that exceed the token window size of LLMs and surpass the baseline by 4.21%, 10.72%, and 14.68% in explaining the purpose, functionality, and clarity of the generated explanation. At the project level, our approach generates explanations that convey the functionality and purpose of 82% of the selected projects.

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

↑