arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.12412cs.SE
收藏

基于静态分析的程序分解与翻译

Program Decomposition and Translation with Static Analysis

Ali Reza Ibrahimzada

AI总结:

本文针对代码 LLM 上下文窗口受限、难以翻译工业级超大 Java 文件的问题,提出方法级程序分解并结合调用图分析,在20个项目约6万方法上验证其可显著缓解上下文限制并提升翻译可行性。

摘要:

大型语言模型(LLM)的日益普及,推动了人们探索将其用于代码相关任务。具有数百万以上参数的代码 LLM 在大量不同编程语言(PL)的代码上进行训练。此类模型通过提示词工程被用于自动化各种软件工程(SE)任务。然而,鉴于工业规模项目文件的体量非常庞大,这些 LLM 的一个主要问题是其上下文窗口大小有限,这引出了一个问题:“这些 LLM 能否处理超大文件,我们又能否有效地执行提示词工程?”代码翻译旨在将源代码从一种 PL 转换为另一种 PL。在本工作中,我们评估了方法级程序分解对 LLM 上下文窗口的影响,并研究该方法如何实现超大文件的翻译;此类翻译最初因上下文不足问题而无法完成。我们基于 20 个知名 Java 项目和约 6 万个方法的观察表明,方法级程序分解将 LLM 有限上下文窗口问题显著改善了 99.5%。此外,我们的实证分析表明,采用方法级分解后,每个输入片段平均仅消耗上下文窗口的 5%,从而为提示词工程和输出留下更多上下文空间。最后,我们研究了在进行方法级程序分解时,调用图(Call Graph,CG)方法在翻译超大文件方面的有效性。

英文摘要:

The rising popularity of Large Language Models (LLMs) has motivated exploring their use in code-related tasks. Code LLMs with more than millions of parameters are trained on a massive amount of code in different Programming Languages (PLs). Such models are used for automating various Software Engineering (SE) tasks using prompt engineering. However, given the very large size of industry-scale project files, a major issue of these LLMs is their limited context window size, motivating the question of "Can these LLMs process very large files and can we effectively perform prompt engineering?". Code translation aims to convert source code from one PL to another. In this work, we assess the effect of method-level program decomposition on context window of LLMs and investigate how this approach can enable translation of very large files which originally could not be done due to out-of-context issue. Our observations from 20 well-known java projects and approximately 60K methods suggest that method-level program decomposition significantly improves the limited context window problem of LLMs by 99.5%. Furthermore, our empirical analysis indicate that with method-level decomposition, each input fragment on average only consumes 5% of the context window, leaving more context space for prompt engineering and the output. Finally, we investigate the effectiveness of a Call Graph (CG) approach for translating very large files when doing method-level program decomposition.

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

↑