给代码生成模型的错误位置打标概率,让开发者一眼看出哪行该改。
Localized Calibrated Uncertainty in Code Language Models
- 用最小修复补丁构建数据集,定位代码错误段落。
- 小规模监督模型实现约0.2的贝叶斯技能分数,校准误差低。
- 方法可泛化到自然语言,适合开发工具与AI监管场景。
大型语言模型(LLMs)能从自然语言提示生成复杂源码,但生成结果常偏离用户意图,需人工修正。为辅助这一过程,本文提出技术以定位生成代码中可能与用户意图不一致的部分。首先构建‘最小意图对齐补丁’数据集,每个程序通过测试用例验证正确性。随后评估不同方法在分配校准概率方面的表现,即预测某行代码是否会被最小补丁修改的概率是否与实际编辑频率一致。对比白盒探测(提出高效任意跨度查询技术)、黑盒反思及自一致性方法,发现仅用小型监督模型即可在比其大数个数量级的代码生成模型上实现约0.2的贝叶斯技能分数和低校准误差。讨论了方法的泛化能力及其在人工智能监管与控制中的意义,发现仅在代码上训练的探测器,在引入新概率缩放后,对自然语言错误也表现出一定泛化迹象。
原文摘要 · Abstract (English)
Large Language models (LLMs) can generate complicated source code from natural language prompts. However, LLMs can generate output that deviates from what the user wants, requiring supervision and editing. To support this process, we offer techniques to localize where generations might be misaligned from user intent. We first create a dataset of "Minimal Intent Aligning Patches" of repaired LLM generated programs. Each program uses test cases to verify correctness. After creating a dataset of programs, we measure how well various techniques can assign a well-calibrated probability to indicate which parts of code will be edited in a minimal patch (i.e., give a probability that corresponds with empirical odds it is edited). We compare white-box probing (where we propose a technique for efficient arbitrary-span querying), against black-box reflective and self-consistency based approaches. We find probes with a small supervisor model can achieve low calibration error and Brier Skill Score of approx 0.2 estimating edited lines on code generated by models many orders of magnitude larger. We discuss the generalizability of the techniques, and the connections to AI oversight and control, finding a probe trained only on code shows some signs of generalizing to natural language errors if new probability scaling is allowed.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。