CoHalLo: code hallucination localization via probing hidden layer vector
Nan Jia, Wangchao Sang, Pengfei Lin, Xiangping Chen, Yuan Huang, Yi Liu, and Mingliang Li

TL;DR
CoHalLo is a novel method that localizes code hallucinations at the line level by probing hidden-layer vectors, improving the precision of identifying hallucinated code segments in AI-generated code.
Contribution
This paper introduces CoHalLo, a fine-grained hallucination localization technique using hidden-layer probing and syntactic analysis, advancing beyond coarse detection methods.
Findings
Achieves up to 83.33% Top-10 accuracy in localization
Outperforms baseline methods in hallucination detection metrics
Effectively identifies key syntactic structures associated with hallucinations
Abstract
The localization of code hallucinations aims to identify specific lines of code containing hallucinations, helping developers to improve the reliability of AI-generated code more efficiently. Although recent studies have adopted several methods to detect code hallucination, most of these approaches remain limited to coarse-grained detection and lack specialized techniques for fine-grained hallucination localization. This study introduces a novel method, called CoHalLo, which achieves line-level code hallucination localization by probing the hidden-layer vectors from hallucination detection models. CoHalLo uncovers the key syntactic information driving the model's hallucination judgments and locates the hallucinating code lines accordingly. Specifically, we first fine-tune the hallucination detection model on manually annotated datasets to ensure that it learns features pertinent to code…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Advanced Malware Detection Techniques · Security and Verification in Computing
