arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.14640cs.SEcs.AIcs.CL
收藏

基于内部状态的代码大语言模型风险评估框架

Risk Assessment Framework for Code LLMs via Leveraging Internal States

The University of Tokyo(东京大学);University of Alberta(阿尔伯塔大学);Fujitsu Limited(富士通株式会社)

Yuheng Huang, Lei Ma, Keizaburo Nishikino, Takumi Akazaki

AI总结:

本文提出PtTrust,一种基于内部状态预训练的两阶段风险评估框架,用于检测代码大语言模型生成的不安全代码,实现行级评估并跨任务和语言泛化。

摘要:

预训练范式在大型语言模型(LLMs)的成功中扮演着关键角色,这些模型被认为是近期人工智能领域最重要的进展之一。在这些突破的基础上,具有先进编码能力的代码大语言模型对软件工程产生了巨大影响,显示出成为开发者日常工作中不可或缺一部分的趋势。然而,当前的代码大语言模型仍然面临与可信度相关的严重挑战,因为它们可能生成不正确、不安全或不可靠的代码。最近的探索性研究发现,通过分析LLMs的内部状态来检测此类有风险输出是有前景的,类似于人脑无意识地识别自身错误的方式。然而,这些方法大多局限于LLM操作的狭窄子领域,未能达到行业级的可扩展性和实用性。为了解决这些挑战,本文提出了PtTrust,一种基于内部状态预训练的代码大语言模型两阶段风险评估框架,旨在与软件公司现有的基础设施无缝集成。核心思想是风险评估框架也可以经历类似于LLMs的预训练过程。具体而言,PtTrust首先在大规模无标签源代码上进行无监督预训练,以学习LLM状态的通用表示。然后,它使用一个小的带标签数据集来训练风险预测器。我们通过细粒度的代码行级风险评估证明了PtTrust的有效性,并表明它能跨任务和不同编程语言进行泛化。进一步的实验还揭示,PtTrust提供了高度直观和可解释的特征,促进了用户更大的信任。我们相信PtTrust在实现代码大语言模型的可扩展和可信保障方面迈出了有前景的一步。

英文摘要:

The pre-training paradigm plays a key role in the success of Large Language Models (LLMs), which have been recognized as one of the most significant advancements of AI recently. Building on these breakthroughs, code LLMs with advanced coding capabilities bring huge impacts on software engineering, showing the tendency to become an essential part of developers' daily routines. However, the current code LLMs still face serious challenges related to trustworthiness, as they can generate incorrect, insecure, or unreliable code. Recent exploratory studies find that it can be promising to detect such risky outputs by analyzing LLMs' internal states, akin to how the human brain unconsciously recognizes its own mistakes. Yet, most of these approaches are limited to narrow sub-domains of LLM operations and fall short of achieving industry-level scalability and practicability. To address these challenges, in this paper, we propose PtTrust, a two-stage risk assessment framework for code LLM based on internal state pre-training, designed to integrate seamlessly with the existing infrastructure of software companies. The core idea is that the risk assessment framework could also undergo a pre-training process similar to LLMs. Specifically, PtTrust first performs unsupervised pre-training on large-scale unlabeled source code to learn general representations of LLM states. Then, it uses a small, labeled dataset to train a risk predictor. We demonstrate the effectiveness of PtTrust through fine-grained, code line-level risk assessment and demonstrate that it generalizes across tasks and different programming languages. Further experiments also reveal that PtTrust provides highly intuitive and interpretable features, fostering greater user trust. We believe PtTrust makes a promising step toward scalable and trustworthy assurance for code LLMs.

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

↑