yhavinga commited on
Commit
840c6e7
β€’
1 Parent(s): 37e7b34

Move texts into app.py

Browse files
Files changed (6) hide show
  1. EVALUATION.md +0 -59
  2. INTRO.md +0 -27
  3. PRETRAINING.md +0 -66
  4. README.md +0 -1
  5. REMARKS.md +0 -20
  6. app.py +119 -8
EVALUATION.md DELETED
@@ -1,59 +0,0 @@
1
- ## Evaluation
2
-
3
- ### Running evaluation runs
4
-
5
- Each pre-trained model was evaluated by fine-tuning on summarization and translation. The learning-rate was set to
6
- a constant schedule after a small warmup of 32 steps.
7
- Fine-tuning for evaluation was done on a limited set of 50K examples from the fine-tuning datasets.
8
-
9
- | | Summarization | Translation |
10
- |-----------------:|------------------|-------------------|
11
- | Dataset | CNN Dailymail NL | CCMatrix en -> nl |
12
- | #train samples | 50K | 50K |
13
- | Optimizer | AdamW | AdamW |
14
- | learning rate | 0.001 | 0.0005 |
15
- | source length | 1024 | 128 |
16
- | target length | 142 | 128 |
17
- | #eval samples | 1000 | 1000 |
18
- | wandb link | [eval_summ](https://wandb.ai/yepster/eval_dutch_cnndaily_202302_flax)|[eval_transl](https://wandb.ai/yepster/eval_dutch_ccmatrix_202302_flax) |
19
-
20
- The graph below shows the Rouge1 score for the summarization runs, evaluated
21
- after 25K and 50K examples on the [CNN Dailymail Dutch](https://huggingface.co/datasets/yhavinga/cnn_dailymail_dutch) dataset:
22
-
23
- ![Rouge1 summarization](eval_summ_rouge1_202302.png)
24
-
25
- * Flan models perform almost instantly well on the summarization task, with `flan-t5-small`
26
- showing performance comparable to Dutch T5 base models.
27
- * After 50K examples, the `ul2` models exhibit similar performance to the `flan` models.
28
- * I am surprised by the consistent bad scores for the `long-t5` runs. I've retried the fine-tuning of these models with
29
- `float32` instead of `bfloat16`, but the results were the same. Maybe this is normal behaviour for these models
30
- targeted at dealing with longer sequence lengths.
31
-
32
- The graph below shows the Bleu score for the translation runs, evaluated at step 25K and
33
- 50K on the [CCMatrix](https://huggingface.co/datasets/yhavinga/ccmatrix_en_nl) dataset, from
34
- English to Dutch:
35
-
36
- ![Bleu score translation](eval_transl_bleu_202302.png)
37
-
38
- * For the translation task from English to Dutch, the Dutch+English pre-trained models perform well. Also
39
- `ul2` pre-trained models are consistently better than their `Flan`, `T5 Dutch` and
40
- `mT5` counterparts.
41
- * Like with the summarization task, the `long-t5` models show bad performance, even after 50K examples. I do not understand
42
- cannot explain this at all for this translation task. With a sequence length of 128 input and output
43
- tokens, the sliding attention window with radius length 127 of the `long-t5` models should be able to handle this.
44
-
45
- The figure below shows the evaluation scores for most models, with summarization Rouge1 on the x-axis (higher is better),
46
- and translation English to Dutch Bleu score on the y-axis (higher is better).
47
- The point size is proportional to the model size. UL2 models are blue, Flan models
48
- red, mT5 green and the other models black.
49
-
50
- ![Evaluation T5 Dutch English](eval_t5_dutch_english.png)
51
-
52
- * For clarity not all models are shown. `t5-base-36L-dutch-english-cased` is model with
53
- scores comparable to `ul2-large-dutch-english`, but with slower inference. All long-t5
54
- runs are left out, as well as the `t5-v1.1-large-dutch-cased` model whose translation fine-tuning
55
- diverged.
56
- * Across the board, for translation the models pre-trained with Dutch+English or Dutch converge faster than other models.
57
- I was surprised to see `t5-xl-4l` among the best models on translation, as it has only 4 layers, and previous tests
58
- showed that it had a very bad performance (In those tests I had forgot to force set the dropout rate to 0.0, and
59
- apparently this model was very sensitive to dropout).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
INTRO.md DELETED
@@ -1,27 +0,0 @@
1
- # Dutch T5 models : UL2, T5, ByT5 and Long-T5 πŸ‡³πŸ‡±πŸ‡§πŸ‡ͺ
2
-
3
- TL;DR: Dutch NLP gets a boost with state-of-the-art T5 models trained on the largest Dutch corpus, mC4, and additional datasets.
4
- See below for model lists and comparison.
5
-
6
- During the [HuggingFace Flax/Jax community week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104) in the summer of 2021,
7
- I was granted access to Google's TPU Research Cloud (TRC),
8
- a cloud-based platform for machine learning research and development that provides access to Google's
9
- Tensor Processing Units (TPUs). My goal was to address the (then) shortage of T5 models for the Dutch language.
10
- -- T5 is a state-of-the-art AI model architecture that can handle text as input and output,
11
- making it an ideal tool for NLP tasks such as summarization, translation, and question-answering --
12
- Since then, with extended access to the TRC, I have been able to train a variety of T5 models for Dutch.
13
-
14
- Relevant papers are:
15
-
16
- * **[Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://arxiv.org/abs/1910.10683)** by *Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu*.
17
- * **[ExT5: Towards Extreme Multi-Task Scaling for Transfer Learning](https://arxiv.org/abs/2111.10952)** by *Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Gupta, Kai Hui, Sebastian Ruder, Donald Metzler*.
18
- * **[Scale Efficiently: Insights from Pre-training and Fine-tuning Transformers](https://arxiv.org/abs/2109.10686)** by *Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, Donald Metzler*.
19
- * **[ByT5: Towards a token-free future with pre-trained byte-to-byte models](https://arxiv.org/abs/2105.13626)** by *Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, Colin Raffel*
20
- * **[LongT5: Efficient Text-To-Text Transformer for Long Sequences](https://arxiv.org/abs/2112.07916)** by *Mandy Guo, Joshua Ainslie, David Uthus, Santiago Ontanon, Jianmo Ni, Yun-Hsuan Sung, Yinfei Yang*
21
- * **[Scaling Up Models and Data with t5x and seqio](https://arxiv.org/abs/2203.17189)** by *Adam Roberts, Hyung Won Chung, Anselm Levskaya, Gaurav Mishra, James Bradbury, Daniel Andor, Sharan Narang, Brian Lester, Colin Gaffney, Afroz Mohiuddin, Curtis Hawthorne, Aitor Lewkowycz, Alex Salcianu, Marc van Zee, Jacob Austin, Sebastian Goodman, Livio Baldini Soares, Haitang Hu, Sasha Tsvyashchenko, Aakanksha Chowdhery, Jasmijn Bastings, Jannis Bulian, Xavier Garcia, Jianmo Ni, Andrew Chen, Kathleen Kenealy, Jonathan H. Clark, Stephan Lee, Dan Garrette, James Lee-Thorp, Colin Raffel, Noam Shazeer, Marvin Ritter, Maarten Bosma, Alexandre Passos, Jeremy Maitin-Shepard, Noah Fiedel, Mark Omernick, Brennan Saeta, Ryan Sepassi, Alexander Spiridonov, Joshua Newlan, Andrea Gesmundo*
22
- * **[UL2: Unifying Language Learning Paradigms](https://arxiv.org/abs/2205.05131)** by *Yi Tay, Mostafa Dehghani, Vinh Q. Tran, Xavier Garcia, Jason Wei, Xuezhi Wang, Hyung Won Chung, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Denny Zhou, Neil Houlsby, Donald Metzler*
23
-
24
- Background on Google's TPU VM's and how to use the Huggingface transformers library to pre-train models can be found
25
- at the following links
26
- * https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104
27
- * https://github.com/huggingface/transformers/tree/main/examples/research_projects/jax-projects#talks
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
PRETRAINING.md DELETED
@@ -1,66 +0,0 @@
1
- ## Pre-training
2
-
3
- ### mC4 dataset
4
-
5
- Together with the T5 model architecture and SeqIO, the T5 authors also created and released
6
- the multilingual [mC4 dataset](https://huggingface.co/datasets/allenai/c4).
7
- It was made available by AllenNLP on the HuggingFace Dataset hub.
8
- Our team confirmed that the Dutch portion of the mC4 dataset was deduplicated,
9
- and we cleaned the Dutch portion of the mC4 dataset using [code adapted](https://gitlab.com/yhavinga/c4nlpreproc) from the TensorFlow C4 dataset.
10
- The resulting [mc4_nl_cleaned](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned) dataset on the HuggingFace hub
11
- has configs for several sizes, and also configs for interleaved mixed Dutch and English
12
- texts, e.g. [micro_en_nl](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned/viewer/micro_en_nl/train).
13
- The `_en_nl` configs were added to accommodate multi-language pre-training
14
- with the Huggingface pre-training script, that accepts only a single dataset as input.
15
- The full, cleaned Dutch mC4 dataset is 151GB and remains (as of June 2022) the largest available Dutch
16
- corpus on the HuggingFace Dataset hub.
17
-
18
- ### Additional books, Wikipedia and Dutch news articles datasets
19
-
20
- The `t5_1_1` and `ul2` models have also been trained on Dutch books, the Dutch subset of Wikipedia (2022-03-20),
21
- the English subset of Wikipedia (2022-03-01), and a subset of "mc4_nl_cleaned" containing only texts
22
- from Dutch and Belgian newspapers. Mixing in the these datasets was done to bias the model towards
23
- descriptions of events in the Netherlands and Belgium.
24
-
25
- ### Pre-Training Objectives
26
-
27
- The T5 models are pre-trained using the [span corruption](https://arxiv.org/abs/1910.10683) denoising objective.
28
- 15% of the tokens in the text are masked, and each span
29
- of masked tokens is replaced with a special token known as a sentinel token, where each span is assigned
30
- its own sentinel token. The model is then trained to predict for each sentinel token the original text
31
- that was replaced by the sentinel tokens.
32
-
33
- The UL2 models are pre-trained with the [Mixture-of-Denoisers (MoD)](https://arxiv.org/abs/2205.05131) objective, that combines diverse pre-training
34
- paradigms together. UL2 frames different objective functions for training language models as denoising tasks, where
35
- the model has to recover missing sub-sequences of a given input. During pre-training it uses a novel mixture-of-denoisers
36
- that samples from a varied set of such objectives, each with different configurations. UL2 is trained using a mixture of
37
- three denoising tasks:
38
-
39
- 1. R-denoising (or regular span corruption), which emulates the standard T5 span corruption objective;
40
- 2. X-denoising (or extreme span corruption); and
41
- 3. S-denoising (or sequential PrefixLM).
42
-
43
- ### Pre-training software
44
-
45
- #### Huggingface [run_t5_mlm_flax.py](https://github.com/huggingface/transformers/blob/main/examples/flax/language-modeling/run_t5_mlm_flax.py)
46
-
47
- All models except `t5_1_1` and `ul2` were pre-trained using the Huggingface `run_t5_mlm_flax.py` script.
48
- This script is a good fit if you want to get a grasp what's needed to pre-train a language model
49
- with Flax and Jax, since all data preparation, model instantiation, loss function, and training loop are
50
- contained in a single file.
51
-
52
- #### Google's [T5X](https://github.com/google-research/t5x)
53
-
54
- The Dutch `t5_1_1` and `ul2` models were pre-trained using T5X. This is a modular framework that can be used for
55
- pre-training, fine-tuning, and evaluation of T5 models. Because of its modular and pluggable design,
56
- by only supplying a few configuration and code files, it is possible to pre-train with your own definitions.
57
- It is even possible to define custom neural network layers and architectures, though I did not do this and only
58
- pre-trained the default T5 encoder-decoder architecture, and varied only the pre-training objective, and the
59
- datasets used and mixed with SeqIO.
60
-
61
- #### Conversion script from T5X to HF
62
-
63
- The T5X models were converted to Huggingface Flax T5 format using a script that was adapted from the
64
- [T5X checkpoint to HuggingFace Flax conversion script](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/convert_t5x_checkpoint_to_flax.py).
65
- This script was modified to cast weights to bf16, and to also convert to pytorch format.
66
- For this conversion to be successful, the T5X model had to be saved with `use_gda=False` set in the GIN file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -4,7 +4,6 @@ emoji: πŸš€
4
  colorFrom: blue
5
  colorTo: pink
6
  sdk: streamlit
7
- sdk_version: 1.10.0
8
  pinned: false
9
  app_file: app.py
10
  license: afl-3.0
 
4
  colorFrom: blue
5
  colorTo: pink
6
  sdk: streamlit
 
7
  pinned: false
8
  app_file: app.py
9
  license: afl-3.0
REMARKS.md DELETED
@@ -1,20 +0,0 @@
1
- ## Miscellaneous remarks
2
-
3
- * Use loss regularization when training with `bfloat16` for better results (more info below).
4
- * Be cautious of the dropout rate in the config.json file and consider training without it.
5
- Check in a model's `config.json` what the dropout rate has been set to. Unless you
6
- intend to run many epochs on the same data, its worth to try a training run without dropout.
7
- If you want to compare losses, be sure to set the dropout rate equal.
8
- The smaller models can probably always be trained without.
9
- * Training with more layers is much slower than you'd expect from the increased model size.
10
- It is also more difficult to get batch size and learning rate right. Below is a section
11
- about finding the right hyperparameters for the base-36L training.
12
- * For the translation task, I am not sure that a 'deep-narrow' model (e.g. base-nl36) is better than a normal model
13
- of comparable size (e.g. `large`).
14
- * PyCharm's remote debugging features are useful to inspect variables on either a TPU VM or your deep-learning rig.
15
- * When increasing the batch size, increase the learning rate. bs * 2 -> lr * sqrt(2) is a good heuristic but mileage may
16
- vary.
17
- * Dataset quality is a key success factor. Do not expect a model to magically turn mediocre data into magic. This holds for
18
- the pre-training data, fine-tuning and also evaluating.
19
- * Good Bleu score does not necessarily mean fluent text. Evaluation loss on a large translation dataset might be
20
- better suited for model comparison, if the models have a tokenizer of comparable size.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -78,11 +78,103 @@ def main():
78
  with open("style.css") as f:
79
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
80
 
81
- with open("INTRO.md", "r") as f:
82
- st.markdown(f.read())
83
-
84
- with open("PRETRAINING.md", "r") as f:
85
- st.markdown(f.read())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  st.markdown(
88
  """## Evaluation
@@ -291,11 +383,30 @@ mT5 green and the other models black.
291
  )
292
  )
293
 
294
- with open("REMARKS.md", "r") as f:
295
- st.markdown(f.read())
296
 
297
  st.markdown(
298
- """### Bfloat16 datatype requires loss regularization
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
  When training models with `bfloat16` and without loss regularization (default in the HuggingFace pre-training script),
301
  the training losses would plateau or diverge. The graph below displays the results of different attempts
 
78
  with open("style.css") as f:
79
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
80
 
81
+ st.markdown("""# Dutch T5 models : UL2, T5, ByT5 and Long-T5 πŸ‡³πŸ‡±πŸ‡§πŸ‡ͺ
82
+
83
+ TL;DR: Dutch NLP gets a boost with state-of-the-art T5 models trained on the largest Dutch corpus, mC4, and additional datasets.
84
+ See below for model lists and comparison.
85
+
86
+ During the [HuggingFace Flax/Jax community week](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104) in the summer of 2021,
87
+ I was granted access to Google's TPU Research Cloud (TRC),
88
+ a cloud-based platform for machine learning research and development that provides access to Google's
89
+ Tensor Processing Units (TPUs). My goal was to address the (then) shortage of T5 models for the Dutch language.
90
+ -- T5 is a state-of-the-art AI model architecture that can handle text as input and output,
91
+ making it an ideal tool for NLP tasks such as summarization, translation, and question-answering --
92
+ Since then, with extended access to the TRC, I have been able to train a variety of T5 models for Dutch.
93
+
94
+ Relevant papers are:
95
+
96
+ * **[Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://arxiv.org/abs/1910.10683)** by *Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu*.
97
+ * **[ExT5: Towards Extreme Multi-Task Scaling for Transfer Learning](https://arxiv.org/abs/2111.10952)** by *Vamsi Aribandi, Yi Tay, Tal Schuster, Jinfeng Rao, Huaixiu Steven Zheng, Sanket Vaibhav Mehta, Honglei Zhuang, Vinh Q. Tran, Dara Bahri, Jianmo Ni, Jai Gupta, Kai Hui, Sebastian Ruder, Donald Metzler*.
98
+ * **[Scale Efficiently: Insights from Pre-training and Fine-tuning Transformers](https://arxiv.org/abs/2109.10686)** by *Yi Tay, Mostafa Dehghani, Jinfeng Rao, William Fedus, Samira Abnar, Hyung Won Chung, Sharan Narang, Dani Yogatama, Ashish Vaswani, Donald Metzler*.
99
+ * **[ByT5: Towards a token-free future with pre-trained byte-to-byte models](https://arxiv.org/abs/2105.13626)** by *Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, Colin Raffel*
100
+ * **[LongT5: Efficient Text-To-Text Transformer for Long Sequences](https://arxiv.org/abs/2112.07916)** by *Mandy Guo, Joshua Ainslie, David Uthus, Santiago Ontanon, Jianmo Ni, Yun-Hsuan Sung, Yinfei Yang*
101
+ * **[Scaling Up Models and Data with t5x and seqio](https://arxiv.org/abs/2203.17189)** by *Adam Roberts, Hyung Won Chung, Anselm Levskaya, Gaurav Mishra, James Bradbury, Daniel Andor, Sharan Narang, Brian Lester, Colin Gaffney, Afroz Mohiuddin, Curtis Hawthorne, Aitor Lewkowycz, Alex Salcianu, Marc van Zee, Jacob Austin, Sebastian Goodman, Livio Baldini Soares, Haitang Hu, Sasha Tsvyashchenko, Aakanksha Chowdhery, Jasmijn Bastings, Jannis Bulian, Xavier Garcia, Jianmo Ni, Andrew Chen, Kathleen Kenealy, Jonathan H. Clark, Stephan Lee, Dan Garrette, James Lee-Thorp, Colin Raffel, Noam Shazeer, Marvin Ritter, Maarten Bosma, Alexandre Passos, Jeremy Maitin-Shepard, Noah Fiedel, Mark Omernick, Brennan Saeta, Ryan Sepassi, Alexander Spiridonov, Joshua Newlan, Andrea Gesmundo*
102
+ * **[UL2: Unifying Language Learning Paradigms](https://arxiv.org/abs/2205.05131)** by *Yi Tay, Mostafa Dehghani, Vinh Q. Tran, Xavier Garcia, Jason Wei, Xuezhi Wang, Hyung Won Chung, Dara Bahri, Tal Schuster, Huaixiu Steven Zheng, Denny Zhou, Neil Houlsby, Donald Metzler*
103
+
104
+ Background on Google's TPU VM's and how to use the Huggingface transformers library to pre-train models can be found
105
+ at the following links
106
+ * https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104
107
+ * https://github.com/huggingface/transformers/tree/main/examples/research_projects/jax-projects#talks
108
+
109
+ ## Pre-training
110
+
111
+ ### mC4 dataset
112
+
113
+ Together with the T5 model architecture and SeqIO, the T5 authors also created and released
114
+ the multilingual [mC4 dataset](https://huggingface.co/datasets/allenai/c4).
115
+ It was made available by AllenNLP on the HuggingFace Dataset hub.
116
+ Our team confirmed that the Dutch portion of the mC4 dataset was deduplicated,
117
+ and we cleaned the Dutch portion of the mC4 dataset using [code adapted](https://gitlab.com/yhavinga/c4nlpreproc) from the TensorFlow C4 dataset.
118
+ The resulting [mc4_nl_cleaned](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned) dataset on the HuggingFace hub
119
+ has configs for several sizes, and also configs for interleaved mixed Dutch and English
120
+ texts, e.g. [micro_en_nl](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned/viewer/micro_en_nl/train).
121
+ The `_en_nl` configs were added to accommodate multi-language pre-training
122
+ with the Huggingface pre-training script, that accepts only a single dataset as input.
123
+ The full, cleaned Dutch mC4 dataset is 151GB and remains (as of June 2022) the largest available Dutch
124
+ corpus on the HuggingFace Dataset hub.
125
+
126
+ ### Additional books, Wikipedia and Dutch news articles datasets
127
+
128
+ The `t5_1_1` and `ul2` models have also been trained on Dutch books, the Dutch subset of Wikipedia (2022-03-20),
129
+ the English subset of Wikipedia (2022-03-01), and a subset of "mc4_nl_cleaned" containing only texts
130
+ from Dutch and Belgian newspapers. Mixing in the these datasets was done to bias the model towards
131
+ descriptions of events in the Netherlands and Belgium.
132
+
133
+ ### Pre-Training Objectives
134
+
135
+ The T5 models are pre-trained using the [span corruption](https://arxiv.org/abs/1910.10683) denoising objective.
136
+ 15% of the tokens in the text are masked, and each span
137
+ of masked tokens is replaced with a special token known as a sentinel token, where each span is assigned
138
+ its own sentinel token. The model is then trained to predict for each sentinel token the original text
139
+ that was replaced by the sentinel tokens.
140
+
141
+ The UL2 models are pre-trained with the [Mixture-of-Denoisers (MoD)](https://arxiv.org/abs/2205.05131) objective, that combines diverse pre-training
142
+ paradigms together. UL2 frames different objective functions for training language models as denoising tasks, where
143
+ the model has to recover missing sub-sequences of a given input. During pre-training it uses a novel mixture-of-denoisers
144
+ that samples from a varied set of such objectives, each with different configurations. UL2 is trained using a mixture of
145
+ three denoising tasks:
146
+
147
+ 1. R-denoising (or regular span corruption), which emulates the standard T5 span corruption objective;
148
+ 2. X-denoising (or extreme span corruption); and
149
+ 3. S-denoising (or sequential PrefixLM).
150
+
151
+ ### Pre-training software
152
+
153
+ #### Huggingface [run_t5_mlm_flax.py](https://github.com/huggingface/transformers/blob/main/examples/flax/language-modeling/run_t5_mlm_flax.py)
154
+
155
+ All models except `t5_1_1` and `ul2` were pre-trained using the Huggingface `run_t5_mlm_flax.py` script.
156
+ This script is a good fit if you want to get a grasp what's needed to pre-train a language model
157
+ with Flax and Jax, since all data preparation, model instantiation, loss function, and training loop are
158
+ contained in a single file.
159
+
160
+ #### Google's [T5X](https://github.com/google-research/t5x)
161
+
162
+ The Dutch `t5_1_1` and `ul2` models were pre-trained using T5X. This is a modular framework that can be used for
163
+ pre-training, fine-tuning, and evaluation of T5 models. Because of its modular and pluggable design,
164
+ by only supplying a few configuration and code files, it is possible to pre-train with your own definitions.
165
+ It is even possible to define custom neural network layers and architectures, though I did not do this and only
166
+ pre-trained the default T5 encoder-decoder architecture, and varied only the pre-training objective, and the
167
+ datasets used and mixed with SeqIO.
168
+
169
+ #### Conversion script from T5X to HF
170
+
171
+ The T5X models were converted to Huggingface Flax T5 format using a script that was adapted from the
172
+ [T5X checkpoint to HuggingFace Flax conversion script](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/convert_t5x_checkpoint_to_flax.py).
173
+ This script was modified to cast weights to bf16, and to also convert to pytorch format.
174
+ For this conversion to be successful, the T5X model had to be saved with `use_gda=False` set in the GIN file.
175
+
176
+
177
+ """)
178
 
179
  st.markdown(
180
  """## Evaluation
 
383
  )
384
  )
385
 
 
 
386
 
387
  st.markdown(
388
+ """## Miscellaneous remarks
389
+
390
+ * Use loss regularization when training with `bfloat16` for better results (more info below).
391
+ * Be cautious of the dropout rate in the config.json file and consider training without it.
392
+ Check in a model's `config.json` what the dropout rate has been set to. Unless you
393
+ intend to run many epochs on the same data, its worth to try a training run without dropout.
394
+ If you want to compare losses, be sure to set the dropout rate equal.
395
+ The smaller models can probably always be trained without.
396
+ * Training with more layers is much slower than you'd expect from the increased model size.
397
+ It is also more difficult to get batch size and learning rate right. Below is a section
398
+ about finding the right hyperparameters for the base-36L training.
399
+ * For the translation task, I am not sure that a 'deep-narrow' model (e.g. base-nl36) is better than a normal model
400
+ of comparable size (e.g. `large`).
401
+ * PyCharm's remote debugging features are useful to inspect variables on either a TPU VM or your deep-learning rig.
402
+ * When increasing the batch size, increase the learning rate. bs * 2 -> lr * sqrt(2) is a good heuristic but mileage may
403
+ vary.
404
+ * Dataset quality is a key success factor. Do not expect a model to magically turn mediocre data into magic. This holds for
405
+ the pre-training data, fine-tuning and also evaluating.
406
+ * Good Bleu score does not necessarily mean fluent text. Evaluation loss on a large translation dataset might be
407
+ better suited for model comparison, if the models have a tokenizer of comparable size.
408
+
409
+ ### Bfloat16 datatype requires loss regularization
410
 
411
  When training models with `bfloat16` and without loss regularization (default in the HuggingFace pre-training script),
412
  the training losses would plateau or diverge. The graph below displays the results of different attempts