【论文阅读】A Transformer-based Approach for Source Code Summarization

发表于 ACL 2020
地址:https://arxiv.org/pdf/2005.00653.pdf
代码:https://github.com/wasiahmad/NeuralCodeSum

一、简介

利用transformer模型来进行代码摘要生成,通过对代码token之间的成对关系建模以捕获其长期依赖来学习代码表示。实验部分和其他一些baselines作了对比,验证了模型达到了最优性能。并通过实验证明了,使用相对位置表示对源代码token之间的成对关系进行建模,相对于使用绝对位置表示的学习代码token的序列信息,可以实现重大改进。并在transformer中整合了复制注意力机制,其能够从源代码复制稀有标记(如:函数名称,变量名称),从而显著提高摘要性能。

二、方法

整体基于transformer方法,但除了transformer里的自注意力机制,还整合了复制注意力机制,并使用相对位置表示对源代码token之间的成对关系进行建模。

  • 复制注意力:文章在Transformer中整合了copying mechanism复制机制,以允许既根据词汇生成单词又根据输入源代码进行复制。使用额外的注意力层来学习解码器堆栈顶部的复制分布。Copy Attention使Transformer能够从源代码复制稀有标记(例如,函数名称,变量名称),从而显著提高摘要性能。
  • Encoding pairwise relationship:代码的语义表示不依赖于其token的绝对位置。相反,它们之间的相互影响会影响源代码的含义。例如,表达式a + b a + ba+b和b + a b + ab+a的语义相同。为了对输入元素之间的成对关系进行编码,将自我注意机制进行了扩展:(第j个token位于第i个token的左侧还是右侧的信息将被忽略)(位置编码部分还没有看的很明白)

在这里插入图片描述

数据预处理:论文将CamelCase和snake_case形式的源代码token拆分为相应的sub-tokens(CamelCase和snake_case token化显著减少了词汇量。例如,Java源代码中唯一token的数量从292,626减少到66,650)。证明了这样的代码token拆分可以提高摘要性能。

评价指标:BLEU、METEOR、ROUGE-L

三、实验

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Visual segmentation is one of the most important tasks in computer vision, which involves dividing an image into multiple segments, each of which corresponds to a different object or region of interest in the image. In recent years, transformer-based methods have emerged as a promising approach for visual segmentation, leveraging the self-attention mechanism to capture long-range dependencies in the image. This survey paper provides a comprehensive overview of transformer-based visual segmentation methods, covering their underlying principles, architecture, training strategies, and applications. The paper starts by introducing the basic concepts of visual segmentation and transformer-based models, followed by a discussion of the key challenges and opportunities in applying transformers to visual segmentation. The paper then reviews the state-of-the-art transformer-based segmentation methods, including both fully transformer-based approaches and hybrid approaches that combine transformers with other techniques such as convolutional neural networks (CNNs). For each method, the paper provides a detailed description of its architecture and training strategy, as well as its performance on benchmark datasets. Finally, the paper concludes with a discussion of the future directions of transformer-based visual segmentation, including potential improvements in model design, training methods, and applications. Overall, this survey paper provides a valuable resource for researchers and practitioners interested in the field of transformer-based visual segmentation.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值