RichardErkhov commited on
Commit
aa11a86
·
verified ·
1 Parent(s): b023b64

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +222 -0
README.md ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ gpt2-xl - bnb 8bits
11
+ - Model creator: https://huggingface.co/openai-community/
12
+ - Original model: https://huggingface.co/openai-community/gpt2-xl/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ language: en
20
+ license: mit
21
+ ---
22
+
23
+ # GPT-2 XL
24
+
25
+ ## Table of Contents
26
+ - [Model Details](#model-details)
27
+ - [How To Get Started With the Model](#how-to-get-started-with-the-model)
28
+ - [Uses](#uses)
29
+ - [Risks, Limitations and Biases](#risks-limitations-and-biases)
30
+ - [Training](#training)
31
+ - [Evaluation](#evaluation)
32
+ - [Environmental Impact](#environmental-impact)
33
+ - [Technical Specifications](#technical-specifications)
34
+ - [Citation Information](#citation-information)
35
+ - [Model Card Authors](#model-card-authors)
36
+
37
+ ## Model Details
38
+
39
+ **Model Description:** GPT-2 XL is the **1.5B parameter** version of GPT-2, a transformer-based language model created and released by OpenAI. The model is a pretrained model on English language using a causal language modeling (CLM) objective.
40
+
41
+ - **Developed by:** OpenAI, see [associated research paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) and [GitHub repo](https://github.com/openai/gpt-2) for model developers.
42
+ - **Model Type:** Transformer-based language model
43
+ - **Language(s):** English
44
+ - **License:** [Modified MIT License](https://github.com/openai/gpt-2/blob/master/LICENSE)
45
+ - **Related Models:** [GPT-2](https://huggingface.co/gpt2), [GPT-Medium](https://huggingface.co/gpt2-medium) and [GPT-Large](https://huggingface.co/gpt2-large)
46
+ - **Resources for more information:**
47
+ - [Research Paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)
48
+ - [OpenAI Blog Post](https://openai.com/blog/better-language-models/)
49
+ - [GitHub Repo](https://github.com/openai/gpt-2)
50
+ - [OpenAI Model Card for GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md)
51
+ - [OpenAI GPT-2 1.5B Release Blog Post](https://openai.com/blog/gpt-2-1-5b-release/)
52
+ - Test the full generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large
53
+
54
+ ## How to Get Started with the Model
55
+
56
+ Use the code below to get started with the model. You can use this model directly with a pipeline for text generation. Since the generation relies on some randomness, we set a seed for reproducibility:
57
+
58
+ ```python
59
+ from transformers import pipeline, set_seed
60
+ generator = pipeline('text-generation', model='gpt2-xl')
61
+ set_seed(42)
62
+ generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)
63
+ ```
64
+
65
+ Here is how to use this model to get the features of a given text in PyTorch:
66
+
67
+ ```python
68
+ from transformers import GPT2Tokenizer, GPT2Model
69
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2-xl')
70
+ model = GPT2Model.from_pretrained('gpt2-xl')
71
+ text = "Replace me by any text you'd like."
72
+ encoded_input = tokenizer(text, return_tensors='pt')
73
+ output = model(**encoded_input)
74
+ ```
75
+
76
+ and in TensorFlow:
77
+
78
+ ```python
79
+ from transformers import GPT2Tokenizer, TFGPT2Model
80
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2-xl')
81
+ model = TFGPT2Model.from_pretrained('gpt2-xl')
82
+ text = "Replace me by any text you'd like."
83
+ encoded_input = tokenizer(text, return_tensors='tf')
84
+ output = model(encoded_input)
85
+ ```
86
+
87
+ ## Uses
88
+
89
+ #### Direct Use
90
+
91
+ In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
92
+
93
+ > The primary intended users of these models are AI researchers and practitioners.
94
+ >
95
+ > We primarily imagine these language models will be used by researchers to better understand the behaviors, capabilities, biases, and constraints of large-scale generative language models.
96
+
97
+ #### Downstream Use
98
+
99
+ In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
100
+
101
+ > Here are some secondary use cases we believe are likely:
102
+ >
103
+ > - Writing assistance: Grammar assistance, autocompletion (for normal prose or code)
104
+ > - Creative writing and art: exploring the generation of creative, fictional texts; aiding creation of poetry and other literary art.
105
+ > - Entertainment: Creation of games, chat bots, and amusing generations.
106
+
107
+ #### Misuse and Out-of-scope Use
108
+
109
+ In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
110
+
111
+ > Because large-scale language models like GPT-2 do not distinguish fact from fiction, we don’t support use-cases that require the generated text to be true.
112
+ >
113
+ > Additionally, language models like GPT-2 reflect the biases inherent to the systems they were trained on, so we do not recommend that they be deployed into systems that interact with humans unless the deployers first carry out a study of biases relevant to the intended use-case. We found no statistically significant difference in gender, race, and religious bias probes between 774M and 1.5B, implying all versions of GPT-2 should be approached with similar levels of caution around use cases that are sensitive to biases around human attributes.
114
+
115
+ ## Risks, Limitations and Biases
116
+
117
+ **CONTENT WARNING: Readers should be aware this section contains content that is disturbing, offensive, and can propogate historical and current stereotypes.**
118
+
119
+ #### Biases
120
+
121
+ Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)).
122
+
123
+ The training data used for this model has not been released as a dataset one can browse. We know it contains a lot of unfiltered content from the internet, which is far from neutral. Predictions generated by the model can include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups. For example:
124
+
125
+ ```python
126
+ from transformers import pipeline, set_seed
127
+ generator = pipeline('text-generation', model='gpt2-xl')
128
+ set_seed(42)
129
+ generator("The man worked as a", max_length=10, num_return_sequences=5)
130
+
131
+ set_seed(42)
132
+ generator("The woman worked as a", max_length=10, num_return_sequences=5)
133
+ ```
134
+
135
+ This bias will also affect all fine-tuned versions of this model. Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
136
+
137
+ #### Risks and Limitations
138
+
139
+ When they released the 1.5B parameter model, OpenAI wrote in a [blog post](https://openai.com/blog/gpt-2-1-5b-release/):
140
+
141
+ > GPT-2 can be fine-tuned for misuse. Our partners at the Middlebury Institute of International Studies’ Center on Terrorism, Extremism, and Counterterrorism (CTEC) found that extremist groups can use GPT-2 for misuse, specifically by fine-tuning GPT-2 models on four ideological positions: white supremacy, Marxism, jihadist Islamism, and anarchism. CTEC demonstrated that it’s possible to create models that can generate synthetic propaganda for these ideologies. They also show that, despite having low detection accuracy on synthetic outputs, ML-based detection methods can give experts reasonable suspicion that an actor is generating synthetic text.
142
+
143
+ The blog post further discusses the risks, limitations, and biases of the model.
144
+
145
+ ## Training
146
+
147
+ #### Training Data
148
+
149
+ The OpenAI team wanted to train this model on a corpus as large as possible. To build it, they scraped all the web
150
+ pages from outbound links on Reddit which received at least 3 karma. Note that all Wikipedia pages were removed from
151
+ this dataset, so the model was not trained on any part of Wikipedia. The resulting dataset (called WebText) weights
152
+ 40GB of texts but has not been publicly released. You can find a list of the top 1,000 domains present in WebText
153
+ [here](https://github.com/openai/gpt-2/blob/master/domains.txt).
154
+
155
+ #### Training Procedure
156
+
157
+ The model is pretrained on a very large corpus of English data in a self-supervised fashion. This
158
+ means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots
159
+ of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
160
+ it was trained to guess the next word in sentences.
161
+
162
+ More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence,
163
+ shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the
164
+ predictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
165
+
166
+ This way, the model learns an inner representation of the English language that can then be used to extract features
167
+ useful for downstream tasks.
168
+
169
+ The texts are tokenized using a byte-level version of Byte Pair Encoding (BPE) (for unicode characters) and a
170
+ vocabulary size of 50,257. The inputs are sequences of 1024 consecutive tokens.
171
+
172
+ ## Evaluation
173
+
174
+ The following evaluation information is extracted from the [associated paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf).
175
+
176
+ #### Testing Data, Factors and Metrics
177
+
178
+ The model authors write in the [associated paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) that:
179
+
180
+ > Since our model operates on a byte level and does not require lossy pre-processing or tokenization, we can evaluate it on any language model benchmark. Results on language modeling datasets are commonly reported in a quantity which is a scaled or ex- ponentiated version of the average negative log probability per canonical prediction unit - usually a character, a byte, or a word. We evaluate the same quantity by computing the log-probability of a dataset according to a WebText LM and dividing by the number of canonical units. For many of these datasets, WebText LMs would be tested significantly out- of-distribution, having to predict aggressively standardized text, tokenization artifacts such as disconnected punctuation and contractions, shuffled sentences, and even the string <UNK> which is extremely rare in WebText - occurring only 26 times in 40 billion bytes. We report our main results...using invertible de-tokenizers which remove as many of these tokenization / pre-processing artifacts as possible. Since these de-tokenizers are invertible, we can still calculate the log probability of a dataset and they can be thought of as a simple form of domain adaptation.
181
+
182
+ #### Results
183
+
184
+ The model achieves the following results without any fine-tuning (zero-shot):
185
+
186
+ | Dataset | LAMBADA | LAMBADA | CBT-CN | CBT-NE | WikiText2 | PTB | enwiki8 | text8 | WikiText103 | 1BW |
187
+ |:--------:|:-------:|:-------:|:------:|:------:|:---------:|:------:|:-------:|:------:|:-----------:|:-----:|
188
+ | (metric) | (PPL) | (ACC) | (ACC) | (ACC) | (PPL) | (PPL) | (BPB) | (BPC) | (PPL) | (PPL) |
189
+ | | 8.63 | 63.24 | 93.30 | 89.05 | 18.34 | 35.76 | 0.93 | 0.98 | 17.48 | 42.16 |
190
+
191
+ ## Environmental Impact
192
+
193
+ 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). The hardware type and hours used are based on information provided by one of the model authors on [Reddit](https://bit.ly/2Tw1x4L).
194
+
195
+ - **Hardware Type:** 32 TPUv3 chips
196
+ - **Hours used:** 168
197
+ - **Cloud Provider:** Unknown
198
+ - **Compute Region:** Unknown
199
+ - **Carbon Emitted:** Unknown
200
+
201
+ ## Technical Specifications
202
+
203
+ See the [associated paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) for details on the modeling architecture, objective, and training details.
204
+
205
+ ## Citation Information
206
+
207
+ ```bibtex
208
+ @article{radford2019language,
209
+ title={Language models are unsupervised multitask learners},
210
+ author={Radford, Alec and Wu, Jeffrey and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya and others},
211
+ journal={OpenAI blog},
212
+ volume={1},
213
+ number={8},
214
+ pages={9},
215
+ year={2019}
216
+ }
217
+ ```
218
+
219
+ ## Model Card Authors
220
+
221
+ This model card was written by the Hugging Face team.
222
+