Skip to main content
QUICK REVIEW

[论文解读] Bridging Semantic Gaps between Natural Languages and APIs with Word Embedding

Xiaochen Li, He Jiang|arXiv (Cornell University)|Oct 23, 2018
Software Engineering Research参考文献 51被引用 4
一句话总结

本文提出 Word2API,一种通过在共享向量空间中联合建模词语和API来弥合自然语言查询与API之间语义鸿沟的方法,利用词嵌入技术实现。通过从GitHub源代码和注释中挖掘数百万个词-API对,并应用洗牌策略进行对齐,Word2API在相关性估计方面将准确率和NDCG提升了10%–49.6%,在查询扩展和API文档链接任务中优于基线方法。

ABSTRACT

Developers increasingly rely on text matching tools to analyze the relation between natural language words and APIs. However, semantic gaps, namely textual mismatches between words and APIs, negatively affect these tools. Previous studies have transformed words or APIs into low-dimensional vectors for matching; however, inaccurate results were obtained due to the failure of modeling words and APIs simultaneously. To resolve this problem, two main challenges are to be addressed: the acquisition of massive words and APIs for mining and the alignment of words and APIs for modeling. Therefore, this study proposes Word2API to effectively estimate relatedness of words and APIs. Word2API collects millions of commonly used words and APIs from code repositories to address the acquisition challenge. Then, a shuffling strategy is used to transform related words and APIs into tuples to address the alignment challenge. Using these tuples, Word2API models words and APIs simultaneously. Word2API outperforms baselines by 10%-49.6% of relatedness estimation in terms of precision and NDCG. Word2API is also effective on solving typical software tasks, e.g., query expansion and API documents linking. A simple system with Word2API-expanded queries recommends up to 21.4% more related APIs for developers. Meanwhile, Word2API improves comparison algorithms by 7.9%-17.4% in linking questions in Question&Answer communities to API documents.

研究动机与目标

  • 为解决自然语言查询与API之间的语义鸿沟问题,该问题阻碍了软件工程中有效的信息检索。
  • 克服现有方法仅孤立建模词语或API所带来的局限性,从而导致相关性估计不准确。
  • 开发一种可扩展的方法,从真实世界代码仓库中获取大规模、多样化的词-API对。
  • 实现更准确、更高效的软件工程任务,如查询扩展和API文档链接。
  • 在共享向量空间中同时建模词语和API,以提升语义相关性估计的准确性。

提出的方法

  • Word2API 从 GitHub 源代码和方法注释中收集数百万个词-API 对,以应对数据获取挑战。
  • 利用启发式规则从方法注释中提取词语,从源代码中提取API,以确保语义相关性。
  • 将来自同一方法的词语和API组合为词-API 元组,以保留上下文关系。
  • 对每个元组内的词语和API应用洗牌策略,随机重新排序,以生成多样化的训练样本并提升对齐效果。
  • Word2API 使用这些洗牌后的元组训练联合嵌入模型,学习低维向量以捕捉词语与API之间的语义相似性。
  • 模型采用带有负采样的跳字模型(与 Word2Vec 类似)来优化词-API 相关性的嵌入空间。

实验结果

研究问题

  • RQ1联合嵌入模型能否有效估计自然语言词语与API之间的语义相关性?
  • RQ2在多种评估指标下,Word2API 相较于现有方法在相关性估计方面表现如何?
  • RQ3Word2API 在代码搜索和API推荐任务中的查询扩展方面,能将相关API推荐提升多大程度?
  • RQ4Word2API 能否提升将软件问答社区中的问题链接到相关API文档的准确性?
  • RQ5洗牌策略在提升词-API 关系对齐与表征方面起到了何种作用?

主要发现

  • 与基线方法相比,Word2API 在准确率和 NDCG 上将相关性估计性能提升了 10% 至 49.6%。
  • 在查询扩展任务中,使用 Word2API 的系统相比基线系统可推荐多达 21.4% 更相关的API。
  • 在将 Stack Overflow 问题链接到相关API文档的任务中,Word2API 相较于现有比较算法提升了 7.9% 至 17.4% 的准确率。
  • 该模型在词-API 相关性估计以及下游软件工程任务中均表现出卓越性能。
  • 洗牌策略显著增强了词语与API之间的对齐效果,从而支持更优的语义关系联合建模。
  • Word2API 在包括代码搜索和API推荐在内的多样化编程任务中展现出强大的泛化能力。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

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