initial preps with config and tokenizers
Browse files- .gitattributes +1 -0
- config.py +7 -0
- run_clm_flax.py +1 -0
- si_tokenizer.py +26 -0
- sinhala-gpt2/config.json +36 -0
- sinhala-gpt2/events.out.tfevents.1625744111.t1v-n-0b4afe6c-w-0.150137.3.v2 +3 -0
- sinhala-gpt2/tokenizer.json +0 -0
.gitattributes
CHANGED
@@ -14,3 +14,4 @@
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
|
|
|
14 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
config.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import GPT2Config
|
2 |
+
|
3 |
+
model_dir = "sinhala-gpt2"
|
4 |
+
|
5 |
+
config = GPT2Config.from_pretrained("gpt2", resid_pdrop=0.0, embd_pdrop=0.0, attn_pdrop=0.0)
|
6 |
+
config.save_pretrained(model_dir)
|
7 |
+
|
run_clm_flax.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/home/Keshan/transformers/examples/flax/language-modeling/run_clm_flax.py
|
si_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 = "./sinhala-gpt2" # ${MODEL_DIR}
|
5 |
+
|
6 |
+
# load dataset
|
7 |
+
dataset = load_dataset("mc4", "si", 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")
|
sinhala-gpt2/config.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation_function": "gelu_new",
|
3 |
+
"architectures": [
|
4 |
+
"GPT2LMHeadModel"
|
5 |
+
],
|
6 |
+
"attn_pdrop": 0.0,
|
7 |
+
"bos_token_id": 50256,
|
8 |
+
"embd_pdrop": 0.0,
|
9 |
+
"eos_token_id": 50256,
|
10 |
+
"gradient_checkpointing": false,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"layer_norm_epsilon": 1e-05,
|
13 |
+
"model_type": "gpt2",
|
14 |
+
"n_ctx": 1024,
|
15 |
+
"n_embd": 768,
|
16 |
+
"n_head": 12,
|
17 |
+
"n_inner": null,
|
18 |
+
"n_layer": 12,
|
19 |
+
"n_positions": 1024,
|
20 |
+
"resid_pdrop": 0.0,
|
21 |
+
"scale_attn_weights": true,
|
22 |
+
"summary_activation": null,
|
23 |
+
"summary_first_dropout": 0.1,
|
24 |
+
"summary_proj_to_labels": true,
|
25 |
+
"summary_type": "cls_index",
|
26 |
+
"summary_use_proj": true,
|
27 |
+
"task_specific_params": {
|
28 |
+
"text-generation": {
|
29 |
+
"do_sample": true,
|
30 |
+
"max_length": 50
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"transformers_version": "4.9.0.dev0",
|
34 |
+
"use_cache": true,
|
35 |
+
"vocab_size": 50257
|
36 |
+
}
|
sinhala-gpt2/events.out.tfevents.1625744111.t1v-n-0b4afe6c-w-0.150137.3.v2
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:91ed273fdad9323ae19e20ef9e232b1dfc8bf623ed07b83e375ccab2950b2c20
|
3 |
+
size 10560081
|
sinhala-gpt2/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|