Lune

ASE2021Top-tier venue

EditSum: A Retrieve-and-Edit Framework for Source Code Summarization

Jia Li, Yongmin Li, Ge Li, Xing Hu, Xin Xia, Zhi Jin

Abstract

Existing studies show that code summaries help developers understand and maintain source code. Unfortunately, these summaries are often missing or outdated in software projects. Code summarization aims to generate natural language descriptions automatically for source code. According to Gros et al., code summaries are highly structured and have repetitive patterns (e.g. "return true if..."). Besides the patternized words, a code summary also contains important keywords, which are the key to reflecting the functionality of the code. However, the state-of-the-art approaches perform poorly on predicting the keywords, which leads to the generated summaries suffer a loss in informativeness. To alleviate this problem, this paper proposes a novel retrieve-and-edit approach named EditSum for code summarization. Specifically, EditSum first retrieves a similar code snippet from a pre-defined corpus and treats its summary as a prototype summary to learn the pattern. Then, EditSum edits the prototype automatically to combine the pattern in the prototype with the semantic information of input code. Our motivation is that the retrieved prototype provides a good start-point for post-generation because the summaries of similar code snippets often have the same pattern. The post-editing process further reuses the patternized words in prototype and generates keywords based on the semantic information of input code. We conduct experiments on a large-scale Java corpus (2M) and experimental results demonstrate that EditSum outperforms the state-of-the-art approaches by a substantial margin. The human evaluation also proves the summaries generated by EditSum are more informative and useful. We also verify that EditSum performs well on predicting the patternized words and keywords.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

18 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Are we building on the rock? on the importance of data preprocessing for code summarization cites Retrieve and Refine: Exemplar-based Neural Comment Generation
  • Are we building on the rock? on the importance of data preprocessing for code summarization cites Code to Comment "Translation": Data, Metrics, Baselining & Evaluation
  • Are we building on the rock? on the importance of data preprocessing for code summarization cites Retrieval-based neural source code summarization
  • ReACC: A Retrieval-Augmented Code Completion Framework cites Retrieve and Refine: Exemplar-based Neural Comment Generation
  • Code to Comment "Translation": Data, Metrics, Baselining & Evaluation cites Retrieval-based neural source code summarization
  • RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program Repair cites ReACC: A Retrieval-Augmented Code Completion Framework
  • Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learning cites Retrieve and Refine: Exemplar-based Neural Comment Generation
  • Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learning cites Retrieval-based neural source code summarization
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers18

  1. ReACC: A Retrieval-Augmented Code Completion FrameworkShuai Lu, Nan Duan, Hojae Han, Daya Guo et al.ACL 2022 · 208 citations
  2. Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context LearningMingyang Geng, Shangwen Wang, Dezun Dong, Haotian Wang et al.ICSE 2024 · 124 citations
  3. RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program RepairWeishi Wang, Yue Wang, Shafiq Joty, Steven C. H. HoiFSE 2023 · 84 citations
  4. CoditT5: Pretraining for Source Code and Natural Language EditingJiyang Zhang, Sheena Panthaplackel, Pengyu Nie, Junyi Jessy Li et al.ASE 2022 · 81 citations
  5. Are we building on the rock? on the importance of data preprocessing for code summarizationLin Shi, Fangwen Mu, Xiao Chen, Song Wang et al.FSE 2022 · 65 citations

Builds on3

  1. Retrieval-based neural source code summarizationJian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun et al.ICSE 2020 · 242 citations
  2. Retrieve and Refine: Exemplar-based Neural Comment GenerationBolin Wei, Yongmin Li, Ge Li, Xin Xia et al.ASE 2020 · 68 citations
  3. Code to Comment "Translation": Data, Metrics, Baselining & EvaluationDavid Gros, Hariharan Sezhiyan, Prem Devanbu, Zhou YuASE 2020 · 43 citations

Related papers

  1. Retrieval Augmented Code Generation and SummarizationMd. Rizwan Parvez, Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray et al.EMNLP Findings 2021 · 141 citations
  2. Retrieval-Augmented Generation for Code Summarization via Hybrid GNNShangqing Liu, Yu Chen, Xiaofei Xie, Jing Kai Siow et al.ICLR 2021 · 194 citations
  3. From Draft to Precision: Iterative Agentic Framework for Intent-Aware Code SummarizationYifei Ge, Chunrong Fang, Zhenyu Chen, Juan ZhaiISSTA 2026
  4. Evaluating Code Summarization Techniques: A New Metric and an Empirical CharacterizationAntonio Mastropaolo, Matteo Ciniselli, Massimiliano Di Penta, Gabriele BavotaICSE 2024 · 28 citations
  5. Modeling Hierarchical Syntax Structure with Triplet Position for Source Code SummarizationJuncai Guo, Jin Liu, Yao Wan, Li Li et al.ACL 2022
Dusk over the sea between two cliffs drawn in fine vertical lines