Improve language tag
#1
by
lbourdois
- opened
README.md
CHANGED
@@ -1,231 +1,242 @@
|
|
1 |
-
---
|
2 |
-
base_model:
|
3 |
-
- Qwen/Qwen2.5-32B-Instruct
|
4 |
-
datasets:
|
5 |
-
- Thaweewat/thai-med-pack
|
6 |
-
language:
|
7 |
-
-
|
8 |
-
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
-
|
13 |
-
-
|
14 |
-
-
|
15 |
-
-
|
16 |
-
-
|
17 |
-
-
|
18 |
-
-
|
19 |
-
-
|
20 |
-
|
21 |
-
-
|
22 |
-
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
-
|
85 |
-
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
#
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
* Montita Somsoo ([email protected])
|
|
|
1 |
+
---
|
2 |
+
base_model:
|
3 |
+
- Qwen/Qwen2.5-32B-Instruct
|
4 |
+
datasets:
|
5 |
+
- Thaweewat/thai-med-pack
|
6 |
+
language:
|
7 |
+
- zho
|
8 |
+
- eng
|
9 |
+
- fra
|
10 |
+
- spa
|
11 |
+
- por
|
12 |
+
- deu
|
13 |
+
- ita
|
14 |
+
- rus
|
15 |
+
- jpn
|
16 |
+
- kor
|
17 |
+
- vie
|
18 |
+
- tha
|
19 |
+
- ara
|
20 |
+
library_name: transformers
|
21 |
+
pipeline_tag: text-generation
|
22 |
+
tags:
|
23 |
+
- text-generation-inference
|
24 |
+
- sft
|
25 |
+
- trl
|
26 |
+
- 4-bit precision
|
27 |
+
- bitsandbytes
|
28 |
+
- LoRA
|
29 |
+
- Fine-Tuning with LoRA
|
30 |
+
- LLM
|
31 |
+
- GenAI
|
32 |
+
- medical
|
33 |
+
- medtech
|
34 |
+
- HealthGPT
|
35 |
+
- NT Academy
|
36 |
+
- minddatatech
|
37 |
+
---
|
38 |
+
|
39 |
+
# 🇹🇭 **Model Card for Qwen2.5-32B-Instruct-medical-tuned**
|
40 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
41 |
+
|
42 |
+
## <font color="red">ℹ️ This version is significantly better than OpenThaiGPT!!.</font>
|
43 |
+
|
44 |
+
## Qwen2.5-32B-Instruct for Thai Medical QA
|
45 |
+
|
46 |
+
This model is fine-tuned from `Qwen2.5-32B-Instruct` using Supervised Fine-Tuning (SFT) on the `Thaweewat/thai-med-pack` dataset. It is designed for medical question-answering tasks in Thai, providing accurate and contextual answers based on medical information.
|
47 |
+
|
48 |
+
## Model Description
|
49 |
+
This model was fine-tuned using Supervised Fine-Tuning (SFT) to enhance its capabilities for medical question answering in Thai. The base model is `Qwen2.5-32B-Instruct`, which has been optimized with domain-specific knowledge using the `Thaweewat/thai-med-pack` dataset.
|
50 |
+
|
51 |
+
- **Model type:** Causal Language Model (AutoModelForCausalLM)
|
52 |
+
- **Language(s):** Thai
|
53 |
+
- **Fine-tuned from model:** Qwen2.5-32B-Instruct
|
54 |
+
- **Dataset used for fine-tuning:** Thaweewat/thai-med-pack
|
55 |
+
|
56 |
+
### Model Sources
|
57 |
+
|
58 |
+
- **Repository:** https://huggingface.co/amornpan
|
59 |
+
- **Citing Repository:** https://huggingface.co/Aekanun
|
60 |
+
- **Base Model:** https://huggingface.co/Qwen/Qwen2.5-32B-Instruct
|
61 |
+
- **Dataset:** https://huggingface.co/datasets/Thaweewat/thai-med-pack
|
62 |
+
|
63 |
+
## Uses
|
64 |
+
|
65 |
+
### Direct Use
|
66 |
+
The model can be used directly for generating medical responses in Thai. It has been optimized for:
|
67 |
+
- Medical question-answering
|
68 |
+
- Providing clinical information
|
69 |
+
- Health-related dialogue generation
|
70 |
+
|
71 |
+
### Downstream Use
|
72 |
+
This model serves as a foundational model for medical assistance systems, chatbots, and applications related to healthcare in the Thai language.
|
73 |
+
|
74 |
+
### Out-of-Scope Use
|
75 |
+
- This model should not be used for real-time diagnosis or emergency medical scenarios.
|
76 |
+
- It should not be relied upon for critical clinical decisions without human oversight, as it is not intended to replace professional medical advice.
|
77 |
+
|
78 |
+
## Bias, Risks, and Limitations
|
79 |
+
|
80 |
+
### Bias
|
81 |
+
- The model may reflect biases present in the dataset, especially regarding underrepresented medical conditions or topics.
|
82 |
+
|
83 |
+
### Risks
|
84 |
+
- Responses may contain inaccuracies due to the model's inherent limitations and the dataset used for fine-tuning.
|
85 |
+
- The model should not be used as the sole source of medical advice.
|
86 |
+
|
87 |
+
### Limitations
|
88 |
+
- Primarily limited to the medical domain.
|
89 |
+
- Sensitive to prompts and may generate off-topic responses for non-medical queries.
|
90 |
+
|
91 |
+
# Model Training Statistics
|
92 |
+
|
93 |
+
## Training Summary
|
94 |
+
- **Total Steps:** 1050
|
95 |
+
- **Total Epochs:** 98.25
|
96 |
+
- **Validation Checks:** 42
|
97 |
+
- **Epoch with Lowest Validation Loss:** 93.57
|
98 |
+
|
99 |
+
## Performance Improvement
|
100 |
+
- **Training Loss Reduction:** 45.32%
|
101 |
+
- **Validation Loss Reduction:** 35.97%
|
102 |
+
- **Final Training Loss:** 1.0060
|
103 |
+
- **Lowest Validation Loss:** 1.1385
|
104 |
+
|
105 |
+
## Loss Values
|
106 |
+
| Metric | Initial | Final | Minimum |
|
107 |
+
|--------|---------|-------|---------|
|
108 |
+
| **Training Loss** | 1.8398 | 1.0060 | 1.0060 |
|
109 |
+
| **Validation Loss** | 1.7782 | 1.1386 | 1.1385 |
|
110 |
+
|
111 |
+
|
112 |
+
## Model Training Results:
|
113 |
+
|
114 |
+

