As Large Language Models (LLMs) are increasingly integrated into software development workflows, their trustworthiness has become a critical concern. However, in dependency recommendation scenarios, the reliability of LLMs is undermined by widespread package hallucinations, where models often recommend hallucinated packages. Recent studies have proposed a range of approaches to mitigate this issue. Nevertheless, existing approaches typically merely reduce hallucination rates rather than eliminate them, leaving persistent software security risks. In this work, we argue that package hallucinations are theoretically preventable based on the key insight that package validity is decidable through finite and enumerable authoritative package lists. Building on this, we propose PackMonitor, the first approach capable of fundamentally eliminating package hallucinations by continuously monitoring the model's decoding process and intervening when necessary. To implement this in practice, PackMonitor addresses three key challenges: (1) determining when to trigger intervention via a Context-Aware Parser that continuously monitors model outputs and selectively activates intervening only during installation command generation; (2) resolving how to intervene by employing a Package-Name Intervenor that strictly limits the decoding space to an authoritative package list; and (3) ensuring monitoring efficiency through a DFA-Caching Mechanism that enables scalability to millions of packages with negligible overhead. Extensive experiments on five widely used LLMs demonstrate that PackMonitor is a training-free, plug-and-play solution that consistently reduces package hallucination rates to zero while maintaining low-latency inference and preserving original model capabilities.


翻译:随着大型语言模型(LLMs)日益融入软件开发工作流,其可信度已成为关键问题。然而,在依赖推荐场景中,LLMs的可靠性受到普遍存在的软件包幻觉现象的破坏——模型经常推荐虚构的软件包。近期研究提出了多种缓解该问题的方法,但现有方案通常仅能降低幻觉率而非彻底消除,导致软件安全风险持续存在。本文基于“软件包有效性可通过有限且可枚举的权威软件包列表进行判定”这一关键洞见,论证了软件包幻觉在理论上可被预防。基于此,我们提出PackMonitor——首个能够通过持续监控模型解码过程并在必要时实施干预,从而从根本上消除软件包幻觉的方法。为实现该目标,PackMonitor解决了三个关键挑战:(1)通过上下文感知解析器持续监控模型输出,并仅在生成安装命令时选择性激活干预,以确定何时触发干预;(2)采用软件包名称干预器将解码空间严格限制在权威软件包列表内,以解决如何干预的问题;(3)通过确定性有限自动机缓存机制确保监控效率,使其可扩展至数百万软件包规模且开销可忽略。在五个广泛使用的LLMs上进行的大量实验表明,PackMonitor是一种无需训练、即插即用的解决方案,能够持续将软件包幻觉率降至零,同时保持低延迟推理并保留原始模型能力。

0
下载
关闭预览

相关内容

软件(中国大陆及香港用语,台湾作软体,英文:Software)是一系列按照特定顺序组织的计算机数据和指令的集合。一般来讲软件被划分为编程语言、系统软件、应用软件和介于这两者之间的中间件。软件就是程序加文档的集合体。
大语言模型幻觉:系统综述
专知会员服务
40+阅读 · 2025年10月10日
【CIKM2024】使用大型视觉语言模型的多模态虚假信息检测
大型语言模型幻觉的综述
专知会员服务
39+阅读 · 2024年2月15日
大型语言模型幻觉缓解技术的全面综述
专知会员服务
72+阅读 · 2024年1月3日
Deformable Kernels,用于图像/视频去噪,即将开源
极市平台
13+阅读 · 2019年8月29日
iOS如何区分App和SDK内部crash
CocoaChina
11+阅读 · 2019年4月17日
自己动手撸一个分布式IM(即时通讯) 系统
51CTO博客
16+阅读 · 2019年3月20日
深入理解BERT Transformer ,不仅仅是注意力机制
大数据文摘
22+阅读 · 2019年3月19日
Spooftooph - 用于欺骗或克隆蓝牙设备的自动工具
黑白之道
17+阅读 · 2019年2月27日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
BES:让语言模型通过双向进化搜索自我改进
专知会员服务
3+阅读 · 5月30日
以色列-美国-伊朗战争中的无人机:关键要点
专知会员服务
4+阅读 · 5月30日
《Palantir任务保障性软件安全标准(MA-S2)》
专知会员服务
10+阅读 · 5月30日
基于声学的无人机检测技术综述
专知会员服务
7+阅读 · 5月30日
《当代混合战争分析框架:俄乌战争经验教训》
战略前沿人工智能的再思考(中文)
专知会员服务
8+阅读 · 5月29日
《量化地基防空系统间接效应的博弈论方法》
专知会员服务
6+阅读 · 5月29日
相关基金
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员