TL;DR
This paper introduces AlchemistCoder, a new family of open-source code LLMs that significantly improve code generation and generalization by harmonizing diverse, multi-source code data. By employing "AlchemistPrompts" and novel code comprehension tasks, AlchemistCoder models achieve state-of-the-art performance, even outperforming larger proprietary models.
What Problem Does This Paper Address?
Large Language Models (LLMs) have shown remarkable capabilities in code generation, but open-source models often lag behind their closed-source counterparts. A key bottleneck is the fine-tuning process, which typically relies on single-source datasets. These datasets, while sometimes high-quality, often lack the diversity and richness needed to fully unlock the potential of pre-trained LLMs. This can lead to models that are good at specific tasks but struggle with generalization and robustness. The authors identify that simply mixing data from various sources can lead to conflicting styles and quality issues, hindering performance.
Methods
The core innovation of AlchemistCoder lies in its approach to harmonizing multi-source data for fine-tuning.
- AlchemistPrompts: The authors introduce "AlchemistPrompts," a novel technique inspired by "hindsight tuning." They use a powerful LLM (GPT-4) to generate data-specific prompts that clarify instructions and align them with their corresponding responses. This helps resolve inherent conflicts in multi-source code corpora, such as differing programming language conventions or response styles. These prompts are applied to a small percentage (around 5%) of the training data to bridge domain gaps and improve instruction-response alignment.
- Code Comprehension Tasks: Beyond standard instruction-response pairs, AlchemistCoder incorporates data construction processes as training tasks. These include:
- Instruction Evolution: Augmenting existing instructions to increase complexity and provide more detailed explanations.
- Data Filtering: Training models to identify and categorize low-quality code data (e.g., short responses, non-compilable code, unclear code).
- Code Review: Training models to assess code correctness and clarity, and suggest improvements.
- Multi-Source Integration: The framework integrates data from various open-source datasets and the newly constructed comprehension task data.
Datasets
The AlchemistCoder dataset is built upon several existing open-source datasets and newly generated data:
- Open-source datasets: Evol-Instruct-Code-80k-v1, CodeExercise-Python-27k, evol-codealpaca-v1.
- Newly generated data:
- EvolCode data (generated using GPT-3.5).
- Data customized by AlchemistPrompts.
- Data from code comprehension tasks (instruction evolution, data filtering, and code review).
The paper also uses standard benchmarks for evaluation: HumanEval, HumanEval+, MBPP, MBPP+, HumanEval-X, DS-1000, MMLU, BBH, and GSM8K.
Key Insights and Ideas
- The power of harmonization: Simply mixing diverse code data isn't enough; it can even hurt performance. The key is to actively harmonize conflicting styles and qualities, which AlchemistPrompts effectively achieve.
- Hindsight tuning for code: Applying "hindsight" by relabeling data with AlchemistPrompts allows models to learn from the desired outcome, leading to better instruction following.
- Data construction as a learning signal: Treating data cleaning, evolution, and review as training tasks significantly boosts a model's understanding and capabilities beyond just generating code.
- Small percentage, big impact: AlchemistPrompts, despite being applied to only a small fraction of the data, yield substantial performance gains, demonstrating an efficient way to leverage powerful LLMs for data enhancement.
Key Results
AlchemistCoder models, particularly the 7B parameter versions, demonstrate impressive performance:
- State-of-the-art for their size: AlchemistCoder models (6.7B/7B) significantly outperform other open-source models of comparable size on benchmarks like HumanEval and MBPP.
- Competitive with larger models: They rival or even surpass larger proprietary models (15B, 33B, 70B) on several benchmarks. For instance, AlchemistCoder-DS (6.7B) achieves a 79.9% pass@1 on HumanEval and 77.0% on MBPP.
- Multilingual capabilities: AlchemistCoder shows significant improvements (over 50%) in multilingual code generation on HumanEval-X.
- Improved generalization: AlchemistCoder models exhibit enhanced reasoning abilities and better instruction-following across diverse benchmarks (MMLU, BBH, GSM8K), suggesting they are better generalists.
- Reduced errors: Error analysis shows a reduction in compilation errors and "wrong answer" cases, indicating improved programming logic and robustness.
Limitations and Future Work
- GPT-4 dependency: While efforts are made to minimize reliance, GPT-4 is still used for generating AlchemistPrompts, which represents a significant cost. The authors plan to explore fine-tuning open-source models for this task.
- Data bias: The paper acknowledges that data bias has not been fully addressed and will be explored in future work.
- Future directions: The authors aim to further enhance code comprehension capabilities and explore more sophisticated data construction processes. They also plan to investigate fine-tuning open-source models for prompt generation to reduce reliance on proprietary LLMs.
Summary updated