Deep API learning
By Xiaodong Gu, Hongyu Zhang, Dongmei Zhang, Sunghun Kim. 2016
579 citations recorded by the source corpus.
Developers often wonder how to implement a certain functionality (e.g., how to parse XML files) using APIs. Obtaining an API usage sequence based on an API-related natural language query is very helpful in this regard. Given a query, existing approaches utilize information retrieval models to search for matching API sequences. These approaches treat queries and APIs as bags-of-words and lack a deep understanding of the semantics of the query. We propose DeepAPI, a deep learning based approach to generate API usage sequences for a given natural language query. Instead of a bag-of-words assumption, it learns the sequence of words in a query and the sequence of associated APIs. DeepAPI adapts a neural language model named RNN Encoder-Decoder. It encodes a word sequence (user query) into a fixed-length context vector, and generates an API sequence based on the context vector. We also augment the RNN Encoder-Decoder by considering the importance of individual APIs. We empirically evaluate our approach with more than 7 million annotated code snippets collected from GitHub. The results show that our approach generates largely accurate API sequences and outperforms the related approaches.
Subfields: Artificial Intelligence, Information Systems
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
- Graham Neubig
- Luke S. Zettlemoyer
- Mohit Bansal
- Xi Victoria Lin
- Hongyu Zhang
- Michael Pradel
- Percy Liang
- Jianfeng Gao
In Information Systems
- Michael Pradel
- Koushik Sen
- Charles Sutton
- Hongyu Zhang
- Miltiadis Allamanis
- Michele Tufano
- Ge Li
- Denys Poshyvanyk
Citations in the corpus
- CodeSearchNet Challenge: Evaluating the State of Semantic Code Search (2019, neutral): “[11, 12], Yao et al.”
- IntelliCode compose: code generation using transformer (2020, background): “Some of the early applications of machine learning of source code include code search [1, 2], bug detection and localization [3], program synthesis [4], code summarization [5] and code completion [6–10].”
- An Empirical Study on Learning Bug-Fixing Patches in the Wild via Neural Machine Translation (2018, background): “Some examples of recent models that can be used in a number of software engineering tasks include: code completion [67, 91], defect prediction [84], bug localization [39], clone detection [80, 90], code search [23], learning Application Programming Interface (API) sequences [24], recommending method”
- DeepBugs: a learning approach to name-based bug detection (2018, background): “Deep neural networks also help recommend API usages [Gu et al. 2016], detect code clones [White et al. 2016], classify programs into pre-defined categories [Mou et al. 2016], and adapt copied-and-pasted code to its surrounding code [Allamanis and Brockschmidt 2017].”
- JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generation (2019, methodology): “The first task is more relaxed and aims to assist users by generating a sequence of all function calls (Gu et al., 2016b) needed to achieve the goal of the cell.”
- Big Code != Big Vocabulary: Open-Vocabulary Models for Source Code (2020, background): “Gu et al. [37] generate API usage sequences for a given natu-ral language query.”
- End-to-End Deep Learning of Optimization Heuristics (2017, background): “These include mining coding conventions [15] and idioms [14], API example code [53] and pseudo-code generation [54], and benchmark generation [8].”
- Learning a classifier for false positive error reports emitted by static code analysis tools (2017, methodology): “…there have been many studies using statistical language models for handling important software development and maintenance tasks (Nguyen et al. 2013; Tu et al. 2014; Raychev et al. 2014, 2015; Allamanis et al. 2015, 2016; Fowkes and Sutton 2016; Gu et al. 2016; White et al. 2016; Dam et al. 2016).”
- Retrieval-based Neural Source Code Summarization (2020, methodology): “The comment of JCSD is the first sentence extracted from its Javadoc, which is similar to the practice in [17].”
- Synthesizing benchmarks for predictive modeling (2017, methodology): “Previous studies have involved data mining of GitHub to analyze software engineering practices [49–52], for example code generation [53], code summarization [54], comment generation [55], and code completion [56].”
- Deep Code Search (2018, methodology): “API Sequence Extraction: We extract an API sequence from each Java method using the same procedures as described in Deep-API [27] – parsing the AST using the Eclipse JDT compiler [2] and traversing the AST.”
- Incorporating External Knowledge through Pre-training for Natural Language to Code Generation (2020, background): “It is also the case that human developers rarely reference such paired examples of NL and code, and rather take external resources on the web and modify them into the desired form (Brandt et al., 2009, 2010; Gu et al., 2016).”
- Bayesian specification learning for finding API usage errors (2017, methodology): “DeepAPI [26] uses a neural encoder-decoder to learn correlations between natural language annotations and API sequences.”
- Deep Code Comment Generation (2018, methodology): “[12] use BLEU to evaluate the accuracy of generated API sequences from natural language queries.”
- On Learning Meaningful Code Changes Via Neural Machine Translation (2019, background): “…the goal of (semi)automating several non-trivial tasks, including code completion [65], generation of commit messages [47], method names [27], code comments [66], defect prediction [63], bug localization [49] and fixing [62], clone detection [64], code search [40], and learning API templates [41].”
- Neural Code Comprehension: A Learnable Representation of Code Semantics (2018, methodology): “Code Representation Previous research focuses on embedding high-level programming languages such as Java [20, 30], C [41], or OpenCL [18] in the form of tokens or statements, as well as lower level representations such as object code [41].”
- On Learning Meaningful Assert Statements for Unit Test Cases (2020, methodology): “We use the BLEU-4 variant, meaning that the BLEU score is computed by considering the 4-grams in the generated text, as previously done in other software-related tasks in the literature [11, 14].”
- Pre-trained Contextual Embedding of Source Code (2019, background): “, 2015), API-sequence prediction (Gu et al., 2016), program repair (Pu et al.”