Lune

ICML2024Top-tier venue

Do Large Code Models Understand Programming Concepts? Counterfactual Analysis for Code Predicates

Ashish Hooda, Mihai Christodorescu, Miltiadis Allamanis, Aaron Wilson, Kassem Fawaz, Somesh Jha

Abstract

Large Language Models' success on text generation has also made them better at code generation and coding tasks. While a lot of work has demonstrated their remarkable performance on tasks such as code completion and editing, it is still unclear as to why. We help bridge this gap by exploring to what degree auto-regressive models understand the logical constructs of the underlying programs. We propose Counterfactual Analysis for Programming Concept Predicates (CACP) as a counterfactual testing framework to evaluate whether Large Code Models understand programming concepts. With only black-box access to the model, we use CACP to evaluate ten popular Large Code Models for four different programming concepts. Our findings suggest that current models lack understanding of concepts such as data flow and control flow.

Ask Lune

Ask anything. The answer quotes the paper.

Lune reads all of it and the papers around it, then shows you the passages behind every answer.

Questions to start from

Lune answers from

the full paper · 6 top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Cited by top-tier papers6

  1. CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code ReasoningMan Ho Lam, Chaozheng Wang, Jen-Tse Huang, Michael R. LyuNeurIPS 2025 · 16 citations
  2. Trust Me, I Know This Function: Hijacking LLM Static Analysis using BiasShir Bernstein, David Beste, Daniel Ayzenshteyn, Lea Schönherr et al.NDSS 2026 · 7 citations
  3. An LLM-Based Agent-Oriented Approach for Automated Code Design Issue LocalizationFraol Batole, David O'Brien, Tien N. Nguyen, Robert Dyer et al.ICSE 2025 · 7 citations
  4. Automated Generation of Issue-Reproducing Tests by Combining LLMs and Search-Based TestingKonstantinos Kitsios, Marco Castelluccio, Alberto BacchelliASE 2025 · 1 citation
  5. Neuron-Guided Interpretation of Code LLMs: Where, Why, and How?Zhe Yin, Xiaodong Gu, Beijun ShenFSE 2026

Builds on7

  1. Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 citations
  2. CURE: Code-Aware Neural Machine Translation for Automatic Program RepairNan Jiang, Thibaud Lutellier, Lin TanICSE 2021 · 267 citations
  3. Repair Is Nearly Generation: Multilingual Program Repair with LLMsHarshit Joshi, José Pablo Cambronero Sánchez, Sumit Gulwani, Vu Le et al.AAAI 2023 · 182 citations
  4. Quantifying Memorization Across Neural Language ModelsNicholas Carlini, Daphne Ippolito, Matthew Jagielski, Katherine Lee et al.ICLR 2023 · 158 citations
  5. Typilus: neural type hintsMiltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng GaoPLDI 2020 · 92 citations

Related papers

  1. The Magic of IF: Investigating Causal Reasoning Abilities in Large Language Models of CodeXiao Liu, Da Yin, Chen Zhang, Yansong Feng et al.ACL Findings 2023 · 9 citations
  2. The Counterfeit Conundrum: Can Code Language Models Grasp the Nuances of Their Incorrect Generations?Alex Gu, Wen-Ding Li, Naman Jain, Theo Olausson et al.ACL Findings 2024 · 3 citations
  3. Causality-Aided Evaluation and Explanation of Large Language Model-Based Code GenerationZhenlan Ji, Pingchuan Ma, Zongjie Li, Zhaoyu Wang et al.ISSTA 2025 · 1 citation
  4. Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChainMarcus J. Min, Yangruibo Ding, Luca Buratti, Saurabh Pujar et al.ICLR 2024 · 39 citations
  5. CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and GenerationWeixiang Yan, Haitian Liu, Yunkun Wang, Yunzhe Li et al.ACL 2024
Dusk over the sea between two cliffs drawn in fine vertical lines