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|
+
license: apache-2.0
|
5 |
+
tags:
|
6 |
+
- Composer
|
7 |
+
- MosaicML
|
8 |
+
- llm-foundry
|
9 |
+
datasets:
|
10 |
+
- the_pile_books3
|
11 |
+
inference: false
|
12 |
+
|
13 |
+
---
|
14 |
+
|
15 |
+
[![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
|
16 |
+
|
17 |
+
|
18 |
+
# QuantFactory/mpt-7b-storywriter-GGUF
|
19 |
+
This is quantized version of [mosaicml/mpt-7b-storywriter](https://huggingface.co/mosaicml/mpt-7b-storywriter) created using llama.cpp
|
20 |
+
|
21 |
+
# Original Model Card
|
22 |
+
|
23 |
+
|
24 |
+
# MPT-7B-StoryWriter-65k+
|
25 |
+
|
26 |
+
MPT-7B-StoryWriter-65k+ is a model designed to read and write fictional stories with super long context lengths.
|
27 |
+
It was built by finetuning MPT-7B with a context length of 65k tokens on a filtered fiction subset of the [books3 dataset](https://huggingface.co/datasets/the_pile_books3).
|
28 |
+
At inference time, thanks to [ALiBi](https://arxiv.org/abs/2108.12409), MPT-7B-StoryWriter-65k+ can extrapolate even beyond 65k tokens.
|
29 |
+
We demonstrate generations as long as 84k tokens on a single node of 8 A100-80GB GPUs in our [blogpost](https://www.mosaicml.com/blog/mpt-7b).
|
30 |
+
* License: Apache 2.0
|
31 |
+
|
32 |
+
This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
|
33 |
+
|
34 |
+
## Model Date
|
35 |
+
|
36 |
+
May 5, 2023
|
37 |
+
|
38 |
+
## Model License
|
39 |
+
|
40 |
+
Apache 2.0
|
41 |
+
|
42 |
+
## Documentation
|
43 |
+
|
44 |
+
* [Blog post: Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs](https://www.mosaicml.com/blog/mpt-7b)
|
45 |
+
* [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
|
46 |
+
* Questions: Feel free to contact us via the [MosaicML Community Slack](https://mosaicml.me/slack)!
|
47 |
+
|
48 |
+
|
49 |
+
## How to Use
|
50 |
+
|
51 |
+
Note: This model requires that `trust_remote_code=True` be passed to the `from_pretrained` method. This is because we use a custom model architecture that is not yet part of the `transformers` package.
|
52 |
+
|
53 |
+
It includes options for many training efficiency features such as [FlashAttention (Dao et al. 2022)](https://arxiv.org/pdf/2205.14135.pdf), [ALiBi](https://arxiv.org/abs/2108.12409), QK LayerNorm, and more.
|
54 |
+
|
55 |
+
```python
|
56 |
+
import transformers
|
57 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
58 |
+
'mosaicml/mpt-7b-storywriter',
|
59 |
+
trust_remote_code=True
|
60 |
+
)
|
61 |
+
```
|
62 |
+
|
63 |
+
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:
|
64 |
+
```python
|
65 |
+
import torch
|
66 |
+
import transformers
|
67 |
+
|
68 |
+
name = 'mosaicml/mpt-7b-storywriter'
|
69 |
+
|
70 |
+
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
|
71 |
+
config.attn_config['attn_impl'] = 'triton'
|
72 |
+
config.init_device = 'cuda:0' # For fast initialization directly on GPU!
|
73 |
+
|
74 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
75 |
+
name,
|
76 |
+
config=config,
|
77 |
+
torch_dtype=torch.bfloat16, # Load model weights in bfloat16
|
78 |
+
trust_remote_code=True
|
79 |
+
)
|
80 |
+
```
|
81 |
+
|
82 |
+
Although the model was trained with a sequence length of 2048 and finetuned with a sequence length of 65536,
|
83 |
+
ALiBi enables users to increase the maximum sequence length during finetuning and/or inference. For example:
|
84 |
+
```python
|
85 |
+
import transformers
|
86 |
+
|
87 |
+
name = 'mosaicml/mpt-7b'
|
88 |
+
|
89 |
+
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
|
90 |
+
config.max_seq_len = 83968 # (input + output) tokens can now be up to 83968
|
91 |
+
|
92 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(
|
93 |
+
name,
|
94 |
+
config=config,
|
95 |
+
trust_remote_code=True
|
96 |
+
)
|
97 |
+
```
|
98 |
+
|
99 |
+
This model was trained with the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
|
100 |
+
|
101 |
+
```python
|
102 |
+
from transformers import AutoTokenizer
|
103 |
+
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
|
104 |
+
```
|
105 |
+
|
106 |
+
The model can then be used, for example, within a text-generation pipeline.
|
107 |
+
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).
|
108 |
+
|
109 |
+
```python
|
110 |
+
from transformers import pipeline
|
111 |
+
|
112 |
+
pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
|
113 |
+
|
114 |
+
with torch.autocast('cuda', dtype=torch.bfloat16):
|
115 |
+
print(
|
116 |
+
pipe('Here is a recipe for vegan banana bread:\n',
|
117 |
+
max_new_tokens=100,
|
118 |
+
do_sample=True,
|
119 |
+
use_cache=True))
|
120 |
+
```
|
121 |
+
|
122 |
+
## Community-Created Resources
|
123 |
+
|
124 |
+
These were not created by MosaicML, but you may find them useful. These links are not an endorsement of the creators or their content.
|
125 |
+
|
126 |
+
- [Oobabooga Running MPT-7B-Storywriter](https://youtu.be/QVVb6Md6huA)
|
127 |
+
- [NEW MPT-7B-StoryWriter CRUSHES GPT-4!](https://www.youtube.com/watch?v=O9Y_ZdsuKWQ&t=649s) - Has a long section on running locally using Oobabooga
|
128 |
+
|
129 |
+
## Example Epilogue
|
130 |
+
|
131 |
+
The full text of the _The Great Gatsby_ (67873 tokens) was fed to the model, followed by the text "EPILOGUE"
|
132 |
+
|
133 |
+
**TheRealFitzgerald233**:
|
134 |
+
|
135 |
+
> ...
|
136 |
+
>
|
137 |
+
> So we beat on, boats against the current, borne back ceaselessly into the past
|
138 |
+
>
|
139 |
+
> EPILOGUE
|
140 |
+
|
141 |
+
**MPT-7B-StoryWriter**:
|
142 |
+
|
143 |
+
>I have lived so long in the shadow of this dream that I may never see the bright sunlight of reality. I may look up some morning and find that I am six feet under, and that Gatsby, who gave me the dream and everything else, will have vanished behind me.
|
144 |
+
>
|
145 |
+
>And so it was. I had hardly crossed the threshold of the old world when my eye caught the headlines of a newspaper, and I knew at once that my dream was over. I knew that Gatsby was dead.
|
146 |
+
>
|
147 |
+
>And I knew that day that I didn't love her.
|
148 |
+
>
|
149 |
+
>That night I took the last train for West Egg, and when I reached home I went directly to my attic and brought down all Gatsby's letters.
|
150 |
+
>
|
151 |
+
>I have sorted them by date and placed them in the order in which they were written. They are very few in number.
|
152 |
+
>
|
153 |
+
>They are dated between April of nineteen eighteen and January of nineteen nineteen, and the last one I have here is the one that told me he was dead.
|
154 |
+
>
|
155 |
+
>There is something in that last letter that frightens me. It is the sense of a finality, of a completeness. I never heard of him after that, and I was glad.
|
156 |
+
>
|
157 |
+
>But a few months ago I read somewhere that he had been seen in New York. He had become a great man.
|
158 |
+
>
|
159 |
+
>And I knew that he had not changed at all.
|
160 |
+
|
161 |
+
## Model Description
|
162 |
+
|
163 |
+
The architecture is a modification of a standard decoder-only transformer.
|
164 |
+
|
165 |
+
The model has been modified from a standard transformer in the following ways:
|
166 |
+
* It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
|
167 |
+
* It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
|
168 |
+
* It does not use biases
|
169 |
+
|
170 |
+
|
171 |
+
| Hyperparameter | Value |
|
172 |
+
|----------------|-------|
|
173 |
+
|n_parameters | 6.7B |
|
174 |
+
|n_layers | 32 |
|
175 |
+
| n_heads | 32 |
|
176 |
+
| d_model | 4096 |
|
177 |
+
| vocab size | 50432 |
|
178 |
+
| sequence length | **65536** |
|
179 |
+
|
180 |
+
## PreTraining Data
|
181 |
+
|
182 |
+
For more details on the pretraining process, see [MPT-7B](https://huggingface.co/mosaicml/mpt-7b).
|
183 |
+
|
184 |
+
The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
|
185 |
+
|
186 |
+
### Training Configuration
|
187 |
+
|
188 |
+
This model was trained on 8 A100-80GBs for about 2 days using the [MosaicML Platform](https://www.mosaicml.com/platform).
|
189 |
+
The model was trained with sharded data parallelism using [FSDP](https://pytorch.org/docs/stable/fsdp.html) and used the [LION](https://arxiv.org/abs/2302.06675) optimizer.
|
190 |
+
|
191 |
+
## Limitations and Biases
|
192 |
+
|
193 |
+
_The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
|
194 |
+
|
195 |
+
MPT-7B-StoryWriter can produce factually incorrect output, and should not be relied on to produce factually accurate information.
|
196 |
+
MPT-7B-StoryWriter was trained on various public datasets.
|
197 |
+
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.
|
198 |
+
|
199 |
+
|
200 |
+
## Acknowledgements
|
201 |
+
|
202 |
+
This model was finetuned by Alex Trott and the MosaicML NLP team
|
203 |
+
|
204 |
+
## MosaicML Platform
|
205 |
+
|
206 |
+
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://forms.mosaicml.com/demo?utm_source=huggingface&utm_medium=referral&utm_campaign=mpt-7b).
|
207 |
+
|
208 |
+
## Disclaimer
|
209 |
+
|
210 |
+
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 cosult an attorney before using this model for commercial purposes.
|
211 |
+
|
212 |
+
|
213 |
+
## Citation
|
214 |
+
|
215 |
+
Please cite this model using the following format:
|
216 |
+
|
217 |
+
```
|
218 |
+
@online{MosaicML2023Introducing,
|
219 |
+
author = {MosaicML NLP Team},
|
220 |
+
title = {Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs},
|
221 |
+
year = {2023},
|
222 |
+
url = {www.mosaicml.com/blog/mpt-7b},
|
223 |
+
note = {Accessed: 2023-03-28}, % change this date
|
224 |
+
urldate = {2023-03-28} % change this date
|
225 |
+
}
|
226 |
+
```
|
227 |
+
|