paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Improving automatic source code summarization via deep reinforcement learning

通过深度强化学习改进自动源代码摘要
ASE Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering2018匹配度 2/10 · 该论文关注代码摘要生成,使用AST与深度强化学习,属于机器学习与程序语言的交叉,但与用户核心方向(静态分析、Agentic程序、LLM辅助形式化验证、浮点/贝叶斯程序分析)没有直接关联,也未涉及LLM/Agent或工业落地。引用 413 inbox
Yao Wan, Zhou Zhao, Min Yang, Guandong Xu, Haochao Ying, Jian Wu, Philip S. Yu
crossref: 2026-09-12

AI 速览

一句话:将代码的AST结构与序列内容融入actor-critic强化学习框架,提升代码摘要生成质量。

代码摘要为代码功能提供高层自然语言描述,有助于软件维护、分类与检索。现有先进方法多采用编码器-解码器框架,但存在两个问题:编码器仅考虑代码的顺序内容,忽略对摘要任务同样关键的树结构;解码器训练时以真实前词预测下一词,而测试时需从头生成整个序列,这造成暴露偏差,使学习到的解码器次优。本文将代码片段的抽象语法树结构与序列内容结合,纳入深度强化学习框架(actor-critic网络)。actor网络根据当前状态给出预测下一词的置信度,critic网络评估当前状态所有可能扩展的奖励值,为探索提供全局指导。两个网络使用由BLEU指标组成的优势奖励进行训练。在真实世界数据集上的综合实验表明,该模型相比一些最先进方法更有效。

问题
现有代码摘要方法多采用编码器-解码器框架,仅利用代码顺序内容而忽略对摘要重要的树结构,且训练与测试目标不一致导致暴露偏差,使解码器次优。
方法
将代码的抽象语法树结构与序列内容结合,放入actor-critic深度强化学习框架;actor根据当前状态预测下一词置信度,critic评估所有可能扩展的奖励值以提供全局探索指导,并用包含BLEU的优势奖励训练两个网络。
评估
在真实世界数据集上与若干state-of-the-art方法进行综合实验,验证所提模型的有效性。
原文摘要(Abstract)

Code summarization provides a high level natural language description of the function performed by code, as it can benefit the software maintenance, code categorization and retrieval. To the best of our knowledge, most state-of-the-art approaches follow an encoder-decoder framework which encodes the code into a hidden space and then decode it into natural language space, suffering from two major drawbacks: a) Their encoders only consider the sequential content of code, ignoring the tree structure which is also critical for the task of code summarization; b) Their decoders are typically trained to predict the next word by maximizing the likelihood of next ground-truth word with previous ground-truth word given. However, it is expected to generate the entire sequence from scratch at test time. This discrepancy can cause an exposure bias issue, making the learnt decoder suboptimal. In this paper, we incorporate an abstract syntax tree structure as well as sequential content of code snippets into a deep reinforcement learning framework (i.e., actor-critic network). The actor network provides the confidence of predicting the next word according to current state. On the other hand, the critic network evaluates the reward value of all possible extensions of the current state and can provide global guidance for explorations. We employ an advantage reward composed of BLEU metric to train both networks. Comprehensive experiments on a real-world dataset show the effectiveness of our proposed model when compared with some state-of-the-art methods.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot4759,
  title = {Improving automatic source code summarization via deep reinforcement learning},
  author = {Yao Wan and Zhou Zhao and Min Yang and Guandong Xu and Haochao Ying and Jian Wu and Philip S. Yu},
  booktitle = {ASE},
  year = {2018},
  doi = {10.1145/3238147.3238206}
}