bayartsogt
commited on
Commit
•
90cbb87
1
Parent(s):
d812eff
train files
Browse files- config.json +25 -0
- run_config.py +7 -0
- run_mlm_flax.py +1 -0
- run_tokenizer.py +26 -0
- tokenizer.json +0 -0
- train_mlm.sh +19 -0
config.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"RobertaForMaskedLM"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"bos_token_id": 0,
|
7 |
+
"eos_token_id": 2,
|
8 |
+
"gradient_checkpointing": false,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 1024,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 4096,
|
14 |
+
"layer_norm_eps": 1e-05,
|
15 |
+
"max_position_embeddings": 514,
|
16 |
+
"model_type": "roberta",
|
17 |
+
"num_attention_heads": 16,
|
18 |
+
"num_hidden_layers": 24,
|
19 |
+
"pad_token_id": 1,
|
20 |
+
"position_embedding_type": "absolute",
|
21 |
+
"transformers_version": "4.9.0.dev0",
|
22 |
+
"type_vocab_size": 1,
|
23 |
+
"use_cache": true,
|
24 |
+
"vocab_size": 50265
|
25 |
+
}
|
run_config.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import RobertaConfig
|
2 |
+
|
3 |
+
model_dir = "./" # ${MODEL_DIR}
|
4 |
+
|
5 |
+
config = RobertaConfig.from_pretrained("roberta-large")
|
6 |
+
config.save_pretrained(model_dir)
|
7 |
+
|
run_mlm_flax.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/home/bayartsogtyadamsuren/transformers/examples/flax/language-modeling/run_mlm_flax.py
|
run_tokenizer.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
from tokenizers import trainers, Tokenizer, normalizers, ByteLevelBPETokenizer
|
3 |
+
|
4 |
+
model_dir = "./" # ${MODEL_DIR}
|
5 |
+
|
6 |
+
# load dataset
|
7 |
+
dataset = load_dataset("oscar", "unshuffled_deduplicated_mn", split="train")
|
8 |
+
|
9 |
+
# Instantiate tokenizer
|
10 |
+
tokenizer = ByteLevelBPETokenizer()
|
11 |
+
|
12 |
+
def batch_iterator(batch_size=1000):
|
13 |
+
for i in range(0, len(dataset), batch_size):
|
14 |
+
yield dataset[i: i + batch_size]["text"]
|
15 |
+
|
16 |
+
# Customized training
|
17 |
+
tokenizer.train_from_iterator(batch_iterator(), vocab_size=50265, min_frequency=2, special_tokens=[
|
18 |
+
"<s>",
|
19 |
+
"<pad>",
|
20 |
+
"</s>",
|
21 |
+
"<unk>",
|
22 |
+
"<mask>",
|
23 |
+
])
|
24 |
+
|
25 |
+
# Save files to disk
|
26 |
+
tokenizer.save(f"{model_dir}/tokenizer.json")
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
train_mlm.sh
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
./run_mlm_flax.py \
|
2 |
+
--output_dir="${MODEL_DIR}" \
|
3 |
+
--model_type="roberta" \
|
4 |
+
--config_name="${MODEL_DIR}" \
|
5 |
+
--tokenizer_name="${MODEL_DIR}" \
|
6 |
+
--dataset_name="oscar" \
|
7 |
+
--dataset_config_name="unshuffled_deduplicated_mn" \
|
8 |
+
--max_seq_length="128" \
|
9 |
+
--weight_decay="0.01" \
|
10 |
+
--per_device_train_batch_size="64" \
|
11 |
+
--per_device_eval_batch_size="64" \
|
12 |
+
--learning_rate="3e-4" \
|
13 |
+
--warmup_steps="1000" \
|
14 |
+
--overwrite_output_dir \
|
15 |
+
--pad_to_max_length \
|
16 |
+
--num_train_epochs="300" \
|
17 |
+
--adam_beta1="0.9" \
|
18 |
+
--adam_beta2="0.98" \
|
19 |
+
--push_to_hub
|