Text Generation
Transformers
PyTorch
mpt
Composer
MosaicML
llm-foundry
custom_code
text-generation-inference
debisoft commited on
Commit
1c98785
1 Parent(s): 5b303ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +194 -0
README.md CHANGED
@@ -1,3 +1,197 @@
1
  ---
2
  license: cc-by-sa-3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-sa-3.0
3
+ datasets:
4
+ - competition_math
5
+ - knkarthick/dialogsum
6
+ - mosaicml/dolly_hhrlhf
7
+ - duorc
8
+ - emozilla/quality
9
+ - scrolls/summ_screen_fd
10
+ - spider
11
+ tags:
12
+ - Composer
13
+ - MosaicML
14
+ - llm-foundry
15
+ inference: false
16
  ---
17
+
18
+ # MPT-7B-Instruct-8k
19
+ Patched based on [eluzhnica/mpt-7b-8k-instruct-peft-compatible](https://huggingface.co/eluzhnica/mpt-7b-8k-instruct-peft-compatible)
20
+
21
+ MPT-7B-Instruct-8k is a model for long-form instruction following, especially question-answering on and summarization of longer documents.
22
+ 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).
23
+ This is the same dataset that [MPT-30B-Instruct](https://huggingface.co/mosaicml/mpt-30b-instruct) was trained on.
24
+ * License: _CC-By-SA-3.0_
25
+
26
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
27
+
28
+ ## Model Date
29
+
30
+ July 18, 2023
31
+
32
+ ## Model License
33
+
34
+ _CC-By-SA-3.0_
35
+
36
+ ## Documentation
37
+
38
+ * [Blog post: MPT-7B-8k](https://www.mosaicml.com/blog/long-context-mpt-7b-8k)
39
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
40
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
41
+
42
+ ## How to Use
43
+
44
+ This model is best used with the MosaicML [llm-foundry repository](https://github.com/mosaicml/llm-foundry) for training and finetuning.
45
+
46
+ ```python
47
+ import transformers
48
+ model = transformers.AutoModelForCausalLM.from_pretrained(
49
+ 'mosaicml/mpt-7b-instruct-8k',
50
+ trust_remote_code=True
51
+ )
52
+ ```
53
+ Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method.
54
+ This is because we use a custom `MPT` model architecture that is not yet part of the Hugging Face `transformers` package.
55
+ `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.
56
+
57
+ 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:
58
+ ```python
59
+ import torch
60
+ import transformers
61
+
62
+ name = 'mosaicml/mpt-7b-instruct-8k'
63
+
64
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
65
+ config.attn_config['attn_impl'] = 'triton' # change this to use triton-based FlashAttention
66
+ config.init_device = 'cuda:0' # For fast initialization directly on GPU!
67
+
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
+
81
+ name = 'mosaicml/mpt-7b-instruct-8k'
82
+
83
+ config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
84
+ config.max_seq_len = 16384 # (input + output) tokens can now be up to 16384
85
+
86
+ model = transformers.AutoModelForCausalLM.from_pretrained(
87
+ name,
88
+ config=config,
89
+ trust_remote_code=True
90
+ )
91
+ ```
92
+
93
+ 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.
94
+
95
+ ```python
96
+ from transformers import AutoTokenizer
97
+ tokenizer = AutoTokenizer.from_pretrained('mosaicml/mpt-7b-8k')
98
+ ```
99
+
100
+ The model can then be used, for example, within a text-generation pipeline.
101
+ 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).
102
+
103
+ ```python
104
+ from transformers import pipeline
105
+
106
+ with torch.autocast('cuda', dtype=torch.bfloat16):
107
+ inputs = tokenizer('Here is a recipe for vegan banana bread:\n', return_tensors="pt").to('cuda')
108
+ outputs = model.generate(**inputs, max_new_tokens=100)
109
+ print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
110
+
111
+ # or using the HF pipeline
112
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
113
+ with torch.autocast('cuda', dtype=torch.bfloat16):
114
+ print(
115
+ pipe('Here is a recipe for vegan banana bread:\n',
116
+ max_new_tokens=100,
117
+ do_sample=True,
118
+ use_cache=True))
119
+ ```
120
+
121
+ ## Model Description
122
+
123
+ The architecture is a modification of a standard decoder-only transformer.
124
+
125
+ The model has been modified from a standard transformer in the following ways:
126
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
127
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
128
+ * It does not use biases
129
+
130
+
131
+ | Hyperparameter | Value |
132
+ |----------------|-------|
133
+ |n_parameters | 6.7B |
134
+ |n_layers | 32 |
135
+ | n_heads | 32 |
136
+ | d_model | 4096 |
137
+ | vocab size | 50432 |
138
+ | sequence length | 2048 |
139
+
140
+ ## Data Mix
141
+
142
+ The model was trained on the following data mix:
143
+
144
+ | Data Source | Number of Tokens in Source | Proportion |
145
+ |-------------|----------------------------|------------|
146
+ | competition_math | 1.6 M | 3.66% |
147
+ | cot_gsm8k | 3.36 M | 7.67% |
148
+ | dialogsum | 0.1 M | 0.23% |
149
+ | dolly_hhrlhf | 5.89 M | 13.43% |
150
+ | duorc | 7.8 M | 17.80% |
151
+ | qasper | 8.72 M | 19.90% |
152
+ | quality | 11.29 M | 25.78% |
153
+ | scrolls/summ_screen_fd | 4.97 M | 11.33% |
154
+ | spider | 0.089 M | 0.20% |
155
+
156
+ ### Training Configuration
157
+
158
+ This model was trained on 8 80GB A100s for about 6.3 hours using the [MosaicML Platform](https://www.mosaicml.com/platform).
159
+ The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the AdamW optimizer.
160
+
161
+ ## Limitations and Biases
162
+
163
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
164
+
165
+ MPT-7B-Instruct-8k can produce factually incorrect output, and should not be relied on to produce factually accurate information.
166
+ MPT-7B-Instruct-8k was trained on various public datasets.
167
+ 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.
168
+
169
+ ## Acknowledgements
170
+
171
+ This model was finetuned by the MosaicML NLP team.
172
+
173
+ ## Disclaimer
174
+
175
+ 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.
176
+
177
+
178
+ ## MosaicML Platform
179
+
180
+ 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).
181
+
182
+
183
+ ## Citation
184
+
185
+ Please cite this model using the following format:
186
+
187
+ ```
188
+ @online{MosaicML2023Introducing,
189
+ author = {MosaicML NLP Team},
190
+ title = {Introducing MPT-30B: Raising the bar
191
+ for open-source foundation models},
192
+ year = {2023},
193
+ url = {www.mosaicml.com/blog/mpt-30b},
194
+ note = {Accessed: 2023-06-22},
195
+ urldate = {2023-06-22}
196
+ }
197
+ ```