Abstract
Large Language Models (LLMs) have demonstrated impressive potential in
translating natural language (NL) instructions into program code. However, user
instructions often contain inherent ambiguities, making it challenging for LLMs
to generate code that accurately reflects the user's true intent. To address
this challenge, researchers have proposed to produce multiple candidates of the
program code and then rerank them to identify the best solution. In this paper,
we propose CodeRSA, a novel code candidate reranking mechanism built upon the
Rational Speech Act (RSA) framework, designed to guide LLMs toward more
comprehensive pragmatic reasoning about user intent. We evaluate CodeRSA using
one of the latest LLMs on a popular code generation dataset. Our experiment
results show that CodeRSA consistently outperforms common baselines, surpasses
the state-of-the-art approach in most cases, and demonstrates robust overall
performance. These findings underscore the effectiveness of integrating
pragmatic reasoning into code candidate reranking, offering a promising
direction for enhancing code generation quality in LLMs.
BibTeX
@online{Cao_2502.15835, TITLE = {Pragmatic Reasoning improves {LLM} Code Generation}, AUTHOR = {Cao, Zhuchen and Apel, Sven and Singla, Adish and Demberg, Vera}, LANGUAGE = {eng}, URL = {https://arxiv.org/abs/2502.15835}, EPRINT = {2502.15835}, EPRINTTYPE = {arXiv}, YEAR = {2025}, MARGINALMARK = {$\bullet$}, ABSTRACT = {Large Language Models (LLMs) have demonstrated impressive potential in<br>translating natural language (NL) instructions into program code. However, user<br>instructions often contain inherent ambiguities, making it challenging for LLMs<br>to generate code that accurately reflects the user's true intent. To address<br>this challenge, researchers have proposed to produce multiple candidates of the<br>program code and then rerank them to identify the best solution. In this paper,<br>we propose CodeRSA, a novel code candidate reranking mechanism built upon the<br>Rational Speech Act (RSA) framework, designed to guide LLMs toward more<br>comprehensive pragmatic reasoning about user intent. We evaluate CodeRSA using<br>one of the latest LLMs on a popular code generation dataset. Our experiment<br>results show that CodeRSA consistently outperforms common baselines, surpasses<br>the state-of-the-art approach in most cases, and demonstrates robust overall<br>performance. These findings underscore the effectiveness of integrating<br>pragmatic reasoning into code candidate reranking, offering a promising<br>direction for enhancing code generation quality in LLMs.<br>}, }
Endnote
%0 Report %A Cao, Zhuchen %A Apel, Sven %A Singla, Adish %A Demberg, Vera %+ Multimodal Language Processing, MPI for Informatics, Max Planck Society External Organizations External Organizations Multimodal Language Processing, MPI for Informatics, Max Planck Society %T Pragmatic Reasoning improves LLM Code Generation : %G eng %U http://hdl.handle.net/21.11116/0000-0010-FB6A-D %U https://arxiv.org/abs/2502.15835 %D 2025 %X Large Language Models (LLMs) have demonstrated impressive potential in<br>translating natural language (NL) instructions into program code. However, user<br>instructions often contain inherent ambiguities, making it challenging for LLMs<br>to generate code that accurately reflects the user's true intent. To address<br>this challenge, researchers have proposed to produce multiple candidates of the<br>program code and then rerank them to identify the best solution. In this paper,<br>we propose CodeRSA, a novel code candidate reranking mechanism built upon the<br>Rational Speech Act (RSA) framework, designed to guide LLMs toward more<br>comprehensive pragmatic reasoning about user intent. We evaluate CodeRSA using<br>one of the latest LLMs on a popular code generation dataset. Our experiment<br>results show that CodeRSA consistently outperforms common baselines, surpasses<br>the state-of-the-art approach in most cases, and demonstrates robust overall<br>performance. These findings underscore the effectiveness of integrating<br>pragmatic reasoning into code candidate reranking, offering a promising<br>direction for enhancing code generation quality in LLMs.<br> %K Computer Science, Computation and Language, cs.CL,Computer Science, Artificial Intelligence, cs.AI,Computer Science, Software Engineering, cs.SE