Bridge and Hint:面向长程代码扩展预训练语言模型
Bridge and Hint: Extending Pre-trained Language Models for Long-Range Code
AI总结:
针对现有预训练语言模型处理长程代码能力不足的问题,提出含桥接记忆与提示记忆双机制的EXPO框架,在5种模型和2项代码智能任务上验证了其显著提升效果。
摘要:
在代码智能领域,有效建模长程代码是一项重大挑战。现有的预训练语言模型(PLM)如UniXcoder已取得显著成效,但在处理长代码输入时仍面临困难,主要原因是它们在长程代码中维持上下文连续性、记忆关键信息的能力有限。为缓解这一问题,我们提出EXPO(面向长程代码的预训练语言模型扩展框架)。EXPO包含本文提出的两种创新记忆机制:Bridge Memory(桥接记忆)和Hint Memory(提示记忆)。Bridge Memory采用标记机制连接长程代码中分散的片段,帮助模型维持上下文连贯性;Hint Memory通过集成kNN注意力层自适应选择相关代码元素,聚焦全局上下文中的关键代码要素(如包导入)。这种双记忆方法填补了局部代码片段理解与全局代码连贯性维持之间的空白,从而提升模型对长代码序列的整体理解能力。我们在UniXcoder等5种主流预训练语言模型,以及API推荐、漏洞检测2项代码智能任务上验证了EXPO的有效性。实验结果表明,EXPO显著提升了预训练语言模型的性能。
英文摘要:
In the field of code intelligence, effectively modeling long-range code poses a significant challenge. Existing pre-trained language models (PLMs) such as UniXcoder have achieved remarkable success, but they still face difficulties with long code inputs. This is mainly due to their limited capacity to maintain contextual continuity and memorize the key information over long-range code. To alleviate the difficulties, we propose EXPO, a framework for EXtending Pre-trained language models for lOng-range code. EXPO incorporates two innovative memory mechanisms we propose in this paper: Bridge Memory and Hint Memory. Bridge Memory uses a tagging mechanism to connect disparate snippets of long-range code, helping the model maintain contextual coherence. Hint Memory focuses on crucial code elements throughout the global context, such as package imports, by integrating a kNN attention layer to adaptively select the relevant code elements. This dual-memory approach bridges the gap between understanding local code snippets and maintaining global code coherence, thereby enhancing the model overall comprehension of long code sequences. We validate the effectiveness of EXPO on five popular pre-trained language models such as UniXcoder and two code intelligence tasks including API recommendation and vulnerability detection. Experimental results demonstrate that EXPO significantly improves the pre-training language models.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。