“shows how to have the language models generate code without hallucinated dereferences.”
Guiding Language Models of Code with Global Context using Monitors
用静态分析监视器引导解码,减少代码模型的幻觉调用
代码语言模型缺乏对仓库中其他位置定义的类型、API 的了解,容易编造不存在的调用。论文提出监视器引导解码(MGD):解码时由监视器借助静态分析约束输出,例如保证对象解引用类型一致。在作者构建的 Java 仓库级方法补全数据集 PragmaticCode 上,MGD 在不同规模模型上都提高了编译率和与真值的一致性,小模型 SantaCoder-1.1B 加上 MGD 后超过大得多的 text-davinci-003;方法还可推广到 C#、Rust 及更丰富的语义约束。
HN 评论者把它当作“在推理时接入静态分析,让生成的代码不止语法正确、没有幻觉的解引用”的代表性工作来引用。
HN 书评
推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及“we propose Monitor Guided Decoding, which interfaces LLMs to static analysis”
“which essentially gives IDE-typical type-aware autocomplete to an LLM to primarily study the scenario of enforcing type-consistent method completion in a Java repository.”
“it's been done, in a limited way: Guiding Language Models of Code with Global Context using Monitors”
“incorporating static analysis at inference time to ensure code is more than just syntactically correct [0]”
“which uses static analysis beyond the type system to filter out e.g. invalid variable names, invalid control flow etc.”