Spaces:
Sleeping
Sleeping
fdsgdfsxnbbsdysjaethaeht
commited on
Commit
β’
7047289
1
Parent(s):
6db7e38
Update app.py
Browse files
app.py
CHANGED
@@ -1,602 +1,4 @@
|
|
1 |
-
from glob import glob
|
2 |
-
from itertools import zip_longest
|
3 |
-
import sqlite3
|
4 |
-
import psutil
|
5 |
-
import streamlit as st
|
6 |
-
import pandas as pd
|
7 |
-
import numpy as np
|
8 |
-
import matplotlib.pyplot as plt
|
9 |
-
import seaborn as sns
|
10 |
-
|
11 |
-
IMAGE_WIDTHS = 900
|
12 |
-
PRE_TRAINED_DB = "data/pretrained.sqlite"
|
13 |
-
|
14 |
-
|
15 |
-
@st.cache_resource
|
16 |
-
def load_eval_data():
|
17 |
-
conn = sqlite3.connect(PRE_TRAINED_DB)
|
18 |
-
conn.row_factory = lambda c, r: {
|
19 |
-
col[0]: r[idx] for idx, col in enumerate(c.description)
|
20 |
-
}
|
21 |
-
df = pd.read_sql_query("SELECT * FROM pretrained", conn)
|
22 |
-
df.replace("None", np.nan, inplace=True)
|
23 |
-
df.rename(columns={"model": "name"}, inplace=True)
|
24 |
-
df = df.infer_objects()
|
25 |
-
int_columns = ["train_batch_size", "num_parameters"]
|
26 |
-
df[int_columns] = df[int_columns].astype("Int32")
|
27 |
-
plot_df = df[["name", "num_parameters", "summ_rouge1", "trans_en_nl_score"]]
|
28 |
-
plot_df[["num_parameters", "summ_rouge1", "trans_en_nl_score"]] = plot_df[
|
29 |
-
["num_parameters", "summ_rouge1", "trans_en_nl_score"]
|
30 |
-
].apply(pd.to_numeric)
|
31 |
-
plot_df["num params (M)"] = plot_df["num_parameters"].map(
|
32 |
-
lambda x: int(x / 10**6)
|
33 |
-
)
|
34 |
-
plot_df.dropna(subset=["summ_rouge1"], inplace=True)
|
35 |
-
plot_df.rename(
|
36 |
-
columns={"summ_rouge1": "summ Rouge1", "trans_en_nl_score": "en->nl Bleu"},
|
37 |
-
inplace=True,
|
38 |
-
)
|
39 |
-
for i, row in df.iterrows():
|
40 |
-
dirs = glob(
|
41 |
-
f"data/eval_summ_results/{row['id']}-{row['name']}/yhavinga_cnn_dailymail_dutch/eval_predictions*"
|
42 |
-
)
|
43 |
-
try:
|
44 |
-
file = dirs[-1] + "/generated.txt"
|
45 |
-
with open(file, "r") as f:
|
46 |
-
text = f.read().replace("<n>", " ")
|
47 |
-
except Exception:
|
48 |
-
text = "fine-tune failed, no data"
|
49 |
-
df.at[i, "summary"] = text
|
50 |
-
|
51 |
-
for i, row in df.iterrows():
|
52 |
-
dirs = glob(
|
53 |
-
f"data/eval_transl_results/{row['id']}-{row['name']}/yhavinga_ccmatrix/eval_predictions*"
|
54 |
-
)
|
55 |
-
try:
|
56 |
-
file = dirs[-1] + "/generated.txt"
|
57 |
-
with open(file, "r") as f:
|
58 |
-
text = f.read().replace("<n>", " ")
|
59 |
-
except Exception:
|
60 |
-
text = "fine-tune failed, no data"
|
61 |
-
df.at[i, "translation"] = text
|
62 |
-
|
63 |
-
# order df by the name column desc
|
64 |
-
df.sort_values(by="name", inplace=True, ascending=False)
|
65 |
-
|
66 |
-
return plot_df, df
|
67 |
-
|
68 |
-
|
69 |
-
def main():
|
70 |
-
st.set_page_config( # Alternate names: setup_page, page, layout
|
71 |
-
page_title="Pre-training Dutch T5 models", # String or None. Strings get appended with "β’ Streamlit".
|
72 |
-
layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc.
|
73 |
-
initial_sidebar_state="collapsed", # Can be "auto", "expanded", "collapsed"
|
74 |
-
page_icon="π", # String, anything supported by st.image, or None.
|
75 |
-
)
|
76 |
-
plot_df, df = load_eval_data()
|
77 |
-
|
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 |
-
TL;DR: Dutch NLP gets a boost with state-of-the-art T5 models trained on the largest Dutch corpus, mC4, and additional datasets.
|
83 |
-
See below for model lists and comparison.
|
84 |
-
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,
|
85 |
-
I was granted access to Google's TPU Research Cloud (TRC),
|
86 |
-
a cloud-based platform for machine learning research and development that provides access to Google's
|
87 |
-
Tensor Processing Units (TPUs). My goal was to address the (then) shortage of T5 models for the Dutch language.
|
88 |
-
-- T5 is a state-of-the-art AI model architecture that can handle text as input and output,
|
89 |
-
making it an ideal tool for NLP tasks such as summarization, translation, and question-answering --
|
90 |
-
Since then, with extended access to the TRC, I have been able to train a variety of T5 models for Dutch.
|
91 |
-
Relevant papers are:
|
92 |
-
|
93 |
-
* **[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*.
|
94 |
-
* **[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*.
|
95 |
-
* **[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*.
|
96 |
-
* **[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*
|
97 |
-
* **[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*
|
98 |
-
* **[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*
|
99 |
-
* **[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*
|
100 |
-
Background on Google's TPU VM's and how to use the Huggingface transformers library to pre-train models can be found
|
101 |
-
at the following links
|
102 |
-
* https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104
|
103 |
-
* https://github.com/huggingface/transformers/tree/main/examples/research_projects/jax-projects#talks
|
104 |
-
## Pre-training
|
105 |
-
### mC4 dataset
|
106 |
-
Together with the T5 model architecture and SeqIO, the T5 authors also created and released
|
107 |
-
the multilingual [mC4 dataset](https://huggingface.co/datasets/allenai/c4).
|
108 |
-
It was made available by AllenNLP on the HuggingFace Dataset hub.
|
109 |
-
Our team confirmed that the Dutch portion of the mC4 dataset was deduplicated,
|
110 |
-
and we cleaned the Dutch portion of the mC4 dataset using [code adapted](https://gitlab.com/yhavinga/c4nlpreproc) from the TensorFlow C4 dataset.
|
111 |
-
The resulting [mc4_nl_cleaned](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned) dataset on the HuggingFace hub
|
112 |
-
has configs for several sizes, and also configs for interleaved mixed Dutch and English
|
113 |
-
texts, e.g. [micro_en_nl](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned/viewer/micro_en_nl/train).
|
114 |
-
The `_en_nl` configs were added to accommodate multi-language pre-training
|
115 |
-
with the Huggingface pre-training script, that accepts only a single dataset as input.
|
116 |
-
The full, cleaned Dutch mC4 dataset is 151GB and remains (as of June 2022) the largest available Dutch
|
117 |
-
corpus on the HuggingFace Dataset hub.
|
118 |
-
### Additional books, Wikipedia and Dutch news articles datasets
|
119 |
-
The `t5_1_1` and `ul2` models have also been trained on Dutch books, the Dutch subset of Wikipedia (2022-03-20),
|
120 |
-
the English subset of Wikipedia (2022-03-01), and a subset of "mc4_nl_cleaned" containing only texts
|
121 |
-
from Dutch and Belgian newspapers. Mixing in the these datasets was done to bias the model towards
|
122 |
-
descriptions of events in the Netherlands and Belgium.
|
123 |
-
### Pre-Training Objectives
|
124 |
-
The T5 models are pre-trained using the [span corruption](https://arxiv.org/abs/1910.10683) denoising objective.
|
125 |
-
15% of the tokens in the text are masked, and each span
|
126 |
-
of masked tokens is replaced with a special token known as a sentinel token, where each span is assigned
|
127 |
-
its own sentinel token. The model is then trained to predict for each sentinel token the original text
|
128 |
-
that was replaced by the sentinel tokens.
|
129 |
-
The UL2 models are pre-trained with the [Mixture-of-Denoisers (MoD)](https://arxiv.org/abs/2205.05131) objective, that combines diverse pre-training
|
130 |
-
paradigms together. UL2 frames different objective functions for training language models as denoising tasks, where
|
131 |
-
the model has to recover missing sub-sequences of a given input. During pre-training it uses a novel mixture-of-denoisers
|
132 |
-
that samples from a varied set of such objectives, each with different configurations. UL2 is trained using a mixture of
|
133 |
-
three denoising tasks:
|
134 |
-
1. R-denoising (or regular span corruption), which emulates the standard T5 span corruption objective;
|
135 |
-
2. X-denoising (or extreme span corruption); and
|
136 |
-
3. S-denoising (or sequential PrefixLM).
|
137 |
-
### Pre-training software
|
138 |
-
#### Huggingface [run_t5_mlm_flax.py](https://github.com/huggingface/transformers/blob/main/examples/flax/language-modeling/run_t5_mlm_flax.py)
|
139 |
-
All models except `t5_1_1` and `ul2` were pre-trained using the Huggingface `run_t5_mlm_flax.py` script.
|
140 |
-
This script is a good fit if you want to get a grasp what's needed to pre-train a language model
|
141 |
-
with Flax and Jax, since all data preparation, model instantiation, loss function, and training loop are
|
142 |
-
contained in a single file.
|
143 |
-
#### Google's [T5X](https://github.com/google-research/t5x)
|
144 |
-
The Dutch `t5_1_1` and `ul2` models were pre-trained using T5X. This is a modular framework that can be used for
|
145 |
-
pre-training, fine-tuning, and evaluation of T5 models. Because of its modular and pluggable design,
|
146 |
-
by only supplying a few configuration and code files, it is possible to pre-train with your own definitions.
|
147 |
-
It is even possible to define custom neural network layers and architectures, though I did not do this and only
|
148 |
-
pre-trained the default T5 encoder-decoder architecture, and varied only the pre-training objective, and the
|
149 |
-
datasets used and mixed with SeqIO.
|
150 |
-
#### Conversion script from T5X to HF
|
151 |
-
The T5X models were converted to Huggingface Flax T5 format using a script that was adapted from the
|
152 |
-
[T5X checkpoint to HuggingFace Flax conversion script](https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/convert_t5x_checkpoint_to_flax.py).
|
153 |
-
This script was modified to cast weights to bf16, and to also convert to pytorch format.
|
154 |
-
For this conversion to be successful, the T5X model had to be saved with `use_gda=False` set in the GIN file.
|
155 |
-
""")
|
156 |
-
|
157 |
-
st.markdown(
|
158 |
-
"""## Evaluation
|
159 |
-
### Evaluation setup
|
160 |
-
Each pre-trained model was evaluated by fine-tuning on summarization and translation. The learning-rate was set to
|
161 |
-
a constant schedule after a small warmup of 32 steps.
|
162 |
-
Fine-tuning for evaluation was done on a limited set of 50K examples from the fine-tuning datasets.
|
163 |
-
| | Summarization | Translation |
|
164 |
-
|-----------------:|------------------|-------------------|
|
165 |
-
| Dataset | [CNN Dailymail Dutch](https://huggingface.co/datasets/yhavinga/cnn_dailymail_dutch) | [CCMatrix En->NL](https://huggingface.co/datasets/yhavinga/ccmatrix_en_nl) |
|
166 |
-
| #train samples | 50K | 50K |
|
167 |
-
| Optimizer | AdamW | AdamW |
|
168 |
-
| learning rate | 0.001 | 0.0005 |
|
169 |
-
| source length | 1024 | 128 |
|
170 |
-
| target length | 142 | 128 |
|
171 |
-
| #eval samples | 1000 | 1000 |
|
172 |
-
| WandB link | [eval_summ](https://wandb.ai/yepster/eval_dutch_cnndaily_202302_flax)|[eval_transl](https://wandb.ai/yepster/eval_dutch_ccmatrix_202302_flax) |
|
173 |
-
On the WandB links above you can also find generated texts for each model to compare.
|
174 |
-
### Evaluation results
|
175 |
-
The figure below shows the evaluation scores for most models, with summarization Rouge1 on the x-axis (higher is better),
|
176 |
-
and translation English to Dutch Bleu score on the y-axis (higher is better).
|
177 |
-
The point size is proportional to the model size.
|
178 |
-
UL2 models are blue,
|
179 |
-
t5_1_1 models orange,
|
180 |
-
Flan models red,
|
181 |
-
mT5 green and the other models black.
|
182 |
-
"""
|
183 |
-
)
|
184 |
-
col1, col2 = st.columns(2)
|
185 |
-
with col1:
|
186 |
-
ul2_enabled = st.checkbox(
|
187 |
-
"UL2 Dutch (and English) (trained with T5X)", value=True
|
188 |
-
)
|
189 |
-
t5_1_1_enabled = st.checkbox("t5_1_1 Dutch (trained with T5X)", value=True)
|
190 |
-
flan_enabled = st.checkbox("Flan T5 (google/flan-t5-*)", value=True)
|
191 |
-
mt5_enabled = st.checkbox("mt5 (google/mt5-*)", value=True)
|
192 |
-
long_t5_enabled = st.checkbox(
|
193 |
-
"Long T5 Dutch+English (trained with HuggingFace script)"
|
194 |
-
)
|
195 |
-
t5_v1_1_enabled = st.checkbox(
|
196 |
-
"T5 Dutch (and English) (trained with HuggingFace script)"
|
197 |
-
)
|
198 |
-
with col2:
|
199 |
-
small_enabled = st.checkbox("small model sizes")
|
200 |
-
base_enabled = st.checkbox("base model sizes")
|
201 |
-
large_enabled = st.checkbox("large model sizes")
|
202 |
-
_24_enabled = st.checkbox("small nl24 deep narrow sizes")
|
203 |
-
_36_enabled = st.checkbox("base nl36 deep narrow sizes")
|
204 |
-
_8l_enabled = st.checkbox("large nl8 shallow sizes")
|
205 |
-
_4xl_enabled = st.checkbox("xlarge nl4 shallow wide sizes")
|
206 |
-
|
207 |
-
plot_df = plot_df[
|
208 |
-
(plot_df["name"].str.contains("ul2") & ul2_enabled)
|
209 |
-
| (plot_df["name"].str.contains("flan") & flan_enabled)
|
210 |
-
| (plot_df["name"].str.contains("mt5") & mt5_enabled)
|
211 |
-
| (plot_df["name"].str.contains("long-t5") & long_t5_enabled)
|
212 |
-
| (plot_df["name"].str.contains("t5_1_1") & t5_1_1_enabled)
|
213 |
-
| (
|
214 |
-
(
|
215 |
-
plot_df["name"].str.startswith("t5")
|
216 |
-
& ~plot_df["name"].str.startswith("t5_1_1")
|
217 |
-
)
|
218 |
-
& t5_v1_1_enabled
|
219 |
-
)
|
220 |
-
| (
|
221 |
-
plot_df["name"].str.contains("base")
|
222 |
-
& base_enabled
|
223 |
-
& ~plot_df["name"].str.contains("36")
|
224 |
-
)
|
225 |
-
| (
|
226 |
-
plot_df["name"].str.contains("small")
|
227 |
-
& small_enabled
|
228 |
-
& ~plot_df["name"].str.contains("24")
|
229 |
-
)
|
230 |
-
| (
|
231 |
-
plot_df["name"].str.contains("large")
|
232 |
-
& large_enabled
|
233 |
-
& ~plot_df["name"].str.contains("8")
|
234 |
-
)
|
235 |
-
| (
|
236 |
-
(
|
237 |
-
plot_df["name"].str.contains("-36L")
|
238 |
-
| plot_df["name"].str.contains("nl36")
|
239 |
-
)
|
240 |
-
& _36_enabled
|
241 |
-
)
|
242 |
-
| (
|
243 |
-
(
|
244 |
-
plot_df["name"].str.contains("-24L")
|
245 |
-
| plot_df["name"].str.contains("nl24")
|
246 |
-
)
|
247 |
-
& _24_enabled
|
248 |
-
)
|
249 |
-
| (
|
250 |
-
(plot_df["name"].str.contains("-8l") | plot_df["name"].str.contains("nl8"))
|
251 |
-
& _8l_enabled
|
252 |
-
)
|
253 |
-
| (
|
254 |
-
(plot_df["name"].str.contains("-4L") | plot_df["name"].str.contains("nl4"))
|
255 |
-
& _4xl_enabled
|
256 |
-
)
|
257 |
-
]
|
258 |
-
|
259 |
-
color_dict = {"flan": "red", "ul2": "blue", "mt5": "green", "t5_1_1": "orange"}
|
260 |
-
colors = [
|
261 |
-
color_dict[name.split("-")[0].lower()]
|
262 |
-
if name.split("-")[0].lower() in color_dict.keys()
|
263 |
-
else "black"
|
264 |
-
for name in plot_df["name"]
|
265 |
-
]
|
266 |
-
fig = plt.figure(figsize=(15, 8))
|
267 |
-
sns.set_style("darkgrid")
|
268 |
-
ax = sns.scatterplot(
|
269 |
-
data=plot_df,
|
270 |
-
y="en->nl Bleu",
|
271 |
-
x="summ Rouge1",
|
272 |
-
size="num params (M)",
|
273 |
-
hue=colors,
|
274 |
-
linewidth=0.7,
|
275 |
-
)
|
276 |
-
for i, row in plot_df.iterrows():
|
277 |
-
ax.annotate(
|
278 |
-
row["name"],
|
279 |
-
(row["summ Rouge1"], row["en->nl Bleu"]),
|
280 |
-
xytext=(0, 7),
|
281 |
-
textcoords="offset points",
|
282 |
-
ha="center",
|
283 |
-
va="center",
|
284 |
-
rotation=0,
|
285 |
-
)
|
286 |
-
# Remove color legend
|
287 |
-
handles, labels = ax.get_legend_handles_labels()
|
288 |
-
size_legend_labels = ["num params (M)"] + labels[-4:]
|
289 |
-
size_legend_handles = handles[-5:]
|
290 |
-
ax.legend(handles=size_legend_handles, labels=size_legend_labels)
|
291 |
-
|
292 |
-
plt.tight_layout()
|
293 |
-
st.pyplot(fig)
|
294 |
-
st.markdown(
|
295 |
-
"""* The `UL2` pre-trained Dutch(English) models consistently outperform the `T5-*` Dutch(English) models.
|
296 |
-
* Flan models perform almost instantly well on the summarization task, with `flan-t5-small`
|
297 |
-
showing performance comparable to Dutch T5 base models.
|
298 |
-
* For the translation task from English to Dutch, the Dutch+English pre-trained models perform well. Also
|
299 |
-
`UL2 Dutch` pre-trained Dutch models are consistently better than their `Flan`, `T5 Dutch` and
|
300 |
-
`mT5` counterparts of the comparable size.
|
301 |
-
* Fine-tuning of `t5-v1.1-large-dutch-cased` failed with the hyperparameters that were fixed to the same value for the
|
302 |
-
evaluation of every model.
|
303 |
-
Since the `UL2` models are better across the board, I've disabled this model on the hub.
|
304 |
-
* The `long-t5` models show bad performance on both tasks.
|
305 |
-
I cannot explain this, especially for the translation task. With a sequence length of 128 input and output
|
306 |
-
tokens, the sliding attention window with radius length 127 of the `long-t5` models should be able to handle this.
|
307 |
-
I've retried the fine-tuning of these models with
|
308 |
-
`float32` instead of `bfloat16`, but the results were the same. Maybe this is normal behaviour for these models
|
309 |
-
targeted at dealing with longer sequence lengths.
|
310 |
-
"""
|
311 |
-
)
|
312 |
-
|
313 |
-
st.markdown("### Compare generated texts")
|
314 |
-
col1, col2 = st.columns(2)
|
315 |
-
with col1:
|
316 |
-
summ_model_left = st.selectbox(
|
317 |
-
"Choose left summarization model", df["name"], index=6
|
318 |
-
)
|
319 |
-
with col2:
|
320 |
-
summ_model_right = st.selectbox(
|
321 |
-
"Choose right summarization model", df["name"], index=33
|
322 |
-
)
|
323 |
-
|
324 |
-
@st.cache_resource
|
325 |
-
def get_row(model):
|
326 |
-
return df[df["name"] == model]
|
327 |
-
|
328 |
-
row_left = get_row(summ_model_left)
|
329 |
-
row_right = get_row(summ_model_right)
|
330 |
-
|
331 |
-
contents1 = row_left["summary"].values[0].split("\n")
|
332 |
-
contents2 = row_right["summary"].values[0].split("\n")
|
333 |
-
contents = list(zip_longest(contents1, contents2))[:5]
|
334 |
-
st.table(
|
335 |
-
pd.DataFrame(
|
336 |
-
contents,
|
337 |
-
columns=[summ_model_left, summ_model_right],
|
338 |
-
)
|
339 |
-
)
|
340 |
-
|
341 |
-
st.markdown("### Compare generated translations")
|
342 |
-
col1, col2 = st.columns(2)
|
343 |
-
with col1:
|
344 |
-
trans_model_left = st.selectbox("Choose left model", df["name"], index=3)
|
345 |
-
with col2:
|
346 |
-
trans_model_right = st.selectbox("Choose right model", df["name"], index=32)
|
347 |
-
|
348 |
-
@st.cache_resource
|
349 |
-
def get_row(model):
|
350 |
-
return df[df["name"] == model]
|
351 |
-
|
352 |
-
row_left = get_row(trans_model_left)
|
353 |
-
row_right = get_row(trans_model_right)
|
354 |
-
|
355 |
-
contents1 = row_left["translation"].values[0].split("\n")
|
356 |
-
contents2 = row_right["translation"].values[0].split("\n")
|
357 |
-
contents = list(zip_longest(contents1, contents2))[:15]
|
358 |
-
st.table(
|
359 |
-
pd.DataFrame(
|
360 |
-
contents,
|
361 |
-
columns=[trans_model_left, trans_model_right],
|
362 |
-
)
|
363 |
-
)
|
364 |
-
|
365 |
-
|
366 |
-
st.markdown(
|
367 |
-
"""## Miscellaneous remarks
|
368 |
-
* Use loss regularization when training with `bfloat16` for better results (more info below).
|
369 |
-
* Be cautious of the dropout rate in the config.json file, as besides learning rate it is probably the most important
|
370 |
-
hyperparameter.
|
371 |
-
If you are evaluating different pre-trained models, be sure to fine-tune with dropout set equal.
|
372 |
-
Check in a model's `config.json` what the dropout rate has been set to. Unless you
|
373 |
-
intend to run many epochs on the same data, its worth to try a training run without dropout.
|
374 |
-
The smaller models can probably always be trained without.
|
375 |
-
* Training with more layers is much slower than you'd expect from the increased model size.
|
376 |
-
It is also more difficult to get batch size and learning rate right. Below is a section
|
377 |
-
about finding the right hyperparameters for the base-36L training.
|
378 |
-
* For the translation task, I am not sure that a 'deep-narrow' model (e.g. base-nl36) is better than a normal model
|
379 |
-
of comparable size (e.g. `large`).
|
380 |
-
* PyCharm's remote debugging features are useful to inspect variables on either a TPU VM or your deep-learning rig.
|
381 |
-
* When increasing the batch size, increase the learning rate. bs * 2 -> lr * sqrt(2) is a good heuristic but mileage may
|
382 |
-
vary.
|
383 |
-
* Dataset quality is a key success factor. Do not expect a model to magically turn mediocre data into magic. This holds for
|
384 |
-
the pre-training data, fine-tuning and also evaluating.
|
385 |
-
* Good Bleu score does not necessarily mean fluent text. Evaluation loss on a large translation dataset might be
|
386 |
-
better suited for model comparison, if the models have a tokenizer of comparable size.
|
387 |
-
|
388 |
-
### Bfloat16 datatype requires loss regularization
|
389 |
-
When training models with `bfloat16` and without loss regularization (default in the HuggingFace pre-training script),
|
390 |
-
the training losses would plateau or diverge. The graph below displays the results of different attempts
|
391 |
-
to train [t5-small-24L-dutch-english](https://huggingface.co/yhavinga/t5-small-24L-dutch-english).
|
392 |
-
The legend indicates the optimizer, data type, learning rate, total batch size, and learning rate schedule used.
|
393 |
-
As you can see, all attempts to train with `bfloat16` failed.
|
394 |
-
"""
|
395 |
-
)
|
396 |
-
st.image("img/bfloat16_loss.png", width=IMAGE_WIDTHS)
|
397 |
-
st.markdown(
|
398 |
-
"""The solution was found when peeking at T5X and the T5 gin configs, where I noticed a `z_loss` parameter,
|
399 |
-
always set to 1e-4. This factor is used in the T5X [cross entropy loss](https://github.com/google-research/t5x/blob/a319e559b4f72bffab91821487382ef4c25dfcf4/t5x/losses.py#L26)
|
400 |
-
function, with the purpose to pull the weights towards zero.
|
401 |
-
I experimented with adding this regularization term in the HF pre-training script,
|
402 |
-
and the `bfloat16` training runs did not exhibit the problems illustrated above anymore.
|
403 |
-
The `z_loss` regularization term in the T5X loss function looks like L2 regularization.
|
404 |
-
(See e.g. Andrej Karpathy [explaining regularization loss](https://youtu.be/PaCmpygFfXo?t=6720)).
|
405 |
-
The Optax optimizer library (used in the HuggingFace script), mentions weight decay for AdaFactor (and AdamW)
|
406 |
-
but also mentions that L2 regularization does not work as expected with adaptive gradient
|
407 |
-
algorithms. It might be the case that setting a non-zero `weight_decay_rate` in the Optax Adafactor call
|
408 |
-
in the HuggingFace pre-training script is an alternative to adding the `z_loss` term, to solve the bfloat16 issues, but
|
409 |
-
I haven't tested this yet.
|
410 |
-
"""
|
411 |
-
)
|
412 |
-
|
413 |
-
st.markdown(
|
414 |
-
"""### Which optimizer and lr to use
|
415 |
-
During the Flax/Jax Community week in '21, our team quickly decided on using Adafactor with learning rate 5e-3.
|
416 |
-
I believed that a more optimal setting could be found with more time.
|
417 |
-
After conducting seven WandB sweeps with
|
418 |
-
Adafactor, AdamW and Distributed Shampoo (experimental PJIT version from Dall-E mini),
|
419 |
-
a better setting had not been found. The graph below shows the runs from all 7 sweeps combined.
|
420 |
-
-- (I apologize for the confusion in the legend; I was unable to display the optimizer in the legend
|
421 |
-
because the initial version of the training script had the optimizer as a boolean, which I later
|
422 |
-
changed to a string with the optimizer name.) --
|
423 |
-
All runs in the graph below that achieve a loss below 4 use **Adafactor**.
|
424 |
-
Peach-sweep-6 is represented by a dashed orange line and had a learning rate of **5e-3**.
|
425 |
-
"""
|
426 |
-
)
|
427 |
-
|
428 |
-
st.image("img/adafactor_vs_adam_pretrain.png", width=IMAGE_WIDTHS)
|
429 |
-
st.markdown(
|
430 |
-
"""While there probably is a setting that will allow Adam and Shampoo to also converge fast below loss 4.0, I was unable
|
431 |
-
to find it. In a recent tweet Lucas Nestler had more success with Shampoo (https://twitter.com/_clashluke/status/1535994026876252160)
|
432 |
-
so maybe I need to revisit the attempt with the latest upstream code bases.
|
433 |
-
Later, when pre-training with T5X, I found that its custom Adafactor implementation with the default settings of the T5X gin configs,
|
434 |
-
a learning rate of 0.001 and inverse square root learning rate decay, worked well.
|
435 |
-
"""
|
436 |
-
)
|
437 |
-
|
438 |
-
st.markdown(
|
439 |
-
"""### Optimizer and learning rate used for summarization
|
440 |
-
Finetuning summarization requires more memory than translation due to the longer sequence lengths involved.
|
441 |
-
I wondered if I could use Adafactor instead of Adam and ran
|
442 |
-
a sweep to test this. The sweep was configured with Hyperband, so not all training runs completed to the end.
|
443 |
-
"""
|
444 |
-
)
|
445 |
-
st.image("img/optim_lr_summarization.png", width=IMAGE_WIDTHS)
|
446 |
-
st.markdown(
|
447 |
-
"""The training losses are graphed below:
|
448 |
-
"""
|
449 |
-
)
|
450 |
-
|
451 |
-
st.image("img/training_losses_summarization_sweep.png", width=IMAGE_WIDTHS)
|
452 |
-
st.markdown(
|
453 |
-
"""
|
454 |
-
While the Adafactor run with learning rate 7e-4 came close to the Adam runs, the consistent stability of training with Adam
|
455 |
-
made me stick with Adam as optimizer for evaluation runs on the several models. For translation the results were similar, though in the end I needed to configure a lower learning rate for all
|
456 |
-
models to converge during fine-tuning.
|
457 |
-
"""
|
458 |
-
)
|
459 |
-
|
460 |
-
st.markdown(
|
461 |
-
"""### Pre-training with sequence length 512 or 1024
|
462 |
-
The models `t5-v1_1-base-dutch-english-cased` and `t5-v1_1-base-dutch-english-cased-1024` have the same model dimensions,
|
463 |
-
but are pre-trained with span corruption on different sequence lenghts, 512 and 1024 respectively.
|
464 |
-
The evaluation loss and accuracy of the models do not look too different. Since training of the 1024 sequence length model was
|
465 |
-
very slow and didn't converge, I stopped it early. The figure below shows the evaluation
|
466 |
-
loss and accuracy.
|
467 |
-
"""
|
468 |
-
)
|
469 |
-
st.image("img/t5v1_1eval_loss_and_accuracy.png", width=IMAGE_WIDTHS)
|
470 |
-
st.markdown(
|
471 |
-
"""The 512 sequence length model was trained for 10 epochs of the `small` nl+en config (186B tokens total) and the 1024
|
472 |
-
sequence length model about 2 epochs of the `large` nl+en config (100B tokens total). While I expected both models to
|
473 |
-
perform similarly on downstream tasks, the 1024 sequence length model has better scores for both
|
474 |
-
summarization and translation.
|
475 |
-
"""
|
476 |
-
)
|
477 |
-
|
478 |
-
st.markdown(
|
479 |
-
"""## Model lists
|
480 |
-
### UL2 Dutch English
|
481 |
-
These models have been trained with T5X on mc4_nl_cleaned, books, Wikipedia and news.
|
482 |
-
| | ul2-base-dutch-english | ul2-large-dutch-english | ul2-small-dutch-english |
|
483 |
-
|:---------------------|:-------------------------|:--------------------------|:--------------------------|
|
484 |
-
| model_type | t5 | t5 | t5 |
|
485 |
-
| _pipeline_tag | text2text-generation | text2text-generation | text2text-generation |
|
486 |
-
| d_model | 768 | 1024 | 512 |
|
487 |
-
| d_ff | 2048 | 2816 | 1024 |
|
488 |
-
| num_heads | 12 | 16 | 6 |
|
489 |
-
| d_kv | 64 | 64 | 64 |
|
490 |
-
| num_layers | 12 | 24 | 8 |
|
491 |
-
| num_decoder_layers | 12 | 24 | 8 |
|
492 |
-
| feed_forward_proj | gated-gelu | gated-gelu | gated-gelu |
|
493 |
-
| dense_act_fn | gelu_new | gelu_new | gelu_new |
|
494 |
-
| vocab_size | 32128 | 32128 | 32128 |
|
495 |
-
| tie_word_embeddings | 0 | 0 | 0 |
|
496 |
-
| torch_dtype | float32 | float32 | float32 |
|
497 |
-
| _gin_batch_size | 128 | 64 | 128 |
|
498 |
-
| _gin_z_loss | 0.0001 | 0.0001 | 0.0001 |
|
499 |
-
| _gin_t5_config_dtype | 'bfloat16' | 'bfloat16' | 'bfloat16' |
|
500 |
-
### UL2 Dutch
|
501 |
-
These models have been trained with T5X on mc4_nl_cleaned, books, Wikipedia and news.
|
502 |
-
| | ul2-base-dutch | ul2-base-nl36-dutch | ul2-large-dutch | ul2-small-dutch |
|
503 |
-
|:---------------------|:---------------------|:----------------------|:---------------------|:---------------------|
|
504 |
-
| model_type | t5 | t5 | t5 | t5 |
|
505 |
-
| _pipeline_tag | text2text-generation | text2text-generation | text2text-generation | text2text-generation |
|
506 |
-
| d_model | 768 | 768 | 1024 | 512 |
|
507 |
-
| d_ff | 2048 | 3072 | 2816 | 1024 |
|
508 |
-
| num_heads | 12 | 12 | 16 | 6 |
|
509 |
-
| d_kv | 64 | 64 | 64 | 64 |
|
510 |
-
| num_layers | 12 | 36 | 24 | 8 |
|
511 |
-
| num_decoder_layers | 12 | 36 | 24 | 8 |
|
512 |
-
| feed_forward_proj | gated-gelu | gated-gelu | gated-gelu | gated-gelu |
|
513 |
-
| dense_act_fn | gelu_new | gelu_new | gelu_new | gelu_new |
|
514 |
-
| vocab_size | 32128 | 32128 | 32128 | 32128 |
|
515 |
-
| tie_word_embeddings | 0 | 0 | 0 | 0 |
|
516 |
-
| torch_dtype | float32 | float32 | float32 | float32 |
|
517 |
-
| _gin_batch_size | 128 | 64 | 64 | 128 |
|
518 |
-
| _gin_z_loss | 0.0001 | 0.0001 | 0.0001 | 0.0001 |
|
519 |
-
| _gin_t5_config_dtype | 'bfloat16' | 'bfloat16' | 'bfloat16' | 'bfloat16' |
|
520 |
-
### T5 models Dutch and Dutch/English
|
521 |
-
These models have been trained with the HuggingFace π€ run_t5_mlm_flax.py script on mc4_nl_cleaned.
|
522 |
-
Most notable differences are the model sizes, activation function, and the dropout rate used during
|
523 |
-
pre-training. The T5-eff models are models that differ in their number of layers. The table will list
|
524 |
-
the several dimensions of these models.
|
525 |
-
| | [t5-base-dutch](https://huggingface.co/yhavinga/t5-base-dutch) | [t5-v1.1-base-dutch-uncased](https://huggingface.co/yhavinga/t5-v1.1-base-dutch-uncased) | [t5-v1.1-base-dutch-cased](https://huggingface.co/yhavinga/t5-v1.1-base-dutch-cased) | [t5-v1.1-large-dutch-cased](https://huggingface.co/yhavinga/t5-v1.1-large-dutch-cased) | [t5-v1_1-base-dutch-english-cased](https://huggingface.co/yhavinga/t5-v1_1-base-dutch-english-cased) | [t5-v1_1-base-dutch-english-cased-1024](https://huggingface.co/yhavinga/t5-v1_1-base-dutch-english-cased-1024) | [t5-small-24L-dutch-english](https://huggingface.co/yhavinga/t5-small-24L-dutch-english) | [t5-xl-4L-dutch-english-cased](https://huggingface.co/yhavinga/t5-xl-4L-dutch-english-cased) | [t5-base-36L-dutch-english-cased](https://huggingface.co/yhavinga/t5-base-36L-dutch-english-cased) | [t5-eff-xl-8l-dutch-english-cased](https://huggingface.co/yhavinga/t5-eff-xl-8l-dutch-english-cased) | [t5-eff-large-8l-dutch-english-cased](https://huggingface.co/yhavinga/t5-eff-large-8l-dutch-english-cased) |
|
526 |
-
|:------------------|:----------------|:-----------------------------|:---------------------------|:----------------------------|:-----------------------------------|:----------------------------------------|:-----------------------------|:-------------------------------|:----------------------------------|:-----------------------------------|:--------------------------------------|
|
527 |
-
| *type* | t5 | t5-v1.1 | t5-v1.1 | t5-v1.1 | t5-v1.1 | t5-v1.1 | t5 eff | t5 eff | t5 eff | t5 eff | t5 eff |
|
528 |
-
| *d_model* | 768 | 768 | 768 | 1024 | 768 | 768 | 512 | 2048 | 768 | 1024 | 1024 |
|
529 |
-
| *d_ff* | 3072 | 2048 | 2048 | 2816 | 2048 | 2048 | 1920 | 5120 | 2560 | 16384 | 4096 |
|
530 |
-
| *num_heads* | 12 | 12 | 12 | 16 | 12 | 12 | 8 | 32 | 12 | 32 | 16 |
|
531 |
-
| *d_kv* | 64 | 64 | 64 | 64 | 64 | 64 | 64 | 64 | 64 | 128 | 64 |
|
532 |
-
| *num_layers* | 12 | 12 | 12 | 24 | 12 | 12 | 24 | 4 | 36 | 8 | 8 |
|
533 |
-
| *num parameters* | 223M | 248M | 248M | 783M | 248M | 248M | 250M | 585M | 729M | 1241M | 335M |
|
534 |
-
| *feed_forward_proj* | relu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu | gated-gelu |
|
535 |
-
| *dropout* | 0.1 | 0.0 | 0.0 | 0.1 | 0.0 | 0.0 | 0.0 | 0.1 | 0.0 | 0.0 | 0.0 |
|
536 |
-
| *dataset* | mc4_nl_cleaned | mc4_nl_cleaned full | mc4_nl_cleaned full | mc4_nl_cleaned | mc4_nl_cleaned small_en_nl | mc4_nl_cleaned large_en_nl | mc4_nl_cleaned large_en_nl | mc4_nl_cleaned large_en_nl | mc4_nl_cleaned large_en_nl | mc4_nl_cleaned large_en_nl | mc4_nl_cleaned large_en_nl |
|
537 |
-
| *tr. seq len* | 512 | 1024 | 1024 | 512 | 512 | 1024 | 512 | 512 | 512 | 512 | 512 |
|
538 |
-
| *batch size* | 128 | 64 | 64 | 64 | 128 | 64 | 128 | 512 | 512 | 64 | 128 |
|
539 |
-
| *total steps* | 527500 | 1014525 | 1210154 | 1120k/2427498 | 2839630 | 1520k/3397024 | 851852 | 212963 | 212963 | 538k/1703705 | 851850 |
|
540 |
-
| *epochs* | 1 | 2 | 2 | 2 | 10 | 4 | 1 | 1 | 1 | 1 | 1 |
|
541 |
-
| *duration* | 2d9h | 5d5h | 6d6h | 8d13h | 11d18h | 9d1h | 4d10h | 6d1h | 17d15h | 4d 19h | 3d 23h |
|
542 |
-
| *optimizer* | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor | adafactor |
|
543 |
-
| *lr* | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.005 | 0.009 | 0.005 | 0.005 |
|
544 |
-
| *warmup* | 10000.0 | 10000.0 | 10000.0 | 10000.0 | 10000.0 | 5000.0 | 20000.0 | 2500.0 | 1000.0 | 1500.0 | 1500.0 |
|
545 |
-
| *eval loss* | 1,38 | 1,20 | 0,96 | 1,07 | 1,11 | 1,13 | 1,18 | 1,27 | 1,05 | 1,3019 | 1,15 |
|
546 |
-
| *eval acc* | 0,70 | 0,73 | 0,78 | 0,76 | 0,75 | 0,74 | 0,74 | 0,72 | 0,76 | 0,71 | 0,74 |
|
547 |
-
### Fine-tuned translation models on ccmatrix
|
548 |
-
The models `t5-small-24L-dutch-english` and `t5-base-36L-dutch-english` have been fine-tuned for both language
|
549 |
-
directions on the first 25M samples from CCMatrix, giving a total of 50M training samples.
|
550 |
-
Evaluation is performed on out-of-sample CCMatrix and also on Tatoeba and Opus Books.
|
551 |
-
The `_bp` columns list the *brevity penalty* (the low score of the 128 seq len models on opus books may be because of the brevity penalty;
|
552 |
-
books tend to have longer sentences than 128 tokens). The `avg_bleu` score is the bleu score
|
553 |
-
averaged over all three evaluation datasets. The best scores displayed in bold for both translation directions.
|
554 |
-
| | [t5-base-36L-ccmatrix-multi](https://huggingface.co/yhavinga/t5-base-36L-ccmatrix-multi) | [t5-base-36L-ccmatrix-multi](https://huggingface.co/yhavinga/t5-base-36L-ccmatrix-multi) | [t5-small-24L-ccmatrix-multi](https://huggingface.co/yhavinga/t5-small-24L-ccmatrix-multi) | [t5-small-24L-ccmatrix-multi](https://huggingface.co/yhavinga/t5-small-24L-ccmatrix-multi) |
|
555 |
-
|:-----------------------|:-----------------------------|:-----------------------------|:------------------------------|:------------------------------|
|
556 |
-
| *source_lang* | en | nl | en | nl |
|
557 |
-
| *target_lang* | nl | en | nl | en |
|
558 |
-
| *source_prefix* | translate English to Dutch: | translate Dutch to English: | translate English to Dutch: | translate Dutch to English: |
|
559 |
-
| *ccmatrix_bleu* | **56.8** | 62.8 | 57.4 | **63.1** |
|
560 |
-
| *tatoeba_bleu* | **46.6** | **52.8** | 46.4 | 51.7 |
|
561 |
-
| *opus_books_bleu* | **13.5** | **24.9** | 12.9 | 23.4 |
|
562 |
-
| *ccmatrix_bp* | 0.95 | 0.96 | 0.95 | 0.96 |
|
563 |
-
| *tatoeba_bp* | 0.97 | 0.94 | 0.98 | 0.94 |
|
564 |
-
| *opus_books_bp* | 0.8 | 0.94 | 0.77 | 0.89 |
|
565 |
-
| *avg_bleu* | **38.96** | **46.86** | 38.92 | 46.06 |
|
566 |
-
| *max_source_length* | 128 | 128 | 128 | 128 |
|
567 |
-
| *max_target_length* | 128 | 128 | 128 | 128 |
|
568 |
-
| *adam_beta1* | 0.9 | 0.9 | 0.9 | 0.9 |
|
569 |
-
| *adam_beta2* | 0.997 | 0.997 | 0.997 | 0.997 |
|
570 |
-
| *weight_decay* | 0.05 | 0.05 | 0.002 | 0.002 |
|
571 |
-
| *lr* | 5e-05 | 5e-05 | 0.0005 | 0.0005 |
|
572 |
-
| *label_smoothing_factor* | 0.15 | 0.15 | 0.1 | 0.1 |
|
573 |
-
| *train_batch_size* | 128 | 128 | 128 | 128 |
|
574 |
-
| *warmup_steps* | 2000 | 2000 | 2000 | 2000 |
|
575 |
-
| *total steps* | 390625 | 390625 | 390625 | 390625 |
|
576 |
-
| *duration* | 4d 5h | 4d 5h | 3d 2h | 3d 2h |
|
577 |
-
| *num parameters* | 729M | 729M | 250M | 250M |
|
578 |
-
## Acknowledgements
|
579 |
-
This project was made possible by the exceptional computing resources provided by Google's
|
580 |
-
[TPU Research Cloud](https://sites.research.google/trc/).
|
581 |
-
The HuggingFace π€ ecosystem of datasets, hub, model architectures
|
582 |
-
and example scripts were an integral part of the training process, while Weights & Biases provided the ability
|
583 |
-
to track multiple training sessions and execute hyperparameter optimization with insightful visualizations.
|
584 |
-
I am grateful to the [https://huggingface.co/Finnish-NLP](Finnish-NLP) authors for their generosity in releasing the UL2 objective code and task
|
585 |
-
definitions, and to [Stephenn Fernandes](https://huggingface.co/StephennFernandes) for his support in getting me started with the T5X framework.
|
586 |
-
Lastly, I want to express my gratitude to Google for their openness and generosity in releasing T5X and related repositories.
|
587 |
-
Created by [Yeb Havinga](https://www.linkedin.com/in/yeb-havinga-86530825/).
|
588 |
-
Some of the sentences were reworded by ChatGPT.
|
589 |
-
"""
|
590 |
-
)
|
591 |
-
|
592 |
-
st.write(
|
593 |
-
f"""
|
594 |
-
---
|
595 |
-
*Memory: {memory.total / 10**9:.2f}GB, used: {memory.percent}%, available: {memory.available / 10**9:.2f}GB*
|
596 |
-
"""
|
597 |
-
)
|
598 |
|
|
|
599 |
|
600 |
-
|
601 |
-
memory = psutil.virtual_memory()
|
602 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
import streamlit as st
|
3 |
|
4 |
+
tedasdasdasdarafasdasdasd
|
|
|
|