CoolFace
Modelpublic

LoRA-TMLR-2024/starcoder-full-finetuning-lr-1e-05-20B-token

sourceHugging Facecc-by-nc-4.0updated 2y agoView on Hugging Face
0likes
Model Card

LoRA Learns Less and Forgets Less

These are model checkpoints and LoRA adapters from the research paper "LoRA Learns Less and Forgets Less" (Biderman et al. TMLR, 2024). This work was done in collaboration with Databricks Mosaic AI Research.

Model Details

  • —Developed by: Databricks Mosaic AI
  • —Model type: Research Artifacts
  • —Language(s) (NLP): English
  • —License: cc-by-nc-4.0
  • —Finetuned from model: Llama-2-7b

We trained Llama-2-7B using full finetuning and LoRA. Model checkpoints and LoRA adapters can be found on HuggingFace here: LoRA-TMLR-2024. Intermediate checkpoints can be found in the branches of the respective models.

All training was done using the Databricks MosaicML composer, streaming, and llm-foundry repositories, as well as the HuggingFace peft library.

Model Sources

<!-- Provide the basic links for the model. -->

Abstract

Low-Rank Adaptation (LoRA) is a widely-used parameter-efficient finetuning method for large language models. LoRA saves memory by training only low rank perturbations to selected weight matrices. In this work, we compare the performance of LoRA and full finetuning on two target domains, programming and mathematics. We consider both the instruction finetuning (≈100K prompt-response pairs) and continued pretraining (≈20B unstructured tokens) data regimes. Our results show that, in the standard low-rank settings, LoRA substantially underperforms full finetuning. Nevertheless, LoRA better maintains the base model’s performance on tasks outside the target domain. We show that LoRA mitigates forgetting more than common regularization techniques such as weight decay and dropout; it also helps maintain more diverse generations. Finally, we show that full finetuning learns perturbations with a rank that is 10-100× greater than typical LoRA configurations, possibly explaining some of the reported gaps. We conclude by proposing best practices for finetuning with LoRA.

Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. --> These are research artifacts that are intended for research purposes only.

Training Details

Training Data

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

The following datasets were used:

SettingDataset
Continued Pretraining - CodeStarCoder-Python
Continued Pretraing - MathOpenWebMath
Instruction Finetuning - CodeMagicoder-Evol-Instruct-110K
Instruction Finetuning - MathMetaMathQA

Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

In all four scenarios below, we use the Llama-2-7B base model meta-llama/Llama-2-7b-hf. For the CPT runs, we use the meta-llama/Llama-2-7b-hf tokenizer, while for the IFT runs we use the meta-llama/Llama-2-7b-chat-hf tokenizer.

Code CPT (StarCoder-Python)

StarCoder-Python (Li et al., 2023a) This dataset consists of permissively licensed repositories from GitHub, including Git commits, in 80+ programming languages. We chose the Python subset and sub-sampled it to 20B tokens.

ParameterValue
seq_len4096
optimizerdecoupled_lionw (betas=[0.9, 0.95])
learning_rate1.0e-05 for LoRA and Full Finetuning
schedulerinvsqrtwithwarmup (tscale=1000ba, twarmup=1000ba, tcooldown=5086ba, alphafdecay=1, alphafcooldown=0)
weight_decay1.0e-06
precisionamp_bf16
globaltrainbatch_size192
devicetrainmicrobatch_size6
gradient_clippingnorm (threshold=1)
num_gpus32

We trained models for 0.25B, 0.5B, 1B, 2B, 4B, 8B, 16B and 20B tokens. These checkpoints can be found for each LoRA and full finetuning setting in the HuggingFace model branches.

Math CPT (OpenWebMath)

OpenWebMath (Paster et al., 2023) - This dataset contains 14.7B tokens derived from mathematical web pages from Common Crawl, correctly formatted to preserve mathematical content such as LaTeX equations. To match with the StarCoder-Python dataset, we trained on up to 20B tokens, repeating tokens beyond the first 14.7B. An analysis of this dataset shows that it contains a considerable amount of full English sentences.

