jacobfulano commited on
Commit
1585186
1 Parent(s): c7c860a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +220 -0
README.md ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ base_model: meta-llama/Llama-2-7b-hf
4
+ license: cc-by-nc-4.0
5
+ datasets:
6
+ - meta-math/MetaMathQA
7
+ - open-web-math/open-web-math
8
+ - bigcode/starcoderdata
9
+ - ise-uiuc/Magicoder-Evol-Instruct-110K
10
+ language:
11
+ - en
12
+ ---
13
+
14
+ # LoRA Learns Less and Forgets Less
15
+
16
+
17
+ These are model checkpoints and LoRA adapters from the research paper ["LoRA Learns Less and Forgets Less"](https://arxiv.org/abs/2405.09673) (Biderman et al. TMLR, 2024). This work was done in collaboration with [Databricks Mosaic AI Research](https://www.databricks.com/research/mosaic).
18
+
19
+
20
+ ## Model Details
21
+
22
+
23
+ - **Developed by:** Databricks Mosaic AI
24
+ - **Model type:** Research Artifacts
25
+ - **Language(s) (NLP):** English
26
+ - **License:** cc-by-nc-4.0
27
+ - **Finetuned from model:** Llama-2-7b
28
+
29
+ We trained [Llama-2-7B](https://huggingface.co/meta-llama/Llama-2-7b-hf) using full finetuning and LoRA. Model checkpoints and LoRA adapters can be found on HuggingFace here: [LoRA-TMLR-2024](https://huggingface.co/LoRA-TMLR-2024). Intermediate checkpoints can be found in the branches of the respective models.
30
+
31
+
32
+ | Setting | Dataset | HuggingFace Collection |
33
+ | --------| ------| ------ |
34
+ | Continued Pretraining - Code | [StarCoder-Python](https://huggingface.co/datasets/bigcode/starcoderdata) | [LoRA-TMLR-2024/continued-pretraining-code-starcoder-python](https://huggingface.co/collections/LoRA-TMLR-2024/continued-pretraining-code-starcoder-python-66f22ce3b26f416f21f58142) |
35
+ | Continued Pretraing - Math | [OpenWebMath](https://huggingface.co/datasets/open-web-math/open-web-math) | [LoRA-TMLR-2024/continued-pretraining-math-openwebmath](https://huggingface.co/collections/LoRA-TMLR-2024/continued-pretraining-math-openwebmath-66f31d12f55fb27de05b2e3f) |
36
+ | Instruction Finetuning - Code | [Magicoder-Evol-Instruct-110K](https://huggingface.co/datasets/ise-uiuc/Magicoder-Evol-Instruct-110K)| [LoRA-TMLR-2024/instruction-finetuning-code-magicoder-evol-instruct-110k](https://huggingface.co/collections/LoRA-TMLR-2024/instruction-finetuning-code-magicoder-evol-instruct-110k-66f224a800152f31e4942a3b) |
37
+ | Instruction Finetuning - Math | [MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) | [LoRA-TMLR-2024/instruction-finetuning-math-metamathqa](https://huggingface.co/collections/LoRA-TMLR-2024/instruction-finetuning-math-metamathqa-66f31cc40fda6b6b938d33e2) |
38
+
39
+ All training was done using the Databricks MosaicML
40
+ [composer](https://github.com/mosaicml/composer), [streaming](https://github.com/mosaicml/streaming), and [llm-foundry](https://github.com/mosaicml/llm-foundry) repositories, as well as the HuggingFace [peft](https://huggingface.co/docs/peft/en/index) library.
41
+
42
+ ### Model Sources
43
+
44
+ <!-- Provide the basic links for the model. -->
45
+
46
+ - **Repository:** [https://github.com/danbider/lora-tradeoffs](https://github.com/danbider/lora-tradeoffs)
47
+ - **Paper:** [LoRA Learns Less and Forgets Less](https://arxiv.org/abs/2405.09673)
48
+
49
+ ### Abstract
50
+
51
+ Low-Rank Adaptation (LoRA) is a widely-used parameter-efficient finetuning method for
52
+ large language models. LoRA saves memory by training only low rank perturbations to
53
+ selected weight matrices. In this work, we compare the performance of LoRA and full
54
+ finetuning on two target domains, programming and mathematics. We consider both the
55
+ instruction finetuning (≈100K prompt-response pairs) and continued pretraining (≈20B
56
+ unstructured tokens) data regimes. Our results show that, in the standard low-rank settings,
57
+ LoRA substantially underperforms full finetuning. Nevertheless, LoRA better maintains the
58
+ base model’s performance on tasks outside the target domain. We show that LoRA mitigates
59
+ forgetting more than common regularization techniques such as weight decay and dropout;
60
+ it also helps maintain more diverse generations. Finally, we show that full finetuning learns
61
+ perturbations with a rank that is 10-100× greater than typical LoRA configurations, possibly
62
+ explaining some of the reported gaps. We conclude by proposing best practices for finetuning
63
+ with LoRA.
64
+
65
+ ## Uses
66
+
67
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
68
+ These are research artifacts that are intended for research purposes only.
69
+
70
+
71
+ ## Training Details
72
+
73
+ ### Training Data
74
+
75
+ <!-- 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. -->
76
+
77
+ The following datasets were used:
78
+
79
+ | Setting | Dataset |
80
+ | --------| ------|
81
+ | Continued Pretraining - Code | [StarCoder-Python](https://huggingface.co/datasets/bigcode/starcoderdata) |
82
+ | Continued Pretraing - Math | [OpenWebMath](https://huggingface.co/datasets/open-web-math/open-web-math) |
83
+ | Instruction Finetuning - Code | [Magicoder-Evol-Instruct-110K](https://huggingface.co/datasets/ise-uiuc/Magicoder-Evol-Instruct-110K)|
84
+ | Instruction Finetuning - Math | [MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) |
85
+
86
+
87
+ ### Training Procedure
88
+
89
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
90
+
91
+ In all four scenarios below, we use the Llama-2-7B base model [meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf). For
92
+ the CPT runs, we use the [meta-llama/Llama-2-7b-hf](https://huggingface.co/meta-llama/Llama-2-7b-hf) tokenizer, while for the IFT runs we use the
93
+ [meta-llama/Llama-2-7b-chat-hf](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf) tokenizer.
94
+
95
+
96
+ ## Code CPT (StarCoder-Python)
97
+
98
+ [StarCoder-Python](https://huggingface.co/datasets/bigcode/starcoderdata) (Li et al., 2023a) This dataset consists of permissively licensed repositories from GitHub, including Git commits, in 80+ programming languages. We chose the Python
99
+ subset and sub-sampled it to 20B tokens.
100
+
101
+ | Parameter | Value |
102
+ |------------------------------|-----------------------------------------------------------------------------------------|
103
+ | seq_len | 4096 |
104
+ | optimizer | decoupled_lionw (betas=[0.9, 0.95]) |
105
+ | learning_rate | 1.0e-05 for LoRA and Full Finetuning |
106
+ | scheduler | inv_sqrt_with_warmup (t_scale=1000ba, t_warmup=1000ba, t_cooldown=5086ba, alpha_f_decay=1, alpha_f_cooldown=0) |
107
+ | weight_decay | 1.0e-06 |
108
+ | precision | amp_bf16 |
109
+ | global_train_batch_size | 192 |
110
+ | device_train_microbatch_size | 6 |
111
+ | gradient_clipping | norm (threshold=1) |
112
+ | num_gpus | 32 |
113
+
114
+ 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.
115
+
116
+ ## Math CPT (OpenWebMath)
117
+
118
+ [OpenWebMath](https://huggingface.co/datasets/open-web-math/open-web-math) (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.
119
+
120
+ | Parameter | Value |
121
+ |------------------------------|-----------------------------------------------------------------------------------------|
122
+ | max_seq_len | 4096 |
123
+ | optimizer | decoupled_lionw (betas=[0.9, 0.95]) |
124
+ | learning_rate | 1.0e-05 for full finetuning, 4.0e-05 for LoRA |
125
+ | scheduler | inv_sqrt_with_warmup (t_scale=1000ba, t_warmup=1000ba, t_cooldown=5086ba, alpha_f_decay=1, alpha_f_cooldown=0) |
126
+ | weight_decay | 0 |
127
+ | precision | amp_bf16 |
128
+ | global_train_batch_size | 192 |
129
+ | device_train_microbatch_size | 6 |
130
+ | gradient_clipping | norm (threshold=1) |
131
+ | num_gpus | 32 |
132
+
133
+
134
+ 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.
135
+
136
+ ## Code IFT (Magicoder-Evol-Instruct-110K)
137
+
138
+ [Magicoder-Evol-Instruct-110K](https://huggingface.co/datasets/ise-uiuc/Magicoder-Evol-Instruct-110K) (Wei et al., 2023) This dataset contains 72.97M tokens
139
+ 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
140
+ from Code Alpaca (Chaudhary, 2023).
141
+
142
+ | Parameter | Value |
143
+ |------------------------------|-----------------------------------------------------------------------------------------|
144
+ | max_seq_len | 4096 |
145
+ | optimizer | decoupled_lionw (betas=[0.9, 0.95]) |
146
+ | learning_rate | 5e-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) |
147
+ | scheduler | cosine_with_warmup (alpha_f=0.01, t_warmup=0.1dur) |
148
+ | weight_decay | 0 |
149
+ | precision | amp_bf16 |
150
+ | global_train_batch_size | 192 |
151
+ | device_train_microbatch_size | 6 |
152
+ | gradient_clipping | norm (threshold=1) |
153
+ | num_gpus | 32 |
154
+
155
+ Each model was finetuned separately for 1, 2, 4, 8 and 16 epochs.
156
+
157
+ | Epoch | Number of Batches | Estimated Tokens |
158
+ | -------- | ---------- | ----------------|
159
+ | 1 | 193 | 72,970,000 |
160
+ | 2 | 386 | 145,940,000 |
161
+ | 4 | 772 | 291,880,000 |
162
+ | 8 | 1544 | 583,760,000 |
163
+ | 16 | 3088 | 1,167,520,000 |
164
+
165
+ ## Math IFT (MetaMathQA)
166
+
167
+ [MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA) (Yu et al., 2023) This dataset was built by bootstrapping mathematical
168
+ word problems from the training sets of GSM8K (Cobbe et al., 2021) and MATH (Hendrycks et al., 2021) by
169
+ rewriting the questions with variations using GPT-3.5. This dataset contains 395K question-answer pairs and
170
+ roughly 103M tokens.
171
+
172
+ | Parameter | Value |
173
+ |------------------------------|-----------------------------------------------------------------------------------------|
174
+ | seq_len | 1024 |
175
+ | optimizer | decoupled_lionw (betas=[0.9, 0.95]) |
176
+ | learning_rate | Full finetuning: 1e-5, LoRA: 1e-4 for r = 16, 64, 5e-5 for r = 256 due to instabilities |
177
+ | scheduler | cosine_with_warmup (alpha_f=0.01, t_warmup=0.1dur) |
178
+ | weight_decay | 0 |
179
+ | precision | amp_bf16 |
180
+ | global_train_batch_size | 768 |
181
+ | device_train_microbatch_size | 24 |
182
+ | gradient_clipping | norm (threshold=1) |
183
+ | num_gpus | 32 |
184
+
185
+ Each model was finetuned separately for 1, 2, 4, 8 and 16 epochs.
186
+
187
+ | Epoch | Estimated Tokens |
188
+ | -------- | ----------------|
189
+ | 1 | 103,000,000 |
190
+ | 2 | 206,000,000 |
191
+ | 4 | 412,000,000 |
192
+ | 8 | 824,000,000 |
193
+ | 16 | 1,648,000,000 |
194
+
195
+ ## Evaluation
196
+
197
+ Model performance can be found in the paper [LoRA Learns Less and Forgets Less](https://arxiv.org/pdf/2405.09673). See Appendix for relevant tables.
198
+
199
+
200
+ ## Citation
201
+
202
+ **BibTeX:**
203
+
204
+ ```
205
+ @article{
206
+ biderman2024lora,
207
+ title={Lo{RA} Learns Less and Forgets Less},
208
+ 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},
209
+ journal={Transactions on Machine Learning Research},
210
+ issn={2835-8856},
211
+ year={2024},
212
+ url={https://openreview.net/forum?id=aloEru2qCG},
213
+ note={Featured Certification}
214
+ }
215
+ ```
216
+
217
+
218
+ ### Framework versions
219
+
220
+ - PEFT 0.11.1