NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Enhancing Code Generation via Bidirectional Comment-Level Mutual Grounding

Yifeng Di, Tianyi Zhang · DOI

Introduction

Large Language Models (LLMs) have revolutionized automated code generation, yet they frequently struggle with alignment. When a model produces code that misses a logical edge case or utilizes a non-existent API, developers often find themselves trapped in a cycle of trial-and-error. Traditional methods of correction—such as re-prompting or multi-turn chat debugging—often fail to pinpoint the exact location of an error or lose the context of previous iterations.

Researchers from Purdue University have introduced PING (Programming with Interactive Grounding), a framework designed to bridge this communication gap. By utilizing line-level natural language comments as a medium for "mutual grounding," PING allows developers to interact with the model's logic directly, enabling surgical refinements to buggy code.

The Challenge of Mutual Grounding

The primary hurdle in AI-assisted coding is the lack of a shared understanding, or mutual grounding, between the human developer and the machine. Current approaches to fixing LLM-generated code face three significant limitations:

  1. Prompt Volatility: Modifying the original prompt often causes the LLM to regenerate the entire solution, frequently discarding correct logic along with the errors.
  2. Localization Issues: Conversational interfaces struggle to map high-level natural language feedback to specific lines of code within a large block.
  3. Execution Blindness: Automated self-debugging tools rely on compiler feedback. While effective for syntax errors, they cannot detect logical errors that do not trigger a crash.

PING addresses these issues by establishing a bidirectional channel where the model explains its intent line-by-line, and the human provides corrective feedback in the same format.

The PING Framework

The PING pipeline consists of three distinct phases designed to align the model's execution with the developer's intent:

1. Comment Generation

Once an initial code snippet is generated, PING parses the code into an Abstract Syntax Tree (AST). A fine-tuned CodeBERT model then generates a natural language comment for every individual statement. This transforms the code into a readable narrative of the model's "thought process."

2. Human Review and Interaction

The developer reviews these inline comments. If a comment reveals a logical flaw—for example, a comment stating "calculates the square root" when the requirement was "calculates the cube root"—the developer simply edits the comment. This allows the developer to guide the model using natural language without needing to provide the exact code syntax.

3. Code Refinement

The edited comments and the original code context are passed to a fine-tuned DeepSeek Coder (6.7B) model. This model treats the corrected comments as the ground truth, regenerating only the specific lines of code necessary to match the updated logic.

Experimental Evaluation

The researchers evaluated PING using industry-standard benchmarks, including HumanEval/HumanEval+ and MBPP/MBPP+. To support the training of the refinement models, they utilized CodeSearchNet and The Stack, and released a new interaction dataset containing 1,224 code-comment-edit triplets.

Quantitative Results

The impact of interactive grounding was significant across all metrics:

  • Accuracy: PING improved the pass@1 rate for code-davinci-002 by 17.1% on the HumanEval benchmark.
  • Developer Efficiency: In a user study involving 12 professional programmers, participants using PING completed tasks 16.7% faster than those using GitHub Copilot.
  • Success Rate: The overall task success rate increased by 10.5% compared to standard AI-assisted workflows.

Qualitative Insights

Beyond speed and accuracy, the study found that PING significantly reduced cognitive load. Participants reported a 20% increase in confidence in the generated code. Because the model's intent was explicitly stated in comments, developers could verify the logic through reading rather than relying solely on manual unit testing.

Discussion and Future Work

While PING represents a major advancement in human-AI collaboration, it introduces new challenges, such as "comment verbosity." Generating a comment for every line can clutter complex files. Future iterations of the framework may explore "collapsing" comments for trivial logic, only expanding them for complex blocks or when the model's confidence is low.

By transforming the "rubber ducking" process into an active, bidirectional dialogue, PING demonstrates that the key to better code generation is not just more data, but better communication. This approach moves us closer to a future where developers and AI act as true collaborators, refining logic line-by-line to build more robust software.

Summary updated

BibTeX
@inproceedings{di2025enhancing,
  author = {Yifeng Di and Tianyi Zhang},
  title = {{Enhancing Code Generation via Bidirectional Comment-Level Mutual Grounding}},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00165},
}
Figure