Demystifying What Code Summarization Models Learned
Not on the map. Why?
Abstract (arXiv)
Study patterns that models have learned has long been a focus of pattern recognition research. Explaining what patterns are discovered from training data, and how patterns are generalized to unseen data are instrumental to understanding and advancing the pattern recognition methods. Unfortunately, the vast majority of the application domains deal with continuous data (i.e. statistical in nature) out of which extracted patterns can not be formally defined. For example, in image classification, there does not exist a principle definition for a label of cat or dog. Even in natural language, the meaning of a word can vary with the context it is surrounded by. Unlike the aforementioned data format, programs are a unique data structure with a well-defined syntax and semantics, which creates a golden opportunity to formalize what models have learned from source code. This paper presents the first formal definition of patterns discovered by code summarization models (i.e. models that predict the name of a method given its body), and gives a sound algorithm to infer a context-free grammar (CFG) that formally describes the learned patterns. We realize our approach in PATIC which produces CFGs for summarizing the patterns discovered by code summarization models. In particular, we pick two prominent instances, code2vec and code2seq, to evaluate PATIC. PATIC shows that the patterns extracted by each model are heavily restricted to local, and syntactic code structures with little to none semantic implication. Based on these findings, we present two example uses of the formal definition of patterns: a new method for evaluating the robustness and a new technique for improving the accuracy of code summarization models. Our work opens up this exciting, new direction of studying what models have learned from source code.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 17 of its 36 references that are in the map. First posted on arXiv 4 Mar 2023.
Builds on
17 of 36 references.
References · 17
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2014Explaining and Harnessing Adversarial Examplescited by 7,287
- 2013Intriguing properties of neural networkscited by 5,114
- 2014Neural Machine Translation by Jointly Learning to Align and Translatecited by 4,530
- 2014Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translationcited by 4,016
- 2016Towards Evaluating the Robustness of Neural Networkscited by 2,976
- 2013Visualizing and Understanding Convolutional Networkscited by 2,278
- 2019Cross-lingual Language Model Pretrainingcited by 1,088
- 2018Certified Defenses against Adversarial Examplescited by 305
- 2018code2vec: Learning Distributed Representations of Codecited by 249
- 2019Fixing the train-test resolution discrepancycited by 209
5 more
- 2018Formal Security Analysis of Neural Networks using Symbolic Intervalscited by 185
- 2018code2seq: Generating Sequences from Structured Representations of Codecited by 177
- 2018Structured Neural Summarizationcited by 53
- 2019On the Units of GANs (Extended Abstract)cited by 19
- 2019COSET: A Benchmark for Evaluating Neural Program Embeddingscited by 10
Built on by
Not cited yet.