Toward a Theory of Causation for Interpreting Neural Code Models
Open accessThe DOI matches its Crossref record; 97 of the 97 references it cites were found in a registry or an index.
Abstract
Neural Language Models of Code, or Neural Code Models (NCMs), are rapidly progressing from research prototypes to commercial developer tools. As such, understanding the capabilities and limitations of such models is becoming critical. However, the abilities of these models are typically measured using automated metrics that often only reveal a portion of their real-world performance. While, in general, the performance of NCMs appears promising, currently much is unknown about how such models arrive at decisions. To this end, this paper introducesdocode, a post hoc interpretability method specific to NCMs that is capable of explaining model predictions.docodeis based upon causal inference to enable programming language-oriented explanations. While the theoretical underpinnings ofdocodeare extensible to exploring different model properties, we provide a concrete instantiation that aims to mitigate the impact of spurious correlations by grounding explanations of model behavior in properties of programming languages. To demonstrate the practical benefit ofdocode, we illustrate the insights that our framework can provide by performing a case study on two popular deep learning architectures and ten NCMs. The results of this case study illustrate that our studied NCMs are sensitive to changes in code syntax. All our NCMs, except for the BERT-like model, statistically learn to predict tokens related to blocks of code (e.g., brackets, parenthesis, semicolon) with less confounding bias as compared to other programming language constructs. These insights demonstrate the potential ofdocodeas a useful method to detect and facilitate the elimination of confounding bias in NCMs.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Figures
![Fig. 1 Common Cause Principle in NCMs [28]](https://figures.cochat.ai/paper-figures/a8530aee695a4063a8a95f591410b2e1/toward-a-theory-of-causation-for-interpreting-neural-code-models-figure-1.png)



















Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
In the citing paper
“Recent studies indicate that causal interpretability [135] can successfully reduce misleading interpretations by mitigating the influence of confounders.”
From A 2030 Roadmap for Software Engineering (2025) · cites this paper as [135]
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I. (2017) · arXiv · doi:10.48550/arxiv.1706.03762 · Cited by 120,404 · cited 3×
“…Recurrent Unit (GRU) [81], which uses reset r t = σ ( W r · [ h t − 1 , w t ]) , and update u t = σ ( W u · [ h t − 1 , w t ]) gates to control how it combines the previous hidden state h t − 1 with a new candidate state Furthermore, GPT and BERT are deep architectures known as Transformers [33].”
BackgroundMethodHochreiter, S., & Schmidhuber, J. (1997) · Neural Computation · doi:10.1162/neco.1997.9.8.1735 · Cited by 102,318 · cited 1×
“IX) on different variations of popular deep learning architectures for the task of code generation, namely RNNs [32] and Transformers [33] trained on the CodeSearchNet dataset [34].”
BackgroundAdam: A Method for Stochastic Optimization
Kingma, D. P., & Ba, J. (2014) · arXiv · doi:10.48550/arxiv.1412.6980 · Cited by 98,946 · cited 1×
“Causation Correlation NCM lyr,unt NCM lyr,hds dropout RNN [42] dropout TF optimizer [43] learning rate beta1|beta2 epsilon epochs batch RNN|TG 0.”
BackgroundExploiting Generative AI to Scale up Intelligent Tutoring Systems
Jakubův, J., Chvalovský, K., Goertzel, Z., Kaliszyk, C., Olšák, M., Piotrowski, B., Schulz, S., Suda, M., & Urban, J. (2023) · DROPS (Schloss Dagstuhl – Leibniz Center for Informatics) · doi:10.4230/lipics.itp.2023.19 · Cited by 76,658
Causality: Models, Reasoning, and Inference
Pearl, J. (2009) · doi:10.1017/cbo9780511803161 · Cited by 11,653
TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems
Abadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z., Citro, C., Corrado, G. S., Davis, A., Dean, J., Devin, M., et al. (2016) · arXiv · doi:10.48550/arxiv.1603.04467 · Cited by 9,408 · cited 1×
“For model development, we employed Tensorflow and Pytorch [84], [85], along with Huggingface’s Transformers library [86].”
MethodTransformers: State-of-the-Art Natural Language Processing
Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., Funtowicz, M., et al. (2020) · Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations · doi:10.18653/v1/2020.emnlp-demos.6 · Cited by 8,741
On the Properties of Neural Machine Translation: Encoder–Decoder Approaches
Cho, K., van Merrienboer, B., Bahdanau, D., & Bengio, Y. (2014) · Proceedings of SSST-8, Eighth Workshop on Syntax, Semantics and Structure in Statistical Translation · doi:10.3115/v1/w14-4012 · Cited by 7,099 · cited 1×
“RNNs can take the form of a Gated Recurrent Unit (GRU) [81], which uses reset r t = σ ( W r · [ h t − 1 , w t ]) , and update u t = σ ( W u · [ h t − 1 , w t ]) gates to control how it combines the previous hidden state h t − 1 with a new candidate state Furthermore, GPT and BERT are deep…”
BackgroundOn the Dangers of Stochastic Parrots: Can Language Models Be Too Big? 🦜
Bender, E. M., Gebru, T., McMillan-Major, A., & Shmitchell, S. (2021) · Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency · doi:10.1145/3442188.3445922 · Cited by 6,988 · cited 1×
“Restrictions apply. and thus may inherit the various limitations often associated with such models — including biases, memorization, and issues with data inefficiency, to name a few [22].”
BackgroundLipton, Z. C. (2018) · Queue · doi:10.1145/3236386.3241340 · Cited by 5,427 · cited 2×
“However, perhaps the most problematic aspect of current neural language models is the fact that they are incapable of explaining their reasoning [23], [24], [25], [26].”
Background
Research works printed but not linked: 6
- F. Doshi-Velez and B. Kim, "Towards A Rigorous Science of Interpretable Machine Learning," arXiv: Machine Learning, no. Ml, pp. 1-13, 2017. [Online]. Available: http://arxiv.org/abs/1702. 08608
- B. Sch ölkopf and J. von K ügelgen, "From statistical to causal learning," 4 2022. [Online]. Available: http://arxiv.org/abs/2204. 00607
- Y. Hu and J. Tian, "Neuron dependency graphs: A causal abstraction of neural networks," in Proceedings of the 39th International Conference on Machine Learning, ser. Proceedings of Machine Learning Research, K. Chaudhuri, S. Jegelka et al., Eds., vol. 162. PMLR, 17-23 Jul 2022, pp. 9020-9040. [Online]. Available: https://proceedings.mlr.press/v162/hu22b.html
- A. Paszke, S. Gross et al., "Pytorch: An imperative style, high- performance deep learning library," in Advances in Neural Infor- mation Processing Systems 32, H. Wallach, H. Larochelle et al., Eds. Curran Associates, Inc., 2019, pp. 8024-8035. · doi:10.5555/3454287.3455008
- R. M. Karampatsis, H. Babii et al., "Big code != big vocabulary: Open-vocabulary models for source code," Proceedings -Interna- tional Conference on Software Engineering, pp. 1073-1085, 2020.
- S. Lu, D. Guo et al., "Codexglue: A machine learning bench- mark dataset for code understanding and generation," CoRR, vol. abs/2102.04664, 2021. · arXiv
Cited by
Artificial Intelligence for Software Engineering: The Journey So Far and the Road Ahead
Ahmed, I., Aleti, A., Cai, H., Chatzigeorgiou, A., He, P., Hu, X., Pezzè, M., Poshyvanyk, D., & Xia, X. (2025) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3719006 · Cited by 54
“…trivially large datasets for specific tasks, for instance, by simply applying semantics-preserving code refactoring schemes, including junk code insertion, to multiply relatively small dataset, the resulting datasets do not significantly increase the knowledge available for training the models.”
Self-citationA Systematic Literature Review on Explainability for ML/DL-based Software Engineering
Cao, S., Sun, X., Widyasari, R., Lo, D., Wu, X., Bo, L., Zhang, J., Li, B., Liu, W., Wu, D., et al. (2025) · ACM Computing Surveys · doi:10.1145/3763230 · Cited by 51
HumanEvalComm: Benchmarking the Communication Competence of Code Generation for LLMs and LLM Agent
Wu, J. J., & Fard, F. H. (2025) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3715109 · Cited by 55
“At a high level, the gap lies in several critical aspects of software development beyond coding, such as effective communications, explanation, requirements, design, domain knowledge, and the broader context of relevant projects and components [47, 51, 63, 65, 69].”
From Triumph to Uncertainty: The Journey of Software Engineering in the AI Era
Mastropaolo, A., Escobar‐Velásquez, C., & Linares‐Vásquez, M. (2025) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3709360 · Cited by 30
“By leveraging our expertise in software engineering, we can design robust frameworks and methodologies to mitigate biases, ensure data quality, and facilitate the adoption of SE for AI-based system development (SE4AI) [16, 190].”
How Propense Are Large Language Models at Producing Code Smells? A Benchmarking Study
Velasco, A., Rodríguez-Cárdenas, D., Alif, L. R., Palacio, D. N., & Poshyvanyk, D. (2025) · IEEE/ACM International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER) · doi:10.1109/icse-nier66352.2025.00025 · Cited by 22
“By aligning meaningful tokens to highlight smelly segments, our approach offers a novel, interpretable metric [29], [43], suitable for black-box code generation models.”
Self-citationDo Large Code Models Understand Programming Concepts? Counterfactual Analysis for Code PredicatesPreprint
Hooda, A., Christodorescu, M., Allamanis, M., Wilson, A. C., Fawaz, K., & Jha, S. (2024) · arXiv (Cornell University) · doi:10.48550/arxiv.2402.05980 · Cited by 23
“Independently, there has been work on counterfactual analysis of output token probabilities of large code models (Palacio et al., 2023a,b).”
Benchmarking Causal Study to Interpret Large Language Models for Source Code
Rodriguez-Cardenas, D., Palacio, D. N., Khati, D., Burke, H., & Poshyvanyk, D. (2023) · 2023 IEEE International Conference on Software Maintenance and Evolution (ICSME) · doi:10.1109/icsme58846.2023.00040 · Cited by 14
“Few studies have sought to examine accuracy metrics from a causal perspective to interpret LLMc [36].”
BackgroundSelf-citationA 2030 Roadmap for Software Engineering
Pezzè, M., Abrahão, S., Penzenstadler, B., Poshyvanyk, D., Roychoudhury, A., & Yue, T. (2025) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3731559 · Cited by 13
Self-citationSecurity of Language Models for Code: A Systematic Literature Review
Chen, Y., Sun, W., Fang, C., Chen, Z., Ge, Y., Han, T., Zhang, Q., Liu, Y., Chen, Z., & Xu, B. (2026) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3735554 · Cited by 10
Snopy: Bridging Sample Denoising with Causal Graph Learning for Effective Vulnerability Detection
Cao, S., Sun, X., Wu, X., Lo, D., Bo, L., Li, B., Liu, X., Lin, X., & Liu, W. (2024) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3691620.3695057 · Cited by 29
Neuron-Guided Interpretation of Code LLMs: Where, Why, and How?
Yin, Z., Gu, X., & Shen, B. (2026) · Proceedings of the ACM on software engineering. · doi:10.1145/3797083 · Cited by 10
Which Syntactic Capabilities Are Statistically Learned by Masked Language Models for Code?
Velasco, A., Palacio, D. N., Rodríguez-Cárdenas, D., & Poshyvanyk, D. (2024) · IEEE/ACM International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER) · doi:10.1145/3639476.3639768 · Cited by 11
“Recent studies have explored the use of structural information as an interpretability tool for pre-trained models for code [25].”
BackgroundMethodSelf-citationToward Neurosymbolic Program Comprehension
Velasco, A., Garryyeva, A., Palacio, D. N., Mastropaolo, A., & Poshyvanyk, D. (2025) · IEEE International Conference on Program Comprehension (ICPC) · doi:10.1109/icpc66645.2025.00047 · Cited by 9
“In practice, SHAP isolates the impact of individual features ( w i ∈ x ) on the model’s output while accounting for the influence of other features ( x \ w i ).”
Self-citationShaky structures: The wobbly world of causal graphs in software analytics
Hulse, J., Eisty, N. U., & Menzies, T. (2025) · Empirical Software Engineering · doi:10.1007/s10664-025-10690-6 · Cited by 13
“These are widely used in software engineering; e.g., Nader et al. [37] use causal graphs to show programmers the significant relationships in their code data and conclude the best ways to effect change in that domain.”
Khati, D., Rodríguez-Cárdenas, D., Palacio, D. N., Velasco, A., Tufano, M., & Poshyvanyk, D. (2026) · ACM/IEEE International Conference on Software Engineering: Companion Proceedings (ICSE-Companion) · doi:10.1145/3744916.3787764 · Cited by 6
“In the context of AI4SE, explanations for code generation have included counterfactual [15] and causal [41].”
Self-citationA Causal Perspective on the Role of Training Dynamics for Interpreting Privacy Risks in Code ModelsPreprint
Yang, H., Velasco, A., Fang, S., Xu, B., & Poshyvanyk, D. (2025) · arXiv (Cornell University) · doi:10.48550/arxiv.2512.07814 · Cited by 5
Self-citationVelasco, A. (2024) · ACM/IEEE International Conference on Software Engineering: Companion Proceedings (ICSE-Companion) · doi:10.1145/3639478.3639815 · Cited by 5
“In recent years, a growing interest has emerged in not only evaluating LLMs for code but also providing interpretations about how these models arrive at generated predictions [5, 13, 19–21, 24, 25].”
BackgroundSelf-citationHow Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?
Yang, H., Velasco, A., Le-Cong, T., Haque, M. N., Xu, B., & Poshyvanyk, D. (2026) · ACM/IEEE International Conference on Software Engineering: Companion Proceedings (ICSE-Companion) · doi:10.1145/3744916.3787843 · Cited by 5
Self-citationMeasuring model alignment for code clone detection using causal interpretation
Abid, S., Cai, X., & Jiang, L. (2024) · Empirical Software Engineering · doi:10.1007/s10664-024-10583-0 · Cited by 7
On Automated and Explainable Provenance of AI-Generated Code
Velasco, A., Wintersgill, N., Stalnaker, T., Chaparro, O., & Poshyvanyk, D. (2026) · IEEE International Conference on Software Maintenance (ICSM) · doi:10.48550/arxiv.2608.02329 · Cited by 3
“We propose G lobal E xplanation A ttribution ( GEA ), a framework that extends causal inference techniques developed for code models [32] to the provenance setting.”
InfluentialSelf-citationToward Explaining Large Language Models in Software Engineering Tasks
Vitale, A., Nguyen, K.-N., Poshyvanyk, D., Oliveto, R., Scalabrino, S., & Mastropaolo, A. (2026) · ACM Transactions on Software Engineering and Methodology · doi:10.1145/3837084 · Cited by 2
“Their work on do [54] proposes a post-hoc interpretability approach based on causal inference, designed to reveal how specific code properties influence model decisions.”
Self-citationImproving Transformer-based Program Repair Model through False Behavior Diagnosis
Kim, Y., Kim, M., & Lee, E. (2023) · Conference on Empirical Methods in Natural Language Processing (EMNLP) · doi:10.18653/v1/2023.emnlp-main.865 · Cited by 2
“Investigating the inner workings of a model can offer valuable insights by identifying its capabilities and limitations (Mohammadkhani et al., 2023; Palacio et al., 2023; Borowski et al., 2020; Gunning and Aha, 2019; Voita et al., 2019; Ribeiro et al., 2016a,b; Katuwal and Chen, 2016).”
Towards More Interpretable Large Language Models for Code
Rodríguez-Cárdenas, D. (2025) · ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE) · doi:10.1145/3696630.3731464 · Cited by 2
Towards Interpreting the Behavior of Large Language Models on Software Engineering Tasks
Dipongkor, A. K. (2024) · ACM/IEEE International Conference on Software Engineering: Companion Proceedings (ICSE-Companion) · doi:10.1145/3639478.3639798 · Cited by 1
“[27], which can help to ascribe meaning to predictions from generative LLMs for code, combine this with existing techniques from NLP, such as LIME, SHAP and Integrated Gradient [24, 29, 32], and use this to generate localized explanations for LLMs applied to specific SE tasks.”
MethodTowards a Science of Causal Interpretability in Deep Learning for Software EngineeringPreprint
Palacio, D. N. (2025) · arXiv (Cornell University) · doi:10.48550/arxiv.2505.15023
Heričko, T. (2025) · University of Maribor digital library (University of Maribor)
Yang, Y., Fan, H., Lin, C., Jiang, W., Wang, S., Li, Q., Zhao, Z., Zhang, C., Guan, X., & Shen, C. (2026) · Science China Information Sciences · doi:10.1007/s11432-025-4703-6
ECLAIR: A Causally-Grounded AI Framework for Scientific Discovery in Empirical Software Engineering
Velasco, A., Rodríguez-Cárdenas, D., Khati, D., Palacio, D. N., & Poshyvanyk, D. (2026) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1145/3832783.3834544
Self-citationProgram Bindings Inside Code ModelsPreprint
Rajput, P. K., Song, Y., Klein, J., & Bissyandé, T. F. (2026) · arXiv (Cornell University) · doi:10.48550/arxiv.2610.39489
Metadata
- Authors
- Nader Palacio, D., Velasco, A., Cooper, N., Rodriguez, A., Moran, K., & Poshyvanyk, D.
- Affiliations
- Department of Computer Science, William & Mary, Williamsburg, VA, USA
- William & Mary (US)
- Department of Computer Science, Universidad Nacional de Colombia, Bogota, Colombia
- George Mason University (US)
- ORCID
- Venue
- IEEE Transactions on Software Engineering
- Published
- 2024-05
- Volume
- 50
- Issue
- 5
- Pages
- 1215-1243
- ISSN
- 0098-5589 (ISSN-L)
- 1939-3520
- 2326-3881
- OpenAlex
- W4393058215
- Cited by
- 18
- References
- 86
- Citations by year
- 2026: 3 · 2025: 8 · 2024: 5
- FWCI
- 2.36
- Type
- journal article
- Language
- en
- Open access
- green
- arxiv.org
- Licence
- Locations
- IEEE Transactions on Software Engineering (publishedVersion)
- arXiv (Cornell University) (submittedVersion, cc-by-sa)
- arXiv (Cornell University)
- Funders
- NSF (CCF-2311469, CNS-2132281, CCF-2007246, CCF-1955853, CCF-2311468, CCF-2132285)
- Topics
- Physical Sciences › Computer Science › Artificial Intelligence › Explainable Artificial Intelligence (XAI)
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
- Keywords
- post-hoc explanation, causal inference, confounding, spurious correlations, programming constructs, token prediction
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.