|
115 |
+

|
116 |
+

|
117 |
+

|
118 |
+

|
119 |
+

|
120 |
+

|
121 |
+

|
122 |
+

|
123 |
+
|
124 |
+
## How to Get Started with the Model
|
125 |
+
|
126 |
+
This section provides a step-by-step guide to loading and using the model for generating medical responses in Thai.
|
127 |
+
|
128 |
+
|
129 |
+
# Qwen 2.5 32B Thai Medical Model
|
130 |
+
|
131 |
+
## Installation Requirements
|
132 |
+
|
133 |
+
```python
|
134 |
+
# Install required libraries if not already installed
|
135 |
+
pip install transformers torch peft
|
136 |
+
```
|
137 |
+
|
138 |
+
## Import Required Libraries
|
139 |
+
|
140 |
+
```python
|
141 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
142 |
+
```
|
143 |
+
|
144 |
+
In this cell, we import the necessary libraries from the Hugging Face Transformers package.
|
145 |
+
|
146 |
+
## Configure 4-bit Quantization
|
147 |
+
|
148 |
+
```python
|
149 |
+
# Configure quantization settings
|
150 |
+
bnb_config = BitsAndBytesConfig(
|
151 |
+
load_in_4bit=True,
|
152 |
+
bnb_4bit_compute_dtype="float16",
|
153 |
+
bnb_4bit_use_double_quant=True,
|
154 |
+
bnb_4bit_quant_type="nf4"
|
155 |
+
)
|
156 |
+
```
|
157 |
+
|
158 |
+
This cell configures 4-bit quantization to reduce the memory footprint of the model.
|
159 |
+
|
160 |
+
## Load Model and Tokenizer
|
161 |
+
|
162 |
+
```python
|
163 |
+
# Load the model directly
|
164 |
+
model_name = "amornpan/V3_qwen2.5-32b-med-thai-optimized"
|
165 |
+
model = AutoModelForCausalLM.from_pretrained(
|
166 |
+
model_name,
|
167 |
+
quantization_config=bnb_config,
|
168 |
+
device_map="auto",
|
169 |
+
trust_remote_code=True
|
170 |
+
)
|
171 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
172 |
+
```
|
173 |
+
|
174 |
+
In this cell, we load the pre-trained Qwen 2.5 32B Thai medical model.
|
175 |
+
|
176 |
+
## Create Testing Function
|
177 |
+
|
178 |
+
```python
|
179 |
+
# Function to test the model
|
180 |
+
def test_model(prompt, max_new_tokens=256):
|
181 |
+
system_prompt = "You are a question answering assistant. Answer the question as truthful and helpful as possible. คุณคือผู้ช่วยตอบคำถาม จงตอบคำถามอย่างถูกต้องและมีประโยชน์ที่สุด"
|
182 |
+
full_prompt = f"system\n{system_prompt}\nuser\n{prompt}\nassistant\n"
|
183 |
+
|
184 |
+
inputs = tokenizer(full_prompt, return_tensors="pt").to(model.device)
|
185 |
+
|
186 |
+
# Generate
|
187 |
+
generated_ids = model.generate(
|
188 |
+
**inputs,
|
189 |
+
max_new_tokens=max_new_tokens,
|
190 |
+
do_sample=True,
|
191 |
+
temperature=0.7,
|
192 |
+
top_p=0.9,
|
193 |
+
)
|
194 |
+
|
195 |
+
response = tokenizer.decode(generated_ids[0], skip_special_tokens=False)
|
196 |
+
# Extract only the assistant's response
|
197 |
+
assistant_response = response.split("assistant\n")[-1].split("")[0]
|
198 |
+
|
199 |
+
return assistant_response
|
200 |
+
```
|
201 |
+
|
202 |
+
This function handles the generation of responses.
|
203 |
+
|
204 |
+
## Test with Example Question
|
205 |
+
|
206 |
+
```python
|
207 |
+
# Test with a single example
|
208 |
+
example_question = "อาการของโรคเบาหวานมีอะไรบ้าง"
|
209 |
+
print(f"\nคำถาม: {example_question}")
|
210 |
+
response = test_model(example_question)
|
211 |
+
print(f"คำตอบ: {response}")
|
212 |
+
```
|
213 |
+
|
214 |
+
## Output
|
215 |
+
```python
|
216 |
+
คำถาม: อาการของโรคเบาหวานมีอะไรบ้าง
|
217 |
+
คำตอบ: สวัสดี โรคเบาหวานเป็นโรคทางระบบเมตาบอลิซึม โดยเกิดจากภาวะการผลิตฮอร์โมนอินซูลินไม่เพียงพอ
|
218 |
+
หรือร่างกายไม่สามารถใช้อินซูลินได้อย่างมีประสิทธิภาพ ทำให้ระดับน้ำตาลในเลือดสูงขึ้น ซึ่งอาจนำไปสู่ความเสียหายของอวัยวะต่างๆ
|
219 |
+
ในร่างกายได้ โดยเฉพาะหัวใจ เลือด เยื่อบุตา และไต เมื่อระดับน้ำตาลในเลือดสูงขึ้นมากขึ้นเรื่อยๆ จะมี��าการทางคลินิก เช่น
|
220 |
+
1. มีปัสสาวะบ่อย ปัสสาวะมาก เนื่องจากต้องขับน้ำตาลออกทางปัสสาวะ
|
221 |
+
2. กระหายน้ำมาก เนื่องจากมีปัสสาวะมาก
|
222 |
+
3. อ่อนแรง หมดแรง
|
223 |
+
|
224 |
+
คำถาม: การรักษาโรคความดันโลหิตสูงทำอย่างไร
|
225 |
+
คำตอบ: สวัสดี ความดันโลหิตสูงสามารถรักษาได้โดยการใช้ยาหลายชนิด เช่น เบนโซเพอรีซิน, อะโมโลนิด, ลิโซโปรตาซอล, อีลาฟอร์เท็ต,
|
226 |
+
อัลฟูราลิท, อะเซติซิลดิโพราเมต, อาราคานา, อาเนอโรนิก, อาเซติซิลสัมพันธ์, อาเนอโรนิก, อะเซติซิลสัมพันธ์ เป็นต้น
|
227 |
+
คุณสามารถปรึกษาแพทย์ผู้เชี่ยวชาญในเรื่องนี้เพื่อทราบข้อมูลเพิ่มเติมเกี่ยวกับยาดังกล่าว หวังว่าคำตอบของฉันจะเป็นประโยชน์สำหรับคุณ
|
228 |
+
ขอให้คุณมีสุขภาพที่ดี ขอบคุณที่เลือกใช้บริการของเรา หากคุณมีคำถามใด ๆ
|
229 |
+
|
230 |
+
คำถาม: ยา Paracetamol มีผลข้างเคียงอะไรบ้าง
|
231 |
+
คำตอบ: Paracetamol เป็นยาแก้ปวดและลดไข้ที่ใช้กันอย่างแพร่หลาย ซึ่งมีผลข้างเคียงน้อยกว่ายาแก้ปวดชนิดอื่นๆ โดยทั่วไปจะไม่มีผลข้างเคียงใดๆ
|
232 |
+
หากใช้ในขนาดที่แนะนำ แต่อาจพบได้ เช่น ปวดท้อง อาเจียน และรู้สึกคลื่นไส้ นอกจากนี้ หากใช้ในปริมาณที่มากเกินไป อาจทำให้มีอาการปัสสาวะขุ่น
|
233 |
+
มีสีเหลืองเข้ม เบื่ออาหาร คลื่นไส้ อาเจียน ปวดท้อง ปวดหัว ตาเหลือง หรือปัสสาวะสีเข้มเป็นสีชาโคล่า
|
234 |
+
หากมีอาการดังกล่าวควรหยุดการใช้ยาและรีบไปพบแพทย์เพื่อตรวจหาความเสียหายของตับจากยา
|
235 |
+
โดยการตรวจการทำงานของตับ ซึ่งหากพบว่ามีอาการของโรคตับวายเฉียบพลัน
|
236 |
+
```
|
237 |
+
|
238 |
+
### 👤 **Authors**
|
239 |
+
|
240 |
+
* Amornpan Phornchaicharoen ([email protected])
|
241 |
+
* Aekanun Thongtae ([email protected])
|
242 |
* Montita Somsoo ([email protected])
|