Pragmatic Reasoning improves LLM Code Generation

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Cao, Zhuchen, Apel, Sven, Singla, Adish, Demberg, Vera
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866914595179855872
author Cao, Zhuchen
Apel, Sven
Singla, Adish
Demberg, Vera
author_facet Cao, Zhuchen
Apel, Sven
Singla, Adish
Demberg, Vera
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2502_15835
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Pragmatic Reasoning improves LLM Code Generation
Cao, Zhuchen
Apel, Sven
Singla, Adish
Demberg, Vera
Computation and Language
Artificial Intelligence
Software Engineering
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.
title Pragmatic Reasoning improves LLM Code Generation
topic Computation and Language
Artificial Intelligence
Software Engineering
url https://arxiv.org/abs/2502.15835