Training CodeParrot 🦜 from Scratch
CodeParrot is a GPT-2 model (110M and 1.5B parameters) trained from scratch for Python code completion, using a 180 GB GitHub Python dump from BigQuery. Heavy duplication in that dump (10% of unique files made up 66% of all files) hurt model quality, so deduplication plus Codex-style filtering cut it to a 50 GB clean dataset. The guide walks through training a code-specific tokenizer, initializing a GPT-2-large config with attention stability flags, a streaming constant-length dataset, and a ~150-line distributed training loop with 🤗 Accelerate using gradient accumulation and checkpoints pushed to the Hub. Training ran on 16 A100s for 1 day (small) and 1 week (large) on about 25-30B tokens, and the models were evaluated on HumanEval with the pass@k metric.
Related posts
- StarCoder: A State-of-the-Art LLM for Code
Hugging Face easyNoviceStarCoder and StarCoderBase are ~15B-parameter code LLMs trained on 1 trillion tokens of permissively licensed GitHub data from The Stack 1.2, covering 80+ languages, commits, issues and notebooks, with StarCoder further fine-tuned on 35B Python tokens. With an 8K+ token context, they beat other open code models and match or exceed OpenAI's code-cushman-001 on HumanEval, MBPP, MultiPL-E and DS-1000. A solution-file prompt prefix lifts StarCoder's HumanEval score from 34% to 40.8%, and prompting alone turns the model into a technical assistant. The release includes weights under OpenRAIL-M, training code, an evaluation harness, a PII-redaction dataset and a code attribution tool.
- Code Llama: Meta’s state-of-the-art LLM for coding
Meta Engineering easyNoviceCode Llama is a code-specialized family of Llama 2 models, built by further training Llama 2 on 500B tokens of code (1T for the 70B model). It ships in 7B, 13B, 34B and 70B sizes, as base, Python-specialized and instruction-tuned variants. The 7B and 13B models support fill-in-the-middle for code completion and are suited to low-latency use. The larger models give better results, and all models handle up to 100K tokens of context despite training on 16K sequences. Code Llama 34B scored 53.7% on HumanEval and 56.2% on MBPP, on par with ChatGPT. The models are free for research and commercial use, and the Instruct variants are recommended for code generation.
- Beat GPT-4o at Python by searching with 100 dumb LLaMAs
Modal mediumAdept
Sampling LLaMA 3.1 8B Instruct many times and checking each candidate against HumanEval's unit tests raises pass@k from 66.4% at k=1 to 90.5% at k=100, matching GPT-4o's reported 90.2% pass@1, and to 95.1% at k=1000. This replicates the core claim of the Large Language Monkeys paper on a new model and dataset, with fail@k following a smooth log-log scaling law across three orders of magnitude. The setup used vLLM with prefix caching on ten A100s, reaching about 40k output tokens/s, plus Modal Sandboxes running about 3,000 isolated test executions in parallel, all for under $50. The larger argument is that search trades memory for compute and depends on fast, objective evaluation, so domains with verifiable outcomes like code and formal math benefit most.
- Code Llama: Llama 2 learns to code
Hugging Face mediumAdeptCode Llama is a family of 7B, 13B and 34B Llama 2 derivatives trained on 500B tokens of code. It comes in base, Python-specialized and instruction-tuned variants, has a 16k training context that extrapolates to 100k via RoPE frequency scaling, and supports fill-in-the-middle infilling in the 7B and 13B models. Hugging Face integration starts at transformers 4.33, with code for completion, infilling with the <FILL_ME> token, the Llama 2 chat prompt template, and 4-bit bitsandbytes loading. Recommended setup is float16 for inference and bfloat16 for fine-tuning, plus GPU sizing guidance for TGI/Inference Endpoints and HumanEval/MultiPL-E evaluation.
- StarCoder2-Instruct: Fully Transparent and Permissive Self-Alignment for Code Generation
Hugging Face hardMasterStarCoder2-15B-Instruct is instruction-tuned entirely on data generated by its own base model, with no human annotations or distillation from proprietary LLMs. The pipeline filters 5M docstring-bearing Python functions from The Stack v1 down to 250k seeds using Pyright type checking, decontamination, LLM-judged docstring quality and MinHash deduplication. It then has the model extract code concepts and write 238k instructions, and keeps only responses that pass self-generated tests executed in a sandbox, ending with 50k SFT pairs. The model scores 72.6 on HumanEval, beating CodeLlama-70B-Instruct, and outperforms a GPT-4-distilled variant on LiveCodeBench, suggesting models learn better from in-distribution self-generated data.