Papers › SelfCodeAlign: Self-Alignment for Code Generation

SelfCodeAlign: Self-Alignment for Code Generation

31 Oct 2024arXiv:2410.24198archive 2025-07-28

Yuxiang Wei, Federico Cassano, Jiawei Liu, Yifeng Ding, Naman jain, Zachary Mueller, Harm de Vries, Leandro von Werra, Arjun Guha, Lingming Zhang

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.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2410.24198")

Code

Syntology Ran 13 of 37 code samples harvested from 3 repositories linked to this paper; 24 have no recorded run. Of those that ran: 1 ran · honoured contract; 8 ran · our draft was wrong; 4 ran with no contract checked.

By repository: official repository: 12 samples from 1 repository, 9 ran; community (archive-listed): 22 samples from 1 repository, 1 ran; community: 3 samples from 1 repository, 3 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

bigcode-project/selfcodealign officialmentioned in papermentioned on GitHub report
bigcode-project/starcoder2-self-align mentioned on GitHubApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

37 samples harvested; 13 ran; 1 honoured the contract we drafted; 24 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
8ran · our draft was wrong
4ran
24unverified

Licence: 0 of the 37 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 3 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Args bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran Apache-2.0 (permissive) · ae0b66e2959a4a8b · report
Example bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran Apache-2.0 (permissive) · ce4e9324e38a0ddf · report
Property bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran Apache-2.0 (permissive) · 5b83b230eb85881a · report
build_kwargs bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 8dd50472f41a7528 · report
flatten_openai_responses bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 1fc3a1bcc54c9a56 · report
parse_generated_content bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran · our draft was wrong Apache-2.0 (permissive) · a75703b3e4e8a6a7 · report
parse_property bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository ran · our draft was wrong Apache-2.0 (permissive) · fba12f4a4a9f3c28 · report
postprocess bigcode-project/selfcodealign/evaluation/ds_1000.py official repository ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 1173d57fe1b4d158 · report
preprocess_completion_prompt bigcode-project/selfcodealign/evaluation/ds_1000.py official repository ran · our draft was wrong Apache-2.0 (permissive) · 956cd0aa1cec0821 · report
Fewshot bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository unverified Apache-2.0 (permissive) · 69d27e542d70e540 · report
get_ossinstruct_fewshots bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository unverified Apache-2.0 (permissive) · d063f1765c316bac · report
main bigcode-project/selfcodealign/src/star_align/self_ossinstruct.py official repository unverified Apache-2.0 (permissive) · 5c02c0de38a6ae98 · report
extract_docstring bigcode-project/starcoder2-self-align/src/star_align/decontamination/benchmark_data.py community (archive-listed) ran Apache-2.0 (permissive) · 0edeacd7a9034f53 · report
benchmark_name_to_filter_reason bigcode-project/starcoder2-self-align/src/star_align/decontamination/find_substrings.py community (archive-listed) unverified Apache-2.0 (permissive) · a349a736c168650a · report
chunked bigcode-project/starcoder2-self-align/src/star_align/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · a6974ed3c2ddb7eb · report
containerized_run bigcode-project/starcoder2-self-align/src/star_align/execution_filter.py community (archive-listed) unverified Apache-2.0 (permissive) · 17b4339501de907f · report
extract_and_concat_function_names bigcode-project/starcoder2-self-align/src/star_align/clean_data.py community (archive-listed) unverified Apache-2.0 (permissive) · ab5fa2503ae7af82 · report
extract_code_with_indentation bigcode-project/starcoder2-self-align/src/star_align/collect_snippets.py community (archive-listed) unverified Apache-2.0 (permissive) · 5483cff90bd19eb8 · report
extract_ds_1000_prompt bigcode-project/starcoder2-self-align/src/star_align/decontamination/benchmark_data.py community (archive-listed) unverified Apache-2.0 (permissive) · 2160a71414dde9a6 · report
extract_snippets_with_constraints bigcode-project/starcoder2-self-align/src/star_align/collect_snippets.py community (archive-listed) unverified Apache-2.0 (permissive) · 465ba803e1fe81b9 · report
filter_reason_to_benchmark_name bigcode-project/starcoder2-self-align/src/star_align/decontamination/find_substrings.py community (archive-listed) unverified Apache-2.0 (permissive) · 9c5b01ef26d74c74 · report
form_starcoder_infill bigcode-project/starcoder2-self-align/src/star_align/llm_wrapper.py community (archive-listed) unverified Apache-2.0 (permissive) · 971c70adc27358da · report
get_model_context bigcode-project/starcoder2-self-align/src/star_align/llm_wrapper.py community (archive-listed) unverified Apache-2.0 (permissive) · 1415e89bd7265711 · report
load_dataset_column bigcode-project/starcoder2-self-align/src/star_align/decontamination/benchmark_data.py community (archive-listed) unverified Apache-2.0 (permissive) · 9c7f0c27b8d08b0f · report
make_python_membound_code_prefix bigcode-project/starcoder2-self-align/src/star_align/execution_filter.py community (archive-listed) unverified Apache-2.0 (permissive) · 8c087c3185ff5fab · report
ngrams bigcode-project/starcoder2-self-align/src/star_align/minhash_dedup.py community (archive-listed) unverified Apache-2.0 (permissive) · a0d7edeceb109990 · report
pad_sequences bigcode-project/starcoder2-self-align/src/star_align/llm_wrapper.py community (archive-listed) unverified Apache-2.0 (permissive) · 7b178c461482e3f6 · report
read_jsonl bigcode-project/starcoder2-self-align/src/star_align/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · b0fdb2b203090d2e · report
retry bigcode-project/starcoder2-self-align/src/star_align/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · e10de9c97d0ec5c5 · report
sha1_hash bigcode-project/starcoder2-self-align/src/star_align/minhash_dedup.py community (archive-listed) unverified Apache-2.0 (permissive) · e5358426087cdd76 · report
split_llama3_response_tests bigcode-project/starcoder2-self-align/src/star_align/sanitize_data.py community (archive-listed) unverified Apache-2.0 (permissive) · 13b161a5bbc15829 · report
suppress_output bigcode-project/starcoder2-self-align/src/star_align/execution_filter.py community (archive-listed) unverified Apache-2.0 (permissive) · d2c4d113d519cc11 · report
update_benchmark_dict bigcode-project/starcoder2-self-align/src/star_align/decontamination/find_substrings.py community (archive-listed) unverified Apache-2.0 (permissive) · 303bc7228b4758e6 · report
xxh3_16hash bigcode-project/starcoder2-self-align/src/star_align/minhash_dedup.py community (archive-listed) unverified Apache-2.0 (permissive) · b85036e1fe10ab3b · report
encode_prompt sahil280114/codealpaca/generate_instruction.py community ran · our draft was wrong Apache-2.0 (permissive) · 9b2dd0265fc6e6b6 · report
find_word_in_string sahil280114/codealpaca/generate_instruction.py community ran · our draft was wrong fingerprinted Apache-2.0 (permissive) · 8ca6a5f9f77053c2 · report
post_process_gpt3_response sahil280114/codealpaca/generate_instruction.py community ran · honoured contract Apache-2.0 (permissive) · a5e4ad4e11cf2143 · report

Tasks

Code GenerationHumanEval

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBASEBPECosine AnnealingDense ConnectionsDropoutGPT-3Layer NormalizationLinear LayerLinear Warmup With Cosine AnnealingMulti-Head AttentionResidual ConnectionSoftmaxWeight Decay

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections