Abstract
High-quality instruction data is essential for fine-tuning Large Language Models (LLMs) for code generation, but human-curated datasets are costly to scale. Existing automated synthesis methods, such as OSS-Instruct and Code Evol-Instruct, typically follow linear paths or rely on random prompts, often resulting in repetitive or low-complexity data. We introduce Tree-of-Evolution (ToE), a framework that treats data synthesis as a branching evolutionary process. By optimizing for both challenge and diversity and pruning low-quality branches, ToE generates a highly efficient dataset of 75,000 samples. Models fine-tuned on this data match or exceed the performance of state-of-the-art models trained on significantly larger datasets across major benchmarks like HumanEval and MBPP.
Introduction
The performance of code-generating LLMs is heavily dependent on the quality of supervised fine-tuning (SFT) data. While automated methods have been developed to generate synthetic data, they face two primary limitations:
- Unidirectional Synthesis: Data expansion along a single path can lead to wasted trajectories if early choices are suboptimal.
- Randomness-Driven Generation: Reliance on random prompts often fails to produce the complex reasoning required for advanced coding tasks.
To address these, Tree-of-Evolution (ToE) shifts the paradigm from linear chains to branching trees, ensuring that synthetic data is both challenging and diverse.
Methods: The Evolutionary Framework
ToE treats data synthesis as an iterative evolutionary process consisting of several key stages:
- Tree-Based Synthesis: Starting from a seed code snippet (e.g., from GitHub), ToE generates multiple candidate instructions in parallel, creating a branching structure that explores diverse evolutionary paths.
- Quality Evaluation (Fitness Function): Each instruction is evaluated based on its Challenge ($V_{comp}$)—rated by an LLM-as-a-judge—and its Diversity ($V_{div}$), measured by its distance from existing instructions in the database.
- Optimization-Driven Evolution: Using a beam search algorithm, the system prunes branches that fail to improve upon their parent's complexity or diversity. Only the "fittest" instructions are allowed to evolve further.
- Collection: After three rounds of evolution, the highest-quality instructions from all levels of the tree are harvested into the final dataset.
Experimental Setup and Results
The authors synthesized a dataset of 75,000 instructions from 5,000 seed snippets and fine-tuned the Qwen2.5-Coder-Base series. Evaluation was conducted on standard benchmarks (HumanEval, MBPP) and more rigorous variants (EvalPlus, LiveCodeBench, BigCodeBench).
Key Performance Insights
- Efficiency: The ToE-1.5B model achieved a 75.0% score on HumanEval, outperforming the official Qwen2.5-Coder-Instruct 1.5B (70.7%) despite being trained on significantly less data.
- Scalability: The ToE-14B model reached 74.9% on MBPP-Plus, rivaling much larger proprietary models and demonstrating the power of high-density information.
- Generalization: On LiveCodeBench—a benchmark designed to be contamination-free—the ToE-1.5B model showed a massive improvement over its baseline (17.3 vs 13.0 Pass@1).
- Complex Reasoning: In the BigCodeBench "Hard" category, the ToE-14B model performed comparably to GPT-4o, highlighting its ability to handle complex library calls and instructions.
Discussion and Conclusion
The success of Tree-of-Evolution underscores that quality and density of information are more critical than raw data volume for training code LLMs. By explicitly pruning "noisy" or repetitive data through an evolutionary tree structure, ToE achieves state-of-the-art results with a fraction of the typical training data.
While the computational cost of building a tree is higher than linear methods, the resulting data efficiency offers a significant advantage. Future work may involve refining the "fitness functions" for general reasoning tasks and incorporating execution-based feedback to further improve the quality of generated code responses.
Summary updated