SelfCodeAlign: Self-Alignment for Code Generation

Yuxiang Wei, Federico Cassano, Jiawei Liu, Yifeng Ding, Naman Jain +5 more
10/31/2024
cs.CLcs.LGcs.SE

No official code found. Best implementation: bigcode-project/selfcodealign (324 stars, Apache-2.0, last commit 2025-02-24).

Abstract

Instruction tuning is a supervised fine-tuning approach that significantly improves the ability of large language models (LLMs) to follow human instructions. We propose SelfCodeAlign, the first fully transparent and permissive pipeline for self-aligning code LLMs without extensive human annotations or distillation. SelfCodeAlign employs the same base model for inference throughout the data generation process. It first extracts diverse coding concepts from high-quality seed snippets to generate new tasks. It then samples multiple responses per task, pairs each with test cases, and validates them in a sandbox environment. Finally, passing examples are selected for instruction tuning. In our primary experiments, we use SelfCodeAlign with CodeQwen1.5-7B to generate a dataset of 74k instruction-response pairs. Finetuning on this dataset leads to a model that achieves a 67.1 pass@1 on HumanEval+, surpassing CodeLlama-70B-Instruct despite being ten times smaller. Across all benchmarks, this finetuned model consistently outperforms the original version trained with OctoPack, the previous state-of-the-art method for instruction tuning without human annotations or distillation. Additionally, we show that SelfCodeAlign is effective across LLMs of various sizes, from 3B to 33B, and that the base models can benefit more from alignment with their own data distribution. We further validate each component's effectiveness in our pipeline, showing that SelfCodeAlign outperforms both direct distillation from GPT-4o and leading GPT-3.5-based distillation methods, such as OSS-Instruct and Evol-Instruct. SelfCodeAlign has also led to the creation of StarCoder2-Instruct, the first fully transparent, permissively licensed, and self-aligned code LLM that achieves state-of-the-art coding performance.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[NeurIPS'24] SelfCodeAlign: Self-Alignment for Code Generation

32424Shell, PythonApr 25, 20241 years agoApache-2.0
large-language-modelsllmllm4code

Similar Papers

Cite this paper

@article{wei2024selfcodealign,
  title  = {SelfCodeAlign: Self-Alignment for Code Generation},
  author = {Yuxiang Wei and Federico Cassano and Jiawei Liu and Yifeng Ding and Naman Jain and Zachary Mueller and Harm de Vries and Leandro von Werra and Arjun Guha and Lingming Zhang},
  year   = {2024},
  eprint = {2410.24198},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2410.24198},
  url    = {http://arxiv.org/abs/2410.24198v2},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.24198.svg)](https://codeofpaper.com/paper/2410.24198)

Discussion