Latest Findings · ASI Lab

R2ComSync harnesses LLMs to automatically keep code comments in sync

An in-context-learning approach that retrieves the right demonstrations and re-ranks candidates — lifting Accuracy by up to 694% over state-of-the-art baselines.

Zhen Yang, Hongyi Lin, Xiao Yu, Jacky W. Keung, Shuo Liu, Pak Yuen Patrick Chan, Yicheng Sun, Fengji Zhang
Agentic Software Intelligence Research Lab · Department of Computer Science, City University of Hong Kong
Empirical Software Engineering · 2026

R2ComSync is a Large Language Model (LLM) framework for Code-Comment Synchronization (CCS): automatically rewriting an outdated comment when its code changes. A pilot study showed vanilla LLMs fall short of state-of-the-art CCS methods. R2ComSync closes two gaps: Ensemble Hybrid Retrieval (EHR), which mixes code-comment semantic similarity with code-change-pattern similarity to build instructive in-context examples, and a Multi-turn Re-ranking (MR) strategy that prioritizes the most correct-prone candidates.

R2ComSync: improving code-comment synchronization with in-context learning and reranking
Fig. 7. Performance of R2ComSync on Small Models.

Why it matters

Code-Comment Synchronization aims to synchronize comments with code changes in an automated fashion, reducing developer workload during software maintenance; prior approaches lack generalization or need extensive resources, motivating an LLM-based solution.

Key findings

R2ComSync

What it means for practitioners

R2ComSync is a zero-training LLM pipeline for keeping comments in sync with code changes. Re-tune its published thresholds (σ=0.35; ϵ=0.25 on Liu's, 0.55 on Panth's, 0.2 on Pai's) per dataset; weight expert-based change-pattern retrieval more on short, high-variability samples and CodeBERT semantic retrieval on longer ones; pick the shot number per model/dataset since performance peaks then declines. Cost is acceptable — most models finish a synchronization in under a second with zero training cost.

Get the paper & cite it

Download full PDF ↓ View at DOI

Official citation: Zhen Yang, Hongyi Lin, Xiao Yu, Jacky W. Keung, Shuo Liu, Pak Yuen Patrick Chan, Yicheng Sun, Fengji Zhang (2026). R2ComSync: improving code-comment synchronization with in-context learning and reranking. Empirical Software Engineering. DOI: 10.1007/s10664-025-10800-4.

Code-comment synchronization Large language models In-context learning Re-ranking Software maintenance Retrieval