初始化项目,由ModelHub XC社区提供模型
Model: stefan-it/german-gpt2-larger Source: Original Platform
This commit is contained in:
28
.gitattributes
vendored
Normal file
28
.gitattributes
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet 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
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
109
README.md
Normal file
109
README.md
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
language: de
|
||||
widget:
|
||||
- text: "Heute ist sehr schönes Wetter in"
|
||||
license: mit
|
||||
---
|
||||
|
||||
# German GPT-2 model
|
||||
In this repository we release (yet another) GPT-2 model, that was trained on ~90 GB from the ["German colossal, clean Common Crawl corpus"](https://german-nlp-group.github.io/projects/gc4-corpus.html) (GC4).
|
||||
|
||||
The model is meant to be an entry point for fine-tuning on other texts, and it is definitely not as good or "dangerous" as the English GPT-3 model. We do not plan extensive PR or staged releases for this model 😉
|
||||
|
||||
---
|
||||
|
||||
**Disclaimer**: the presented and trained language models in this repository are for **research only** purposes.
|
||||
The GC4 corpus - that was used for training - contains crawled texts from the internet. Thus, this GPT-2 model can
|
||||
be considered as highly biased, resulting in a model that encodes stereotypical associations along gender, race,
|
||||
ethnicity and disability status. Before using and working with the released checkpoints, it is highly recommended
|
||||
to read:
|
||||
|
||||
[On the Dangers of Stochastic Parrots: Can Language Models Be Too Big?](https://faculty.washington.edu/ebender/papers/Stochastic_Parrots.pdf)
|
||||
|
||||
from Emily M. Bender, Timnit Gebru, Angelina McMillan-Major and Shmargaret Shmitchell.
|
||||
|
||||
The aim of this released GPT-2 model for German is to boost research on (large) pre-trained language models for German, especially
|
||||
for identifying biases and how to prevent them, as most research is currently done for English only.
|
||||
|
||||
---
|
||||
|
||||
# Changelog
|
||||
|
||||
* 17.10.2021: We highly recommend to try the Text Generation Pipeline in Transformers. The quality of the generated text from the Inference Widget here can be lower.
|
||||
* 06.09.2021: Initial release. Detailed information about training parameters coming soon.
|
||||
|
||||
# Text Generation
|
||||
|
||||
The following code snippet can be used to generate text with this German GPT-2 model:
|
||||
|
||||
```python
|
||||
from transformers import pipeline
|
||||
|
||||
model_name = "stefan-it/german-gpt2-larger"
|
||||
|
||||
pipe = pipeline('text-generation', model=model_name, tokenizer=model_name)
|
||||
|
||||
text = pipe("Der Sinn des Lebens ist es", max_length=200)[0]["generated_text"]
|
||||
|
||||
print(text)
|
||||
```
|
||||
|
||||
# Training Data
|
||||
|
||||
The following archives are used for training the (first version) of this GPT-2 model:
|
||||
|
||||
* `de_head_0000_2015-48.tar.gz`
|
||||
* `de_head_0000_2016-18.tar.gz`
|
||||
* `de_head_0000_2016-44.tar.gz`
|
||||
* `de_head_0000_2017-13.tar.gz`
|
||||
* `de_head_0000_2017-30.tar.gz`
|
||||
* `de_head_0000_2017-39.tar.gz`
|
||||
* `de_head_0000_2017-51.tar.gz`
|
||||
* `de_head_0000_2018-09.tar.gz`
|
||||
* `de_head_0000_2018-17.tar.gz`
|
||||
* `de_head_0000_2018-30.tar.gz`
|
||||
* `de_head_0000_2018-39.tar.gz`
|
||||
* `de_head_0000_2018-51.tar.gz`
|
||||
* `de_head_0000_2019-18.tar.gz`
|
||||
* `de_head_0000_2019-30.tar.gz`
|
||||
* `de_head_0006_2019-09.tar.gz`
|
||||
* `de_head_0006_2019-18.tar.gz`
|
||||
* `de_head_0006_2019-30.tar.gz`
|
||||
* `de_head_0006_2019-47.tar.gz`
|
||||
* `de_head_0006_2020-10.tar.gz`
|
||||
* `de_head_0007_2018-30.tar.gz`
|
||||
* `de_head_0007_2018-51.tar.gz`
|
||||
* `de_head_0007_2019-09.tar.gz`
|
||||
* `de_head_0007_2019-18.tar.gz`
|
||||
* `de_head_0007_2019-47.tar.gz`
|
||||
* `de_head_0007_2020-10.tar.gz`
|
||||
|
||||
Details and URLs can be found on the [GC4](https://german-nlp-group.github.io/projects/gc4-corpus.html)
|
||||
page.
|
||||
|
||||
Archives are then extracted and NLTK (`german` model) is used to sentence split the corpus.
|
||||
This results in a total training corpus size of 90GB.
|
||||
|
||||
# Training Details
|
||||
|
||||
We use the recently re-trained `dbmdz/german-gpt2` ([version 2](https://huggingface.co/dbmdz/german-gpt2)!)
|
||||
model as back-bone model. Thus, the tokenizer and vocab is the same as used in the `dbmdz/german-gpt2` model.
|
||||
|
||||
The model was trained on a v3-8 TPU, with the following parameters:
|
||||
|
||||
```bash
|
||||
python ./run_clm_flax.py --output_dir=/mnt/datasets/german-gpt2-larger/ --name_or_path dbmdz/german-gpt2 --do_train --do_eval --block_size=512 --per_device_train_batch_size=16 --per_device_eval_batch_size=16 --learning_rate=5e-3 --warmup_steps=1000 --adam_beta1=0.9 --adam_beta2=0.98 --weight_decay=0.01 --overwrite_output_dir --num_train_epochs=20 --logging_steps=500 --save_steps=2500 --eval_steps=2500 --train_file /mnt/datasets/gc4/train.txt --validation_file /mnt/datasets/gc4/validation.txt --preprocessing_num_workers 16
|
||||
```
|
||||
|
||||
Training took around 17 days for 20 epochs.
|
||||
|
||||
# Acknowledgments
|
||||
Research supported with Cloud TPUs from Google's TensorFlow Research Cloud (TFRC).
|
||||
Thanks for providing access to the TFRC ❤️
|
||||
|
||||
Thanks to the generous support from the [Hugging Face](https://huggingface.co/) team,
|
||||
it is possible to download this model from their S3 storage 🤗
|
||||
|
||||
This project heavily profited from the amazing Hugging Face
|
||||
[Community Week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104).
|
||||
Many thanks for the great organization and discussions during and after the week!
|
||||
38
config.json
Normal file
38
config.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"_name_or_path": "./",
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.0,
|
||||
"bos_token_id": 50256,
|
||||
"embd_pdrop": 0.0,
|
||||
"eos_token_id": 50256,
|
||||
"gradient_checkpointing": false,
|
||||
"initializer_range": 0.02,
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 768,
|
||||
"n_head": 12,
|
||||
"n_inner": null,
|
||||
"n_layer": 12,
|
||||
"n_positions": 1024,
|
||||
"resid_pdrop": 0.0,
|
||||
"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
|
||||
}
|
||||
},
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.10.0.dev0",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50265
|
||||
}
|
||||
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:b96e5a7dece1bf40bfff0ba8673f3f4d4cd1a999e49dd735b7844f8cfeef41c0
|
||||
size 497788696
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d7cff59742ed95812623c158603c72da409f8fd3211cb33d1b19dabf0e38da4d
|
||||
size 510384216
|
||||
8
onnx/added_tokens.json
Normal file
8
onnx/added_tokens.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"</s>": 2,
|
||||
"<mask>": 4,
|
||||
"<pad>": 1,
|
||||
"<s>": 0,
|
||||
"<unk>": 3,
|
||||
"<|endoftext|>": 50265
|
||||
}
|
||||
39
onnx/config.json
Normal file
39
onnx/config.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"_name_or_path": "stefan-it/german-gpt2-larger",
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.0,
|
||||
"bos_token_id": 50256,
|
||||
"embd_pdrop": 0.0,
|
||||
"eos_token_id": 50256,
|
||||
"gradient_checkpointing": false,
|
||||
"initializer_range": 0.02,
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 768,
|
||||
"n_head": 12,
|
||||
"n_inner": null,
|
||||
"n_layer": 12,
|
||||
"n_positions": 1024,
|
||||
"reorder_and_upcast_attn": false,
|
||||
"resid_pdrop": 0.0,
|
||||
"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.34.0",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50265
|
||||
}
|
||||
3
onnx/decoder_model.onnx
Normal file
3
onnx/decoder_model.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a39ea53ec68588da329f77f294eea8b33ae6c5305dbb984680ab775c39f3c068
|
||||
size 653714566
|
||||
3
onnx/decoder_model_merged.onnx
Normal file
3
onnx/decoder_model_merged.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a309e2519fd85c396c0e0b313c9a20df8d5654f2bd700d9169f8445a4c6945e9
|
||||
size 655237634
|
||||
3
onnx/decoder_with_past_model.onnx
Normal file
3
onnx/decoder_with_past_model.onnx
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:21b0bcd9d692371b79de797b733f0b5be6fc6171632db5088e8c9998377c3773
|
||||
size 653721372
|
||||
6
onnx/generation_config.json
Normal file
6
onnx/generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 50256,
|
||||
"eos_token_id": 50256,
|
||||
"transformers_version": "4.34.0"
|
||||
}
|
||||
50005
onnx/merges.txt
Normal file
50005
onnx/merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
5
onnx/special_tokens_map.json
Normal file
5
onnx/special_tokens_map.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"bos_token": "<|endoftext|>",
|
||||
"eos_token": "<|endoftext|>",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
100362
onnx/tokenizer.json
Normal file
100362
onnx/tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
60
onnx/tokenizer_config.json
Normal file
60
onnx/tokenizer_config.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"add_prefix_space": false,
|
||||
"added_tokens_decoder": {
|
||||
"0": {
|
||||
"content": "<s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"1": {
|
||||
"content": "<pad>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"2": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"3": {
|
||||
"content": "<unk>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"4": {
|
||||
"content": "<mask>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
},
|
||||
"50265": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false,
|
||||
"special": true
|
||||
}
|
||||
},
|
||||
"additional_special_tokens": [],
|
||||
"bos_token": "<|endoftext|>",
|
||||
"clean_up_tokenization_spaces": true,
|
||||
"eos_token": "<|endoftext|>",
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"tokenizer_class": "GPT2Tokenizer",
|
||||
"unk_token": "<|endoftext|>"
|
||||
}
|
||||
1
onnx/vocab.json
Normal file
1
onnx/vocab.json
Normal file
File diff suppressed because one or more lines are too long
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:9127626d2b273a7b7ed789491ac20869086f74750e49944c2764507a0a9bb407
|
||||
size 510428686
|
||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user