Safetensors
Tim Dettmers commited on
Commit
3179178
1 Parent(s): 3816f5e

adding readme and license

Browse files
Files changed (2) hide show
  1. LICENSE.txt +202 -0
  2. README.md +172 -0
LICENSE.txt ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Guanaco Models Based on LLaMA
2
+
3
+ | [Paper](https://arxiv.org/abs/2305.14314) | [Code](https://github.com/artidoro/qlora) | [Demo](https://huggingface.co/spaces/uwnlp/guanaco-playground-tgi) |
4
+
5
+ **The Guanaco models are open-source finetuned chatbots obtained through 4-bit QLoRA tuning of LLaMA base models on the OASST1 dataset. They are available in 7B, 13B, 33B, and 65B parameter sizes.**
6
+
7
+ ⚠️Guanaco is a model purely intended for research purposes and could produce problematic outputs.
8
+
9
+ ## Why use Guanaco?
10
+ - **Competitive with commercial chatbot systems on the Vicuna and OpenAssistant benchmarks** (ChatGPT and BARD) according to human and GPT-4 raters. We note that the relative performance on tasks not covered in these benchmarks could be very different. In addition, commercial systems evolve over time (we used outputs from the March 2023 version of the models).
11
+ - **Available open-source for research purposes**. Guanaco models allow *cheap* and *local* experimentation with high-quality chatbot systems.
12
+ - **Replicable and efficient training procedure** that can be extended to new use cases. Guanaco training scripts are available in the [QLoRA repo](https://github.com/artidoro/qlora).
13
+ - **Rigorous comparison to 16-bit methods** (both 16-bit full-finetuning and LoRA) in [our paper](https://arxiv.org/abs/2305.14314) demonstrates the effectiveness of 4-bit QLoRA finetuning.
14
+ - **Lightweight** checkpoints which only contain adapter weights.
15
+
16
+ ## License and Intended Use
17
+ Guanaco adapter weights are available under Apache 2 license. Note the use of the Guanaco adapter weights, requires access to the LLaMA model weighs.
18
+ Guanaco is based on LLaMA and therefore should be used according to the LLaMA license.
19
+
20
+ ## Usage
21
+ Here is an example of how you would load Guanaco 7B in 4-bits:
22
+ ```python
23
+ import torch
24
+ from peft import PeftModel
25
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
26
+
27
+ model_name = "huggyllama/llama-7b"
28
+ adapters_name = 'timdettmers/guanaco-7b'
29
+
30
+ model = AutoModelForCausalLM.from_pretrained(
31
+ model_name,
32
+ load_in_4bit=True,
33
+ torch_dtype=torch.bfloat16,
34
+ device_map="auto",
35
+ max_memory= {i: '24000MB' for i in range(torch.cuda.device_count())},
36
+ quantization_config=BitsAndBytesConfig(
37
+ load_in_4bit=True,
38
+ bnb_4bit_compute_dtype=torch.bfloat16,
39
+ bnb_4bit_use_double_quant=True,
40
+ bnb_4bit_quant_type='nf4'
41
+ ),
42
+ )
43
+ model = PeftModel.from_pretrained(model, adapters_name)
44
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
45
+
46
+ ```
47
+ Inference can then be performed as usual with HF models as follows:
48
+ ```python
49
+ prompt = "Introduce yourself"
50
+ formatted_prompt = (
51
+ f"A chat between a curious human and an artificial intelligence assistant."
52
+ f"The assistant gives helpful, detailed, and polite answers to the user's questions.\n"
53
+ f"### Human: {prompt} ### Assistant:"
54
+ )
55
+ inputs = tokenizer(formatted_prompt, return_tensors="pt").to("cuda:0")
56
+ outputs = model.generate(inputs=inputs.input_ids, max_new_tokens=20)
57
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
58
+ ```
59
+ Expected output similar to the following:
60
+ ```
61
+ A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
62
+ ### Human: Introduce yourself ### Assistant: I am an artificial intelligence assistant. I am here to help you with any questions you may have.
63
+ ```
64
+
65
+
66
+ ## Current Inference Limitations
67
+ Currently, 4-bit inference is slow. We recommend loading in 16 bits if inference speed is a concern. We are actively working on releasing efficient 4-bit inference kernels.
68
+
69
+ Below is how you would load the model in 16 bits:
70
+ ```python
71
+ model_name = "huggyllama/llama-7b"
72
+ adapters_name = 'timdettmers/guanaco-7b'
73
+ model = AutoModelForCausalLM.from_pretrained(
74
+ model_name,
75
+ torch_dtype=torch.bfloat16,
76
+ device_map="auto",
77
+ max_memory= {i: '24000MB' for i in range(torch.cuda.device_count())},
78
+ )
79
+ model = PeftModel.from_pretrained(model, adapters_name)
80
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
81
+
82
+ ```
83
+
84
+
85
+ ## Model Card
86
+ **Architecture**: The Guanaco models are LoRA adapters to be used on top of LLaMA models. They are added to all layers. For all model sizes, we use $r=64$.
87
+
88
+ **Base Model**: Guanaco uses LLaMA as base model with sizes 7B, 13B, 33B, 65B. LLaMA is a causal language model pretrained on a large corpus of text. See [LLaMA paper](https://arxiv.org/abs/2302.13971) for more details. Note that Guanaco can inherit biases and limitations of the base model.
89
+
90
+ **Finetuning Data**: Guanaco is finetuned on OASST1. The exact dataset is available at [timdettmers/openassistant-guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco).
91
+
92
+ **Languages**: The OASST1 dataset is multilingual (see [the paper](https://arxiv.org/abs/2304.07327) for details) and as such Guanaco responds to user queries in different languages. We note, however, that OASST1 is heavy in high-resource languages. In addition, human evaluation of Guanaco was only performed in English and based on qualitative analysis we observed degradation in performance in other languages.
93
+
94
+ Next, we describe Training and Evaluation details.
95
+
96
+ ### Training
97
+ Guanaco models are the result of 4-bit QLoRA supervised finetuning on the OASST1 dataset.
98
+
99
+ All models use NormalFloat4 datatype for the base model and LoRA adapters on all linear layers with BFloat16 as computation datatype. We set LoRA $r=64$, $\alpha=16$. We also use Adam beta2 of 0.999, max grad norm of 0.3 and LoRA dropout of 0.1 for models up to 13B and 0.05 for 33B and 65B models.
100
+ For the finetuning process, we use constant learning rate schedule and paged AdamW optimizer.
101
+
102
+ ### Training hyperparameters
103
+ Size| Dataset | Batch Size | Learning Rate | Max Steps | Sequence length
104
+ ---|---|---|---|---|---
105
+ 7B | OASST1 | 16 | 2e-4 | 1875 | 512
106
+ 13B | OASST1 | 16 | 2e-4 | 1875 | 512
107
+ 33B | OASST1 | 16 | 1e-4 | 1875 | 512
108
+ 65B | OASST1 | 16 | 1e-4 | 1875 | 512
109
+
110
+ ### Evaluation
111
+ We test generative language capabilities through both automated and human evaluations. This second set of evaluations relies on queries curated by humans and aims at measuring the quality of model responses. We use the Vicuna and OpenAssistant datasets with 80 and 953 prompts respectively.
112
+
113
+ In both human and automated evaluations, for each prompt, raters compare all pairs of responses across the models considered. For human raters we randomize the order of the systems, for GPT-4 we evaluate with both orders.
114
+
115
+
116
+ Benchmark | Vicuna | | Vicuna | | OpenAssistant | | -
117
+ -----------|----|-----|--------|---|---------------|---|---
118
+ Prompts | 80 | | 80 | | 953 | |
119
+ Judge | Human | | GPT-4 | | GPT-4 | |
120
+ Model | Elo | Rank | Elo | Rank | Elo | Rank | **Median Rank**
121
+ GPT-4 | 1176 | 1 | 1348 | 1 | 1294 | 1 | 1
122
+ Guanaco-65B | 1023 | 2 | 1022 | 2 | 1008 | 3 | 2
123
+ Guanaco-33B | 1009 | 4 | 992 | 3 | 1002 | 4 | 4
124
+ ChatGPT-3.5 Turbo | 916 | 7 | 966 | 5 | 1015 | 2 | 5
125
+ Vicuna-13B | 984 | 5 | 974 | 4 | 936 | 5 | 5
126
+ Guanaco-13B | 975 | 6 | 913 | 6 | 885 | 6 | 6
127
+ Guanaco-7B | 1010 | 3 | 879 | 8 | 860 | 7 | 7
128
+ Bard | 909 | 8 | 902 | 7 | - | - | 8
129
+
130
+
131
+ We also use the MMLU benchmark to measure performance on a range of language understanding tasks. This is a multiple-choice benchmark covering 57 tasks including elementary mathematics, US history, computer science, law, and more. We report 5-shot test accuracy.
132
+
133
+ Dataset | 7B | 13B | 33B | 65B
134
+ ---|---|---|---|---
135
+ LLaMA no tuning | 35.1 | 46.9 | 57.8 | 63.4
136
+ Self-Instruct | 36.4 | 33.3 | 53.0 | 56.7
137
+ Longform | 32.1 | 43.2 | 56.6 | 59.7
138
+ Chip2 | 34.5 | 41.6 | 53.6 | 59.8
139
+ HH-RLHF | 34.9 | 44.6 | 55.8 | 60.1
140
+ Unnatural Instruct | 41.9 | 48.1 | 57.3 | 61.3
141
+ OASST1 (Guanaco) | 36.6 | 46.4 | 57.0 | 62.2
142
+ Alpaca | 38.8 | 47.8 | 57.3 | 62.5
143
+ FLAN v2 | 44.5 | 51.4 | 59.2 | 63.9
144
+
145
+ ## Risks and Biases
146
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. The model was trained on various public datasets; it is possible that this model could generate lewd, biased, or otherwise offensive outputs.
147
+
148
+ However, we note that finetuning on OASST1 seems to reduce biases as measured on the CrowS dataset. We report here the performance of Guanaco-65B compared to other baseline models on the CrowS dataset.
149
+
150
+ | | LLaMA-65B | GPT-3 | OPT-175B | Guanaco-65B |
151
+ |----------------------|-----------|-------|----------|---------------|
152
+ | Gender | 70.6 | 62.6 | 65.7 | **47.5** |
153
+ | Religion | {79.0} | 73.3 | 68.6 | **38.7** |
154
+ | Race/Color | 57.0 | 64.7 | 68.6 | **45.3** |
155
+ | Sexual orientation | {81.0} | 76.2 | 78.6 | **59.1** |
156
+ | Age | 70.1 | 64.4 | 67.8 | **36.3** |
157
+ | Nationality | 64.2 | 61.6 | 62.9 | **32.4** |
158
+ | Disability | 66.7 | 76.7 | 76.7 | **33.9** |
159
+ | Physical appearance | 77.8 | 74.6 | 76.2 | **43.1** |
160
+ | Socioeconomic status | 71.5 | 73.8 | 76.2 | **55.3** |
161
+ | Average | 66.6 | 67.2 | 69.5 | **43.5** |
162
+
163
+ ## Citation
164
+
165
+ ```bibtex
166
+ @article{dettmers2023qlora,
167
+ title={QLoRA: Efficient Finetuning of Quantized LLMs},
168
+ author={Dettmers, Tim and Pagnoni, Artidoro and Holtzman, Ari and Zettlemoyer, Luke},
169
+ journal={arXiv preprint arXiv:2305.14314},
170
+ year={2023}
171
+ }
172
+ ```