Optimizing Knowledge Utilization for Multi-Intent Comment Generation with Large Language Models
Shuochuan LiZan Wang
Xiaoning DuZhuo WuJiuqiao Yu
Junjie Chen Shuochuan Li
Zan Wang

Xiaoning Du
Zhuo Wu
Jiuqiao Yu

Junjie Chen
+6
Existing LLM-based multi-intent code comment generation fails to build correct relationships among intents, code, and comments, especially with few demonstrations. KUMIC, a framework built on in-context learning, addresses this by using Chain-of-Thought (CoT) to optimize knowledge utilization. It first retrieves similar examples with high code-comment consistency, then uses CoT to guide LLMs to focus on statements that help derive intent-specific comments, constructing a mapping from code to intent-specific statements to comments. KUMIC outperforms baselines by 14.49%–22.41% in BLEU, METEOR, ROUGE-L, and SBERT.

arXiv ·
· October 29, 2025