Skip to main content
QUICK REVIEW

[论文解读] Deep API Learning

Xiaodong Gu, Hongyu Zhang|arXiv (Cornell University)|May 27, 2016
Software Engineering Research参考文献 42被引用 35
一句话总结

DeepAPI 提出一种基于深度学习的方法,采用 RNN 编码器-解码器模型,从自然语言查询生成准确的 API 使用序列,超越关键词匹配,通过捕捉语义含义实现。在 700 万个 GitHub 代码片段上评估,通过上下文建模查询和 API 序列,其序列准确率优于现有的基于信息检索的方法。

ABSTRACT

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 bag-of-words (i.e., keyword matching or word-to-word alignment) 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 bags-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.

研究动机与目标

  • 解决现有 API 推荐系统依赖词袋模型、缺乏对用户查询语义理解的局限性。
  • 通过建模自然语言查询和对应 API 调用的序列结构,生成语义准确的 API 使用序列。
  • 通过深度学习提升真实编程场景中 API 推荐的精确度和相关性。
  • 在生成过程中引入单个 API 的重要性,提升序列质量。

提出的方法

  • 将基于 RNN 的编码器-解码器架构适配为将自然语言查询映射为固定长度的上下文向量。
  • 使用循环编码器网络将输入查询的词序列编码为上下文向量。
  • 利用带有编码表示注意力机制的解码器 RNN,从上下文向量逐步生成 API 序列。
  • 在序列生成过程中引入机制,对单个 API 的重要性进行加权。
  • 在 GitHub 上 700 万个带注释的代码片段上端到端训练模型,学习查询到 API 的映射关系。
  • 采用带注意力机制的序列到序列学习,提升查询语义与 API 序列之间的对齐效果。

实验结果

研究问题

  • RQ1深度学习模型能否在生成准确的 API 使用序列方面优于基于关键词匹配的信息检索模型?
  • RQ2建模查询和 API 的序列结构在多大程度上提升了推荐质量?
  • RQ3在生成过程中引入 API 重要性在多大程度上增强了生成序列的相关性?
  • RQ4该模型在多样化编程任务和 API 领域上的泛化能力如何?

主要发现

  • DeepAPI 在生成准确的 API 使用序列方面显著优于现有的基于信息检索的方法。
  • 通过捕捉超越关键词匹配的语义含义,模型在推荐正确 API 序列方面实现了更高的精确率和召回率。
  • 在生成过程中引入 API 重要性显著提升了推荐序列的质量和相关性。
  • 带有注意力机制的 RNN 编码器-解码器框架能够有效实现从自然语言查询到 API 代码的序列到序列映射。
  • 在 700 万个 GitHub 代码片段上的实证评估证实了该模型的鲁棒性和可扩展性。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。