Update README.md
Browse files
README.md
CHANGED
@@ -10,4 +10,143 @@ metrics:
|
|
10 |
- exact_match
|
11 |
base_model:
|
12 |
- kobkrit/thai-t5-base
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
- exact_match
|
11 |
base_model:
|
12 |
- kobkrit/thai-t5-base
|
13 |
+
pipeline_tag: question-answering
|
14 |
+
---
|
15 |
+
|
16 |
+
# **ThaiT5-Instruct**
|
17 |
+
|
18 |
+
## **Model Description**
|
19 |
+
`ThaiT5-Instruct` is a fine-tuned version of `kobkrit/thai-t5-base`, trained on the **WangchanX Seed-Free Synthetic Instruct Thai 120k** dataset. This model supports various NLP tasks, including:
|
20 |
+
- **Conversational AI**
|
21 |
+
- **Multiple Choice Reasoning**
|
22 |
+
- **Brainstorming**
|
23 |
+
- **Question Answering**
|
24 |
+
- **Summarization**
|
25 |
+
|
26 |
+
The model has been trained for **13 epochs** and can be further improved with more resources.
|
27 |
+
|
28 |
+
---
|
29 |
+
|
30 |
+
## **Training Details**
|
31 |
+
- **Base Model**: `kobkrit/thai-t5-base`
|
32 |
+
- **Epochs**: `13`
|
33 |
+
- **Batch Size per Device**: `32`
|
34 |
+
- **Gradient Accumulation Steps**: `2`
|
35 |
+
- **Optimizer**: AdamW
|
36 |
+
- **Hardware Used**: `A100`
|
37 |
+
|
38 |
+
**Training Loss per Epoch**:
|
39 |
+
```
|
40 |
+
[2.2463, 1.7010, 1.5261, 1.4626, 1.4085, 1.3844, 1.3647, 1.3442, 1.3373, 1.3182, 1.3169, 1.3016]
|
41 |
+
```
|
42 |
+
|
43 |
+
**Validation Loss per Epoch**:
|
44 |
+
```
|
45 |
+
[1.4781, 1.3761, 1.3131, 1.2775, 1.2549, 1.2364, 1.2226, 1.2141, 1.2043, 1.1995, 1.1954, 1.1929]
|
46 |
+
```
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
+
## **Evaluation Results**
|
51 |
+
The model was evaluated using several NLP metrics, with the following results:
|
52 |
+
|
53 |
+
| Metric | Score |
|
54 |
+
|-------------|--------|
|
55 |
+
| ROUGE-1 | 0.0617 |
|
56 |
+
| ROUGE-2 | 0.0291 |
|
57 |
+
| ROUGE-L | 0.061 |
|
58 |
+
| BLEU | 0.0093 |
|
59 |
+
| Exact Match | 0.2516 |
|
60 |
+
| F1 Score | 27.8984 |
|
61 |
+
|
62 |
+
---
|
63 |
+
|
64 |
+
## **Usage**
|
65 |
+
|
66 |
+
### **Basic Inference (Without Context)**
|
67 |
+
```python
|
68 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
69 |
+
|
70 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Peenipat/ThaiT5-Instruct", trust_remote_code=True)
|
71 |
+
tokenizer = AutoTokenizer.from_pretrained("Peenipat/ThaiT5-Instruct")
|
72 |
+
|
73 |
+
input_text = "หวัดดี"
|
74 |
+
|
75 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
76 |
+
outputs = model.generate(input_ids=inputs["input_ids"])
|
77 |
+
output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
78 |
+
|
79 |
+
print(output_text)
|
80 |
+
```
|
81 |
+
|
82 |
+
**Example:**
|
83 |
+
```python
|
84 |
+
input_text = "คำว่า ฮัก หมายถึงอะไร"
|
85 |
+
|
86 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
87 |
+
outputs = model.generate(input_ids=inputs["input_ids"])
|
88 |
+
output_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
89 |
+
|
90 |
+
print(output_text)
|
91 |
+
```
|
92 |
+
**Output:**
|
93 |
+
```
|
94 |
+
"ฮัก หมายถึง ภาษา สันสกฤต ภาษา สันสกฤต "
|
95 |
+
```
|
96 |
+
|
97 |
+
---
|
98 |
+
|
99 |
+
### **Question Answering (With Context)**
|
100 |
+
```python
|
101 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
|
102 |
+
|
103 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Peenipat/ThaiT5-Instruct", trust_remote_code=True)
|
104 |
+
tokenizer = AutoTokenizer.from_pretrained("Peenipat/ThaiT5-Instruct")
|
105 |
+
|
106 |
+
model.eval()
|
107 |
+
qa_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
108 |
+
|
109 |
+
def ask_question():
|
110 |
+
context = input("Input Context: ")
|
111 |
+
question = input("Input Question: ")
|
112 |
+
input_text = f"Context: {context} Question: {question}"
|
113 |
+
output = qa_pipeline(input_text,
|
114 |
+
max_length=60,
|
115 |
+
min_length=20,
|
116 |
+
no_repeat_ngram_size=3,
|
117 |
+
num_beams=5,
|
118 |
+
early_stopping=True)
|
119 |
+
output_text = output[0]['generated_text']
|
120 |
+
print("\nOutput:")
|
121 |
+
print(output_text)
|
122 |
+
```
|
123 |
+
|
124 |
+
**Example:**
|
125 |
+
```
|
126 |
+
Input Context: ฮัก คือความรู้สึกผูกพันและห่วงใยที่เกิดขึ้นระหว่างคนที่มีความสำคัญต่อกัน ไม่ว่าจะเป็นฮักหนุ่มสาว ฮักพ่อแม่ลูก หรือฮักพี่น้อง ฮักบ่ได้หมายถึงแค่ความสุข แต่ยังรวมถึงความเข้าใจ การอดทน และการเสียสละเพื่อกันและกัน คนอีสานมักแสดงความฮักผ่านการกระทำมากกว่าคำพูด เช่น การดูแลเอาใจใส่ และการอยู่เคียงข้างยามทุกข์ยาก ฮักแท้คือฮักที่มั่นคง บ่เปลี่ยนแปลงตามกาลเวลา และเต็มไปด้วยความจริงใจ
|
127 |
+
Input Question: คำว่า ฮัก หมายถึงอะไร
|
128 |
+
|
129 |
+
Output:
|
130 |
+
ฮัก ความรู้สึกผูกพันและห่วงใย เกิดขึ้นระหว่างคนมีความสําคัญต่อกัน ฮักบ่ได้หมายถึงความสุข ความเข้าใจ การอดทน เสียสละเพื่อกันและกัน คนอีสานมักแสดงความฮักผ่านการกระทํามากกว่าค���าพูด ดูแลเอาใจใส่ ที่อยู่เคียงข้างยามทุกข์
|
131 |
+
```
|
132 |
+
|
133 |
+
---
|
134 |
+
|
135 |
+
## **Limitations & Future Improvements**
|
136 |
+
- The model can be further improved with additional training resources.
|
137 |
+
- Performance on complex reasoning tasks may require further fine-tuning on domain-specific datasets.
|
138 |
+
- The model does not possess general intelligence like **ChatGPT**, **Gemini**, or other advanced AI models. It excels at extracting answers from given contexts rather than generating knowledge independently.
|
139 |
+
|
140 |
+
---
|
141 |
+
|
142 |
+
## **Citation**
|
143 |
+
If you use this model, please cite it as follows:
|
144 |
+
|
145 |
+
```bibtex
|
146 |
+
@misc{PeenipatThaiT5Instruct,
|
147 |
+
title={ThaiT5-Instruct},
|
148 |
+
author={Peenipat},
|
149 |
+
year={2025},
|
150 |
+
publisher={Hugging Face},
|
151 |
+
url={https://huggingface.co/Peenipat/ThaiT5-Instruct}
|
152 |
+
}
|