Title: Topology of Attention Detects Hallucinations in Code LLMs
Primary area: foundation or frontier models, including LLMs
Keywords: Code Models, Robustness, Attention Matrices

Abstract: While the AI-code assistant tools become widespread, automatic assessment of the correctness of the generated code becomes a significant challenge. Code LLMs are prone to hallucinations, which may lead to code that does not solve a required problem, or even to code with severe security vulnerabilities. 
In this paper, we propose a new approach to assessment of code correctness. Our solution is based on topological data analysis (TDA) of attention maps of code LLMs.
We carry out experiments with two benchmarks - HumanEval, MBPP and 5 code LLMs: StarCoder2-7B,  CodeLlama-7B, DeepSeek-Coder-6.7B, Qwen2.5-Coder-7B, Magicoder-S-DS-6.7B.
The experimental results show that the proposed method is better than several baselines. Moreover, the trained classifiers are transferable between coding benchmarks.