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 introduces $do_{code}$, a post-hoc interpretability methodology specific to NCMs that is capable of explaining model predictions. $do_{code}$ is based upon causal inference to enable programming language-oriented explanations. While the theoretical underpinnings of $do_{code}$ are 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 of $do_{code}$, we illustrate the insights that our framework can provide by performing a case study on two popular deep learning architectures and nine NCMs. The results of this case study illustrate that our studied NCMs are sensitive to changes in code syntax and 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 of $do_{code}$ as a useful model debugging mechanism that may aid in discovering biases and limitations in NCMs.
翻译:代码神经语言模型,即神经代码模型(NCMs),正从研究原型迅速转化为商业开发者工具。因此,理解这类模型的能力与局限性变得至关重要。然而,这些模型的能力通常通过自动化指标衡量,这些指标往往仅揭示其真实世界性能的一部分。尽管NCMs的整体表现看似有前景,但目前对其决策机制仍存在大量未知。为此,本文引入$do_{code}$——一种专门针对NCMs的事后可解释性方法,能够解释模型预测。$do_{code}$基于因果推断,旨在提供面向编程语言的解释。虽然$do_{code}$的理论基础可扩展至探索不同模型属性,我们给出了具体实现方案,其核心是通过将模型行为解释锚定于编程语言属性,来减轻虚假相关性的影响。为展示$do_{code}$的实际效用,我们通过两个主流深度学习架构及九个NCMs的案例研究,阐明了该框架能提供的洞见。案例研究结果表明:所研究的NCMs对代码语法变化敏感,且在统计上预测与代码块相关的标记(如括号、圆括号、分号)时,其混杂偏差相较于其他编程语言结构更小。这些发现揭示了$do_{code}$作为有效模型调试机制的潜力,可助力发现NCMs中的偏差与局限性。