<p>Code-Comment Synchronization (CCS) aims to synchronize the comments with code changes in an automated fashion, thereby significantly reducing the workload of developers during software maintenance and evolution. While previous studies have proposed various solutions that have shown success, they often exhibit limitations, such as a lack of generalization ability or the need for extensive task-specific learning resources. This motivates us to investigate the potential of Large Language Models (LLMs) in this area. However, a pilot analysis proves that LLMs fall short of State-Of-The-Art (SOTA) CCS approaches because (1) they lack instructive demonstrations for In-Context Learning (ICL) and (2) many correct-prone candidates are not prioritized. To tackle the above challenges, we propose <Emphasis Type="Underline">R</Emphasis><InlineEquation ID="IEq2"> <EquationSource Format="TEX">\(^2\)</EquationSource> </InlineEquation><Emphasis Type="Underline">ComSync</Emphasis>, an ICL-based code-<Emphasis Type="Underline">Com</Emphasis>ment <Emphasis Type="Underline">Sync</Emphasis>hronization approach enhanced with <Emphasis Type="Underline">R</Emphasis>etrieval and <Emphasis Type="Underline">R</Emphasis>e-ranking. Specifically, R<InlineEquation ID="IEq3"> <EquationSource Format="TEX">\(^2\)</EquationSource> </InlineEquation>ComSync carries corresponding two novelties: (1) Ensemble hybrid retrieval. It equally considers the similarity in both code-comment semantics and change patterns when retrieval, thereby creating ICL prompts with effective examples. (2) Multi-turn re-ranking strategy. We derived three significant rules through large-scale CCS sample analysis. Given the inference results of LLMs, it progressively exploits three re-ranking rules to prioritize relatively correct-prone candidates. We evaluate R<InlineEquation ID="IEq4"> <EquationSource Format="TEX">\(^2\)</EquationSource> </InlineEquation>ComSync using five recent LLMs on three CCS datasets covering both Java and Python programming languages, and make comparisons with five SOTA approaches. Extensive experiments demonstrate the superior performance of R<InlineEquation ID="IEq5"> <EquationSource Format="TEX">\(^{2}\)</EquationSource> </InlineEquation>ComSync against other approaches. Moreover, both quantitative and qualitative analyses provide compelling evidence that the comments synchronized by our proposal exhibit significantly higher quality. </p>

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

R\(^2\)ComSync: improving code-comment synchronization with in-context learning and reranking

  • Zhen Yang,
  • Hongyi Lin,
  • Xiao Yu,
  • Jacky Wai Keung,
  • Shuo Liu,
  • Pak Yuen Patrick Chan,
  • Yicheng Sun,
  • Fengji Zhang

摘要

Code-Comment Synchronization (CCS) aims to synchronize the comments with code changes in an automated fashion, thereby significantly reducing the workload of developers during software maintenance and evolution. While previous studies have proposed various solutions that have shown success, they often exhibit limitations, such as a lack of generalization ability or the need for extensive task-specific learning resources. This motivates us to investigate the potential of Large Language Models (LLMs) in this area. However, a pilot analysis proves that LLMs fall short of State-Of-The-Art (SOTA) CCS approaches because (1) they lack instructive demonstrations for In-Context Learning (ICL) and (2) many correct-prone candidates are not prioritized. To tackle the above challenges, we propose R \(^2\) ComSync, an ICL-based code-Comment Synchronization approach enhanced with Retrieval and Re-ranking. Specifically, R \(^2\) ComSync carries corresponding two novelties: (1) Ensemble hybrid retrieval. It equally considers the similarity in both code-comment semantics and change patterns when retrieval, thereby creating ICL prompts with effective examples. (2) Multi-turn re-ranking strategy. We derived three significant rules through large-scale CCS sample analysis. Given the inference results of LLMs, it progressively exploits three re-ranking rules to prioritize relatively correct-prone candidates. We evaluate R \(^2\) ComSync using five recent LLMs on three CCS datasets covering both Java and Python programming languages, and make comparisons with five SOTA approaches. Extensive experiments demonstrate the superior performance of R \(^{2}\) ComSync against other approaches. Moreover, both quantitative and qualitative analyses provide compelling evidence that the comments synchronized by our proposal exhibit significantly higher quality.