初始化项目,由ModelHub XC社区提供模型
Model: Narsil/gpt3 Source: Original Platform
This commit is contained in:
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
*.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
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
3
64-8bits.tflite
Normal file
3
64-8bits.tflite
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c966da3b74697803352ca7c6f2f220e7090a557b619de9da0c6b34d89f7825c1
|
||||
size 125162496
|
||||
3
64-fp16.tflite
Normal file
3
64-fp16.tflite
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1ceafd82e733dd4b21570b2a86cf27556a983041806c033a55d086e0ed782cd3
|
||||
size 248269688
|
||||
3
64.tflite
Normal file
3
64.tflite
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cfcd510b239d90b71ee87d4e57a5a8c2d55b2a941e5d9fe5852298268ddbe61b
|
||||
size 495791932
|
||||
166
README.md
Normal file
166
README.md
Normal file
@@ -0,0 +1,166 @@
|
||||
---
|
||||
language: en
|
||||
tags:
|
||||
- exbert
|
||||
license: mit
|
||||
pipeline_tag: text-generation
|
||||
duplicated_from: Narsil/gpt2
|
||||
---
|
||||
|
||||
|
||||
# GPT-2
|
||||
|
||||
Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large
|
||||
|
||||
Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in
|
||||
[this paper](https://d4mucfpksywv.cloudfront.net/better-language-models/language_models_are_unsupervised_multitask_learners.pdf)
|
||||
and first released at [this page](https://openai.com/blog/better-language-models/).
|
||||
|
||||
Disclaimer: The team releasing GPT-2 also wrote a
|
||||
[model card](https://github.com/openai/gpt-2/blob/master/model_card.md) for their model. Content from this model card
|
||||
has been written by the Hugging Face team to complete the information they provided and give specific examples of bias.
|
||||
|
||||
## Model description
|
||||
|
||||
GPT-2 is a transformers model pretrained on a very large corpus of English data in a self-supervised fashion. This
|
||||
means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots
|
||||
of 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 the
|
||||
predictions 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 features
|
||||
useful for downstream tasks. The model is best at what it was pretrained for however, which is generating texts from a
|
||||
prompt.
|
||||
|
||||
## Intended uses & limitations
|
||||
|
||||
You can use the raw model for text generation or fine-tune it to a downstream task. See the
|
||||
[model hub](https://huggingface.co/models?filter=gpt2) to look for fine-tuned versions on a task that interests you.
|
||||
|
||||
### How to use
|
||||
|
||||
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:
|
||||
|
||||
```python
|
||||
>>> from transformers import pipeline, set_seed
|
||||
>>> generator = pipeline('text-generation', model='gpt2')
|
||||
>>> 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, a language for thinking, a language for expressing thoughts."},
|
||||
{'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"},
|
||||
{'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"},
|
||||
{'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"},
|
||||
{'generated_text': 'Hello, I\\'m a language model, not a language model"\
|
||||
\
|
||||
The concept of "no-tricks" comes in handy later with new'}]
|
||||
```
|
||||
|
||||
Here is how to use this model to get the features of a given text in PyTorch:
|
||||
|
||||
```python
|
||||
from transformers import GPT2Tokenizer, GPT2Model
|
||||
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
||||
model = GPT2Model.from_pretrained('gpt2')
|
||||
text = "Replace me by any text you'd like."
|
||||
encoded_input = tokenizer(text, return_tensors='pt')
|
||||
output = model(**encoded_input)
|
||||
```
|
||||
|
||||
and in TensorFlow:
|
||||
|
||||
```python
|
||||
from transformers import GPT2Tokenizer, TFGPT2Model
|
||||
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
||||
model = TFGPT2Model.from_pretrained('gpt2')
|
||||
text = "Replace me by any text you'd like."
|
||||
encoded_input = tokenizer(text, return_tensors='tf')
|
||||
output = model(encoded_input)
|
||||
```
|
||||
|
||||
### Limitations and bias
|
||||
|
||||
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. As the openAI team themselves point out in their
|
||||
[model card](https://github.com/openai/gpt-2/blob/master/model_card.md#out-of-scope-use-cases):
|
||||
|
||||
> 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.
|
||||
|
||||
Here's an example of how the model can have biased predictions:
|
||||
|
||||
```python
|
||||
>>> from transformers import pipeline, set_seed
|
||||
>>> generator = pipeline('text-generation', model='gpt2')
|
||||
>>> set_seed(42)
|
||||
>>> generator("The White man worked as a", max_length=10, num_return_sequences=5)
|
||||
|
||||
[{'generated_text': 'The White man worked as a mannequin for'},
|
||||
{'generated_text': 'The White man worked as a maniser of the'},
|
||||
{'generated_text': 'The White man worked as a bus conductor by day'},
|
||||
{'generated_text': 'The White man worked as a plumber at the'},
|
||||
{'generated_text': 'The White man worked as a journalist. He had'}]
|
||||
|
||||
>>> set_seed(42)
|
||||
>>> generator("The Black man worked as a", max_length=10, num_return_sequences=5)
|
||||
|
||||
[{'generated_text': 'The Black man worked as a man at a restaurant'},
|
||||
{'generated_text': 'The Black man worked as a car salesman in a'},
|
||||
{'generated_text': 'The Black man worked as a police sergeant at the'},
|
||||
{'generated_text': 'The Black man worked as a man-eating monster'},
|
||||
{'generated_text': 'The Black man worked as a slave, and was'}]
|
||||
```
|
||||
|
||||
This bias will also affect all fine-tuned versions of this model.
|
||||
|
||||
## Training data
|
||||
|
||||
The OpenAI team wanted to train this model on a corpus as large as possible. To build it, they scraped all the web
|
||||
pages from outbound links on Reddit which received at least 3 karma. Note that all Wikipedia pages were removed from
|
||||
this dataset, so the model was not trained on any part of Wikipedia. The resulting dataset (called WebText) weights
|
||||
40GB 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
|
||||
|
||||
### Preprocessing
|
||||
|
||||
The texts are tokenized using a byte-level version of Byte Pair Encoding (BPE) (for unicode characters) and a
|
||||
vocabulary size of 50,257. The inputs are sequences of 1024 consecutive tokens.
|
||||
|
||||
The larger model was trained on 256 cloud TPU v3 cores. The training duration was not disclosed, nor were the exact
|
||||
details of training.
|
||||
|
||||
## Evaluation 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) |
|
||||
| | 35.13 | 45.99 | 87.65 | 83.4 | 29.41 | 65.85 | 1.16 | 1,17 | 37.50 | 75.20 |
|
||||
|
||||
|
||||
### BibTeX entry and citation info
|
||||
|
||||
```bibtex
|
||||
@article{radford2019language,
|
||||
title={Language Models are Unsupervised Multitask Learners},
|
||||
author={Radford, Alec and Wu, Jeff and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},
|
||||
year={2019}
|
||||
}
|
||||
```
|
||||
|
||||
<a href="https://huggingface.co/exbert/?model=gpt2">
|
||||
\t<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
|
||||
</a>
|
||||
31
config.json
Normal file
31
config.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"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": 768,
|
||||
"n_head": 12,
|
||||
"n_layer": 12,
|
||||
"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
|
||||
}
|
||||
3
flax_model.msgpack
Normal file
3
flax_model.msgpack
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:192e8257ae9e8f796f764630f4a488a6a16d1461762d62b49ef7405df951a283
|
||||
size 497764120
|
||||
50001
merges.txt
Normal file
50001
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:158e291215633e14f93e58f4f4cc16c61d14be67960efd20aa07eb260e177069
|
||||
size 548105230
|
||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7c5d3f4b8b76583b422fcb9189ad6c89d5d97a094541ce8932dce3ecabde1421
|
||||
size 548118077
|
||||
3
rust_model.ot
Normal file
3
rust_model.ot
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:adf0adedbf4016b249550f866c66a3b3a3d09c8b3b3a1f6e5e9a265d94e0270e
|
||||
size 702517648
|
||||
3
tf_model.h5
Normal file
3
tf_model.h5
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d08c1307f7dfae6f878e0a2ca5715d587d2640530db8ef96fc0c1fc474dd9fee
|
||||
size 497933648
|
||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user