Upload folder using huggingface_hub
Browse filesFiles changed (29)
- gpt2-large/pretrained/.gitattributesAdded+15
- gpt2-large/pretrained/README.mdAdded+212
- gpt2-large/pretrained/config.jsonAdded+31
- gpt2-large/pretrained/flax_model.msgpackAdded+3
- gpt2-large/pretrained/generation_config.jsonAdded+6
- gpt2-large/pretrained/generation_config_for_text_generation.jsonAdded+8
- gpt2-large/pretrained/merges.txtAdded
- gpt2-large/pretrained/model.safetensorsAdded+3
- gpt2-large/pretrained/onnx/Constant_164_attr__valueAdded+3
- gpt2-large/pretrained/onnx/Constant_174_attr__valueAdded+3
- gpt2-large/pretrained/onnx/config.jsonAdded+38
- gpt2-large/pretrained/onnx/decoder_model.onnxAdded+3
- gpt2-large/pretrained/onnx/decoder_model.onnx_dataAdded+3
- gpt2-large/pretrained/onnx/decoder_model_merged.onnxAdded+3
- gpt2-large/pretrained/onnx/decoder_model_merged.onnx_dataAdded+3
- gpt2-large/pretrained/onnx/decoder_with_past_model.onnxAdded+3
- gpt2-large/pretrained/onnx/decoder_with_past_model.onnx_dataAdded+3
- gpt2-large/pretrained/onnx/generation_config.jsonAdded+6
- gpt2-large/pretrained/onnx/merges.txtAdded
- gpt2-large/pretrained/onnx/special_tokens_map.jsonAdded+5
- gpt2-large/pretrained/onnx/tokenizer.jsonAdded
- gpt2-large/pretrained/onnx/tokenizer_config.jsonAdded+9
- gpt2-large/pretrained/onnx/vocab.jsonAdded
- gpt2-large/pretrained/pytorch_model.binAdded+3
- gpt2-large/pretrained/rust_model.otAdded+3
- gpt2-large/pretrained/tf_model.h5Added+3
- gpt2-large/pretrained/tokenizer.jsonAdded
- gpt2-large/pretrained/tokenizer_config.jsonAdded+1
- gpt2-large/pretrained/vocab.jsonAdded
123456789101112131415*.bin.* filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tar.gz filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -textmodel.safetensors filter=lfs diff=lfs merge=lfs -textonnx/Constant_164_attr__value filter=lfs diff=lfs merge=lfs -textonnx/Constant_174_attr__value filter=lfs diff=lfs merge=lfs -textonnx/decoder_model_merged.onnx_data filter=lfs diff=lfs merge=lfs -textonnx/decoder_model.onnx_data filter=lfs diff=lfs merge=lfs -textonnx/decoder_with_past_model.onnx_data filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212---language: enlicense: mit---
# GPT-2 Large
## Table of Contents- [Model Details](#model-details)- [How To Get Started With the Model](#how-to-get-started-with-the-model)- [Uses](#uses)- [Risks, Limitations and Biases](#risks-limitations-and-biases)- [Training](#training)- [Evaluation](#evaluation)- [Environmental Impact](#environmental-impact)- [Technical Specifications](#technical-specifications)- [Citation Information](#citation-information)- [Model Card Authors](#model-card-author)
## Model Details
**Model Description:** GPT-2 Large is the **774M 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.
- **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.- **Model Type:** Transformer-based language model- **Language(s):** English- **License:** [Modified MIT License](https://github.com/openai/gpt-2/blob/master/LICENSE)- **Related Models:** [GPT-2](https://huggingface.co/gpt2), [GPT-Medium](https://huggingface.co/gpt2-medium) and [GPT-XL](https://huggingface.co/gpt2-xl)- **Resources for more information:** - [Research Paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) - [OpenAI Blog Post](https://openai.com/blog/better-language-models/) - [GitHub Repo](https://github.com/openai/gpt-2) - [OpenAI Model Card for GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md) - Test the full generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large
## How to Get Started with the Model
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, weset a seed for reproducibility:
```python>>> from transformers import pipeline, set_seed>>> generator = pipeline('text-generation', model='gpt2-large')>>> set_seed(42)>>> generator("Hello, I'm a language model,", max_length=30, num_return_sequences=5)
[{'generated_text': "Hello, I'm a language model, I can do language modeling. In fact, this is one of the reasons I use languages. To get a"}, {'generated_text': "Hello, I'm a language model, which in its turn implements a model of how a human can reason about a language, and is in turn an"}, {'generated_text': "Hello, I'm a language model, why does this matter for you?\n\nWhen I hear new languages, I tend to start thinking in terms"}, {'generated_text': "Hello, I'm a language model, a functional language...\n\nI don't need to know anything else. If I want to understand about how"}, {'generated_text': "Hello, I'm a language model, not a toolbox.\n\nIn a nutshell, a language model is a set of attributes that define how"}]```
Here is how to use this model to get the features of a given text in PyTorch:
```pythonfrom transformers import GPT2Tokenizer, GPT2Modeltokenizer = GPT2Tokenizer.from_pretrained('gpt2-large')model = GPT2Model.from_pretrained('gpt2-large')text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='pt')output = model(**encoded_input)```
and in TensorFlow:
```pythonfrom transformers import GPT2Tokenizer, TFGPT2Modeltokenizer = GPT2Tokenizer.from_pretrained('gpt2-large')model = TFGPT2Model.from_pretrained('gpt2-large')text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='tf')output = model(encoded_input)```
## Uses
#### Direct Use
In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
> The primary intended users of these models are AI researchers and practitioners.> > 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.
#### Downstream Use
In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
> Here are some secondary use cases we believe are likely:> > - Writing assistance: Grammar assistance, autocompletion (for normal prose or code)> - Creative writing and art: exploring the generation of creative, fictional texts; aiding creation of poetry and other literary art.> - Entertainment: Creation of games, chat bots, and amusing generations.
#### Misuse and Out-of-scope Use
In their [model card about GPT-2](https://github.com/openai/gpt-2/blob/master/model_card.md), OpenAI wrote:
> 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.> > 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.
## Risks, Limitations and Biases
**CONTENT WARNING: Readers should be aware this section contains content that is disturbing, offensive, and can propogate historical and current stereotypes.**
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)).
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:
```python>>> from transformers import pipeline, set_seed>>> generator = pipeline('text-generation', model='gpt2-large')>>> set_seed(42)>>> generator("The man worked as a", max_length=10, num_return_sequences=5)
[{'generated_text': 'The man worked as a security guard in a hotel'}, {'generated_text': 'The man worked as a salesman in Mexico and in'}, {'generated_text': 'The man worked as a supervisor at the warehouse for'}, {'generated_text': "The man worked as a cleaner for the store's"}, {'generated_text': 'The man worked as a barbershop apprentice.'}]
>>> set_seed(42)>>> generator("The woman worked as a", max_length=10, num_return_sequences=5)
[{'generated_text': 'The woman worked as a clerk at the bank.'}, {'generated_text': 'The woman worked as a caregiver, and her'}, {'generated_text': 'The woman worked as a customer service agent for a'}, {'generated_text': 'The woman worked as a cleaner at the store,'}, {'generated_text': 'The woman worked as a barista and was "'}]```
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.
## Training
#### Training Data
The OpenAI team wanted to train this model on a corpus as large as possible. To build it, they scraped all the webpages from outbound links on Reddit which received at least 3 karma. Note that all Wikipedia pages were removed fromthis dataset, so the model was not trained on any part of Wikipedia. The resulting dataset (called WebText) weights40GB of texts but has not been publicly released. You can find a list of the top 1,000 domains present in WebText[here](https://github.com/openai/gpt-2/blob/master/domains.txt).
#### Training Procedure
The model is pretrained on a very large corpus of English data in a self-supervised fashion. Thismeans it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lotsof publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,it was trained to guess the next word in sentences.
More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence,shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure thepredictions for the token `i` only uses the inputs from `1` to `i` but not the future tokens.
This way, the model learns an inner representation of the English language that can then be used to extract featuresuseful for downstream tasks.
The texts are tokenized using a byte-level version of Byte Pair Encoding (BPE) (for unicode characters) and avocabulary size of 50,257. The inputs are sequences of 1024 consecutive tokens.
## Evaluation
The following evaluation information is extracted from the [associated paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf).
#### Testing Data, Factors and Metrics
The model authors write in the [associated paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) that:
> 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.
#### Results
The model achieves the following results without any fine-tuning (zero-shot):
| Dataset | LAMBADA | LAMBADA | CBT-CN | CBT-NE | WikiText2 | PTB | enwiki8 | text8 | WikiText103 | 1BW ||:--------:|:-------:|:-------:|:------:|:------:|:---------:|:------:|:-------:|:------:|:-----------:|:-----:|| (metric) | (PPL) | (ACC) | (ACC) | (ACC) | (PPL) | (PPL) | (BPB) | (BPC) | (PPL) | (PPL) || | 10.87 | 60.12 | 93.45 | 88.0 | 19.93 | 40.31 | 0.97 | 1.02 | 22.05 | 44.575|
## Environmental Impact
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).
- **Hardware Type:** Unknown- **Hours used:** Unknown- **Cloud Provider:** Unknown- **Compute Region:** Unknown- **Carbon Emitted:** Unknown
## Technical Specifications
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, compute infrastructure, and training details.
## Citation Information
```bibtex@article{radford2019language, title={Language models are unsupervised multitask learners}, author={Radford, Alec and Wu, Jeffrey and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya and others}, journal={OpenAI blog}, volume={1}, number={8}, pages={9}, year={2019}}```
## Model Card Authors
This model card was written by the Hugging Face team.12345678910111213141516171819202122232425262728293031{ "activation_function": "gelu_new", "architectures": [ "GPT2LMHeadModel" ], "attn_pdrop": 0.1, "bos_token_id": 50256, "embd_pdrop": 0.1, "eos_token_id": 50256, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "model_type": "gpt2", "n_ctx": 1024, "n_embd": 1280, "n_head": 20, "n_layer": 36, "n_positions": 1024, "resid_pdrop": 0.1, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "task_specific_params": { "text-generation": { "do_sample": true, "max_length": 50 } }, "vocab_size": 50257}123version https://git-lfs.github.com/spec/v1oid sha256:9aa10eb25a628041355dfb4803839c592573a33d4bcdc9300f2c50a170f04a42size 3096134690123456{ "_from_model_config": true, "bos_token_id": 50256, "eos_token_id": 50256, "transformers_version": "4.27.0.dev0"}12345678{ "_from_model_config": true, "bos_token_id": 50256, "do_sample": true, "eos_token_id": 50256, "max_length": 50, "transformers_version": "4.27.0.dev0"}123version https://git-lfs.github.com/spec/v1oid sha256:5f47f3e12f91cd33b662ce7e433b6150ad5512b5884a2cee961b50e9c3bbebcesize 3247159078123version https://git-lfs.github.com/spec/v1oid sha256:ae525b5c247f1f7b8310c42b37be7aed79adadb1806bb109d1e14c8c896fc319size 1048576123version https://git-lfs.github.com/spec/v1oid sha256:ae525b5c247f1f7b8310c42b37be7aed79adadb1806bb109d1e14c8c896fc319size 10485761234567891011121314151617181920212223242526272829303132333435363738{ "_name_or_path": "gpt2-large", "activation_function": "gelu_new", "architectures": [ "GPT2LMHeadModel" ], "attn_pdrop": 0.1, "bos_token_id": 50256, "embd_pdrop": 0.1, "eos_token_id": 50256, "initializer_range": 0.02, "layer_norm_epsilon": 1e-05, "model_type": "gpt2", "n_ctx": 1024, "n_embd": 1280, "n_head": 20, "n_inner": null, "n_layer": 36, "n_positions": 1024, "reorder_and_upcast_attn": false, "resid_pdrop": 0.1, "scale_attn_by_inverse_layer_idx": false, "scale_attn_weights": true, "summary_activation": null, "summary_first_dropout": 0.1, "summary_proj_to_labels": true, "summary_type": "cls_index", "summary_use_proj": true, "task_specific_params": { "text-generation": { "do_sample": true, "max_length": 50 } }, "transformers_version": "4.30.2", "use_cache": true, "vocab_size": 50257}123version https://git-lfs.github.com/spec/v1oid sha256:6928b9ea9cefb712ddb36264ac8b572f7df0ee5d3d774f45154ca0cd381ccbc2size 2650140123version https://git-lfs.github.com/spec/v1oid sha256:37e3f7ff14aa5b4d2eb0362f3139744f0a327054d16806a8d8b5cbf021c8d990size 3353436160123version https://git-lfs.github.com/spec/v1oid sha256:fb52fbf6a99a73c98e2125a77d5932d4d0a3da5ef2cf6451cb6408a96e57a504size 5289305123version https://git-lfs.github.com/spec/v1oid sha256:37e3f7ff14aa5b4d2eb0362f3139744f0a327054d16806a8d8b5cbf021c8d990size 3353436160123version https://git-lfs.github.com/spec/v1oid sha256:620cad159131a999e2a5b73717246b0e1ceb85c644f0f4d4e7899907d133abedsize 2673585123version https://git-lfs.github.com/spec/v1oid sha256:37e3f7ff14aa5b4d2eb0362f3139744f0a327054d16806a8d8b5cbf021c8d990size 3353436160123456{ "_from_model_config": true, "bos_token_id": 50256, "eos_token_id": 50256, "transformers_version": "4.30.2"}12345{ "bos_token": "<|endoftext|>", "eos_token": "<|endoftext|>", "unk_token": "<|endoftext|>"}123456789{ "add_prefix_space": false, "bos_token": "<|endoftext|>", "clean_up_tokenization_spaces": true, "eos_token": "<|endoftext|>", "model_max_length": 1024, "tokenizer_class": "GPT2Tokenizer", "unk_token": "<|endoftext|>"}123version https://git-lfs.github.com/spec/v1oid sha256:8d3ade6b55ac440e926112267b9ec784097437c7300544b8beec562a411428ecsize 3247202234123version https://git-lfs.github.com/spec/v1oid sha256:4da5e3c0a8b10f3fecb775a1c312814d7f0b08699ca08b14f820801caf9ca42fsize 3504540144123version https://git-lfs.github.com/spec/v1oid sha256:71e91ce5f1120392f874e9dd6037c6fd81e24ea945c957156e8e5b31f00c81fesize 30966180241{"model_max_length": 1024}gpt2-large/pretrained/.gitattributesAdded+15
gpt2-large/pretrained/README.mdAdded+212
gpt2-large/pretrained/config.jsonAdded+31
gpt2-large/pretrained/flax_model.msgpackAdded+3
gpt2-large/pretrained/generation_config.jsonAdded+6
gpt2-large/pretrained/generation_config_for_text_generation.jsonAdded+8
gpt2-large/pretrained/merges.txtAdded
gpt2-large/pretrained/model.safetensorsAdded+3
gpt2-large/pretrained/onnx/Constant_164_attr__valueAdded+3
gpt2-large/pretrained/onnx/Constant_174_attr__valueAdded+3
gpt2-large/pretrained/onnx/config.jsonAdded+38
gpt2-large/pretrained/onnx/decoder_model.onnxAdded+3
gpt2-large/pretrained/onnx/decoder_model.onnx_dataAdded+3
gpt2-large/pretrained/onnx/decoder_model_merged.onnxAdded+3
gpt2-large/pretrained/onnx/decoder_model_merged.onnx_dataAdded+3
gpt2-large/pretrained/onnx/decoder_with_past_model.onnxAdded+3
gpt2-large/pretrained/onnx/decoder_with_past_model.onnx_dataAdded+3
gpt2-large/pretrained/onnx/generation_config.jsonAdded+6
gpt2-large/pretrained/onnx/merges.txtAdded
gpt2-large/pretrained/onnx/special_tokens_map.jsonAdded+5
gpt2-large/pretrained/onnx/tokenizer.jsonAdded
gpt2-large/pretrained/onnx/tokenizer_config.jsonAdded+9
gpt2-large/pretrained/onnx/vocab.jsonAdded
gpt2-large/pretrained/pytorch_model.binAdded+3
gpt2-large/pretrained/rust_model.otAdded+3
gpt2-large/pretrained/tf_model.h5Added+3
gpt2-large/pretrained/tokenizer.jsonAdded
gpt2-large/pretrained/tokenizer_config.jsonAdded+1
gpt2-large/pretrained/vocab.jsonAdded