arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.15835cs.CLcs.AIcs.SE
收藏

语用推理提升LLM代码生成

Pragmatic Reasoning improves LLM Code Generation

Max Planck Institute for Informatics Saarland Campus(马克斯·普朗克信息研究所萨尔兰州分校);Computer Science Saarland University(萨尔兰州大学计算机科学系);Max Planck Institute for Software Systems Saarland Campus(马克斯·普朗克软件系统研究所萨尔兰州分校)

Zhuchen Cao, Sven Apel, Adish Singla, Vera Demberg

AI总结:

提出CodeRSA方法,通过局部语用竞赛对候选代码进行重排序,以解决自然语言到代码生成中的歧义问题,在多个基准测试中取得最佳平均准确率。

摘要:

语用推理帮助对话者通过考虑共享上下文和反事实替代方案,从模糊或未充分指定的信息中推断出预期含义。自然语言到代码生成中也会出现类似的挑战,因为用户指令通常允许多个合理的候选程序。然而,直接的RSA风格推理是困难的,因为它需要对程序空间和替代指令的大空间进行概率估计。我们提出了CodeRSA,一种受RSA启发的重排序方法,通过对采样代码候选进行局部语用竞赛,使语用推理变得可行。CodeRSA构建候选诱导的替代指令,并估计哪些候选最独特地受到原始指令的支持,从而避免了对整个程序-指令空间的全局归一化。我们在HumanEval+、MBPP+和BigCodeBench上使用四个开放权重的指令跟随模型评估了CodeRSA。在12个模型-基准设置中,CodeRSA在10个设置中取得了最强的平均准确率,并在其余情况下保持竞争力。进一步分析表明,其收益来自于将局部成对语用比较与更广泛的全局支持相结合,这为自然语言不确定性下的语言到代码重排序提供了一个可扩展的方向。

英文摘要:

Pragmatic reasoning helps interlocutors infer intended meaning from ambiguous or underspecified messages by considering shared context and counterfactual alternatives. Similar challenges arise in natural language-to-code generation, where user instructions often admit multiple plausible candidate programs. However, direct RSA-style inference is difficult because it requires probability estimation over large spaces of programs and alternative instructions. We propose CodeRSA, an RSA-motivated reranking method that makes pragmatic reasoning tractable through local pragmatic contests among sampled code candidates. CodeRSA constructs candidate-induced alternative instructions and estimates which candidates are most distinctively supported by the original instruction, avoiding global normalization over the full program-instruction space. We evaluate CodeRSA on HumanEval+, MBPP+, and BigCodeBench using four open-weight instruction-following models. CodeRSA achieves the strongest average accuracy in 10 of 12 model-benchmark settings and remains competitive in the remaining cases. Further analyses show that its gains come from combining local pairwise pragmatic comparison with broader global support, suggesting a scalable direction for language-to-code reranking under natural-language uncertainty.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