readme: ---
  language: de
  license: mit
  thumbnail: "https://raw.githubusercontent.com/German-NLP-Group/german-transformer-training/master/model_cards/german-electra-logo.png"
  tags:
  - electra
  - commoncrawl
  - uncased
  - umlaute
  - umlauts
  - german
  - deutsch
  ---
  
  # German Electra Uncased
  <img width="300px" src="https://raw.githubusercontent.com/German-NLP-Group/german-transformer-training/master/model_cards/german-electra-logo.png">
  [¹]
  
  ## Version 2 Release
  We released an improved version of this model. Version 1 was trained for 766,000 steps. For this new version we continued the training for an additional 734,000 steps. It therefore follows that version 2 was trained on a total of 1,500,000 steps. See "Evaluation of Version 2: GermEval18 Coarse" below for details.
  
  ## Model Info
  This Model is suitable for training on many downstream tasks in German (Q&A, Sentiment Analysis, etc.).
  
  It can be used as a drop-in replacement for **BERT** in most down-stream tasks (**ELECTRA** is even implemented as an extended **BERT** Class).
  
  At the time of release (August 2020) this model is the best performing publicly available German NLP model on various German evaluation metrics (CONLL03-DE, GermEval18 Coarse, GermEval18 Fine). For GermEval18 Coarse results see below. More will be published soon.
  
  ## Installation
  This model has the special feature that it is **uncased** but does **not strip accents**.
  This possibility was added by us with [PR #6280](https://github.com/huggingface/transformers/pull/6280).
  To use it you have to use Transformers version 3.1.0 or newer.
  
  ```bash
  pip install transformers -U
  ```
  
  ## Uncase and Umlauts ('Ö', 'Ä', 'Ü')
  This model is uncased. This helps especially for domains where colloquial terms with uncorrect capitalization is often used.
  
  The special characters 'ö', 'ü', 'ä' are included through the `strip_accent=False` option, as this leads to an improved precision.
  
  ## Creators
  This model was trained and open sourced in conjunction with the [**German NLP Group**](https://github.com/German-NLP-Group) in equal parts by:
  - [**Philip May**](https://May.la) - [T-Systems on site services GmbH](https://www.t-systems-onsite.de/)
  - [**Philipp Reißel**](https://www.reissel.eu) - [ambeRoad](https://amberoad.de/)
  
  ## Evaluation of Version 2: GermEval18 Coarse
  We evaluated all language models on GermEval18 with the F1 macro score. For each model we did an extensive automated hyperparameter search. With the best hyperparmeters we did fit the moodel multiple times on GermEval18. This is done to cancel random effects and get results of statistical relevance.
  
  ![GermEval18 Coarse Model Evaluation for Version 2](https://raw.githubusercontent.com/German-NLP-Group/german-transformer-training/master/model_cards/model-eval-v2.png)
  
  ## Checkpoint evaluation
  Since it it not guaranteed that the last checkpoint is the best, we evaluated the checkpoints on GermEval18. We found that the last checkpoint is indeed the best. The training was stable and did not overfit the text corpus.
  
  ## Pre-training details
  
  ### Data
  - Cleaned Common Crawl Corpus 2019-09 German: [CC_net](https://github.com/facebookresearch/cc_net) (Only head coprus and filtered for language_score > 0.98) - 62 GB
  - German Wikipedia Article Pages Dump (20200701) - 5.5 GB
  - German Wikipedia Talk Pages Dump (20200620) - 1.1 GB
  - Subtitles - 823 MB
  - News 2018 - 4.1 GB
  
  The sentences were split with [SojaMo](https://github.com/tsproisl/SoMaJo). We took the German Wikipedia Article Pages Dump 3x to oversample. This approach was also used in a similar way in GPT-3 (Table 2.2).
  
  More Details can be found here [Preperaing Datasets for German Electra Github](https://github.com/German-NLP-Group/german-transformer-training)
  
  ### Electra Branch no_strip_accents
  Because we do not want to stip accents in our training data we made a change to Electra and used this repo [Electra no_strip_accents](https://github.com/PhilipMay/electra/tree/no_strip_accents) (branch `no_strip_accents`). Then created the tf dataset with:
  
  ```bash
  python build_pretraining_dataset.py --corpus-dir <corpus_dir> --vocab-file <dir>/vocab.txt --output-dir ./tf_data --max-seq-length 512 --num-processes 8 --do-lower-case --no-strip-accents
  ```
  
  ### The training
  The training itself can be performed with the Original Electra Repo (No special case for this needed).
  We run it with the following Config:
  
  <details>
  <summary>The exact Training Config</summary>
  <br/>debug False
  <br/>disallow_correct False
  <br/>disc_weight 50.0
  <br/>do_eval False
  <br/>do_lower_case True
  <br/>do_train True
  <br/>electra_objective True
  <br/>embedding_size 768
  <br/>eval_batch_size 128
  <br/>gcp_project None
  <br/>gen_weight 1.0
  <br/>generator_hidden_size 0.33333
  <br/>generator_layers 1.0
  <br/>iterations_per_loop 200
  <br/>keep_checkpoint_max 0
  <br/>learning_rate 0.0002
  <br/>lr_decay_power 1.0
  <br/>mask_prob 0.15
  <br/>max_predictions_per_seq 79
  <br/>max_seq_length 512
  <br/>model_dir gs://XXX
  <br/>model_hparam_overrides {}
  <br/>model_name 02_E