arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2502.08172cs.SE
收藏

意图即所需:从意图中优化你的代码

Intention is All You Need: Refining Your Code from Your Intention

Qi Guo, Xiaofei Xie, Shangqing Liu, Ming Hu, Xiaohong Li, Lei Bu

AI总结:

针对代码优化中传统迭代交流繁琐、现有深度学习技术难理解评审意图的问题,提出基于意图的两阶段技术(意图提取+意图引导生成),实验显示其意图提取准确率79%、代码生成准确率最高66%,可提升数据质量与优化效率。

摘要:

代码优化旨在通过解决问题、重构和优化现有代码来提升质量并满足特定需求。随着软件项目规模和复杂度的扩大,评审者与开发者之间的传统迭代交流变得日益繁琐。尽管近年来深度学习技术被探索用于加速该过程,但其性能仍受限制,主要因难以准确理解评审者意图。本文提出一种基于意图的代码优化技术,通过从评审意见中显式提取意图来增强传统的“意见转代码”流程。该方法包含两个关键阶段:意图提取和意图引导的修订生成。意图提取使用预定义模板对意见分类,意图引导的修订生成则利用大型语言模型(LLMs)基于这些定义的意图生成修订代码。我们设计了含8个子类别的3个意见转换类别,随后采用结合规则和LLM分类器的混合方法实现准确分类。对5个LLM(GPT4o、GPT3.5、DeepSeekV2、DeepSeek7B、CodeQwen7B)在不同提示设置下的大量实验表明,该方法的意图提取准确率达79%,代码优化生成准确率最高达66%。结果凸显了该方法在提升数据质量和代码优化效率方面的潜力。

英文摘要:

Code refinement aims to enhance existing code by addressing issues, refactoring, and optimizing to improve quality and meet specific requirements. As software projects scale in size and complexity, the traditional iterative exchange between reviewers and developers becomes increasingly burdensome. While recent deep learning techniques have been explored to accelerate this process, their performance remains limited, primarily due to challenges in accurately understanding reviewers' intents. This paper proposes an intention-based code refinement technique that enhances the conventional comment-to-code process by explicitly extracting reviewer intentions from the comments. Our approach consists of two key phases: Intention Extraction and Intention Guided Revision Generation. Intention Extraction categorizes comments using predefined templates, while Intention Guided Revision Generation employs large language models (LLMs) to generate revised code based on these defined intentions. Three categories with eight subcategories are designed for comment transformation, which is followed by a hybrid approach that combines rule-based and LLM-based classifiers for accurate classification. Extensive experiments with five LLMs (GPT4o, GPT3.5, DeepSeekV2, DeepSeek7B, CodeQwen7B) under different prompting settings demonstrate that our approach achieves 79% accuracy in intention extraction and up to 66% in code refinement generation. Our results highlight the potential of our approach in enhancing data quality and improving the efficiency of code refinement.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