ParameterValue
maxseqlen4096
optimizerdecoupled_lionw (betas=[0.9, 0.95])
learning_rate1.0e-05 for full finetuning, 4.0e-05 for LoRA
schedulerinvsqrtwithwarmup (tscale=1000ba, twarmup=1000ba, tcooldown=5086ba, alphafdecay=1, alphafcooldown=0)
weight_decay0
precisionamp_bf16
globaltrainbatch_size192
devicetrainmicrobatch_size6
gradient_clippingnorm (threshold=1)
num_gpus32

We trained models for 0.25B, 0.5B, 1B, 2B, 4B, 8B, 16B and 20B tokens. These checkpoints can be found for each LoRA and full finetuning setting in the HuggingFace model branches.

Code IFT (Magicoder-Evol-Instruct-110K)

Magicoder-Evol-Instruct-110K (Wei et al., 2023) This dataset contains 72.97M tokens of programming questions and answers. It reproduces the “Evol-Instruct” dataset of WizardCoder (Luo et al., 2023b) by iteratively prompting an LLM (GPT-4) to increase the difficulty of a set of question-answer pairs from Code Alpaca (Chaudhary, 2023).

ParameterValue
maxseqlen4096
optimizerdecoupled_lionw (betas=[0.9, 0.95])
learning_rate5e-5 for full finetuning; 2e-4 for rank r = 16, 64 and 1e-4 for r = 256 α = 2r = 512 (due to instabilities/loss spikes at 2e-4)
schedulercosinewithwarmup (alphaf=0.01, twarmup=0.1dur)
weight_decay0
precisionamp_bf16
globaltrainbatch_size192
devicetrainmicrobatch_size6
gradient_clippingnorm (threshold=1)
num_gpus32

Each model was finetuned separately for 1, 2, 4, 8 and 16 epochs.

EpochNumber of BatchesEstimated Tokens
119372,970,000
2386145,940,000
4772291,880,000
81544583,760,000
1630881,167,520,000

Math IFT (MetaMathQA)

MetaMathQA (Yu et al., 2023) This dataset was built by bootstrapping mathematical word problems from the training sets of GSM8K (Cobbe et al., 2021) and MATH (Hendrycks et al., 2021) by rewriting the questions with variations using GPT-3.5. This dataset contains 395K question-answer pairs and roughly 103M tokens.

ParameterValue
seq_len1024
optimizerdecoupled_lionw (betas=[0.9, 0.95])
learning_rateFull finetuning: 1e-5, LoRA: 1e-4 for r = 16, 64, 5e-5 for r = 256 due to instabilities
schedulercosinewithwarmup (alphaf=0.01, twarmup=0.1dur)
weight_decay0
precisionamp_bf16
globaltrainbatch_size768
devicetrainmicrobatch_size24
gradient_clippingnorm (threshold=1)
num_gpus32

Each model was finetuned separately for 1, 2, 4, 8 and 16 epochs.

EpochEstimated Tokens
1103,000,000
2206,000,000
4412,000,000
8824,000,000
161,648,000,000

Evaluation

Model performance can be found in the paper LoRA Learns Less and Forgets Less. See Appendix for relevant tables.

Citation

BibTeX:

@article{
biderman2024lora,
title={Lo{RA} Learns Less and Forgets Less},
author={Dan Biderman and Jacob Portes and Jose Javier Gonzalez Ortiz and Mansheej Paul and Philip Greengard and Connor Jennings and Daniel King and Sam Havens and Vitaliy Chiley and Jonathan Frankle and Cody Blakeney and John Patrick Cunningham},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2024},
url={https://openreview.net/forum?id=aloEru2qCG},
note={Featured Certification}
}

Framework versions

  • —PEFT 0.11.1