Skip to main content
QUICK REVIEW

[论文解读] Automatic Code Summarization via ChatGPT: How Far Are We?

Weisong Sun, Chunrong Fang|arXiv (Cornell University)|May 22, 2023
Software Engineering ResearchComputer Science被引用 34
一句话总结

本文评估 ChatGPT 在 CSN-Python 上用于自动代码摘要的能力,并将其与 SOTA 模型(NCS、CodeBERT、CodeT5)进行比较;ChatGPT 在 BLEU 和 ROUGE-L 上表现落后,但在 METEOR 上与 CodeT5 相当。

ABSTRACT

To support software developers in understanding and maintaining programs, various automatic code summarization techniques have been proposed to generate a concise natural language comment for a given code snippet. Recently, the emergence of large language models (LLMs) has led to a great boost in the performance of natural language processing tasks. Among them, ChatGPT is the most popular one which has attracted wide attention from the software engineering community. However, it still remains unclear how ChatGPT performs in (automatic) code summarization. Therefore, in this paper, we focus on evaluating ChatGPT on a widely-used Python dataset called CSN-Python and comparing it with several state-of-the-art (SOTA) code summarization models. Specifically, we first explore an appropriate prompt to guide ChatGPT to generate in-distribution comments. Then, we use such a prompt to ask ChatGPT to generate comments for all code snippets in the CSN-Python test set. We adopt three widely-used metrics (including BLEU, METEOR, and ROUGE-L) to measure the quality of the comments generated by ChatGPT and SOTA models (including NCS, CodeBERT, and CodeT5). The experimental results show that in terms of BLEU and ROUGE-L, ChatGPT's code summarization performance is significantly worse than all three SOTA models. We also present some cases and discuss the advantages and disadvantages of ChatGPT in code summarization. Based on the findings, we outline several open challenges and opportunities in ChatGPT-based code summarization.

研究动机与目标

  • 评估 ChatGPT 在自动代码摘要方面的能力。
  • 识别有效的提示以引导 ChatGPT 生成分布内注释。
  • 在 CSN-Python 上将 ChatGPT 与最先进的代码摘要模型进行基准比较。
  • 分析定性案例并讨论基于 ChatGPT 的代码摘要中的挑战与机遇。

提出的方法

  • 设计启发式问题以获取 ChatGPT 的反馈并撰写提示。
  • 使用提示为 CSN-Python 测试集生成分布内的一句注释。
  • 用 BLEU、METEOR 和 ROUGE-L 将生成的注释与真实摘要进行比较评估。
  • 将 ChatGPT 的结果与 NCS、CodeBERT 及 CodeT5 的基线进行比较。
  • 进行案例研究,分析 ChatGPT 在代码摘要中的优点与局限。

实验结果

研究问题

  • RQ1Can ChatGPT perform code summarization tasks effectively on CSN-Python?
  • RQ2What prompts yield concise, in-distribution comments from ChatGPT?
  • RQ3How does ChatGPT compare to SOTA code summarization models on standard metrics?
  • RQ4What are the strengths and limitations of ChatGPT in code summarization tasks?

主要发现

  • ChatGPT (one sentence prompt) achieves BLEU 10.28, METEOR 14.40, ROUGE-L 20.81 on CSN-Python.
  • CodeT5 outperforms ChatGPT across BLEU (20.0), METEOR (14.7), and ROUGE-L (37.7).
  • CodeBERT outperforms ChatGPT on BLEU (18.7 vs 10.28) and ROUGE-L (34.8 vs 20.81).
  • NCS shows BLEU 15.8, METEOR 10.6, ROUGE-L 31.3, all below CodeT5 but above ChatGPT in BLEU/ROUGE-L.
  • METEOR shows ChatGPT comparable to CodeT5, and better than NCS/CodeBERT.
  • Prompt design studies indicate that a short, one-sentence prompt yields the best overall quantitative performance among tested ChatGPT configurations.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。