A Critical Study of What Code-LLMs (Do Not) Learn
Abhinav Anand, Shweta Verma, Krishna Narasimhan, Mira Mezini
TL;DR
The paper critically examines how code-LLMs encode code properties, arguing that attention maps and hidden representations largely miss cross-relations between syntactic tokens and identifiers, which are essential for program flow. Using AST and data-flow graphs, along with DirectProbe, it shows that large, fine-tuned models encode these relations poorly compared with smaller pre-trained models, suggesting memorization and shortcuts rather than genuine code understanding. The study reveals non-linear encoding in hidden representations and warns that prior interpretability methods, which rely on fixed thresholds or linear probes, can mislead conclusions. These findings motivate new training objectives and architectures beyond mere scaling to robustly capture code structure and semantics. The work also emphasizes careful experimental design for interpretability in cLLMs and NL-PL alignment considerations for future research.
Abstract
Large Language Models trained on code corpora (code-LLMs) have demonstrated impressive performance in various coding assistance tasks. However, despite their increased size and training dataset, code-LLMs still have limitations such as suggesting codes with syntactic errors, variable misuse etc. Some studies argue that code-LLMs perform well on coding tasks because they use self-attention and hidden representations to encode relations among input tokens. However, previous works have not studied what code properties are not encoded by code-LLMs. In this paper, we conduct a fine-grained analysis of attention maps and hidden representations of code-LLMs. Our study indicates that code-LLMs only encode relations among specific subsets of input tokens. Specifically, by categorizing input tokens into syntactic tokens and identifiers, we found that models encode relations among syntactic tokens and among identifiers, but they fail to encode relations between syntactic tokens and identifiers. We also found that fine-tuned models encode these relations poorly compared to their pre-trained counterparts. Additionally, larger models with billions of parameters encode significantly less information about code than models with only a few hundred million parameters.
