paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Generating Variable Explanations via Zero-shot Prompt Learning

基于零样本提示学习生成变量解释
ASE 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)2023匹配度 3/10 · 该论文用代码预训练模型和零样本提示学习为变量生成自然语言解释,属于 LLM 辅助程序理解/开发者工具,与“PL→AI”或“AI→PL”的静态分析、形式化验证、Agentic 程序等核心方向只有较弱的交集。它不涉及静态分析、浮点程序分析或贝叶斯程序分析,也并非用 LLM 改进分析/验证工具。引用 13 inbox
Chong Wang, Yiling Lou, Junwei Liu, Xin Peng
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 ZeroVar,用代码预训练模型和零样本提示学习为变量生成自然语言解释,并在自动/人工指标及变量命名任务上优于基线。

低质量变量名使变量含义难以理解,故需为变量生成简洁自然语言解释以辅助程序理解。该任务面临训练数据不足和变量上下文复杂两大挑战。本文提出 ZeroVar,利用代码预训练模型与零样本提示学习从代码上下文生成解释。方法分两阶段:先持续预训练 CodeT5 以恢复方法文档字符串中被随机掩码的参数描述;再基于变量及其所属方法上下文构造提示,进行零样本提示学习。在 773 个变量数据集上,ZeroVar 在 BLEU、ROUGE 等自动指标及正确性、完整性、简洁性等人工指标上优于基线,并提升缩写扩展与拼写纠错两项下游任务,如拼写纠错 hit@1 提升 162.9%。

问题
低质量变量名普遍存在,变量含义难以理解;如何为变量生成简洁自然语言解释以辅助程序理解,并应对训练数据不足与代码上下文复杂的问题。
方法
提出 ZeroVar,两阶段:持续预训练 CodeT5 以恢复方法 docstring 中随机掩码的参数描述;再用变量及所属方法上下文构造提示,进行零样本提示学习生成解释。
评估
构建 773 个变量及参考解释数据集,用 BLEU/ROUGE 与人工正确性、完整性、简洁性对比基线,并在缩写扩展和拼写纠错下游任务中验证解释的实用性。
原文摘要(Abstract)

As basic elements in program, variables convey essential information that is critical for program comprehension and maintenance. However, understanding the meanings of variables in program is not always easy for developers, since poor-quality variable names are prevalent while such variable are less informative for program comprehension. Therefore, in this paper, we target at generating concise natural language explanations for variables to facilitate program comprehension. In particular, there are two challenges in variable explanation generation, including the lack of training data and the association with complex code contexts around the variable. To address these issues, we propose a novel approach ZeroVar,which leverages code pre-trained models and zero-shot prompt learning to generate explanations for the variable based on its code context. ZeroVarcontains two stages: (i) a pre-training stage that continually pre-trains a base model (i.e., CodeT5) to recover the randomly-masked parameter descriptions in method docstrings; and (ii) a zero-shot prompt learning stage that leverages the pre-trained model to generate explanations for a given variable via the prompt constructed with the variable and its belonging method context. We then extensively evaluate the quality and usefulness of the variable explanations generated by ZeroVar.We construct an evaluation dataset of 773 variables and their reference explanations. Our results show that ZeroVarcan generate higher-quality explanations than baselines, not only on automated metrics such as BLEU and ROUGE, but also on human metrics such as correctness, completeness, and conciseness. Moreover, we further assess the usefulness of ZeroVAR-generated explanations on two downstream tasks related to variable naming quality, i.e., abbreviation expansion and spelling correction. For abbreviation expansion, the generated variable explanations can help improve the present rate (+13.1%), precision (+3.6%), and recall (+10.0%) of the state-of-the-art abbreviation explanation approach. For spelling correction, by using the generated explanations we can achieve higher hit@1 (+162.9(%) and hit@3 (+49.6%) than the recent variable representation learning approach.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{WangLLP23,
  title = {Generating Variable Explanations via Zero-shot Prompt Learning},
  author = {Chong Wang and Yiling Lou and Junwei Liu and Xin Peng},
  booktitle = {ASE},
  year = {2023},
  doi = {10.1109/ase56229.2023.00130}
}