Enhancing Code Generation via Bidirectional Comment-Level Mutual Grounding
Authors:
- 26 April 2025
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1359-1371
Abstract
Large Language Models (LLMs) have demonstrated unprecedented capability in code generation. However, LLM-generated code is still plagued with a wide range of functional errors, especially for complex programming tasks that LLMs have not seen before. Recent studies have shown that developers often struggle with inspecting and fixing incorrect code generated by LLMs, diminishing their productivity and trust in LLM-based code generation. Inspired by the mutual grounding theory in communication, we propose an interactive approach that leverages code comments as a medium for developers and LLMs to establish a shared understanding. Our approach facilitates iterative grounding by interleaving code generation, inline comment generation, and contextualized user feedback through editable comments to align generated code with developer intent. We evaluated our approach on two popular benchmarks and demonstrated that our approach significantly improved multiple state-of-the-art LLMs, e.g., 17.1% pass@1 improvement for code-davinci-002 on HumanEval. Furthermore, we conducted a user study with 12 participants in comparison to two baselines: (1) interacting with GitHub Copilot, and (2) interacting with a multi-step code generation paradigm called Multi-Turn Program Synthesis. Participants completed the given programming tasks 16.7% faster and with 10.5% improvement in task success rate when using our approach. Both results show that interactively refining code comments enables the collaborative establishment of mutual grounding, leading to more accurate code generation and higher developer confidence.Keywords
All Related Versions
Funding Information
- NSF (ITE-2333736,CCF-2340408)
This publication has 35 references indexed in Scilit:
- Competition-level code generation with AlphaCodeScience, 2022
- The Cross-Entropy Method for Combinatorial and Continuous OptimizationMethodology and Computing in Applied Probability, 1999
- Conceptual pacts and lexical choice in conversation.Journal of Experimental Psychology: Learning, Memory, and Cognition, 1996
- Perspectives on socially shared cognition.1991
- Ostensible invitationsLanguage in Society, 1990
- Development of NASA-TLX (Task Load Index): Results of Empirical and Theoretical Research1988
- Top-down synthesis of divide-and-conquer algorithmsArtificial Intelligence, 1985
- Audience Design in Meaning and Reference1982
- Synthesis: Dreams → ProgramsIEEE Transactions on Software Engineering, 1979
- A Transformation System for Developing Recursive ProgramsJournal of the ACM, 1977