Update README.md
Browse files
README.md
CHANGED
@@ -1,63 +1,95 @@
|
|
1 |
-
---
|
2 |
-
library_name: transformers
|
3 |
-
language:
|
4 |
-
- th
|
5 |
-
- ipa
|
6 |
-
license: apache-2.0
|
7 |
-
base_model: google/byt5-small
|
8 |
-
tags:
|
9 |
-
- generated_from_trainer
|
10 |
-
metrics:
|
11 |
-
- bleu
|
12 |
-
model-index:
|
13 |
-
- name: thai-g2p-byt5-finetuned-final
|
14 |
-
results: []
|
15 |
-
---
|
16 |
-
|
17 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
18 |
-
should probably proofread and complete it, then remove this comment. -->
|
19 |
-
|
20 |
-
# thai-g2p-byt5-finetuned-final
|
21 |
-
|
22 |
-
This model is a fine-tuned version of [google/byt5-small](https://huggingface.co/google/byt5-small) on an unknown dataset.
|
23 |
-
It achieves the following results on the evaluation set:
|
24 |
-
- Loss: 0.0385
|
25 |
-
- Bleu: 91.9589
|
26 |
-
- Gen Len: 31.241
|
27 |
-
|
28 |
-
## Model description
|
29 |
-
|
30 |
-
More information needed
|
31 |
-
|
32 |
-
## Intended uses & limitations
|
33 |
-
|
34 |
-
More information needed
|
35 |
-
|
36 |
-
## Training and evaluation data
|
37 |
-
|
38 |
-
More information needed
|
39 |
-
|
40 |
-
## Training procedure
|
41 |
-
|
42 |
-
### Training hyperparameters
|
43 |
-
|
44 |
-
The following hyperparameters were used during training:
|
45 |
-
- learning_rate: 5e-05
|
46 |
-
- train_batch_size: 16
|
47 |
-
- eval_batch_size: 16
|
48 |
-
- seed: 42
|
49 |
-
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
50 |
-
- lr_scheduler_type: linear
|
51 |
-
- lr_scheduler_warmup_steps: 500
|
52 |
-
- num_epochs: 5.0
|
53 |
-
|
54 |
-
### Training results
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
### Framework versions
|
59 |
-
|
60 |
-
- Transformers 4.52.0.dev0
|
61 |
-
- Pytorch 2.6.0+cu118
|
62 |
-
- Datasets 3.5.0
|
63 |
-
- Tokenizers 0.21.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
language:
|
4 |
+
- th
|
5 |
+
- ipa
|
6 |
+
license: apache-2.0
|
7 |
+
base_model: google/byt5-small
|
8 |
+
tags:
|
9 |
+
- generated_from_trainer
|
10 |
+
metrics:
|
11 |
+
- bleu
|
12 |
+
model-index:
|
13 |
+
- name: thai-g2p-byt5-finetuned-final
|
14 |
+
results: []
|
15 |
+
---
|
16 |
+
|
17 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
18 |
+
should probably proofread and complete it, then remove this comment. -->
|
19 |
+
|
20 |
+
# thai-g2p-byt5-finetuned-final
|
21 |
+
|
22 |
+
This model is a fine-tuned version of [google/byt5-small](https://huggingface.co/google/byt5-small) on an unknown dataset.
|
23 |
+
It achieves the following results on the evaluation set:
|
24 |
+
- Loss: 0.0385
|
25 |
+
- Bleu: 91.9589
|
26 |
+
- Gen Len: 31.241
|
27 |
+
|
28 |
+
## Model description
|
29 |
+
|
30 |
+
More information needed
|
31 |
+
|
32 |
+
## Intended uses & limitations
|
33 |
+
|
34 |
+
More information needed
|
35 |
+
|
36 |
+
## Training and evaluation data
|
37 |
+
|
38 |
+
More information needed
|
39 |
+
|
40 |
+
## Training procedure
|
41 |
+
|
42 |
+
### Training hyperparameters
|
43 |
+
|
44 |
+
The following hyperparameters were used during training:
|
45 |
+
- learning_rate: 5e-05
|
46 |
+
- train_batch_size: 16
|
47 |
+
- eval_batch_size: 16
|
48 |
+
- seed: 42
|
49 |
+
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
50 |
+
- lr_scheduler_type: linear
|
51 |
+
- lr_scheduler_warmup_steps: 500
|
52 |
+
- num_epochs: 5.0
|
53 |
+
|
54 |
+
### Training results
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
### Framework versions
|
59 |
+
|
60 |
+
- Transformers 4.52.0.dev0
|
61 |
+
- Pytorch 2.6.0+cu118
|
62 |
+
- Datasets 3.5.0
|
63 |
+
- Tokenizers 0.21.1
|
64 |
+
|
65 |
+
### How to use
|
66 |
+
|
67 |
+
from transformers import T5ForConditionalGeneration, ByT5Tokenizer
|
68 |
+
|
69 |
+
# --- Make sure this path points to the LATEST training output ---
|
70 |
+
# (The one corresponding to the metrics above)
|
71 |
+
model_path = r"C:\thai-g2p-v2\thai-g2p-byt5-finetuned" # Or whatever you named it
|
72 |
+
|
73 |
+
print(f"Loading model from: {model_path}")
|
74 |
+
tokenizer = ByT5Tokenizer.from_pretrained(model_path)
|
75 |
+
model = T5ForConditionalGeneration.from_pretrained(model_path)
|
76 |
+
# model.to("cuda") # If using GPU
|
77 |
+
|
78 |
+
def thai_to_ipa(text):
|
79 |
+
# ... (rest of your function is fine) ...
|
80 |
+
input_ids = tokenizer(text, return_tensors="pt").input_ids # .to(model.device)
|
81 |
+
# Increase max_length slightly just in case IPA is longer
|
82 |
+
outputs = model.generate(input_ids, max_length=192)
|
83 |
+
ipa_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
84 |
+
return ipa_output
|
85 |
+
|
86 |
+
# --- Test with examples NOT in your train/val data ---
|
87 |
+
test_word1 = "สวัสดี"
|
88 |
+
test_word2 = "ภาษาไทย"
|
89 |
+
test_word3 = "สำนักงานคณะกรรมการส่งเสริมและประสานงานเยาวชนแห่งชาติ"
|
90 |
+
test_word4 = "สมเด็จพระเจ้าพี่นางเธอ เจ้าฟ้ากัลยาณิวัฒนา กรมหลวงนราธิวาสราชนครินทร์"
|
91 |
+
|
92 |
+
print(f"'{test_word1}' -> {thai_to_ipa(test_word1)}")
|
93 |
+
print(f"'{test_word2}' -> {thai_to_ipa(test_word2)}")
|
94 |
+
print(f"'{test_word3}' -> {thai_to_ipa(test_word3)}")
|
95 |
+
print(f"'{test_word4}' -> {thai_to_ipa(test_word4)}")
|