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

Transformer模型对不同长度代码补全的泛化能力研究

On the Generalizability of Transformer Models to Code Completions of Different Lengths

Nathan Cooper, Rosalia Tufano, Gabriele Bavota, Denys Poshyvanyk

AI总结:

本文通过大规模实证研究评估Sinusoidal、xPOS、ALiBi和T5等编码方案在编码器-解码器LLM代码补全中对未见输入长度的泛化能力,发现均无法成功泛化,训练集需覆盖推理时可能遇到的长度。

摘要:

如今,大型语言模型(LLM)的出现正在重塑编程领域,这些模型能够自动化完成与代码实现(例如代码补全)和代码理解(例如代码摘要)相关的任务。这种范式转变带来了许多关于软件将如何编写、维护和演化的影响。此外,这些LLM的训练成本极高,这引发了关于其长期可持续性的疑问。鉴于其训练成本,它们的泛化能力,即在不同于训练所用任务实例上工作的能力,是一个值得研究的方面。先前的工作已经表明,transformer模型可以在跨项目环境中成功支持代码补全。然而,尚不清楚LLM是否能够泛化到训练期间未见过的输入长度。例如,众所周知,在短实例上训练模型可以大幅降低训练成本。但是,这样的模型在训练期间未见过长度的序列上能在多大程度上提供良好性能,目前尚不清楚。自然语言处理(NLP)领域的许多近期工作在仅解码器LLM的背景下解决了这个问题,即xPOS和ALiBi。为了评估这些解决方案是否能扩展到代码相关任务中通常采用的编码器-解码器LLM,我们提出了一项大规模实证研究,评估这些方案以及文献中提出的其他编码方案(即Sinusoidal、xPOS、ALiBi和T5)的这种泛化特性。我们发现,这些解决方案都不能成功泛化到未见过的长度,唯一安全的解决方案是确保训练集中代表推理时可能遇到的所有长度。

英文摘要:

The programming landscape is nowadays being reshaped by the advent of Large Language Models (LLMs) able to automate code-related tasks related to code implementation (e.g., code completion) and comprehension (e.g., code summarization). Such a paradigm shift comes with a number of implications related to how software will be written, maintained, and evolved. Also, these LLMs are extremely expensive to train, posing questions on their sustainability over time. Given their training cost, their ability to generalize, namely their ability to work on task instances different from those on which they have been trained, is an aspect worth being investigated. Previous work already showed that transformer models can successfully support code completion in a cross-project setting. However, it is unclear whether LLM are able to generalize to inputs having lengths not seen during training. For example, it is known that training a model on short instances allows to substantially reduce the training cost. However, the extent to which such a model would provide good performance on sequences having lengths not seen during training is not known. Many recent works in Natural Language Processing (NLP) tackled this problem in the context of decoder-only LLMs, i.e., xPOS and ALiBi. To assess if these solutions extend to encoder-decoder LLMs usually adopted in the code-related tasks, we present a large empirical study evaluating this generalization property of these and other encoding schemes proposed in the literature, namely Sinusoidal, xPOS, ALiBi, and T5. We found that none of these solutions successfully generalize to unseen lengths and that the only safe solution is to ensure the representativeness in the training set of all lengths likely to be encountered at inference time.

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

↑