TK17250's picture
Update README.md
5ed0fd6 verified
---
base_model: mistralai/Mistral-7B-Instruct-v0.3
library_name: transformers
model_name: mistral-bloom-finetune
tags:
- generated_from_trainer
- trl
- sft
licence: license
---
# 🤖 Thai-HomeworkGen — โมเดลสร้าง/แก้โจทย์คณิตศาสตร์ภาษาไทย
**Thai-HomeworkGen** เป็นโมเดลภาษาไทยขนาด 7B ที่ถูก fine-tune ด้วยเทคนิค **Supervised Fine-tuning (SFT)**
โดยใช้ไลบรารี [`trl`](https://github.com/huggingface/trl) ร่วมกับ **QLoRA** บนฐาน [mistralai/Mistral-7B-Instruct-v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3)
---
## 🧪 ตัวอย่างการใช้งาน
```python
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("UpMath/Thai-HomeworkGen-7.2B-v1")
model = AutoModelForCausalLM.from_pretrained("UpMath/Thai-HomeworkGen-7.2B-v1",device_map="auto")
generator = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto",
max_new_tokens=2048,
do_sample=True,
temperature=0.7,
pad_token_id=tokenizer.eos_token_id
)
prompt = """
ระดับ Bloom: "วิเคราะห์" # หรือ ["วิเคราะห์", "จดจำ"]
ระดับชั้น: 'มัธยมศึกษาปีที่ 4'
โปรดสร้างโจทย์ พร้อมวิธีทำและคำตอบ:
"""
result = generator(prompt)[0]['generated_text']
print(result)
```
---
## 🎯 จุดประสงค์ของโมเดล
- ✅ สร้างโจทย์คณิตศาสตร์ใหม่ในรูปแบบภาษาไทย
- ✅ แสดงวิธีทำและคำตอบที่ชัดเจน
- ✅ รองรับระดับความคิดตามแนวทาง **Bloom’s Taxonomy**
- ✅ ออกแบบมาเพื่อใช้ในบริบทการศึกษา การสอน และการวัดผล reasoning
---
## 🧠 ข้อมูลการฝึก (Training Details)
- **Base Model:** `mistralai/Mistral-7B-Instruct-v0.3`
- **Library:** [`trl`](https://github.com/huggingface/trl) (`SFTTrainer`)
- **Adapter:** QLoRA (`peft`)
- **Batch Size:** 2 × 4 (gradient_accumulation)
- **Epochs:** 3
- **Sequence Length:** 1024
- **Dataset:** Thai Math Dataset (~32K examples, translated + aligned)
โมเดลถูกฝึกด้วย QLoRA โดยใช้เทคนิค **low-rank adapter (LoRA)** ร่วมกับ quantization 4-bit
เพื่อให้สามารถฝึกบน GPU ขนาดกลาง เช่น A100 หรือ Colab Pro ได้อย่างมีประสิทธิภาพ
---
## 📦 Dataset ที่ใช้
ชื่อชุดข้อมูล: **Thai-HomeworkGen-32K**
เนื้อหา: โจทย์คณิตศาสตร์ภาษาไทยระดับมัธยมปลาย พร้อมวิธีทำ คำตอบ และระดับ Bloom Taxonomy
ต้นฉบับแปลจากชุดข้อมูลภาษาอังกฤษ
1. [MathQA (allenai)](https://huggingface.co/datasets/allenai/math_qa)
2. [MATH-500 (HuggingFaceH4)](https://huggingface.co/datasets/HuggingFaceH4/MATH-500)
3. [MATH-Algebra](https://huggingface.co/datasets/themanas021/MATH-Algebra)
4. [math-mixture: mix_intermediate_algebra97_algebra01_prealgebra00](https://huggingface.co/datasets/andrewsiah/math-mixture-mix_intermediate_algebra97_algebra01_prealgebra00)
5. [math-mixture: mix_algebra76_prealgebra12_number_theory08](https://huggingface.co/datasets/andrewsiah/math-mixture-mix_algebra76_prealgebra12_number_theory08)
6. [Math-algebra (datafreak)](https://huggingface.co/datasets/datafreak/Math-algebra)
7. [MATH Dataset (Hendrycks et al.)](https://github.com/hendrycks/math/)
8. [GSM8K (openai)](https://huggingface.co/datasets/openai/gsm8k)
9. [Math QSA Dataset (Kaggle)](https://www.kaggle.com/datasets/awsaf49/math-qsa-dataset)
10. [AQuA (DeepMind)](https://github.com/google-deepmind/AQuA)
ชุดข้อมูลถูกแปลและจัดโครงสร้างโดยใช้ LLM (Gemma 2 27B) พร้อมตรวจสอบโดยผู้เชี่ยวชาญจาก สวทช.
👉 [ดูรายละเอียดของ Dataset](https://huggingface.co/datasets/UpMath/Thai-HomeworkGen-32K)
---
## การอ้างอิง
หากคุณใช้งานโมเดลนี้ สามารถให้เครดิตโปรเจกต์นี้ได้ด้วย