File size: 9,723 Bytes
b0e475c 120ded9 792d34a b0e475c 120ded9 b0e475c 792d34a b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c d855c3e 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c bc2d8d0 b0e475c 120ded9 bc2d8d0 120ded9 b0e475c bc2d8d0 120ded9 bc2d8d0 b0e475c 3e84d87 120ded9 bc2d8d0 120ded9 bc2d8d0 120ded9 b0e475c bc2d8d0 120ded9 3e84d87 bc2d8d0 3e84d87 bc2d8d0 3e84d87 bc2d8d0 3e84d87 bc2d8d0 120ded9 b0e475c bc2d8d0 3e84d87 bc2d8d0 120ded9 b0e475c bc2d8d0 120ded9 b0e475c 120ded9 b0e475c 120ded9 b0e475c 120ded9 030a0c1 |
1 2 3 4 5 6 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 |
---
base_model:
- Qwen/Qwen2.5-32B-Instruct
datasets:
- Thaweewat/thai-med-pack
language:
- th
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- text-generation-inference
- sft
- trl
- 4-bit precision
- bitsandbytes
- LoRA
- Fine-Tuning with LoRA
- LLM
- GenAI
- medical
- medtech
- HealthGPT
- NT Academy
- minddatatech
---
# 🇹🇭 **Model Card for Qwen2.5-32B-Instruct-medical-tuned**
<!-- Provide a quick summary of what the model is/does. -->
## <font color="red">ℹ️ This version is significantly better than OpenThaiGPT!!.</font>
## Qwen2.5-32B-Instruct for Thai Medical QA
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.
## Model Description
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.
- **Model type:** Causal Language Model (AutoModelForCausalLM)
- **Language(s):** Thai
- **Fine-tuned from model:** Qwen2.5-32B-Instruct
- **Dataset used for fine-tuning:** Thaweewat/thai-med-pack
### Model Sources
- **Repository:** https://huggingface.co/amornpan
- **Citing Repository:** https://huggingface.co/Aekanun
- **Base Model:** https://huggingface.co/Qwen/Qwen2.5-32B-Instruct
- **Dataset:** https://huggingface.co/datasets/Thaweewat/thai-med-pack
## Uses
### Direct Use
The model can be used directly for generating medical responses in Thai. It has been optimized for:
- Medical question-answering
- Providing clinical information
- Health-related dialogue generation
### Downstream Use
This model serves as a foundational model for medical assistance systems, chatbots, and applications related to healthcare in the Thai language.
### Out-of-Scope Use
- This model should not be used for real-time diagnosis or emergency medical scenarios.
- It should not be relied upon for critical clinical decisions without human oversight, as it is not intended to replace professional medical advice.
## Bias, Risks, and Limitations
### Bias
- The model may reflect biases present in the dataset, especially regarding underrepresented medical conditions or topics.
### Risks
- Responses may contain inaccuracies due to the model's inherent limitations and the dataset used for fine-tuning.
- The model should not be used as the sole source of medical advice.
### Limitations
- Primarily limited to the medical domain.
- Sensitive to prompts and may generate off-topic responses for non-medical queries.
# Model Training Statistics
## Training Summary
- **Total Steps:** 1050
- **Total Epochs:** 98.25
- **Validation Checks:** 42
- **Epoch with Lowest Validation Loss:** 93.57
## Performance Improvement
- **Training Loss Reduction:** 45.32%
- **Validation Loss Reduction:** 35.97%
- **Final Training Loss:** 1.0060
- **Lowest Validation Loss:** 1.1385
## Loss Values
| Metric | Initial | Final | Minimum |
|--------|---------|-------|---------|
| **Training Loss** | 1.8398 | 1.0060 | 1.0060 |
| **Validation Loss** | 1.7782 | 1.1386 | 1.1385 |
## Model Training Results:









