Helping LLMs improve code generation using feedback from testing and static analysis

作者
Greta Dolcetti,Vincenzo Arceri,Eleonora Iotti,Sergio Maffeis,Agostino Cortesi,Enea Zaffanella A
出处
期刊:Discover Artificial Intelligence [Springer Nature]
卷期号:6 (1) 被引量:21
标识
DOI:10.1007/s44163-026-01009-5
摘要

Large Language Models (LLMs) are one of the most promising developments in the field of artificial intelligence, and the software engineering community has readily noticed their potential role in the software development life-cycle. Developers routinely ask LLMs to generate code snippets, increasing productivity but also potentially introducing ownership, privacy, correctness, and security issues. Previous work highlighted how code generated by mainstream commercial LLMs is often not safe, containing vulnerabilities, bugs, and code smells. In this paper, we present a framework that leverages testing and static analysis to assess the quality, and guide the self-improvement, of code generated by general-purpose, open-source LLMs. First, we ask LLMs to generate C code to solve a number of programming tasks. Then we employ ground-truth tests to assess the (in)correctness of the generated code, and a static analysis tool to detect potential safety vulnerabilities. Next, we assess the models ability to evaluate the generated code, by asking them to detect errors and vulnerabilities. Finally, we test the models ability to fix the generated code, providing the reports produced during the static analysis and incorrectness evaluation phases as feedback. Our results show that models often produce incorrect code, and that the generated code can include safety issues. Moreover, they perform very poorly at detecting either issue. On the positive side, we observe a substantial ability to fix flawed code when provided with information about failed tests or potential vulnerabilities, indicating a promising avenue for improving the safety of LLM-based code generation tools.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
刘刘刘完成签到 ,获得积分10
1秒前
无花果的应助被东起欧采纳,获得10
1秒前
莉莉子发布了新的文献求助10
2秒前
情怀的应助被学术丁真采纳,获得20
2秒前
Yhooo的应助被彩色白桃采纳,获得10
2秒前
孙嘉畯发布了新的文献求助10
2秒前
yy发布了新的文献求助10
2秒前
CodeCraft的应助被guo7700采纳,获得10
2秒前
和谐亦瑶完成签到,获得积分10
3秒前
秦婧发布了新的文献求助10
4秒前
YY的应助被lani采纳,获得30
4秒前
5秒前
5秒前
5秒前
NexusExplorer的应助被欢喜的不尤采纳,获得10
6秒前
6秒前
7秒前
冀子丹完成签到 ,获得积分10
7秒前
7秒前
热情友桃完成签到,获得积分10
7秒前
sssssssssssss关注了科研通微信公众号
7秒前
无敌猫猫王完成签到,获得积分10
8秒前
8秒前
8秒前
8秒前
8秒前
痞老板发布了新的文献求助10
8秒前
8秒前
无花果的应助被小万采纳,获得10
9秒前
Jasper的应助被清爽翩跹采纳,获得20
10秒前
天天快乐的应助被罗伯特骚塞采纳,获得10
11秒前
笨笨豌豆发布了新的文献求助10
11秒前
王哈哈发布了新的文献求助10
11秒前
11秒前
传奇3的应助被不鸭采纳,获得10
11秒前
11秒前
12秒前
ma发布了新的文献求助10
12秒前
爱芮芮发布了新的文献求助10
13秒前
研友_VZG7GZ的应助被coco采纳,获得10
14秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
Encyclopedia of Modern Artificial Intelligence 1000
Особенности технологий и методов информационно-психологических войн СССР с Великобританией и США в период 1939-1953 гг 1000
Das Matthäusevangelium: Kapitel 1:1–17 1000
Analyses de reconnaissances de dettes passées devant les échevins d'Ypres (1249-1291) 600
拉伸高分子熔体中缠结行为的模拟和小角中子散射研究 600
Cellulose and Cellulose Derivatives: Synthesis, Modification and Applications 600
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 计算机科学 工程类 有机化学 化学工程 生物化学 物理 复合材料 内科学 催化作用 光电子学 人工智能 细胞生物学 无机化学 物理化学 数学
热门帖子
关注 科研通微信公众号,转发送积分 8141413
求助须知:如何正确求助?哪些是违规求助? 9541274
关于积分的说明 21645122
捐赠科研通 7725429
什么是DOI,文献DOI怎么找? 3421324
关于科研通互助平台的介绍 2546516
邀请新用户注册赠送积分活动 2463521