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

自然即最优:面向预训练大语言模型的模型无关代码简化方法

Natural Is The Best: Model-Agnostic Code Simplification for Pre-trained Large Language Models

Yan Wang, Xiaoning Li, Tien Nguyen, Shaohua Wang, Chao Ni, Ling Ding

AI总结:

针对预训练代码大语言模型输入复杂度高的问题,提出依赖输入词元固有属性的模型无关代码简化方案SlimCode,在多项任务上效果、速度均优于现有方法,还能降低GPT-4调用成本。

摘要:

预训练大语言模型(LLM)已在多个领域取得显著成效。然而,面向代码的大语言模型计算复杂度极高,且复杂度随输入长度呈二次增长。为简化大语言模型的输入程序,现有最优方法采用基于大语言模型给出的注意力得分过滤输入代码词元的策略。但输入简化的决策不应依赖大语言模型的注意力模式,因为这些模式同时受模型架构和预训练数据集的影响。由于模型和数据集属于解决方案域而非输入所属的问题域,当模型在不同数据集上预训练时,简化结果可能会出现差异。我们提出SlimCode,这是一种面向大语言模型的模型无关代码简化方案,其决策依据输入代码词元的固有属性。我们针对CodeBERT、CodeT5和GPT-4等大语言模型,在代码搜索和代码摘要两项核心任务上开展了实证研究,结果表明:1)代码移除比例与训练时间节省比例呈近似线性关系;2)不同类别的词元对代码简化的影响存在显著差异;3)分类词元对代码简化的影响具有任务特异性,但与模型无关;4)上述发现在提示工程和交互式上下文学习范式下同样成立。实证结果显示,在代码搜索和代码摘要任务上,SlimCode的MRR和BLEU得分分别比现有最优技术提升9.46%和5.15%。此外,SlimCode的运行速度是现有最优方法的133倍。同时,SlimCode可将每次GPT-4 API查询的调用成本降低最高24%,且生成结果与使用原始代码的结果相当。

英文摘要:

Pre-trained Large Language Models (LLM) have achieved remarkable successes in several domains. However, code-oriented LLMs are heavy in computational complexity, and quadratically with the length of the input. Toward simplifying the input program of an LLM, the state-of-the-art approach has the strategies to filter the input code tokens based on the attention scores given by the LLM. The decision to simplify the input should not rely on the attention patterns of an LLM, as these patterns are influenced by both the model architecture and the pre-training dataset. Since the model and dataset are part of the solution domain, not the problem domain where the input belongs, the outcome may differ when the model is pre-trained on a different dataset. We propose SlimCode, a model-agnostic code simplification solution for LLMs that depends on the nature of input code tokens. As an empirical study on the LLMs including CodeBERT, CodeT5, and GPT-4 for two main tasks: code search and summarization, we reported that 1) the removal ratio of code has a linear-like relation with the saving ratio on training time, 2) the impact of categorized tokens on code simplification can vary significantly, 3) the impact of categorized tokens on code simplification is task-specific but model-agnostic, and 4) the above findings hold for the paradigm-prompt engineering and interactive in-context learning. The empirical results showed that SlimCode can improve the state-of-the-art technique by 9.46% and 5.15% in terms of MRR and BLEU score on code search and summarization. Moreover, SlimCode is 133 times faster than the state-of-the-art approach. Additionally, SlimCode can reduce the cost of invoking GPT-4 by up to 24% per API query, while still producing comparable results to those with the original code.

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

↑