合成幻觉,真实收益:来自前沿模型的硬负样本用于FIM幻觉缓解
Synthetic Hallucinations, Real Gains: Hard Negatives from Frontier Models for FIM Hallucination Mitigation
AI总结:
针对小型开源代码模型在IDE自动补全中产生的填充中间(FIM)幻觉问题,提出一种无需执行的替代方法:利用前沿代码模型合成看似合理但错误的补全作为硬负样本,通过对比合成幻觉与真实开发者编辑的差异作为监督微调信号,在Delulu基准上提升精确匹配18.8个百分点。
摘要:
驱动IDE自动补全的小型开源代码模型仍然会输出幻觉的填充中间(FIM)补全:对项目中不存在的方法、参数、变量和导入的语法上自然的调用。现有的缓解方法要么需要每种语言的执行沙箱(在按键中途不适用),要么需要偏好优化管道(需要大量人工标注语料库)。我们提出一种无需执行的替代方案:使用前沿代码模型合成看似合理但错误的补全作为硬负样本,然后利用这些合成幻觉与真实开发者编辑之间的对比作为监督微调信号。我们的管道从公共GitHub中跨八种语言抓取多语言FIM上下文,并让一组三个前沿生成器为每个上下文针对Delulu分类法(一个经Docker验证的多语言FIM幻觉基准)中的四种幻觉类型各生成一个硬负样本,从而产生配对的选定/拒绝数据集。在10万行精选子集上微调Qwen2.5-Coder-7B-Instruct,使Delulu精确匹配提升+18.8点,编辑相似度提升+0.22,覆盖每种语言和每种类型,同时改进每个HumanEval-Infilling分割和每个SAFIM子集。同样的配方在3B模型上使Delulu提升+12.8 EM,并带有小的、特征化的一般FIM权衡。五轴消融实验(规模、类型混合、语言覆盖、基础模型家族和难度感知的愚弄率)加上头对头的SFT与DPO/ORPO比较,映射了哪些设计选择驱动了收益。我们发布完整的管道源代码——生成、愚弄率LLM评判、筛选和FIM微调配方——以便本文中的实验可以在任何许可语料库上端到端复现。
英文摘要:
Small open-source code models that power IDE autocomplete still emit hallucinated Fill-in-the-Middle (FIM) completions: syntactically natural calls to methods, parameters, variables, and imports that do not exist in the surrounding project. Existing mitigations either require per-language execution sandboxes that do not apply at mid-keystroke or preference-optimisation pipelines that need large human-labelled corpora. We propose an execution-free alternative: use frontier code models to synthesise plausible-but-wrong completions as hard negatives, then leverage the contrast between these synthetic hallucinations and the ground-truth developer edit as a supervised fine-tuning signal. Our pipeline scrapes multilingual FIM contexts from public GitHub across eight languages and asks a panel of three frontier generators to produce one hard negative per context for each of four hallucination types drawn from the Delulu taxonomy, a Docker-verified multilingual FIM hallucination benchmark, yielding a paired chosen/rejected dataset. Fine-tuning Qwen2.5-Coder-7B-Instruct on a 100K-row curated subset lifts Delulu exact match by +18.8 points and edit similarity by +0.22 on every language and every type, while also improving every HumanEval-Infilling split and every SAFIM subset. The same recipe at 3B lifts Delulu by +12.8 EM with a small, characterised general-FIM trade-off. Five-axis ablations (size, type mix, language coverage, base-model family, and a difficulty-aware fool rate) plus a head-to-head SFT vs. DPO/ORPO comparison map which design choices drive the gain. We release the full pipeline source code -- generation, fool-rate LLM judging, curation, and the FIM fine-tuning recipe -- so that the experiments in this paper can be reproduced end-to end on any permissively licensed corpus.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。