Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contexts
By Rohan Bavishi, Michael Pradel, Koushik Sen. 2017
65 citations recorded by the source corpus.
Most of the JavaScript code deployed in the wild has been minified, a process in which identifier names are replaced with short, arbitrary and meaningless names. Minified code occupies less space, but also makes the code extremely difficult to manually inspect and understand. This paper presents Context2Name, a deep learningbased technique that partially reverses the effect of minification by predicting natural identifier names for minified names. The core idea is to predict from the usage context of a variable a name that captures the meaning of the variable. The approach combines a lightweight, token-based static analysis with an auto-encoder neural network that summarizes usage contexts and a recurrent neural network that predict natural names for a given usage context. We evaluate Context2Name with a large corpus of real-world JavaScript code and show that it successfully predicts 47.5% of all minified identifiers while taking only 2.9 milliseconds on average to predict a name. A comparison with the state-of-the-art tools JSNice and JSNaughty shows that our approach performs comparably in terms of accuracy while improving in terms of efficiency. Moreover, Context2Name complements the state-of-the-art by predicting 5.3% additional identifiers that are missed by both existing tools.
Subfields: Artificial Intelligence, Information Systems, Natural Language Processing
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Miltiadis Allamanis
- Charles Sutton
- Romain Robbes
- Hlib Babii
- Andrea Janes
- Rafael-Michael Karampatsis
- Earl T. Barr
- Premkumar T. Devanbu
In Information Systems
- Charles Sutton
- Miltiadis Allamanis
- Michael Pradel
- Rafael-Michael Karampatsis
- Earl T. Barr
- Romain Robbes
- Hlib Babii
- Andrea Janes
In Natural Language Processing
- Charles Sutton
- Michael Pradel
- Miltiadis Allamanis
- Premkumar T. Devanbu
- Rafael-Michael Karampatsis
- Earl T. Barr
- Baptiste Rozière
- Marie-Anne Lachaux
Citations in the corpus
- A Survey of Machine Learning for Big Code and Naturalness (2017, background): “nt challenge in this applicationdomainisthesparsityofthecodeconstructs,causedbythediverseandnon-repeatable form of source code within projects and domains. Allamanis et al. [5, 6, 10], Bavishi et al. [22] exploit thestatistical similarities of code’ssurface structure to learnand suggest variable, me”
- DOBF: A Deobfuscation Pre-Training Objective for Programming Languages (2021, methodology): “…deobfuscation of identifier names and identifier name proposal using n-grams (Allamanis et al., 2014; 2015), probabilistic models (Raychev et al., 2015; Bichsel et al., 2016; Vasilescu et al., 2017; Alon et al., 2018), and recurrent neural networks (Bavishi et al., 2018; Lacomis et al., 2019).”
- Big Code != Big Vocabulary: Open-Vocabulary Models for Source Code (2020, background): “code, such as models to suggest readable names [3], summarizing source code [5, 49], predicting bugs [70], detecting code clones [87], comment generation [47], and variable de-obfuscation [10].”
- NL2Type: Inferring JavaScript Function Types from Natural Language Information (2019, background): “Other approaches predict natural language information from source code, e.g., by predicting function name-like summaries for code snippets [48], or by de-obfuscating minified JavaScript code [15], [49], [50].”
- Maybe Deep Neural Networks are the Best Choice for Modeling Source Code (2019, methodology): “Therefore, we hope that this idea could have broad application throughout software engineering, such as in models to suggest readable function and class names [3], summarizing source code [5, 43], predicting bugs [60], detecting code clones [73], comment generation [42], fixing syntactic errors [47]”
- Anything to Hide? Studying Minified and Obfuscated Code in the Web (2019, background): “Techniques for purpose include learning-based approaches [3, 25] and semantics-preserving rewriting of the obfuscated code [16, 39].”
- Typilus: neural type hints (2020, methodology): “Machine learning models of code are also used to predict names of variables and functions [2, 3, 8, 9, 12], with applications to deobfuscation [51, 59] and decompilation [22, 30, 41].”
- Modeling Vocabulary for Big Code Machine Learning (2019, methodology): “Bavishi et al. [11] accomplish this using a deep learning-based technique.”