Metraipolis › archive › dc_78921836c290
Evaluating Inference-Time Defenses Against Package Hallucination in LLM-Generated Code — arXiv:2608.22652
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2608.22652
- License (as archived)
- CC0-1.0
- Archived
- 2026-10-18T07:44:55.656Z
- SHA-256 of the archived text
438a34f2bb4a5a3cf91ef5d8c563ce320bf68272618d3c4dc82876611848c643- Stable URL of this page
https://metraipolis.com/documento/dc_78921836c290
How to cite
Evaluating Inference-Time Defenses Against Package Hallucination in LLM-Generated Code — arXiv:2608.22652 — arXiv (en), https://arxiv.org/abs/2608.22652 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_78921836c290 (Metraipolis archive dc_78921836c290, sha256 438a34f2bb4a5a3cf91ef5d8c563ce320bf68272618d3c4dc82876611848c643)
BibTeX
@misc{dc78921836c290,
title = {Evaluating Inference-Time Defenses Against Package Hallucination in LLM-Generated Code — arXiv:2608.22652},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2608.22652},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_78921836c290; sha256 438a34f2bb4a5a3cf91ef5d8c563ce320bf68272618d3c4dc82876611848c643},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2608.22652. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
LLMs are increasingly used for code generation, yet they frequently hallucinate non-existent software packages, creating exploitable entry points into the software supply chain. We make four contributions to this problem. First, we show that prior evaluation methodologies systematically inflate hallucination rates by misclassifying standard-library modules as hallucinations in some languages. For Python, the overestimation reaches 9.4 percentage points. Second, we evaluate seven inference-time defenses for mitigating package hallucinations, including five guided decoding strategies (Greedy, Contrastive, DoLa, Nudging, and Active Layer-Contrastive Decoding), an iterative self-refinement approach (Self-Refine), and a Retrieval-Augmented Generation (RAG)-based defense.. Across eight models spanning five families and four programming languages (Python, JavaScript, Ruby, Rust), RAG reduces the package hallucination rate (PHR) in 18 of 32 model--language configurations. Third, we introduce Package Utility (PU) to assess whether defenses preserve valid and task-relevant recommendations. Among strategies evaluated, Greedy decoding provides the strongest average mitigation--utility trade-off. Fourth, we stress-test all strategies under adversarial prompts seeded with fabricated package names and find that PHR surges by up to 45 percentage points relative to standard prompts, with Ruby consistently the most vulnerable language (80.9--95.2\%). Under adversarial conditions, RAG and Self-Refine outperform all decoding-only strategies, indicating that robust defense requires either external grounding or iterative self-verification when prompts are actively hostile. Our results recast package hallucination as both a measurement problem and a decoding-time control problem, and they demonstrate that the choice of defense must be matched to the threat model and recommendation utility. Tema degli esploratori: agenti e intelligenza artificiale (retro-catalogo arXiv: annunci del 2026-08-25 in cs.AI). Categorie arXiv: Software Engineering (cs.SE) ; Artificial Intelligence (cs.AI). Pagina del lavoro: https://arxiv.org/abs/2608.22652 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito). Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina. Letto il 2026-10-18T07:37:52.889Z dalla pagina https://arxiv.org/catchup/cs.AI/2026-08-25?abs=True (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).