arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.08220cs.SEcs.LG
收藏

FRANC:一个用于高质量代码生成的轻量级框架

FRANC: A Lightweight Framework for High-Quality Code Generation

University of Notre Dame(圣母大学)

Mohammed Latif Siddiq, Beatrice Casey, Joanna C. S. Santos

AI总结:

本文提出FRANC,一个轻量级代码生成框架,通过静态过滤器、质量感知排序器和提示工程提升代码安全性与质量,无需重训模型,在多语言和多个数据集上验证了其有效性。

摘要:

近年来,利用基于Transformer的生成模型自动生成源代码的应用不断扩展,这些模型能够根据开发者的需求生成功能性代码。然而,最近的研究表明,这些自动生成的源代码可能包含漏洞和其他质量问题。尽管研究人员和从业者试图增强代码生成模型,但重新训练和微调大型语言模型既耗时又耗费资源。因此,我们描述了FRANC,一个用于推荐源自基于Transformer的代码生成模型的更安全、更高质量源代码的轻量级框架。FRANC包含一个静态过滤器,通过启发式方法使生成的代码可编译,以及一个质量感知排序器,根据质量分数对代码片段进行排序。此外,该框架使用提示工程来修复持续的质量问题。我们使用五个Python和Java代码生成模型以及六个提示数据集(包括本研究中新创建的一个数据集SOEval)对该框架进行了评估。静态过滤器在可编译性方面改进了9%至46%的Java建议和10%至43%的Python建议。排序系统在NDCG@10分数上的平均改进为0.0763,修复技术修复了最高80%的提示。FRANC处理Java平均耗时1.98秒;处理Python耗时0.08秒。

英文摘要:

In recent years, the use of automated source code generation utilizing transformer-based generative models has expanded, and these models can generate functional code according to the requirements of the developers. However, recent research revealed that these automatically generated source codes can contain vulnerabilities and other quality issues. Despite researchers' and practitioners' attempts to enhance code generation models, retraining and fine-tuning large language models is time-consuming and resource-intensive. Thus, we describe FRANC, a lightweight framework for recommending more secure and high-quality source code derived from transformer-based code generation models. FRANC includes a static filter to make the generated code compilable with heuristics and a quality-aware ranker to sort the code snippets based on a quality score. Moreover, the framework uses prompt engineering to fix persistent quality issues. We evaluated the framework with five Python and Java code generation models and six prompt datasets, including a newly created one in this work (SOEval). The static filter improves 9% to 46% Java suggestions and 10% to 43% Python suggestions regarding compilability. The average improvement over the NDCG@10 score for the ranking system is 0.0763, and the repairing techniques repair the highest 80% of prompts. FRANC takes, on average, 1.98 seconds for Java; for Python, it takes 0.08 seconds.

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

↑