## How to Get Started with the Model
This section provides a step-by-step guide to loading and using the model for generating medical responses in Thai.
### 1. Install the Required Packages
```python
#Import necessary libraries for working with the model
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
```
### 2. Load Model and Tokenizer
```
#Set the model to amornpan/V3_qwen2.5-32b-med-thai-optimized
base_model_name = "amornpan/V3_qwen2.5-32b-med-thai-optimized"
# Load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True)
```
### 3. Define Test Function
```
# Function for testing the model
def test_model(prompt, max_new_tokens=256):
system_prompt = "You are a question answering assistant. Answer the question as truthful and helpful as possible. คุณคือผู้ช่วยตอบคำถาม จงตอบคำถามอย่างถูกต้องและมีประโยชน์ที่สุด"
full_prompt = f"<s><|im_start|>system\n{system_prompt}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
inputs = tokenizer(full_prompt, return_tensors="pt").to(model.device)
# Generate
generated_ids = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=0.7,
top_p=0.9,
)
response = tokenizer.decode(generated_ids[0], skip_special_tokens=False)
# Extract only the assistant's response
assistant_response = response.split("<|im_start|>assistant\n")[-1].split("<|im_end|>")[0]
return assistant_response
```
### 4. Test with an Example Question
# Show an example question
```
# Show an example question
example_question = "อาการของโรคเบาหวานมีอะไรบ้าง"
print(f"\nคำถาม: {example_question}")
response = test_model(example_question)
print(f"คำตอบ: {response}")
```
### 5. Output
```python
คำถาม: การรักษาโรคความดันโลหิตสูงทำอย่างไร
คำตอบ: สวัสดี ความดันโลหิตสูงสามารถรักษาได้โดยการใช้ยาหลายชนิด เช่น เบนโซเพอรีซิน, อะโมโลนิด, ลิโซโปรตาซอล, อีลาฟอร์เท็ต,
อัลฟูราลิท, อะเซติซิลดิโพราเมต, อาราคานา, อาเนอโรนิก, อาเซติซิลสัมพันธ์, อาเนอโรนิก, อะเซติซิลสัมพันธ์ เป็นต้น
คุณสามารถปรึกษาแพทย์ผู้เชี่ยวชาญในเรื่องนี้เพื่อทราบข้อมูลเพิ่มเติมเกี่ยวกับยาดังกล่าว หวังว่าคำตอบของฉันจะเป็นประโยชน์สำหรับคุณ
ขอให้คุณมีสุขภาพที่ดี ขอบคุณที่เลือกใช้บริการของเรา หากคุณมีคำถามใด ๆ
คำถาม: ยา Paracetamol มีผลข้างเคียงอะไรบ้าง
คำตอบ: Paracetamol เป็นยาแก้ปวดและลดไข้ที่ใช้กันอย่างแพร่หลาย ซึ่งมีผลข้างเคียงน้อยกว่ายาแก้ปวดชนิดอื่นๆ โดยทั่วไปจะไม่มีผลข้างเคียงใดๆ
หากใช้ในขนาดที่แนะนำ แต่อาจพบได้ เช่น ปวดท้อง อาเจียน และรู้สึกคลื่นไส้ นอกจากนี้ หากใช้ในปริมาณที่มากเกินไป อาจทำให้มีอาการปัสสาวะขุ่น
มีสีเหลืองเข้ม เบื่ออาหาร คลื่นไส้ อาเจียน ปวดท้อง ปวดหัว ตาเหลือง หรือปัสสาวะสีเข้มเป็นสีชาโคล่า
หากมีอาการดังกล่าวควรหยุดการใช้ยาและรีบไปพบแพทย์เพื่อตรวจหาความเสียหายของตับจากยา
โดยการตรวจการทำงานของตับ ซึ่งหากพบว่ามีอาการของโรคตับวายเฉียบพลัน
```
### 👤 **Authors**
* Amornpan Phornchaicharoen ([email protected])
* Aekanun Thongtae ([email protected])
* Montita Somsoo ([email protected]) |