PackMonitor eliminates package hallucinations in LLM-generated dependency recommendations
PackMonitor can completely prevent LLMs from recommending non-existent software packages
Software arXiv 24 Feb 2026 Method Prototype evidence
Published as “PackMonitor: Enabling Zero Package Hallucinations Through Decoding-Time Monitoring”
Why it matters
Enables safe deployment of LLM-powered coding assistants by removing a concrete software-supply-chain attack vector without sacrificing performance.
Summary
PackMonitor eliminates package hallucinations completely, achieving 0% package and response hallucination rates across five LLMs and two benchmarks. The approach adds only a tiny latency overhead (about +0.05-0.3 s, roughly ×1.07-×1.28) and does not degrade code generation performance on HumanEval. Evidence comes from extensive HFuzzer and HumanEval experiments comparing against RAG, SR, RAG+SR, and SFT baselines.
What they found 2
- PackMonitor reduces package hallucination rates to zero across all evaluated models and benchmarks.
“PackMonitor consistently outperforms all training-free baselines across every model, reducing all hallucination-related metrics to absolute zero.”
- The method incurs only a modest inference overhead.
“PackMonitor introduces only a modest and consistent slowdown across all five models, with a normalized inference-time ratio between ×1.07 and ×1.28.”
What’s new here 4
- Decoding-time monitoring that masks logits leading to invalid package names.
- Use of a deterministic finite automaton built from an authoritative package list to enforce validity.
- A context-aware parser that activates intervention only for installation-command contexts.
- DFA-caching mechanism that makes the approach scalable to hundreds of thousands of packages without retraining.