OctoPack: Instruction Tuning Code Large Language Models

Niklas Muennighoff, Qian Liu, Armel Randy Zebaze, Qinkai Zheng, Binyuan Hui, Terry Yue Zhuo, Swayam Singh, Xiangru Tang, Leandro Von Werra, Shayne Longpre

Introduction

Large Language Models (LLMs) have become incredibly adept at following natural language instructions, but "Code LLMs" often remain specialized for simple code completion. Existing attempts to instruction-tune these models frequently rely on synthetic data generated by proprietary models like GPT-4. This creates a "distillation" dependency that raises legal concerns for commercial use and limits the diversity of the training data.

Furthermore, standard benchmarks like HumanEval only measure code synthesis in Python. In the real world, developers need models that can also explain existing code, fix bugs, and work across dozens of different programming languages. OctoPack introduces a novel way to instruction-tune code LLMs by leveraging the natural structure of Git commits—pairing human-written commit messages with code changes—to create state-of-the-art, permissively licensed code models.

Methods: Git Commits as Natural Instructions

The core innovation of OctoPack is treating Git commits as a "natural" instruction-tuning dataset. Git history is a goldmine of human intent. By filtering for high-quality commit messages, researchers can bypass the need for expensive manual labeling or closed-source model generation. A Git commit naturally consists of:

  1. Code Before: The state of the file before the change.
  2. Commit Message: A human-written instruction describing the change.
  3. Code After: The resulting code.
Overview of the OctoPack approach, showing how Git commits are transformed into instruction-following pairs.

The researchers fine-tuned the 16B-parameter StarCoder model and the 6B-parameter CodeGeeX2 model using this commit-based format. To ensure the models could still handle natural language conversations, they mixed the code data with the OASST (Open Assistant) dataset. The resulting models are named OctoCoder and OctoGeeX, respectively.

New Datasets and Benchmarks

To support this training and evaluation, the authors introduced several new resources:

  • CommitPack: A gargantuan 4TB dataset of permissively licensed Git commits spanning 350 programming languages.
  • CommitPackFT: A high-quality, filtered 2GB subset of CommitPack specifically curated for fine-tuning.
  • HumanEvalPack: A rigorous new benchmark that expands the original HumanEval to three distinct tasks—Code Repair (Fixing), Code Explanation, and Code Synthesis—across six major languages: Python, JavaScript, Java, Go, C++, and Rust.

Key Insights and Results

Fine-tuning on CommitPackFT proved to be highly effective, particularly for tasks that traditional instruction tuning misses.

  • State-of-the-Art Permissive Model: OctoCoder achieved a 46.2% pass@1 on the HumanEval Python benchmark, the highest score for any model not trained on OpenAI-generated outputs.
  • Benchmark Dominance: OctoCoder and OctoGeeX outperformed all other permissive models (like StarCoder and BLOOMZ) across the entire HumanEvalPack suite.
  • The "Fixing" Criticality: Training on Git commits is uniquely effective for teaching models how to fix bugs. Standard instruction datasets (like OASST) provide almost no benefit for code repair, whereas CommitPack provides a massive performance boost.
  • Cross-lingual Generalization: Instruction tuning on a diverse set of languages improves performance even on languages not heavily represented in the fine-tuning set, provided they were present during the initial pre-training phase.
Performance of OctoCoder and OctoGeeX on the HumanEvalPack benchmark compared to other models.

The authors also noted an "Explanation Gap." Models trained purely on code-to-code tasks (like commits) struggle to explain code in natural language. Mixing in a small amount of high-quality natural language dialogue (OASST) was essential to create a well-rounded assistant.

Limitations and Future Work

While OctoCoder represents a significant step forward, current models still exhibit output length sensitivity, often writing too much or too little when given strict length constraints. Furthermore, while OctoCoder is better at fixing bugs than its predecessors, it still struggles with very subtle logic errors compared to massive proprietary models. Future iterations could explore multi-file changes to better reflect complex software engineering tasks and scale the base model beyond 16B parameters for even stronger results.

Summary updated

BibTeX
@inproceedings{muennighoff2024octopack,
  author = {Niklas Muennighoff and Qian Liu and Armel Randy Zebaze and Qinkai Zheng and Binyuan Hui and Terry Yue Zhuo and Swayam Singh and Xiangru Tang and Leandro Von Werra and Shayne Longpre},
  title = {{OctoPack: Instruction Tuning Code Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=mw1PWNSWZP},
}
Figure