Safetensors
llama
sea-snell commited on
Commit
228fbd1
1 Parent(s): 1f8f9e5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +120 -172
README.md CHANGED
@@ -1,199 +1,147 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
 
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
39
 
40
- ### Direct Use
 
 
 
 
 
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- 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. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
 
103
  ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - togethercomputer/RedPajama-Data-1T
5
  ---
6
 
7
+ # OpenLLaMA: An Open Reproduction of LLaMA
8
 
 
9
 
10
+ In this repo, we present a permissively licensed open source reproduction of Meta AI's [LLaMA](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/) large language model. We are releasing a 7B and 3B model trained on 1T tokens, as well as the preview of a 13B model trained on 600B tokens. We provide PyTorch and JAX weights of pre-trained OpenLLaMA models, as well as evaluation results and comparison against the original LLaMA models. Please see the [project homepage of OpenLLaMA](https://github.com/openlm-research/open_llama) for more details.
11
 
12
 
13
+ ## Weights Release, License and Usage
14
 
15
+ We release the weights in two formats: an EasyLM format to be use with our [EasyLM framework](https://github.com/young-geng/EasyLM), and a PyTorch format to be used with the [Hugging Face transformers](https://huggingface.co/docs/transformers/index) library. Both our training framework EasyLM and the checkpoint weights are licensed permissively under the Apache 2.0 license.
16
 
17
+ ### Loading the Weights with Hugging Face Transformers
18
+ Preview checkpoints can be directly loaded from Hugging Face Hub. **Please note that it is advised to avoid using the Hugging Face fast tokenizer for now, as we’ve observed that the auto-converted fast tokenizer sometimes gives incorrect tokenizations.** This can be achieved by directly using the `LlamaTokenizer` class, or passing in the `use_fast=False` option for the `AutoTokenizer` class. See the following example for usage.
19
 
20
+ ```python
21
+ import torch
22
+ from transformers import LlamaTokenizer, LlamaForCausalLM
23
 
24
+ model_path = 'openlm-research/open_llama_3b'
25
+ # model_path = 'openlm-research/open_llama_7b'
 
 
 
 
 
26
 
27
+ tokenizer = LlamaTokenizer.from_pretrained(model_path)
28
+ model = LlamaForCausalLM.from_pretrained(
29
+ model_path, torch_dtype=torch.float16, device_map='auto',
30
+ )
31
 
32
+ prompt = 'Q: What is the largest animal?\nA:'
33
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
34
 
35
+ generation_output = model.generate(
36
+ input_ids=input_ids, max_new_tokens=32
37
+ )
38
+ print(tokenizer.decode(generation_output[0]))
39
+ ```
40
 
41
+ For more advanced usage, please follow the [transformers LLaMA documentation](https://huggingface.co/docs/transformers/main/model_doc/llama).
42
 
43
+ ### Evaluating with LM-Eval-Harness
44
+ The model can be evaluated with [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness). However, due to the aforementioned tokenizer issue, we need to avoid using the fast tokenizer to obtain the correct results. This can be achieved by passing in `use_fast=False` to [this part of lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/blob/4b701e228768052cfae9043dca13e82052ca5eea/lm_eval/models/huggingface.py#LL313C9-L316C10), as shown in the example below:
45
 
46
+ ```python
47
+ tokenizer = self.AUTO_TOKENIZER_CLASS.from_pretrained(
48
+ pretrained if tokenizer is None else tokenizer,
49
+ revision=revision + ("/" + subfolder if subfolder is not None else ""),
50
+ use_fast=False
51
+ )
52
+ ```
53
 
54
+ ### Loading the Weights with EasyLM
55
 
56
+ For using the weights in our EasyLM framework, please refer to the [LLaMA documentation of EasyLM](https://github.com/young-geng/EasyLM/blob/main/docs/llama.md). Note that unlike the original LLaMA model, our OpenLLaMA tokenizer and weights are trained completely from scratch so it is no longer needed to obtain the original LLaMA tokenizer and weights. Note that we use BOS (beginning of sentence) token (id=1) during training, so it is best to prepend this token for best performance during few-shot evaluation.
57
 
 
58
 
 
59
 
60
+ ## Dataset and Training
61
 
62
+ We train our models on the [RedPajama](https://www.together.xyz/blog/redpajama) dataset released by [Together](https://www.together.xyz/), which is a reproduction of the LLaMA training dataset containing over 1.2 trillion tokens. We follow the exactly same preprocessing steps and training hyperparameters as the original LLaMA paper, including model architecture, context length, training steps, learning rate schedule, and optimizer. The only difference between our setting and the original one is the dataset used: OpenLLaMA employs the RedPajama dataset rather than the one utilized by the original LLaMA.
63
 
64
+ We train the models on cloud TPU-v4s using [EasyLM](https://github.com/young-geng/EasyLM), a JAX based training pipeline we developed for training and fine-tuning large language models. We employ a combination of normal data parallelism and [fully sharded data parallelism (also know as ZeRO stage 3)](https://engineering.fb.com/2021/07/15/open-source/fsdp/) to balance the training throughput and memory usage. Overall we reach a throughput of over 2200 tokens / second / TPU-v4 chip for our 7B model.
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  ## Evaluation
68
+ We evaluated OpenLLaMA on a wide range of tasks using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness). The LLaMA results are generated by running the original LLaMA model on the same evaluation metrics. We note that our results for the LLaMA model differ slightly from the original LLaMA paper, which we believe is a result of different evaluation protocols. Similar differences have been reported in [this issue of lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/issues/443). Additionally, we present the results of GPT-J, a 6B parameter model trained on the [Pile](https://pile.eleuther.ai/) dataset by [EleutherAI](https://www.eleuther.ai/).
69
+
70
+ The original LLaMA model was trained for 1 trillion tokens and GPT-J was trained for 500 billion tokens. We present the results in the table below. OpenLLaMA exhibits comparable performance to the original LLaMA and GPT-J across a majority of tasks, and outperforms them in some tasks.
71
+
72
+
73
+ | **Task/Metric** | GPT-J 6B | LLaMA 7B | OpenLLaMA 7B | OpenLLaMA 3B | OpenLLaMA 13B 600BT |
74
+ | ---------------------- | -------- | -------- | ------------ | ------------ | ------------------- |
75
+ | anli_r1/acc | 0.32 | 0.35 | 0.33 | 0.33 | 0.33 |
76
+ | anli_r2/acc | 0.34 | 0.34 | 0.36 | 0.32 | 0.35 |
77
+ | anli_r3/acc | 0.35 | 0.37 | 0.38 | 0.35 | 0.38 |
78
+ | arc_challenge/acc | 0.34 | 0.39 | 0.37 | 0.34 | 0.39 |
79
+ | arc_challenge/acc_norm | 0.37 | 0.41 | 0.38 | 0.37 | 0.42 |
80
+ | arc_easy/acc | 0.67 | 0.68 | 0.72 | 0.69 | 0.74 |
81
+ | arc_easy/acc_norm | 0.62 | 0.52 | 0.68 | 0.65 | 0.70 |
82
+ | ddboolq/acc | 0.50 | 0.56 | 0.53 | 0.49 | 0.71 |
83
+ | hellaswag/acc | 0.36 | 0.36 | 0.63 | 0.43 | 0.54 |
84
+ | hellaswag/acc_norm | 0.66 | 0.73 | 0.72 | 0.67 | 0.73 |
85
+ | openbookqa/acc | 0.29 | 0.29 | 0.30 | 0.27 | 0.30 |
86
+ | openbookqa/acc_norm | 0.38 | 0.41 | 0.40 | 0.40 | 0.41 |
87
+ | piqa/acc | 0.75 | 0.78 | 0.76 | 0.75 | 0.77 |
88
+ | piqa/acc_norm | 0.76 | 0.78 | 0.77 | 0.76 | 0.78 |
89
+ | record/em | 0.88 | 0.91 | 0.89 | 0.88 | 0.90 |
90
+ | record/f1 | 0.89 | 0.91 | 0.90 | 0.89 | 0.90 |
91
+ | rte/acc | 0.54 | 0.56 | 0.60 | 0.58 | 0.65 |
92
+ | truthfulqa_mc/mc1 | 0.20 | 0.21 | 0.23 | 0.22 | 0.22 |
93
+ | truthfulqa_mc/mc2 | 0.36 | 0.34 | 0.35 | 0.35 | 0.35 |
94
+ | wic/acc | 0.50 | 0.50 | 0.51 | 0.48 | 0.49 |
95
+ | winogrande/acc | 0.64 | 0.68 | 0.67 | 0.62 | 0.67 |
96
+ | Average | 0.51 | 0.53 | 0.55 | 0.52 | 0.56 |
97
+
98
+
99
+ We removed the task CB and WSC from our benchmark, as our model performs suspiciously well on these two tasks. We hypothesize that there could be a benchmark data contamination in the training set.
100
+
101
+
102
+ ## Contact
103
+
104
+ We would love to get feedback from the community. If you have any questions, please open an issue or contact us.
105
+
106
+ OpenLLaMA is developed by:
107
+ [Xinyang Geng](https://young-geng.xyz/)* and [Hao Liu](https://www.haoliu.site/)* from Berkeley AI Research.
108
+ *Equal Contribution
109
+
110
+
111
+
112
+ ## Acknowledgment
113
+
114
+ We thank the [Google TPU Research Cloud](https://sites.research.google/trc/about/) program for providing part of the computation resources. We’d like to specially thank Jonathan Caton from TPU Research Cloud for helping us organizing compute resources, Rafi Witten from the Google Cloud team and James Bradbury from the Google JAX team for helping us optimizing our training throughput. We’d also want to thank Charlie Snell, Gautier Izacard, Eric Wallace, Lianmin Zheng and our user community for the discussions and feedback.
115
+
116
+ The OpenLLaMA 13B model is trained in collaboration with [Stability AI](https://stability.ai/), and we thank Stability AI for providing the computation resources. We’d like to especially thank David Ha and Shivanshu Purohit for the coordinating the logistics and providing engineering support.
117
+
118
+
119
+ ## Reference
120
+
121
+ If you found OpenLLaMA useful in your research or applications, please cite using the following BibTeX:
122
+ ```
123
+ @software{openlm2023openllama,
124
+ author = {Geng, Xinyang and Liu, Hao},
125
+ title = {OpenLLaMA: An Open Reproduction of LLaMA},
126
+ month = May,
127
+ year = 2023,
128
+ url = {https://github.com/openlm-research/open_llama}
129
+ }
130
+ ```
131
+ ```
132
+ @software{together2023redpajama,
133
+ author = {Together Computer},
134
+ title = {RedPajama-Data: An Open Source Recipe to Reproduce LLaMA training dataset},
135
+ month = April,
136
+ year = 2023,
137
+ url = {https://github.com/togethercomputer/RedPajama-Data}
138
+ }
139
+ ```
140
+ ```
141
+ @article{touvron2023llama,
142
+ title={Llama: Open and efficient foundation language models},
143
+ author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and others},
144
+ journal={arXiv preprint arXiv:2302.13971},
145
+ year={2023}
146
+ }
147
+ ```