benjamin / gerpt2-large

huggingface.co
Total runs: 1.6K
24-hour runs: 0
7-day runs: -70
30-day runs: 566
Model's Last Updated: May 30 2023
text-generation

Introduction of gerpt2-large

Model Details of gerpt2-large

GerPT2

German large and small versions of GPT2:

See the GPT2 model card for considerations on limitations and bias. See the GPT2 documentation for details on GPT2.

Comparison to dbmdz/german-gpt2

I evaluated both GerPT2-large and the other German GPT2, dbmdz/german-gpt2 on the CC-100 dataset and on the German Wikipedia:

CC-100 (PPL) Wikipedia (PPL)
dbmdz/german-gpt2 49.47 62.92
GerPT2 24.78 35.33
GerPT2-large 16.08 23.26

See the script evaluate.py in the GerPT2 Github repository for the code.

Usage
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

tokenizer = AutoTokenizer.from_pretrained("benjamin/gerpt2-large")
model = AutoModelForCausalLM.from_pretrained("benjamin/gerpt2-large")

prompt = "<your prompt>"

pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
print(pipe(prompt)[0]["generated_text"])

Also, two tricks might improve the generated text:

output = model.generate(
    # during training an EOS token was used to mark the beginning of each text
    # so it can help to insert it at the start
    torch.tensor(
        [tokenizer.eos_token_id] + tokenizer.encode(prompt)
    ).unsqueeze(0),
    do_sample=True,
    # try setting bad_words_ids=[[0]] to disallow generating an EOS token, without this the model is
    # prone to ending generation early because a significant number of texts from the training corpus
    # is quite short
    bad_words_ids=[[0]],
    max_length=max_length,
)[0]
print(tokenizer.decode(output))
Training details

GerPT2-large is trained on the entire German data from the CC-100 Corpus and weights were initialized from the English GPT2 model . GerPT2-large was trained with:

  • a batch size of 256
  • using OneCycle learning rate with a maximum of 5e-3
  • with AdamW with a weight decay of 0.01
  • for 2 epochs

Training took roughly 12 days on 8 TPUv3 cores.

To train GerPT2-large, follow these steps. Scripts are located in the Github repository :

  1. Download and unzip training data from http://data.statmt.org/cc-100/ .
  2. Train a tokenizer using prepare/train_tokenizer.py . As training data for the tokenizer I used a random subset of 5% of the CC-100 data.
  3. (optionally) generate a German input embedding matrix with prepare/generate_aligned_wte.py . This uses a neat trick to semantically map tokens from the English tokenizer to tokens from the German tokenizer using aligned word embeddings. E. g.:
ĠMinde -> Ġleast
Ġjed -> Ġwhatsoever
flughafen -> Air
vermittlung -> employment
teilung -> ignment
ĠInterpretation -> Ġinterpretation
Ġimport -> Ġimported
hansa -> irl
genehmigungen -> exempt
ĠAuflist -> Ġlists
Ġverschwunden -> Ġdisappeared
ĠFlyers -> ĠFlyers
Kanal -> Channel
Ġlehr -> Ġteachers
Ġnahelie -> Ġconvenient
gener -> Generally
mitarbeiter -> staff

This helps a lot on a trial run I did, although I wasn't able to do a full comparison due to budget and time constraints. To use this WTE matrix it can be passed via the wte_path to the training script. Credit to this blogpost for the idea of initializing GPT2 from English weights.

  1. Tokenize the corpus using prepare/tokenize_text.py . This generates files for train and validation tokens in JSON Lines format.
  2. Run the training script train.py ! run.sh shows how this was executed for the full run with config configs/tpu_large.json .
License

GerPT2 is licensed under the MIT License.

Citing

Please cite GerPT2 as follows:

@misc{Minixhofer_GerPT2_German_large_2020,
author = {Minixhofer, Benjamin},
doi = {10.5281/zenodo.5509984},
month = {12},
title = {{GerPT2: German large and small versions of GPT2}},
url = {https://github.com/bminixhofer/gerpt2},
year = {2020}
}
Acknowledgements

Thanks to Hugging Face for awesome tools and infrastructure. Huge thanks to Artus Krohn-Grimberghe at LYTiQ for making this possible by sponsoring the resources used for training.

Runs of benjamin gerpt2-large on huggingface.co

1.6K
Total runs
0
24-hour runs
-3
3-day runs
-70
7-day runs
566
30-day runs

More Information About gerpt2-large huggingface.co Model

More gerpt2-large license Visit here:

https://choosealicense.com/licenses/mit

gerpt2-large huggingface.co

gerpt2-large huggingface.co is an AI model on huggingface.co that provides gerpt2-large's model effect (), which can be used instantly with this benjamin gerpt2-large model. huggingface.co supports a free trial of the gerpt2-large model, and also provides paid use of the gerpt2-large. Support call gerpt2-large model through api, including Node.js, Python, http.

gerpt2-large huggingface.co Url

https://huggingface.co/benjamin/gerpt2-large

benjamin gerpt2-large online free

gerpt2-large huggingface.co is an online trial and call api platform, which integrates gerpt2-large's modeling effects, including api services, and provides a free online trial of gerpt2-large, you can try gerpt2-large online for free by clicking the link below.

benjamin gerpt2-large online free url in huggingface.co:

https://huggingface.co/benjamin/gerpt2-large

gerpt2-large install

gerpt2-large is an open source model from GitHub that offers a free installation service, and any user can find gerpt2-large on GitHub to install. At the same time, huggingface.co provides the effect of gerpt2-large install, users can directly use gerpt2-large installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

gerpt2-large install url in huggingface.co:

https://huggingface.co/benjamin/gerpt2-large

Url of gerpt2-large

gerpt2-large huggingface.co Url

Provider of gerpt2-large huggingface.co

benjamin
ORGANIZATIONS

Other API from benjamin

huggingface.co

Total runs: 5.0K
Run Growth: 3.8K
Growth Rate: 81.84%
Updated:May 30 2023