arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2308.07429cs.SEcs.AI
收藏

用于神经源代码摘要的语义相似度损失

Semantic Similarity Loss for Neural Source Code Summarization

University of Notre Dame(圣母大学)

Chia-Yi Su, Collin McMillan

AI总结:

本文针对神经代码摘要中 CCE 逐词优化且不认可同义词的问题,提出整句语义相似度损失并与 CCE 结合,实验表明其在多数条件下优于基线。

摘要:

本文介绍了一种将语义相似度指标用作神经源代码摘要损失函数的流程及其评估。代码摘要任务是指为源代码编写自然语言描述。神经代码摘要指利用神经网络自动生成这些描述的技术。目前几乎所有方法都将神经网络作为独立模型,或作为预训练大语言模型(例如 GPT、Codex、LLaMA)的一部分,但它们几乎也都使用类别交叉熵(CCE)损失函数进行网络优化。CCE 存在两个问题:1)它逐词计算每次单词预测的损失,而不是评估整个句子;2)它要求完美预测,同义词无法获得部分分数。本文扩展了我们此前关于语义相似度指标的工作,展示了将语义相似度用作损失函数以缓解该问题的流程,并在多种设置下通过指标驱动研究和人工研究评估了这一流程。本质上,我们提出使用语义相似度指标,在每个训练批次上针对整个输出句子预测计算损失,而不仅计算每个词的损失。我们还提出将该损失与逐词 CCE 相结合,从而相比基线简化训练过程。我们在多个基线上评估了所提方法,并报告其在绝大多数条件下均取得改进。

英文摘要:

This paper presents a procedure for and evaluation of using a semantic similarity metric as a loss function for neural source code summarization. Code summarization is the task of writing natural language descriptions of source code. Neural code summarization refers to automated techniques for generating these descriptions using neural networks. Almost all current approaches involve neural networks as either standalone models or as part of a pretrained large language models e.g., GPT, Codex, LLaMA. Yet almost all also use a categorical cross-entropy (CCE) loss function for network optimization. Two problems with CCE are that 1) it computes loss over each word prediction one-at-a-time, rather than evaluating a whole sentence, and 2) it requires a perfect prediction, leaving no room for partial credit for synonyms. In this paper, we extend our previous work on semantic similarity metrics to show a procedure for using semantic similarity as a loss function to alleviate this problem, and we evaluate this procedure in several settings in both metrics-driven and human studies. In essence, we propose to use a semantic similarity metric to calculate loss over the whole output sentence prediction per training batch, rather than just loss for each word. We also propose to combine our loss with CCE for each word, which streamlines the training process compared to baselines. We evaluate our approach over several baselines and report improvement in the vast majority of conditions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