---
title: "Learning to Represent Programs with Graphs — Allamanis 2017"
description: "VarMisuse was proposed by the authors themselves: the model has… 32.9% accuracy on VarNaming. 30 references, cited by 81 papers here."
authors: ["Miltiadis Allamanis", "Marc Brockschmidt", "Mahmoud Khademi"]
year: 2017
venue: "arXiv:1711.00740"
source: "https://arxiv.org/abs/1711.00740"
doi: "10.48550/arxiv.1711.00740"
arxiv: "1711.00740"
licence: "arXiv — non-exclusive licence to distribute"
licence_url: "http://arxiv.org/licenses/nonexclusive-distrib/1.0/"
summary_licence: "Elamur Cosmic License"
canonical: "https://research.elamur.ai/free/en/papers/allamanis-2017-learning-represent-programs-graphs/"
---
[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/allamanis-2017-learning-represent-programs-graphs/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2017](https://md.research.elamur.ai/free/en/papers/2017/page/3/) / Learning to Represent Programs with Graphs

# Learning to Represent Programs with Graphs

**Authors:** [Miltiadis Allamanis](https://md.research.elamur.ai/free/en/authors/miltiadis-allamanis/), [Marc Brockschmidt](https://md.research.elamur.ai/free/en/authors/marc-brockschmidt/) and [Mahmoud Khademi](https://md.research.elamur.ai/free/en/authors/mahmoud-khademi/) · **Year:** 2017 · **Venue:** arXiv:1711.00740 · **Licence:** [arXiv — non-exclusive licence to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

**Links:** [Publisher's page](https://arxiv.org/abs/1711.00740) · [PDF](https://arxiv.org/pdf/1711.00740) · [DOI 10.48550/arxiv.1711.00740](https://doi.org/10.48550/arxiv.1711.00740) · [arXiv 1711.00740](https://arxiv.org/abs/1711.00740) · [OpenAlex](https://openalex.org/W2765574772)

**Citations:** 46 citations (OpenAlex, 2026-10-14) · [81](https://md.research.elamur.ai/free/en/papers/allamanis-2017-learning-represent-programs-graphs/cited-by/) in our library, of the 149,439 papers whose bibliographies we read

## Summary

The authors argue that most neural networks for code analysis treat code like ordinary text, either as a sequence of tokens or as a syntax tree. As a result, they miss relationships that the compiler knows for certain, such as where a variable was last written or read. In this paper, a program is converted into a graph. The graph's backbone is the abstract syntax tree (AST). The authors add edges for token order and data flow, as well as links between call arguments and the names of formal parameters. Gated Graph Neural Networks (GGNN) are trained on these graphs, and the authors show how to scale this training to large graphs. The approach was evaluated on two tasks. In VarNaming, the model has to recover a variable's name from how the variable is used. VarMisuse was proposed by the authors themselves: the model has to choose which of the available variables is correct at a given location in the code. The corpus consists of open-source C# projects. The graph model outperformed simpler approaches that use less structured representations of code. It also found real bugs in mature projects, which means such models can complement classical static analysis.

## Key points

- **Data:** 29 open-source C# repositories with about 2.9 million lines of code in total (among them RavenDB, Roslyn-like libraries, Newtonsoft.Json, EntityFramework, Lean). Some projects were held out for testing only, to check how the model performs on unfamiliar codebases.
- **Program graph:** Child edges (AST structure) and NextToken edges (token order), as well as the semantic edges LastUse, LastWrite and ComputedFrom, which describe data flow.
- **Results of the best model:** 32.9% accuracy on VarNaming and 85.5% on VarMisuse. On the published version of the dataset, which excludes GPL projects, VarMisuse reaches 84.0% accuracy (PR AUC 0.976) on projects already seen and 74.1% (PR AUC 0.934) on new ones.
- **Practical value:** in RavenDB, the model found a place where the variable `clazz` had been used by mistake instead of `first`. The authors reported the bug, and it was fixed in PR 4138.
- **Resources:** a sample GGNN implementation is on GitHub (`Microsoft/gated-graph-neural-network-samples`), and the dataset is at https://aka.ms/iclr18-prog-graphs-dataset.

*Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.*

## Institutions

- [Microsoft](https://md.research.elamur.ai/free/en/companies/microsoft/) — Company, Redmond, United States · 378 works · 161,630 citations

📚 Shelves (4): [🖥️ Computer Science](https://md.research.elamur.ai/free/en/shelves/computer-science/) · 18,614 works · [🗄️ Information Systems](https://md.research.elamur.ai/free/en/shelves/computer-science/information-systems/) · 1,730 works · [💻 Software](https://md.research.elamur.ai/free/en/shelves/computer-science/software/) · 119 works · [🖥️ Computer Science Applications](https://md.research.elamur.ai/free/en/shelves/computer-science/computer-science-applications/) · 131 works

## Cite

Cite as: Miltiadis Allamanis, Marc Brockschmidt and Mahmoud Khademi. 2017. Learning to Represent Programs with Graphs. arXiv:1711.00740.

The paper itself, not this page. BibTeX from the library's record of the work.

```bibtex
@misc{allamanis2017learning,
  title = {{Learning to Represent Programs with Graphs}},
  author = {Miltiadis Allamanis, Marc Brockschmidt and Mahmoud Khademi},
  year = {2017},
  doi = {10.48550/arxiv.1711.00740},
  eprint = {1711.00740},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1711.00740}
}
```

- [← previous FOIL it! Find One mismatch between Image and Language caption](https://md.research.elamur.ai/free/en/papers/shekhar-2017-foil-it-find-one-mismatch/)
- [next → Arabic Language Sentiment Analysis on Health Services](https://md.research.elamur.ai/free/en/papers/alayba-2017-arabic-language-sentiment-analysis-health/)
- [↑ back to papers of 2017](https://md.research.elamur.ai/free/en/papers/2017/page/3/)

## References

30 references, 10 of them with a card of ours. ↗ leads to the work, «find» searches for one we have no id for yet.

1. Martín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, et al. [Tensorflow: Large-scale machine learning on heterogeneous distributed systems](https://md.research.elamur.ai/free/en/papers/abadi-2016-tensorflow-large-scale-machine-learning/). arXiv preprint arXiv:1603.04467, 2016.
2. Miltiadis Allamanis, Earl T Barr, Christian Bird, and Charles Sutton. Learning natural coding conventions. In Foundations of Software Engineering (FSE), 2014. [find](https://scholar.google.com/scholar?q=Miltiadis+Allamanis%2C+Earl+T+Barr%2C+Christian+Bird%2C+and+Charles+Sutton%2E+Learning+natural+coding+conventions%2E+In+Foundations+of+Software+Engineering+%28FSE%29%2C+2014%2E)
3. Miltiadis Allamanis, Earl T Barr, Christian Bird, and Charles Sutton. Suggesting accurate method and class names. In Foundations of Software Engineering (FSE), 2015. [find](https://scholar.google.com/scholar?q=Miltiadis+Allamanis%2C+Earl+T+Barr%2C+Christian+Bird%2C+and+Charles+Sutton%2E+Suggesting+accurate+method+and+class+names%2E+In+Foundations+of+Software+Engineering+%28FSE%29%2C+2015%2E)
4. Miltiadis Allamanis, Hao Peng, and Charles Sutton. [A convolutional attention network for extreme summarization of source code](https://md.research.elamur.ai/free/en/papers/allamanis-2016-convolutional-attention-network-extreme-summarization/). In International Conference on Machine Learning (ICML), pp. 2091–2100, 2016.
5. Miltiadis Allamanis, Earl T Barr, Premkumar Devanbu, and Charles Sutton. [A survey of machine learning for big code and naturalness](https://md.research.elamur.ai/free/en/papers/allamanis-2017-survey-machine-learning-big-code/). arXiv preprint arXiv:1709.06182, 2017.
6. Earl T Barr, Mark Harman, Yue Jia, Alexandru Marginean, and Justyna Petke. Automated software transplantation. In International Symposium on Software Testing and Analysis (ISSTA), 2015. [find](https://scholar.google.com/scholar?q=Earl+T+Barr%2C+Mark+Harman%2C+Yue+Jia%2C+Alexandru+Marginean%2C+and+Justyna+Petke%2E+Automated+software+transplantation%2E+In+International+Symposium+on+Software+Testing+and+Analysis+%28ISSTA%29%2C+2015%2E)
7. Al Bessey, Ken Block, Ben Chelf, Andy Chou, Bryan Fulton, Seth Hallem, Charles Henri-Gros, Asya Kamsky, Scott McPeak, and Dawson Engler. A few billion lines of code later: using static analysis to find bugs in the real world. Communications of the ACM, 53(2):66–75, 2010. [find](https://scholar.google.com/scholar?q=Al+Bessey%2C+Ken+Block%2C+Ben+Chelf%2C+Andy+Chou%2C+Bryan+Fulton%2C+Seth+Hallem%2C+Charles+Henri%2DGros%2C+Asya+Kamsky%2C+Scott+McPeak%2C+and+Dawson+Engler%2E+A+few+billion+lines+of+code+later%3A+using+static+analysis+to+fin)
8. Avishkar Bhoopchand, Tim Rocktäschel, Earl Barr, and Sebastian Riedel. Learning Python code suggestion with a sparse pointer network. arXiv preprint arXiv:1611.08307, 2016. [find](https://scholar.google.com/scholar?q=Avishkar+Bhoopchand%2C+Tim+Rockt%C3%A4schel%2C+Earl+Barr%2C+and+Sebastian+Riedel%2E+Learning+Python+code+suggestion+with+a+sparse+pointer+network%2E+arXiv+preprint+arXiv%3A1611%2E08307%2C+2016%2E)
9. Benjamin Bichsel, Veselin Raychev, Petar Tsankov, and Martin Vechev. Statistical deobfuscation of android applications. In Conference on Computer and Communications Security (CCS), 2016. [find](https://scholar.google.com/scholar?q=Benjamin+Bichsel%2C+Veselin+Raychev%2C+Petar+Tsankov%2C+and+Martin+Vechev%2E+Statistical+deobfuscation+of+android+applications%2E+In+Conference+on+Computer+and+Communications+Security+%28CCS%29%2C+2016%2E)
10. Pavol Bielik, Veselin Raychev, and Martin Vechev. PHOG: probabilistic model for code. In International Conference on Machine Learning (ICML), 2016. [find](https://scholar.google.com/scholar?q=Pavol+Bielik%2C+Veselin+Raychev%2C+and+Martin+Vechev%2E+PHOG%3A+probabilistic+model+for+code%2E+In+International+Conference+on+Machine+Learning+%28ICML%29%2C+2016%2E)
11. Kyunghyun Cho, Bart van Merriënboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties of neural machine translation: Encoder–decoder approaches. Syntax, Semantics and Structure in Statistical Translation, 2014. — [On the Properties of Neural Machine Translation: Encoder-Decoder Approaches](https://md.research.elamur.ai/free/en/papers/cho-2014-properties-neural-machine-translation-encoder/)
12. Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. [Convolutional neural networks on graphs with fast localized spectral filtering](https://md.research.elamur.ai/free/en/papers/defferrard-2016-convolutional-neural-networks-graphs-fast/). In Neural Information Processing Systems (NIPS), pp. 3844–3852, 2016.
13. Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. [Neural message passing for quantum chemistry](https://md.research.elamur.ai/free/en/papers/gilmer-2017-neural-message-passing-quantum-chemistry/). arXiv preprint arXiv:1704.01212, 2017.
14. Marco Gori, Gabriele Monfardini, and Franco Scarselli. A new model for learning in graph domains. In IEEE International Joint Conference Neural Networks (IJCNN). IEEE, 2005. [find](https://scholar.google.com/scholar?q=Marco+Gori%2C+Gabriele+Monfardini%2C+and+Franco+Scarselli%2E+A+new+model+for+learning+in+graph+domains%2E+In+IEEE+International+Joint+Conference+Neural+Networks+%28IJCNN%29%2E+IEEE%2C+2005%2E)
15. Aditya Grover and Jure Leskovec. node2vec: Scalable feature learning for networks. In International Conference on Knowledge Discovery and Data Mining (SIGKDD), pp. 855–864. ACM, 2016. [find](https://scholar.google.com/scholar?q=Aditya+Grover+and+Jure+Leskovec%2E+node2vec%3A+Scalable+feature+learning+for+networks%2E+In+International+Conference+on+Knowledge+Discovery+and+Data+Mining+%28SIGKDD%29%2C+pp%2E+855%E2%80%93864%2E+ACM%2C+2016%2E)
16. Abram Hindle, Earl T Barr, Zhendong Su, Mark Gabel, and Premkumar Devanbu. On the naturalness of software. In International Conference on Software Engineering (ICSE), 2012. [find](https://scholar.google.com/scholar?q=Abram+Hindle%2C+Earl+T+Barr%2C+Zhendong+Su%2C+Mark+Gabel%2C+and+Premkumar+Devanbu%2E+On+the+naturalness+of+software%2E+In+International+Conference+on+Software+Engineering+%28ICSE%29%2C+2012%2E)
17. Thomas N Kipf and Max Welling. [Semi-supervised classification with graph convolutional networks](https://md.research.elamur.ai/free/en/papers/kipf-2016-semi-supervised-classification-graph-convolutional/). arXiv preprint arXiv:1609.02907, 2016.
18. Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. In International Conference on Learning Representations (ICLR), 2015. [find](https://scholar.google.com/scholar?q=Yujia+Li%2C+Daniel+Tarlow%2C+Marc+Brockschmidt%2C+and+Richard+Zemel%2E+Gated+graph+sequence+neural+networks%2E+In+International+Conference+on+Learning+Representations+%28ICLR%29%2C+2015%2E)
19. Chris J Maddison and Daniel Tarlow. Structured generative models of natural source code. In International Conference on Machine Learning (ICML), 2014. [find](https://scholar.google.com/scholar?q=Chris+J+Maddison+and+Daniel+Tarlow%2E+Structured+generative+models+of+natural+source+code%2E+In+International+Conference+on+Machine+Learning+%28ICML%29%2C+2014%2E)
20. Diego Marcheggiani and Ivan Titov. [Encoding sentences with graph convolutional networks for semantic role labeling](https://md.research.elamur.ai/free/en/papers/marcheggiani-2017-encoding-sentences-graph-convolutional-networks/). In ACL, 2017.
21. Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. [Distributed representations of words and phrases and their compositionality](https://md.research.elamur.ai/free/en/papers/mikolov-2013-distributed-representations-words-phrases-their/). In Neural Information Processing Systems (NIPS), 2013.
22. Jeffrey Pennington, Richard Socher, and Christopher D Manning. [GloVe: Global vectors for word representation](https://md.research.elamur.ai/free/en/papers/pennington-2014-glove-global-vectors-word-representation/). In EMNLP, 2014.
23. Veselin Raychev, Martin Vechev, and Eran Yahav. Code completion with statistical language models. In Programming Languages Design and Implementation (PLDI), pp. 419–428, 2014. [find](https://scholar.google.com/scholar?q=Veselin+Raychev%2C+Martin+Vechev%2C+and+Eran+Yahav%2E+Code+completion+with+statistical+language+models%2E+In+Programming+Languages+Design+and+Implementation+%28PLDI%29%2C+pp%2E+419%E2%80%93428%2C+2014%2E)
24. Veselin Raychev, Martin Vechev, and Andreas Krause. Predicting program properties from Big Code. In Principles of Programming Languages (POPL), 2015. [find](https://scholar.google.com/scholar?q=Veselin+Raychev%2C+Martin+Vechev%2C+and+Andreas+Krause%2E+Predicting+program+properties+from+Big+Code%2E+In+Principles+of+Programming+Languages+%28POPL%29%2C+2015%2E)
25. Veselin Raychev, Pavol Bielik, and Martin Vechev. Probabilistic model for code with decision trees. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 2016. [find](https://scholar.google.com/scholar?q=Veselin+Raychev%2C+Pavol+Bielik%2C+and+Martin+Vechev%2E+Probabilistic+model+for+code+with+decision+trees%2E+In+Object%2DOriented+Programming%2C+Systems%2C+Languages%2C+and+Applications+%28OOPSLA%29%2C+2016%2E)
26. Andrew Rice, Edward Aftandilian, Ciera Jaspan, Emily Johnston, Michael Pradel, and Yulissa Arroyo-Paredes. Detecting argument selection defects. Proceedings of the ACM on Programming Languages, 1(OOPSLA):104, 2017. [find](https://scholar.google.com/scholar?q=Andrew+Rice%2C+Edward+Aftandilian%2C+Ciera+Jaspan%2C+Emily+Johnston%2C+Michael+Pradel%2C+and+Yulissa+Arroyo%2DParedes%2E+Detecting+argument+selection+defects%2E+Proceedings+of+the+ACM+on+Programming+Languages%2C+1%28OOPS)
27. Michael Schlichtkrull, Thomas N. Kipf, Peter Bloem, Rianne van den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional network. arXiv preprint arXiv:1703.06103, 2017. [find](https://scholar.google.com/scholar?q=Michael+Schlichtkrull%2C+Thomas+N%2E+Kipf%2C+Peter+Bloem%2C+Rianne+van+den+Berg%2C+Ivan+Titov%2C+and+Max+Welling%2E+Modeling+relational+data+with+graph+convolutional+network%2E+arXiv+preprint+arXiv%3A1703%2E06103%2C+2017%2E)
28. Armando Solar-Lezama. Program synthesis by sketching. University of California, Berkeley, 2008. [find](https://scholar.google.com/scholar?q=Armando+Solar%2DLezama%2E+Program+synthesis+by+sketching%2E+University+of+California%2C+Berkeley%2C+2008%2E)
29. Mingzhe Wang, Yihe Tang, Jian Wang, and Jia Deng. Premise selection for theorem proving by deep graph embedding. In Advances in Neural Information Processing Systems, pp. 2783–2793, 2017. 1.0 0.9 0.8 0.7 0.6 0.5 0.0 [find](https://scholar.google.com/scholar?q=Mingzhe+Wang%2C+Yihe+Tang%2C+Jian+Wang%2C+and+Jia+Deng%2E+Premise+selection+for+theorem+proving+by+deep+graph+embedding%2E+In+Advances+in+Neural+Information+Processing+Systems%2C+pp%2E+2783%E2%80%932793%2C+2017%2E+1%2E0+0%2E9+0%2E8+)
30. True Positive Rate SeenProjTest UnseenProjTest 0.2 0.4 0.6 0.8 False Positive Rate (a) Precision-Recall Curve Figure 6: Precision-Recall and ROC curves for the GGNN model on V AR M ISUSE . Note that the y axis starts from 50%. Table 3: Performance of GGNN model on V AR M ISUSE per number of type-cor… [find](https://scholar.google.com/scholar?q=True+Positive+Rate+SeenProjTest+UnseenProjTest+0%2E2+0%2E4+0%2E6+0%2E8+False+Positive+Rate+%28a%29+Precision%2DRecall+Curve+Figure+6%3A+Precision%2DRecall+and+ROC+curves+for+the+GGNN+model+on+V+AR+M+ISUSE+%2E+Note+that+t)

*Updated 2 November 2026*
