Skip to main content
QUICK REVIEW

[论文解读] A Convolutional Attention Network for Extreme Summarization of Source Code

Miltiadis Allamanis, Hao Peng|arXiv (Cornell University)|Feb 9, 2016
Software Engineering Research参考文献 41被引用 323
一句话总结

本文提出一种带复制机制的卷积注意力网络,从 Java 代码片段生成简洁、类似方法名的摘要,在 10 个开源项目上优于标准注意力和 tf-idf 基线。

ABSTRACT

Attention mechanisms in neural networks have proved useful for problems in which the input and output do not have fixed dimension. Often there exist features that are locally translation invariant and would be valuable for directing the model's attention, but previous attentional architectures are not constructed to learn such features specifically. We introduce an attentional neural network that employs convolution on the input tokens to detect local time-invariant and long-range topical attention features in a context-dependent way. We apply this architecture to the problem of extreme summarization of source code snippets into short, descriptive function name-like summaries. Using those features, the model sequentially generates a summary by marginalizing over two attention mechanisms: one that predicts the next summary token based on the attention weights of the input tokens and another that is able to copy a code token as-is directly into the summary. We demonstrate our convolutional attention neural network's performance on 10 popular Java projects showing that it achieves better performance compared to previous attentional mechanisms.

研究动机与目标

  • Motivate extreme summarization of source code into short, descriptive method names.
  • Develop a convolutional attention architecture that detects translation-invariant and topical features in code.
  • Incorporate a copy mechanism to handle out-of-vocabulary tokens from input code.
  • Evaluate against strong baselines on real-world Java projects to demonstrate advantages in precision and OoV handling.

提出的方法

  • Introduce a convolutional attention network that uses input token convolutions to learn local and long-range features.
  • Compute attention features via convolutional layers fed by input subtokens and previous decoder state.
  • Use an attention weight vector to form a context representation and predict next summary subtokens.
  • Extend with a copy mechanism (meta-attention) to copy input tokens directly when beneficial.
  • Train with maximum likelihood and use a hybrid search (beam and BFS) to generate top-k summary candidates.
  • Evaluate against tf-idf and Bahdanau-style standard attention on per-project data with Bayesian hyperparameter optimization.

实验结果

研究问题

  • RQ1Can a convolutional attention mechanism effectively identify translation-invariant features in code to improve extreme code summarization?
  • RQ2Does adding a copy mechanism improve handling of out-of-vocabulary tokens and overall summary quality?
  • RQ3How does the proposed model compare to tf-idf and standard attention baselines across real Java projects?
  • RQ4What is the impact of architectural choices (attention features, meta-attention lambda) on exact-match and F1 performance?
  • RQ5Is code-specific extreme summarization more effective when models are trained per project rather than jointly across projects?

主要发现

  • Conv_attention and copy_attention outperform standard attention and tf-idf baselines in F1 and exact-match metrics across projects.
  • Copy mechanism provides higher F1 at rank 5 and improves exact-match recall by leveraging input tokens not seen in training.
  • Out-of-vocabulary subtokens are partly addressable via copying, with OoV accuracy averaging 4.4% overall (Rank 1) and 19.4% (Rank 5).
  • Copy_attention yields higher F1 at rank 1 (44.7) and rank 5 (59.6) than standard attention (43.6 and 57.7).
  • Standard Bahdanau-style attention underperforms tf-idf in this domain, highlighting the long input sequences and structured nature of code.
  • Topic and local feature detection via convolutional attention helps the model capture long-range cues beyond what a plain biRNN can learn.

更好的研究,从现在开始

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

无需绑定信用卡

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