DolphCoder: Echo-Locating Code Large Language Models with Diverse and Multi-Objective Instruction Tuning

Yejie Wang, Keqing He, Guanting Dong, Pei Wang, Weihao Zeng, Muxi Diao, Yutao Mou, Mengdi Zhang, Jingang Wang, Xunliang Cai, Weiran XuarXiv 2024 · DOI

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:

  1. 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.
  2. 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

Abstract

Code Large Language Models (Code LLMs) have demonstrated outstanding performance in code-related tasks. Several instruction tuning approaches have been proposed to boost the code generation performance of pre-trained Code LLMs. In this paper, we introduce a diverse instruction model (DolphCoder) with self-evaluating for code generation. It learns diverse instruction targets and combines a code evaluation objective to enhance its code generation ability. Our model achieves superior performance on the HumanEval and MBPP benchmarks, demonstrating new insights for future code instruction tuning work. Our key findings are: (1) Augmenting more diverse responses with distinct reasoning paths increases the code capability of LLMs. (2) Improving one's ability to evaluate the correctness of code solutions also enhances their ability to create it.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
HumanEvalDolphCoder-7BGreedy (pass@1, greedy decoding)62.8+4.9 vs baselineparams=7B · backbone=7B
Source quote
L192: Model │ Greedy │ Pass@1 │ Pass@10 DolphCoder │ 62.8 │ 59.9 │ 71.3
HumanEvalDolphCoder-7B without MOTGreedy (pass@1, greedy decoding)57.9params=7B · ablation=without-MOT · backbone=7B
Source quote
L193: -w/o MOT │ 57.9 │ 56.6 │ 69.5 Improvement │ 4.9 │ 3.3 │ 1.8
Reported baseline / comparator measurements (2)
BenchmarkMethodMetricScoreProtocol / Evidence
HumanEval · BaseDIT (CODELLAMA-13B-PYTHON), no system prompt in training or inference baselinepass@157.9params=13B · backbone=CodeLlama-13B-Python
Source quote
L206: \color{red}\ding{53} │ \color{red}\ding{53} │ 57.9 │ 50.6
HumanEval · PlusDIT (CODELLAMA-13B-PYTHON), no system prompt in training or inference baselinepass@150.6params=13B · backbone=CodeLlama-13B-Python
Source quote
L206: \color{red}\ding{53} │ \color{red}\ding{53} │ 57.9 │ 50.6
BibTeX
@misc{wang2024dolphcoder,
  author = {Yejie Wang and Keqing He and Guanting Dong and Pei Wang and Weihao Zeng and Muxi Diao and Yutao Mou and Mengdi Zhang and Jingang Wang and Xunliang Cai and Weiran Xu},
  title = {{DolphCoder: Echo-Locating Code Large Language Models with Diverse and Multi-Objective Instruction Tuning}},
  year = {2024},
  eprint = {2402.09136},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.09136},
}
Figure