We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
University of Texas at San Antonio(德克萨斯大学圣安东尼奥分校);University of Oklahoma(俄克拉荷马大学);Virginia Tech(弗吉尼亚理工大学)
Joseph Spracklen, Raveen Wijewickrama, A H M Nazmus Sakib, Anindya Maiti, Bimal Viswanath, Murtuza Jadliwala
备注:
To appear in the 2025 USENIX Security Symposium. 22 pages, 14 figures, 8 tables. Edited from original version for submission to a different conference. No change to original results or findings
The reliance of popular programming languages such as Python and JavaScript on centralized package repositories and open-source software, combined with the emergence of code-generating Large Language Models (LLMs), has created a new type of threat to the software supply chain: package hallucinations. These hallucinations, which arise from fact-conflicting errors when generating code using LLMs, represent a novel form of package confusion attack that poses a critical threat to the integrity of the software supply chain. This paper conducts a rigorous and comprehensive evaluation of package hallucinations across different programming languages, settings, and parameters, exploring how a diverse set of models and configurations affect the likelihood of generating erroneous package recommendations and identifying the root causes of this phenomenon. Using 16 popular LLMs for code generation and two unique prompt datasets, we generate 576,000 code samples in two programming languages that we analyze for package hallucinations. Our findings reveal that that the average percentage of hallucinated packages is at least 5.2% for commercial models and 21.7% for open-source models, including a staggering 205,474 unique examples of hallucinated package names, further underscoring the severity and pervasiveness of this threat. To overcome this problem, we implement several hallucination mitigation strategies and show that they are able to significantly reduce the number of package hallucinations while maintaining code quality. Our experiments and findings highlight package hallucinations as a persistent and systemic phenomenon while using state-of-the-art LLMs for code generation, and a significant challenge which deserves the research community's urgent attention.
HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzing
School of Software Technology, Zhejiang University, Ningbo, China(软件技术学院,浙江大学,宁波,中国);The State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, China(区块链与数据安全国家重点实验室,浙江大学,杭州,中国)
Harmless Yet Harmful: Neutral Prompting Attacks for Stealthy Hallucination Steering in Agent Skills
Department of Computer Science(计算机科学系);National Yang Ming Chiao Tung University(阳明交通大学);Department of Electronics and Electrical Engineering(电子与电气工程系);School of Computing(计算学院);Institute of Science Tokyo(东京科学研究所)
Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Code
2 State Key Laboratory of Complex \& Critical Software Environment (SKLCCSE) School of Computer Science;Engineering, Beihang University, Beijing, China;3 School of Software, Beihang University, Beijing, China;4 School of Computer Science;Technology, Shandong University, Qingdao, China;5 Huawei Cloud Computing Technologies Co., Ltd, China
An Evolutionary Large Language Model for Hallucination Mitigation
BIOSTIM Laboratory Faculty of Medicine Salah Boubnider University Constantine, Algeria(BIOSTIM实验室医学院萨拉赫·布宾德大学阿尔及利亚科纳克特);Department of IFA Faculty of NTIC Abdelhamid Mehri University Constantine, Algeria(IFA部门NTIC学院阿卜杜勒哈米德·梅赫里大学阿尔及利亚科纳克特)
MHSA: A Lightweight Framework for Mitigating Hallucinations via Steered Attention in LVLMs
Tsinghua University(清华大学);Tsinghua University, Tencent(清华大学腾讯);Tencent(腾讯);University of Science and Technology Beijing(北京科技大学);University of Macau(澳门大学)
SeeMe: Mitigating Hallucinations in Large Vision-Language Models through Effective Visual Token Engineering
State Key Laboratory of Multimedia Information Processing, School of Computer Science, Peking University(北京大学计算机科学学院多媒体信息处理国家重点实验室);University of Pennsylvania(宾夕法尼亚大学);University of Electronic Science and Technology of China(电子科技大学);Nanyang Technological University(南洋理工大学);Tsinghua University(清华大学);The Chinese University of Hong Kong, Shenzhen(香港中文大学(深圳));De Artificial Intelligence Lab(德人工智能实验室)
Cross-Modal Attention Calibration for LVLM Hallucination Mitigation
Sun Yat-sen University(中山大学);The University of Hong Kong(香港大学);Meituan(美团);Inspur Database Technology(Inspur数据库技术);Guilin University of Electronic Technology(桂林电子科技大学);Shenzhen Loop Area Institute(深圳河套学院);Guangdong Key Laboratory of Big Data Analysis and Processing(广东大数据分析与处理重点实验室)