Context-Focused Prompt Tuning Pre-Trained Code Models to Improve Code Summarization

Xinglu Pan,Chenxiao Liu,Yanzhen Zou,Xianlin Zhao,Bing Xie
DOI: https://doi.org/10.1109/compsac61105.2024.00177
2024-01-01
Abstract:Existing code summarization approaches overlook developers' discriminative context focuses when generating code comments. This paper proposes a context-focused code sum-marization approach based on the prompt tuning technique. It enables the pre-trained code models to identify specific context focuses around a method and to generate the method's comment with corresponding contextual information, which improves the accuracy and informativeness of the generated comments. As the first attempt, we design prompt templates for six common types of contexts, construct a context-focused code-comment dataset, and prompt-tune two pre-trained code models with the dataset to generate code comments. The experimental results demonstrate that our approach significantly improves the existing models to generate context-focused comments. Compared with existing approaches, our generated comments are more informative, and our models can adapt to different code contexts, making the generation process more interpretable. We discuss the envisioned application of our approach and challenges for future work to tackle, including identifying more essential code contexts automatically, constructing more effective prompts, etc.
What problem does this paper attempt to address?