We present a new approach for predicting program properties from large codebases (aka "Big Code"). Our approach learns a probabilistic model from "Big Code" and uses this model to predict properties of new, unseen programs. The key idea of our work is to transform the program into a representation that allows us to formulate the problem of inferring program properties as structured prediction in machine learning. This enables us to leverage powerful probabilistic models such as Conditional Random Fields (CRFs) and perform joint prediction of program properties. As an example of our approach, we built a scalable prediction engine called JSNICE for solving two kinds of tasks in the context of JavaScript: predicting (syntactic) names of identifiers and predicting (semantic) type annotations of variables. Experimentally, JSNICE predicts correct names for 63% of name identifiers and its type annotation predictions are correct in 81% of cases. Since its public release at http://jsnice.org, JSNice has become a popular system with hundreds of thousands of uses. By formulating the problem of inferring program properties as structured prediction, our work opens up the possibility for a range of new "Big Code" applications such as de-obfuscators, decompilers, invariant generators, and others.
[1]
Miguel Á. Carreira-Perpiñán,et al.
Multiscale conditional random fields for image labeling
,
2004,
Proceedings of the 2004 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2004. CVPR 2004..
[2]
Nir Friedman,et al.
Probabilistic Graphical Models - Principles and Techniques
,
2009
.
[3]
Veselin Raychev,et al.
Learning from Large Codebases
,
2016
.
[4]
Petar Tsankov,et al.
Statistical Deobfuscation of Android Applications
,
2016,
CCS.
[5]
Eran Yahav,et al.
Programming with "Big Code"
,
2015,
Found. Trends Program. Lang..
[6]
Trevor Darrell,et al.
Conditional Random Fields for Object Recognition
,
2004,
NIPS.
[7]
Peter Thiemann,et al.
Type Analysis for JavaScript
,
2009,
SAS.
[8]
Martin T. Vechev,et al.
PHOG: Probabilistic Model for Code
,
2016,
ICML.
[9]
J. Andrew Bagnell,et al.
(Approximate) Subgradient Methods for Structured Prediction
,
2007,
International Conference on Artificial Intelligence and Statistics.
[10]
Andrew McCallum,et al.
Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence Data
,
2001,
ICML.