Abstract
Recent advancements in Code Large Language Models (LLMs) have significantly improved automated programming tasks. However, standard instruction-tuning methods often suffer from limited reasoning diversity and a lack of self-evaluative capabilities. We present DolphCoder, a novel two-stage training framework that utilizes Diverse Instruction Tuning (DIT) and Multi-Objective Tuning (MOT) to enhance model performance. By training models to both generate and critique code, DolphCoder-7B achieves a 62.8% Pass@1 on HumanEval, outperforming significantly larger models such as CodeLlama-34B. Our results demonstrate that reasoning diversity and self-evaluation are critical components for developing robust, high-efficiency code generation models.
Introduction
Instruction-tuning is the cornerstone of transforming pre-trained LLMs into functional assistants. In the coding domain, this process typically involves fine-tuning a model on pairs of natural language instructions and corresponding code solutions. Despite the success of this approach, existing methods face two primary bottlenecks:
- The "Golden Answer" Trap: Most datasets provide a single ground-truth solution for every prompt. This ignores the inherent flexibility of programming, where multiple valid logic paths can solve the same problem. By focusing on a single answer, models fail to learn the diverse reasoning paths required for complex problem-solving.
- The "Blind Author" Issue: While LLMs can generate plausible code, they often struggle to identify subtle logic errors or edge cases within their own output. A model that can write but cannot critique is fundamentally limited in its ability to produce reliable, production-ready code.
DolphCoder addresses these issues by introducing a training methodology inspired by echolocation—using diverse signals to "sense" the boundaries of correct logic and training the model to act as its own evaluator.
The DolphCoder Framework
The researchers developed a two-stage pipeline designed to broaden the model's reasoning capabilities and instill a sense of self-critique.
Diverse Instruction Tuning (DIT)
To break the "Golden Answer" trap, the authors expanded the training signal by generating multiple responses for each instruction. Using six distinct system prompts, they queried a teacher model (ChatGPT) to adopt various personas, such as a step-by-step teacher, a cross-language translator, or a detailed technical assistant. This process yielded a dataset of 510,000 pairs, exposing the model to a wide array of reasoning styles and implementation strategies for the same underlying problems.
Multi-Objective Tuning (MOT)
This stage focuses on the "Blind Author" problem. The authors sampled 5,000 instructions and generated 100 candidate answers for each. These candidates were then labeled by GPT-4 as <passed> or <not passed>, accompanied by natural language explanations for the success or failure of the code. This created a 370,000-item evaluation dataset, teaching the model to discriminate between functional and buggy code.
Sequential Training Strategy
Initial experiments revealed that mixing generation and evaluation tasks simultaneously led to overfitting. To optimize learning, the authors employed a sequential approach:
- Step A (Evaluator): The model is first fine-tuned on the MOT dataset to develop its critical faculties.
- Step B (Generator): The model then undergoes training on the diverse DIT data to refine its generation capabilities.
Experimental Results
DolphCoder was evaluated on standard benchmarks including HumanEval and MBPP, as well as their more rigorous "Plus" versions, which utilize extensive test cases to uncover subtle logic flaws.
Performance and Efficiency
DolphCoder-7B (based on CodeLlama) demonstrated remarkable efficiency, achieving a 62.8% Pass@1 on HumanEval. This result is particularly significant as it surpasses the performance of much larger models, including CodeLlama-34B (51.8%) and WizardCoder-13B (60.4%).
Robustness
On the HumanEval+ benchmark, which is designed to catch models that pass simple tests but fail on edge cases, DolphCoder-7B scored 54.9%. This represents a massive 20-point improvement over the base CodeLlama-7B model, highlighting the impact of the MOT stage on code reliability.
Scaling Potential
The 13B parameter version of DolphCoder reached 67.7% on HumanEval, further narrowing the performance gap between open-source models and proprietary systems like GPT-3.5.
Discussion and Key Insights
The success of DolphCoder provides several key insights into the future of Code LLM training:
- Diversity as a Signal: Exposing models to multiple reasoning paths for the same problem is more effective than simply increasing the volume of unique problems. Diversity acts as a supervised signal that helps the model generalize better.
- The Critic Improves the Author: There is a measurable correlation between a model's ability to evaluate code and its ability to generate it. By learning to spot errors, the model becomes more "aware" of potential pitfalls during the generation process.
- Echolocation Effect: The MOT stage acts like sonar, helping the model map the boundaries of correct logic more effectively than standard supervised learning alone.
Limitations and Future Work
While promising, the current approach relies on GPT-4 for evaluation labels, which introduces a "noise ceiling" due to GPT-4's own ~20% error rate in code critique. Future iterations of DolphCoder aim to integrate automated unit testing and execution-based feedback to provide a more objective ground-truth signal. Additionally, the authors plan to explore Reinforcement Learning (RL) to further bridge the gap between the model's roles as both author and critic.
Summary updated