Crataco commited on
Commit
413f41b
·
1 Parent(s): 572e050

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +174 -0
README.md CHANGED
@@ -1,3 +1,177 @@
1
  ---
2
  license: mit
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language: en
4
+ tags:
5
+ - text generation
6
+ - ggml
7
+ inference: false
8
  ---
9
+
10
+ # GPT-2 Series GGML
11
+ ### This repository contains quantized conversions of the original Tensorflow GPT-2 checkpoints.
12
+ *For use with frontends that support GGML quantized GPT-2 models, such as KoboldCpp and Oobabooga (with the CTransformers loader).*
13
+
14
+ *Last updated on 2023-09-27.*
15
+
16
+ The original models can be found [here](https://github.com/openai/gpt-2/blob/master/download_model.py), and the original model card (from Huggingface) can be found below.
17
+
18
+ * * *
19
+
20
+ # GPT-2
21
+
22
+ Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large
23
+
24
+ Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in
25
+ [this paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)
26
+ and first released at [this page](https://openai.com/blog/better-language-models/).
27
+
28
+ Disclaimer: The team releasing GPT-2 also wrote a
29
+ [model card](https://github.com/openai/gpt-2/blob/master/model_card.md) for their model. Content from this model card
30
+ has been written by the Hugging Face team to complete the information they provided and give specific examples of bias.
31
+
32
+ ## Model description
33
+
34
+ GPT-2 is a transformers model pretrained on a very large corpus of English data in a self-supervised fashion. This
35
+ means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots
36
+ of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
37
+ it was trained to guess the next word in sentences.
38
+
39
+ More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence,
40
+ shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the
41
+ predictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
42
+
43
+ This way, the model learns an inner representation of the English language that can then be used to extract features
44
+ useful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from a
45
+ prompt.
46
+
47
+ This is the **smallest** version of GPT-2, with 124M parameters.
48
+
49
+ **Related Models:** [GPT-Large](https://huggingface.co/gpt2-large), [GPT-Medium](https://huggingface.co/gpt2-medium) and [GPT-XL](https://huggingface.co/gpt2-xl)
50
+
51
+ ## Intended uses & limitations
52
+
53
+ You can use the raw model for text generation or fine-tune it to a downstream task. See the
54
+ [model hub](https://huggingface.co/models?filter=gpt2) to look for fine-tuned versions on a task that interests you.
55
+
56
+ ### How to use
57
+
58
+ You can use this model directly with a pipeline for text generation. Since the generation relies on some randomness, we
59
+ set a seed for reproducibility:
60
+
61
+ ```python
62
+ >>> from transformers import pipeline, set_seed
63
+ >>> generator = pipeline('text-generation', model='gpt2')
64
+ >>> set_seed(42)
65
+ >>> generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)
66
+
67
+ [{'generated_text': "Hello, I'm a language model, a language for thinking, a language for expressing thoughts."},
68
+ {'generated_text': "Hello, I'm a language model, a compiler, a compiler library, I just want to know how I build this kind of stuff. I don"},
69
+ {'generated_text': "Hello, I'm a language model, and also have more than a few of your own, but I understand that they're going to need some help"},
70
+ {'generated_text': "Hello, I'm a language model, a system model. I want to know my language so that it might be more interesting, more user-friendly"},
71
+ {'generated_text': 'Hello, I\'m a language model, not a language model"\n\nThe concept of "no-tricks" comes in handy later with new'}]
72
+ ```
73
+
74
+ Here is how to use this model to get the features of a given text in PyTorch:
75
+
76
+ ```python
77
+ from transformers import GPT2Tokenizer, GPT2Model
78
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
79
+ model = GPT2Model.from_pretrained('gpt2')
80
+ text = "Replace me by any text you'd like."
81
+ encoded_input = tokenizer(text, return_tensors='pt')
82
+ output = model(**encoded_input)
83
+ ```
84
+
85
+ and in TensorFlow:
86
+
87
+ ```python
88
+ from transformers import GPT2Tokenizer, TFGPT2Model
89
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
90
+ model = TFGPT2Model.from_pretrained('gpt2')
91
+ text = "Replace me by any text you'd like."
92
+ encoded_input = tokenizer(text, return_tensors='tf')
93
+ output = model(encoded_input)
94
+ ```
95
+
96
+ ### Limitations and bias
97
+
98
+ The training data used for this model has not been released as a dataset one can browse. We know it contains a lot of
99
+ unfiltered content from the internet, which is far from neutral. As the openAI team themselves point out in their
100
+ [model card](https://github.com/openai/gpt-2/blob/master/model_card.md#out-of-scope-use-cases):
101
+
102
+ > Because large-scale language models like GPT-2 do not distinguish fact from fiction, we don’t support use-cases
103
+ > that require the generated text to be true.
104
+ >
105
+ > Additionally, language models like GPT-2 reflect the biases inherent to the systems they were trained on, so we do
106
+ > not recommend that they be deployed into systems that interact with humans > unless the deployers first carry out a
107
+ > study of biases relevant to the intended use-case. We found no statistically significant difference in gender, race,
108
+ > and religious bias probes between 774M and 1.5B, implying all versions of GPT-2 should be approached with similar
109
+ > levels of caution around use cases that are sensitive to biases around human attributes.
110
+
111
+ Here's an example of how the model can have biased predictions:
112
+
113
+ ```python
114
+ >>> from transformers import pipeline, set_seed
115
+ >>> generator = pipeline('text-generation', model='gpt2')
116
+ >>> set_seed(42)
117
+ >>> generator("The White man worked as a", max_length=10, num_return_sequences=5)
118
+
119
+ [{'generated_text': 'The White man worked as a mannequin for'},
120
+ {'generated_text': 'The White man worked as a maniser of the'},
121
+ {'generated_text': 'The White man worked as a bus conductor by day'},
122
+ {'generated_text': 'The White man worked as a plumber at the'},
123
+ {'generated_text': 'The White man worked as a journalist. He had'}]
124
+
125
+ >>> set_seed(42)
126
+ >>> generator("The Black man worked as a", max_length=10, num_return_sequences=5)
127
+
128
+ [{'generated_text': 'The Black man worked as a man at a restaurant'},
129
+ {'generated_text': 'The Black man worked as a car salesman in a'},
130
+ {'generated_text': 'The Black man worked as a police sergeant at the'},
131
+ {'generated_text': 'The Black man worked as a man-eating monster'},
132
+ {'generated_text': 'The Black man worked as a slave, and was'}]
133
+ ```
134
+
135
+ This bias will also affect all fine-tuned versions of this model.
136
+
137
+ ## Training data
138
+
139
+ The OpenAI team wanted to train this model on a corpus as large as possible. To build it, they scraped all the web
140
+ pages from outbound links on Reddit which received at least 3 karma. Note that all Wikipedia pages were removed from
141
+ this dataset, so the model was not trained on any part of Wikipedia. The resulting dataset (called WebText) weights
142
+ 40GB of texts but has not been publicly released. You can find a list of the top 1,000 domains present in WebText
143
+ [here](https://github.com/openai/gpt-2/blob/master/domains.txt).
144
+
145
+ ## Training procedure
146
+
147
+ ### Preprocessing
148
+
149
+ The texts are tokenized using a byte-level version of Byte Pair Encoding (BPE) (for unicode characters) and a
150
+ vocabulary size of 50,257. The inputs are sequences of 1024 consecutive tokens.
151
+
152
+ The larger model was trained on 256 cloud TPU v3 cores. The training duration was not disclosed, nor were the exact
153
+ details of training.
154
+
155
+ ## Evaluation results
156
+
157
+ The model achieves the following results without any fine-tuning (zero-shot):
158
+
159
+ | Dataset | LAMBADA | LAMBADA | CBT-CN | CBT-NE | WikiText2 | PTB | enwiki8 | text8 | WikiText103 | 1BW |
160
+ |:--------:|:-------:|:-------:|:------:|:------:|:---------:|:------:|:-------:|:------:|:-----------:|:-----:|
161
+ | (metric) | (PPL) | (ACC) | (ACC) | (ACC) | (PPL) | (PPL) | (BPB) | (BPC) | (PPL) | (PPL) |
162
+ | | 35.13 | 45.99 | 87.65 | 83.4 | 29.41 | 65.85 | 1.16 | 1,17 | 37.50 | 75.20 |
163
+
164
+
165
+ ### BibTeX entry and citation info
166
+
167
+ ```bibtex
168
+ @article{radford2019language,
169
+ title={Language Models are Unsupervised Multitask Learners},
170
+ author={Radford, Alec and Wu, Jeff and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},
171
+ year={2019}
172
+ }
173
+ ```
174
+
175
+ <a href="https://huggingface.co/exbert/?model=gpt2">
176
+ <img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
177
+ </a>