TL;DR
ClarifyCoder is a novel framework designed to train Code Large Language Models (LLMs) to recognize ambiguous, incomplete, or inconsistent requirements. By shifting from a "guess-and-generate" approach to a clarification-seeking one, researchers increased the model's communication rate from 24% to 63% while maintaining high-quality functional code generation.
The Problem: The "Eager to Please" LLM
In human-to-human software development, vague instructions like "increment the list by a number" naturally prompt a clarifying question: "Which number?" However, current LLMs are typically "eager to please" to a fault. They tend to generate code based on an internal guess, often leading to solutions that are syntactically correct but functionally useless because they do not align with the user's actual intent.
While previous attempts to address this have relied on external "agentic" workflows—multi-step processes that wrap around a model—this research argues that the ability to recognize ambiguity should be an intrinsic property of the model itself. The challenge lies in fine-tuning a model to balance two conflicting goals: being a proficient coder when instructions are clear and an inquisitive collaborator when they are not.
The ClarifyCoder Framework
The researchers introduced ClarifyCoder, a framework built on two main pillars: Clarify-Aware Data Construction and specialized Instruction Tuning.
1. Clarify-Aware Data Construction
To overcome the lack of large-scale datasets containing vague prompts paired with clarifying questions, the authors developed a synthetic pipeline. They took 10,000 clear problems from the APPS dataset and used Google Gemini to systematically "break" them into three categories:
- Ambiguity: Creating multiple valid interpretations of the task.
- Incompleteness: Omitting key constraints or logic necessary for implementation.
- Inconsistency: Introducing contradictory requirements. For each modified prompt, they generated an "ideal" clarifying question to serve as the ground truth for training.
2. Instruction Tuning and Joint Optimization
The team fine-tuned a DeepSeek Coder 7B model using this synthetic data. A significant technical finding was that calculating training loss only on the answer (the clarifying question) yielded better performance than calculating it on both the problem and the answer. This allowed the model to focus more effectively on the nuances of the dialogue.
To prevent the model from becoming "too talkative"—asking questions even when instructions are perfectly clear—the researchers employed joint optimization. They mixed the new clarification data with standard coding data, finding a "sweet spot" ratio that preserves coding proficiency while enabling clarification behavior.
Key Results and Insights
The evaluation of ClarifyCoder across benchmarks like HumanEval and the specialized HumanEvalComm revealed several key insights:
- Significant Communication Gains: ClarifyCoder achieved a 63.6% communication rate on ambiguous tasks, a massive improvement over the base DeepSeek Coder’s 24.1%.
- High-Quality Clarification: The "Good Question Rate" rose from 21.3% to 51.9%. Manual evaluation confirmed a high correlation (Kappa score of 0.8-0.9) between human judgment and the LLM-based metrics used for evaluation.
- Maintaining Coding Proficiency: On the standard HumanEval benchmark (clear tasks), ClarifyCoder maintained a 74.8% Pass@1 score, slightly outperforming the base model (73.6%) in certain configurations. This demonstrates that clarification awareness does not necessarily come at the cost of coding skill.
- Category Sensitivity: Models find it significantly easier to detect missing information (Incompleteness, 76% communication rate) than to spot logical contradictions (Inconsistency, 48% communication rate).
Conclusion and Future Work
ClarifyCoder demonstrates that clarification-seeking behavior can be successfully baked into a model's weights, outperforming some complex multi-call agent systems with a single LLM call. While the model is highly effective at identifying the need for clarification, future work will focus on the "second round" of the interaction—optimizing how the model integrates the user's response to generate the final, correct code. Additionally, improving the model's reasoning to detect subtle inconsistencies remains a primary goal for future iterations.
Summary updated