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-citation
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.