arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2609.23270cs.SEcs.CR

生成之前先规格说明:针对LLM生成代码在金钱、时间、幂等性和访问任务中规格框架的预注册五模型配对评估

Specification Before Generation: A Pre-Registered, Five-Model Paired Evaluation of a Specification Frame for LLM-Generated Code in Money, Time, Idempotency, and Access Tasks

Sandeep Dhuri

首次发表
浏览论文内容

中文总结 AI 辅助

本研究通过预注册的五模型配对实验,验证了在提示中加入规格框架可显著减少LLM生成代码在金钱、时间、幂等性和访问任务中的缺陷,且效果在模型默认行为较弱时最大。

中文摘要 AI 辅助

大型语言模型生成的代码通过安全检查的比例在四年内几乎没有变化。在受监管的后端系统中,最重要的缺陷类别是金钱算术、时间处理、重试安全性和访问控制。团队用指令文件来应对,但迄今为止最大规模的指令文件对照研究发现其并无益处。本文测试了一个更窄的想法:当提示包含规格说明(即一个固定的前言,陈述结果必须满足的条件)时,生成的代码会得到改进。我们预先注册了假设、反驳者、分析代码和一次性生成规则,然后通过来自五个供应商谱系的五个前沿模型,运行了来自金融、医疗保健和保险实践的50个现实后端任务,每个任务运行两次:一次是裸提示,另一次是前面加上一个267字的已填充规格框架。九个确定性的基于AST的检查器对输出进行评分。Bandit安全扫描器(对框架一无所知)独立地对它们进行评分。该框架在所有五个模型中减少了缺陷(平均每个任务减少0.16到0.70个发现,每个Holm调整的符号检验均显著,每个自举置信区间均排除零)。在两组不同的情况下,框架组在100次中赢了95次。它从未使任何模型在任何领域变得更差。Bandit在裸提示组中发现了53个中或高严重性问题,在框架组中发现了11个,每个模型的方向都相同。效果在模型未经提示的默认行为最弱的地方最大:框架提供了模型所缺乏的纪律。所有500个输出、提示、检查器、评分代码和预注册都通过DOI发布,因此任何团队都可以在不信任作者的情况下重新推导结果。

英文摘要

Code generated by large language models passes security checks at a rate that has barely moved in four years. In regulated backends, the defect classes that matter most are money arithmetic, time handling, retry safety, and access control. Teams answer with instruction files, yet the largest controlled study of instruction files we are aware of found no general benefit. This paper tests a narrower idea: generated code improves when the prompt carries a specification, a fixed preamble stating what must be true of the result. We pre-registered hypotheses, refuters, analysis code, and a one-shot generation rule, then ran 50 realistic backend tasks from finance, healthcare, and insurance practice through five frontier models from five vendor lineages, each task twice: bare, and preceded by a 267-word filled specification frame. Nine deterministic AST-based checkers scored the outputs. The Bandit security scanner, which knows nothing of the frame, scored them independently. The frame reduced defects in all five models (mean reduction 0.16 to 0.70 findings per task, every Holm-adjusted sign test significant, every bootstrap confidence interval excluding zero). Where the arms differed, the frame arm won 95 of 100 times. It never made any model worse in any domain. Bandit found 53 medium-or-high issues in the bare arm and 11 in the frame arm, in the same direction for every model. The effect was largest where a model's unprompted defaults were weakest: the frame supplies the discipline a model lacks. All 500 outputs, prompts, checkers, scoring code, and the pre-registration are published with a DOI, so any team can re-derive the result without trusting the author.

补充信息

↑