SmartPaste: Learning to Adapt Source Code
Open accessAbstract
Deep Neural Networks have been shown to succeed at a range of natural language tasks such as machine translation and text summarization. While tasks on source code (ie, formal languages) have been considered recently, most work in this area does not attempt to capitalize on the unique opportunities offered by its known syntax and structure. In this work, we introduce SmartPaste, a first task that requires to use such information. The task is a variant of the program repair problem that requires to adapt a given (pasted) snippet of code to surrounding, existing source code. As first solutions, we design a set of deep neural models that learn to represent the context of each variable location and variable usage in a data flow-sensitive way. Our evaluation suggests that our models can learn to solve the SmartPaste task in many cases, achieving 58.6% accuracy, while learning meaningful representation of variable usages.
Integrity signals
Registry
Cites
Statistics
Claims the paper makes
Claims other papers make about this one
Each is checked against this paper’s own text: does it say what the citing paper says it does?
Code completion models are typically trained on data collected from existing codebases but then deployed more generally across other codebases, which may have different distributions of API usages.
“These models are typically trained on data collected from existing codebases but then deployed more generally across other codebases, which may have different distributions of API usages (Nita and Notkin, 2010; Proksch et al., 2016; Allamanis and Brockschmidt, 2017).”
From WILDS: A Benchmark of in-the-Wild Distribution Shifts (2020) · cites this paper as Allamanis and Brockschmidt, 2017
Distribution shifts across codebases require systems to adapt to factors such as project content, coding conventions, or library/API usage.
“One major challenge is the shifts across codebases (which our Py150-wilds dataset focuses on), where systems need to adapt to factors such as project content, coding conventions, or library or API usage in each codebase (Nita and Notkin, 2010; Allamanis and Brockschmidt, 2017).”
From WILDS: A Benchmark of in-the-Wild Distribution Shifts (2020) · cites this paper as Allamanis and Brockschmidt, 2017
As programming tools like code completion are expected to be used across codebases in real applications, it is important for models to learn generalizable representations of code and extrapolate well on unseen codebases.
“As programming tools like code completion are expected to be used across codebases in real applications (Nita and Notkin, 2010; Allamanis and Brockschmidt, 2017), it is important for models to learn generalizable representations of code and extrapolate well on unseen codebases.”
From WILDS: A Benchmark of in-the-Wild Distribution Shifts (2020) · cites this paper as Allamanis and Brockschmidt, 2017
Cites
Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks
Tai, K. S., Socher, R., & Manning, C. D. (2015) · Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 1: Long Papers) · doi:10.3115/v1/p15-1150 · Cited by 3,081 · see citing works
On the naturalness of software
Hindle, A., Barr, E. T., Su, Z., Gabel, M., & Dévanbu, P. (2012) · doi:10.5555/2337223.2337322 · Cited by 574 · see citing works
A Convolutional Attention Network for Extreme Summarization of Source CodePreprint
Allamanis, M., Peng, H. M., & Sutton, C. A. (2016) · arXiv (Cornell University) · doi:10.48550/arxiv.1602.03001 · Cited by 436 · see citing works
Self-citationLearning natural coding conventions
Allamanis, M., Barr, E. T., Bird, C., & Sutton, C. A. (2014) · ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE) · doi:10.1145/2635868.2635883 · Cited by 380 · see citing works
Self-citationSuggesting accurate method and class names
Allamanis, M., Barr, E. T., Bird, C., & Sutton, C. A. (2015) · ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE) · doi:10.1145/2786805.2786849 · Cited by 379 · see citing works
Self-citationImproving Coreference Resolution by Learning Entity-Level Distributed Representations
Clark, K., & Manning, C. D. (2016) · Annual Meeting of the Association for Computational Linguistics (ACL) · doi:10.18653/v1/p16-1061 · Cited by 327 · see citing works
Program synthesis by sketching
Bodík, R., & Solar-Lezama, A. (2008) · Cited by 319 · see citing works
Probabilistic model for code with decision trees
Raychev, V., Bielik, P., & Vechev, M. (2016) · Conference on Object-Oriented Programming Systems, Languages, and Applications · doi:10.1145/2983990.2984041 · Cited by 157 · see citing works
Automated software transplantation
Barr, E. T., Harman, M., Jia, Y., Marginean, A., & Petke, J. (2015) · International Symposium on Software Testing and Analysis · doi:10.1145/2771783.2771796 · Cited by 134 · see citing works
Structured Generative Models of Natural Source CodePreprint
Maddison, C. J., & Tarlow, D. (2014) · arXiv (Cornell University) · doi:10.48550/arxiv.1401.0514 · Cited by 129 · see citing works
PHOG: probabilistic model for code
Bielik, P., Raychev, V., & Vechev, M. (2016) · International Conference on Machine Learning · Cited by 115 · see citing works
A Study of Visual Studio Usage in Practice
Amann, S., Proksch, S., Nadi, S., & Mezini, M. (2016) · 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER) · doi:10.1109/saner.2016.39 · Cited by 77 · see citing works
Detecting and characterizing semantic inconsistencies in ported code
Ray, B., Kim, M., Person, S., & Rungta, N. (2013) · IEEE/ACM International Conference on Automated Software Engineering (ASE) · doi:10.1109/ase.2013.6693095 · Cited by 66 · see citing works
Learning Python Code Suggestion with a Sparse Pointer NetworkPreprint
Bhoopchand, A., Rocktäschel, T., Barr, E. T., & Riedel, S. (2016) · arXiv (Cornell University) · doi:10.48550/arxiv.1611.08307 · Cited by 60 · see citing works
Flagged first, then by citations
2 of the 16 references couldn’t be matched to a known paper.
Cited by
Sorted by citations
DeepBugs: a learning approach to name-based bug detection
Pradel, M., & Sen, K. (2018) · Proceedings of the ACM on Programming Languages · doi:10.1145/3276517 · Cited by 352 · see citing works
WILDS: A Benchmark of in-the-Wild Distribution Shifts
Koh, P. W., Sagawa, S., Marklund, H., Xie, S. M., Zhang, M., Balsubramani, A., Hu, W., Yasunaga, M., Phillips, R. L., Gao, I., et al. (2020) · arXiv · doi:10.48550/arxiv.2012.07421 · Cited by 518 · see citing works
“One major challenge is the shifts across code bases, where systems need to adapt to the project content, coding convention, and library or API usage, etc. in each code base (Nita and Notkin, 2010; Allamanis and Brockschmidt, 2017).”
A Survey of Machine Learning for Big Code and Naturalness
Allamanis, M., Barr, E. T., Devanbu, P., & Sutton, C. (2019) · ACM Computing Surveys · doi:10.1145/3212695 · Cited by 150 · see citing works
Self-citationContext2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage ContextsPreprint
Bavishi, R., Pradel, M., & Sen, K. (2018) · arXiv (Cornell University) · doi:10.48550/arxiv.1809.05193 · Cited by 42 · see citing works
Deep Learning for Code Intelligence: Survey, Benchmark and Toolkit
Wan, Y., Bi, Z., He, Y., Zhang, J., Zhang, H., Sui, Y., Xu, G., Jin, H., & Yu, P. S. (2024) · ACM Computing Surveys · doi:10.1145/3664597 · Cited by 34 · see citing works
Pradel, M., & Sen, K. (2017) · TUbilio (Technical University of Darmstadt) · Cited by 24 · see citing works
SnapCode - A Snapshot Based Approach to Code Stylometry
Sarnot, S. A. P., Rinke, S., Raimalwalla, R., Joshi, R. B., Khengare, R., & Goel, P. (2019) · doi:10.1109/icit48102.2019.00066 · Cited by 4 · see citing works
AdaptivePaste: Intelligent Copy-Paste in IDE
Liu, X., Jang, J., Sundaresan, N., Allamanis, M., & Svyatkovskiy, A. (2023) · ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE) · doi:10.1145/3611643.3613895 · Cited by 7 · see citing works
Self-citationAssessing the Effectiveness of Syntactic Structure to Learn Code Edit RepresentationsPreprint
Qureshi, S. A., Mehta, S., Bhagwan, R., & Kumar, R. (2021) · arXiv (Cornell University) · doi:10.48550/arxiv.2106.06110 · Cited by 2 · see citing works
Defining behaviorizeable relations to enable inference in semi-automatic program synthesis
Krasanakis, E., & Symeonidis, A. L. (2021) · Journal of Logical and Algebraic Methods in Programming · doi:10.1016/j.jlamp.2021.100714 · Cited by 1 · see citing works
Harnessing Syntactic Feature for Code Representation LearningPreprint
Clevor, B., Patel, R., & Slyder, W. (2023) · Preprints.org · doi:10.20944/preprints202312.1463.v1 · Cited by 1 · see citing works
- Authors
- Allamanis, M., & Brockschmidt, M.
- Venue
- arXiv
- Publisher
- arXiv
- Published
- 2017
- ISSN
- 2331-8422 (ISSN-L)
- arXiv
- 1705.07867
- OpenAlex
- W2616956063
- Cited by
- 13
- References
- 16
- Citations by year
- 2024: 1 · 2023: 2 · 2021: 3 · 2020: 1 · 2019: 2 · 2018: 3 · 2017: 1
- Type
- posted content
- Language
- en
- Open access
- green
- arxiv.org
- Locations
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Topics
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
- Physical Sciences › Computer Science › Computer Science Applications › Teaching and Learning Programming
- Keywords
- program adaptation, program repair, data flow analysis
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review