TehVenom commited on
Commit
4adc9cf
·
1 Parent(s): 5308784

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +184 -0
README.md ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - Composer
5
+ - MosaicML
6
+ - llm-foundry
7
+ datasets:
8
+ - the_pile_books3
9
+ inference: false
10
+ ---
11
+
12
+ # MPT-7B-StoryWriter-65k+
13
+
14
+ MPT-7B-StoryWriter-65k+ is a model designed to read and write fictional stories with super long context lengths.
15
+ 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).
16
+ At inference time, thanks to [ALiBi](https://arxiv.org/abs/2108.12409), MPT-7B-StoryWriter-65k+ can extrapolate even beyond 65k tokens.
17
+ 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).
18
+ * License: _Apache-2.0_ (commercial use permitted)
19
+
20
+ This model was trained by [MosaicML](https://www.mosaicml.com) and follows a modified decoder-only transformer architecture.
21
+
22
+ ## Model Date
23
+
24
+ May 5, 2023
25
+
26
+ ## Model License
27
+
28
+ Apache-2.0 (commercial use permitted)
29
+
30
+ ## Documentation
31
+
32
+ * [Blog post: Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs](https://www.mosaicml.com/blog/mpt-7b)
33
+ * [Codebase (mosaicml/llm-foundry repo)](https://github.com/mosaicml/llm-foundry/)
34
+ * Questions: Feel free to contact us via the [MosaicML Community Slack](https://join.slack.com/t/mosaicml-community/shared_invite/zt-1btms90mc-GipE2ufuPkKY0QBrmF3LSA)!
35
+
36
+
37
+ ## How to Use
38
+
39
+ 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.
40
+
41
+ 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.
42
+
43
+ ```python
44
+ import transformers
45
+ model = transformers.AutoModelForCausalLM.from_pretrained(
46
+ 'mosaicml/mpt-7b-storywriter',
47
+ trust_remote_code=True
48
+ )
49
+ ```
50
+
51
+ To use the optimized [triton implementation](https://github.com/openai/triton) of FlashAttention, you can load the model with `attn_impl='triton'` and move the model to `bfloat16`:
52
+ ```python
53
+ config = transformers.AutoConfig.from_pretrained(
54
+ 'mosaicml/mpt-7b-storywriter',
55
+ trust_remote_code=True
56
+ )
57
+ config.attn_config['attn_impl'] = 'triton'
58
+
59
+ model = transformers.AutoModelForCausalLM.from_pretrained(
60
+ 'mosaicml/mpt-7b-storywriter',
61
+ config=config,
62
+ torch_dtype=torch.bfloat16,
63
+ trust_remote_code=True
64
+ )
65
+ model.to(device='cuda:0')
66
+ ```
67
+
68
+ Although the model was trained with a sequence length of 2048 and finetuned with a sequence length of 65536,
69
+ ALiBi enables users to increase the maximum sequence length during finetuning and/or inference. For example:
70
+
71
+ ```python
72
+ config = transformers.AutoConfig.from_pretrained(
73
+ 'mosaicml/mpt-7b-storywriter',
74
+ trust_remote_code=True
75
+ )
76
+ config.update({"max_seq_len": 83968})
77
+ model = transformers.AutoModelForCausalLM.from_pretrained(
78
+ 'mosaicml/mpt-7b-storywriter',
79
+ config=config,
80
+ trust_remote_code=True
81
+ )
82
+ ```
83
+
84
+ This model was trained with the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
85
+
86
+ ```python
87
+ from transformers import AutoTokenizer
88
+ tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
89
+ ```
90
+
91
+ ## Example Epilogue
92
+
93
+ The full text of the _The Great Gatsby_ (67873 tokens) was fed to the model, followed by the text "EPILOGUE"
94
+
95
+ **TheRealFitzgerald233**:
96
+
97
+ > ...
98
+ >
99
+ > So we beat on, boats against the current, borne back ceaselessly into the past
100
+ >
101
+ > EPILOGUE
102
+
103
+ **MPT-7B-StoryWriter**:
104
+
105
+ >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.
106
+ >
107
+ >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.
108
+ >
109
+ >And I knew that day that I didn't love her.
110
+ >
111
+ >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.
112
+ >
113
+ >I have sorted them by date and placed them in the order in which they were written. They are very few in number.
114
+ >
115
+ >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.
116
+ >
117
+ >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.
118
+ >
119
+ >But a few months ago I read somewhere that he had been seen in New York. He had become a great man.
120
+ >
121
+ >And I knew that he had not changed at all.
122
+
123
+ ## Model Description
124
+
125
+ The architecture is a modification of a standard decoder-only transformer.
126
+
127
+ The model has been modified from a standard transformer in the following ways:
128
+ * It uses [FlashAttention](https://arxiv.org/pdf/2205.14135.pdf)
129
+ * It uses [ALiBi (Attention with Linear Biases)](https://arxiv.org/abs/2108.12409) and does not use positional embeddings
130
+ * It does not use biases
131
+
132
+
133
+ | Hyperparameter | Value |
134
+ |----------------|-------|
135
+ |n_parameters | 6.7B |
136
+ |n_layers | 32 |
137
+ | n_heads | 32 |
138
+ | d_model | 4096 |
139
+ | vocab size | 50432 |
140
+ | sequence length | **65536** |
141
+
142
+ ## PreTraining Data
143
+
144
+ For more details on the pretraining process, see [MPT-7B](https://huggingface.co/mosaicml/mpt-7b).
145
+
146
+ The data was tokenized using the [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b) tokenizer.
147
+
148
+ ### Training Configuration
149
+
150
+ This model was trained on 8 A100-80GBs for about 2 days using the [MosaicML Platform](https://www.mosaicml.com/platform).
151
+ 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.
152
+
153
+ ## Limitations and Biases
154
+
155
+ _The following language is modified from [EleutherAI's GPT-NeoX-20B](https://huggingface.co/EleutherAI/gpt-neox-20b)_
156
+
157
+ MPT-7B-StoryWriter can produce factually incorrect output, and should not be relied on to produce factually accurate information.
158
+ MPT-7B-StoryWriter was trained on various public datasets.
159
+ 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.
160
+
161
+
162
+ ## Acknowledgements
163
+
164
+ This model was finetuned by Alex Trott and the MosaicML NLP team
165
+
166
+ ## MosaicML Platform
167
+
168
+ 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).
169
+
170
+
171
+ ## Citation
172
+
173
+ Please cite this model using the following format:
174
+
175
+ ```
176
+ @online{MosaicML2023Introducing,
177
+ author = {MosaicML NLP Team},
178
+ title = {Introducing MPT-7B: A New Standard for Open-Source, Commercially Usable LLMs},
179
+ year = {2023},
180
+ url = {www.mosaicml.com/blog/mpt-7b},
181
+ note = {Accessed: 2023-03-28}, % change this date
182
+ urldate = {2023-03-28} % change this date
183
+ }
184
+ ```