czurita commited on
Commit
c30b4e8
1 Parent(s): b33a24b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +188 -0
README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-3.0
3
+ datasets:
4
+ - competition_math
5
+ - conceptofmind/cot_submix_original/cot_gsm8k
6
+ - knkarthick/dialogsum
7
+ - mosaicml/dolly_hhrlhf
8
+ - duorc
9
+ - tau/scrolls/qasper
10
+ - emozilla/quality
11
+ - scrolls/summ_screen_fd
12
+ - spider
13
+ tags:
14
+ - Composer
15
+ - MosaicML
16
+ - llm-foundry
17
+ inference: false
18
+ ---
19
+ Resharded version of https://huggingface.co/mosaicml/mpt-7b-8k-instruct for low RAM enviroments (e.g. Colab, Kaggle) in safetensors.
20
+
21
+ ---
22
+ # MPT-7B-Instruct-8k
23
+
24
+ MPT-7B-Instruct-8k is a model for long-form instruction following, especially question-answering on and summarization of longer documents.
25
+ It is built by finetuning [MPT-7B-8k](https://huggingface.co/mosaicml/mpt-7b-8k) on [Dolly HHRLHF](https://huggingface.co/datasets/mosaicml/dolly_hhrlhf) derived from the [Databricks Dolly-15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) and the [Anthropic Helpful and Harmless (HH-RLHF)](https://huggingface.co/datasets/Anthropic/hh-rlhf) datasets. It is also trained on [Competition Math](https://huggingface.co/datasets/competition_math), [Duorc](https://huggingface.co/datasets/duorc), [CoT GSM8k](https://huggingface.co/datasets/conceptofmind/cot_submix_original), [Qasper](https://huggingface.co/datasets/allenai/qasper), [Quality](https://huggingface.co/datasets/emozilla/quality), [Summ Screen FD](https://huggingface.co/datasets/tau/scrolls) and [Spider](https://huggingface.co/datasets/spider).
26
+ This is the same dataset that [MPT-30B-Instruct](https://huggingface.co/mosaicml/mpt-30b-instruct) was trained on.
27
+ * License: _CC-By-SA-3.0_
28
+
29
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
30
+
31
+ ## Model Date
32
+
33
+ July 18, 2023
34
+
35
+ ## Model License
36
+
37
+ _CC-By-SA-3.0_
38
+
39
+ ## Documentation
40
+
41
+ * [Blog post: MPT-7B-8k](https://www.mosaicml.com/blog/long-context-mpt-7b-8k)
42
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
43
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
44
+
45
+ ## How to Use
46
+
47
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
48
+
49
+ ```python
50
+ import transformers
51
+ model = transformers.AutoModelForCausalLM.from_pretrained(
52
+ 'mosaicml/mpt-7b-instruct-8k',
53
+ trust_remote_code=True
54
+ )
55
+ ```
56
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
57
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
58
+ `MPT` includes options for many training efficiency features such as [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf), [ALiBi](https://arxiv.org/abs/2108.12409), [QK LayerNorm](https://arxiv.org/abs/2010.04245), and more.
59
+
60
+ To use the optimized [triton implementation](https://github.com/openai/triton) of FlashAttention, you can load the model on GPU (`cuda:0`) with `attn_impl='triton'` and with `bfloat16` precision:
61
+ ```python
62
+ import torch
63
+ import transformers
64
+ name = 'mosaicml/mpt-7b-instruct-8k'
65
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
66
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
67
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
68
+ model = transformers.AutoModelForCausalLM.from_pretrained(
69
+ name,
70
+ config=config,
71
+ torch_dtype=torch.bfloat16, # Load model weights in bfloat16
72
+ trust_remote_code=True
73
+ )
74
+ ```
75
+
76
+ The model was trained initially with a sequence length of 2048 with an additional pretraining stage for sequence length adapation up to 8192. However, ALiBi enables users to increase the maximum sequence length even further during finetuning and/or inference. For example:
77
+
78
+ ```python
79
+ import transformers
80
+ name = 'mosaicml/mpt-7b-instruct-8k'
81
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
82
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
83
+ model = transformers.AutoModelForCausalLM.from_pretrained(
84
+ name,
85
+ config=config,
86
+ trust_remote_code=True
87
+ )
88
+ ```
89
+
90
+ This model was trained with the MPT-7B-chat tokenizer which is based on the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer and includes additional ChatML tokens.
91
+
92
+ ```python
93
+ from transformers import AutoTokenizer
94
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b-8k')
95
+ ```
96
+
97
+ The model can then be used, for example, within a text-generation pipeline.
98
+ Note: when running Torch modules in lower precision, it is best practice to use the [torch.autocast context manager](https://pytorch.org/docs/stable/amp.html).
99
+
100
+ ```python
101
+ from transformers import pipeline
102
+ with torch.autocast('cuda', dtype=torch.bfloat16):
103
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
104
+ outputs = model.generate(**inputs, max_new_tokens=100)
105
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
106
+ # or using the HF pipeline
107
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
108
+ with torch.autocast('cuda', dtype=torch.bfloat16):
109
+ print(
110
+ pipe('Here is a recipe for vegan banana bread:\n',
111
+ max_new_tokens=100,
112
+ do_sample=True,
113
+ use_cache=True))
114
+ ```
115
+
116
+ ## Model Description
117
+
118
+ The architecture is a modification of a standard decoder-only transformer.
119
+
120
+ The model has been modified from a standard transformer in the following ways:
121
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
122
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
123
+ * It does not use biases
124
+
125
+
126
+ | Hyperparameter | Value |
127
+ |----------------|-------|
128
+ |n_parameters | 6.7B |
129
+ |n_layers | 32 |
130
+ | n_heads | 32 |
131
+ | d_model | 4096 |
132
+ | vocab size | 50432 |
133
+ | sequence length | 2048 |
134
+
135
+ ## Data Mix
136
+
137
+ The model was trained on the following data mix:
138
+
139
+ | Data Source | Number of Tokens in Source | Proportion |
140
+ |-------------|----------------------------|------------|
141
+ | competition_math | 1.6 M | 3.66% |
142
+ | cot_gsm8k | 3.36 M | 7.67% |
143
+ | dialogsum | 0.1 M | 0.23% |
144
+ | dolly_hhrlhf | 5.89 M | 13.43% |
145
+ | duorc | 7.8 M | 17.80% |
146
+ | qasper | 8.72 M | 19.90% |
147
+ | quality | 11.29 M | 25.78% |
148
+ | scrolls/summ_screen_fd | 4.97 M | 11.33% |
149
+ | spider | 0.089 M | 0.20% |
150
+ ### Training Configuration
151
+ This model was trained on 8 80GB A100s for about 6.3 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
152
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
153
+ ## Limitations and Biases
154
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
155
+
156
+ MPT-7B-Instruct-8k can produce factually incorrect output, and should not be relied on to produce factually accurate information.
157
+ MPT-7B-Instruct-8k was trained on various public datasets.
158
+ While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
159
+
160
+ ## Acknowledgements
161
+
162
+ This model was finetuned by the MosaicML NLP team.
163
+
164
+ ## Disclaimer
165
+
166
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
167
+
168
+
169
+ ## MosaicML Platform
170
+
171
+ If you're interested in [training](https://www.mosaicml.com/training) and [deploying](https://www.mosaicml.com/inference) your own MPT or LLMs on the MosaicML Platform, [sign up here](https://www.mosaicml.com/get-started?utm_source=huggingface&utm_medium=referral&utm_campaign=mpt-7b-8k).
172
+
173
+
174
+ ## Citation
175
+
176
+ Please cite this model using the following format:
177
+
178
+ ```
179
+ @online{MosaicML2023Introducing,
180
+ author = {MosaicML NLP Team},
181
+ title = {Introducing MPT-30B: Raising the bar
182
+ for open-source foundation models},
183
+ year = {2023},
184
+ url = {www.mosaicml.com/blog/mpt-30b},
185
+ note = {Accessed: 2023-06-22},
186
+ urldate = {2023-06-22}
187
+ }
188
+ ```