[Paper Review] Automatic Code Summarization via ChatGPT: How Far Are We?
The paper evaluates ChatGPT for automatic code summarization on CSN-Python and compares it to SOTA models (NCS, CodeBERT, CodeT5); ChatGPT underperforms on BLEU and ROUGE-L but shows comparable METEOR to CodeT5.
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.
Motivation & Objective
- Assess ChatGPT’s capability in automatic code summarization.
- Identify effective prompts to guide ChatGPT for in-distribution comments.
- Benchmark ChatGPT against state-of-the-art code summarization models on CSN-Python.
- Analyze qualitative cases and discuss challenges/opportunities in ChatGPT-based code summarization.
Proposed method
- Design heuristic questions to elicit ChatGPT feedback and craft prompts.
- Use a prompt to generate in-distribution one-sentence comments for CSN-Python test set.
- Evaluate generated comments with BLEU, METEOR, and ROUGE-L against ground-truth summaries.
- Compare ChatGPT results with NCS, CodeBERT, and CodeT5 baselines.
- Perform case studies to analyze strengths and weaknesses of ChatGPT in code summarization.
Experimental results
Research questions
- 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?
Key findings
- 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.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.