TK17250 commited on
Commit
b341a1b
·
verified ·
1 Parent(s): 0244e68

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - UpMath/Thai-HomeworkGen-138K
5
+ base_model:
6
+ - Qwen/Qwen2.5-7B
7
+ pipeline_tag: text-generation
8
+ ---
9
+
10
+ # 🤖 Thai-HomeworkGen — โมเดลสร้าง/แก้โจทย์คณิตศาสตร์ภาษาไทย
11
+
12
+ **Thai-HomeworkGen** เป็นโมเดลภาษาไทยขนาด 4B ที่ถูก fine-tune ด้วยเทคนิค **Supervised Fine-tuning (SFT)**
13
+ โดยใช้ไลบรารี [`trl`](https://github.com/huggingface/trl) ร่วมกับ **QLoRA** บนฐาน [Qwen/Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B)
14
+
15
+ ---
16
+
17
+ ## 🧪 ตัวอย่างการใช้งาน
18
+
19
+ ```python
20
+ from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
21
+ import torch
22
+ tokenizer = AutoTokenizer.from_pretrained("UpMath/Thai-HomeworkGen-4B-v2")
23
+ model = AutoModelForCausalLM.from_pretrained("UpMath/Thai-HomeworkGen-4B-v2",device_map="auto")
24
+ generator = pipeline(
25
+ "text-generation",
26
+ model=model,
27
+ tokenizer=tokenizer,
28
+ device_map="auto",
29
+ max_new_tokens=2048,
30
+ do_sample=True,
31
+ temperature=0.7,
32
+ pad_token_id=tokenizer.eos_token_id
33
+ )
34
+ prompt = """
35
+ โปรดสร้างโจทย์คณิตศาสตร์ใหม่ โดยมีรายละเอียดดังนี้:
36
+ ระดับ Bloom: ["วิเคราะห์"] # หรือ ["วิเคราะห์", "จดจำ", .....]
37
+ ระดับชั้น: มัธยมศึกษาปีที่ 4
38
+ รูปแบบ: ปรนัย # หรือ อัตนัย
39
+ โปรดสร้างโจทย์ พร้อมวิธีทำและคำตอบ:
40
+ """
41
+ result = generator(prompt)[0]['generated_text']
42
+ print(result)
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 🎯 จุดประสงค์ของโมเดล
48
+
49
+ - ✅ สร้างโจทย์คณิตศาสตร์ใหม่ในรูปแบบภาษาไทย
50
+ - ✅ แสดงวิธีทำและคำตอบที่ชัดเจน
51
+ - ✅ รองรับระดับความคิดตามแนวทาง **Bloom’s Taxonomy**
52
+ - ✅ ออกแบบมาเพื่อใช้ในบริบทการศึกษา การสอน และการวัดผล reasoning
53
+
54
+ ---
55
+
56
+ ## 🧠 ข้อมูลการฝึก (Training Details)
57
+
58
+ - **Base Model:** `Qwen/Qwen2.5-7B`
59
+ - **Library:** [`trl`](https://github.com/huggingface/trl) (`SFTTrainer`)
60
+ - **Adapter:** QLoRA (`peft`)
61
+ - **Batch Size:** 2 × 4 (gradient_accumulation)
62
+ - **Epochs:** 3
63
+ - **Sequence Length:** 1024
64
+ - **Dataset:** Thai Math Dataset (~138K examples, translated + aligned)
65
+ โมเดลถูกฝึกด้วย QLoRA โดยใช้เทคนิค **low-rank adapter (LoRA)** ร่วมกับ quantization 4-bit
66
+ เพื่อให้สามารถฝึกบน GPU ขนาดกลาง เช่น A100 หรือ Colab Pro ได้อย่างมีประสิทธิภาพ
67
+ ---
68
+
69
+ ## 📦 Dataset ที่ใช้
70
+ ชื่อชุดข้อมูล: **Thai-HomeworkGen-138K**
71
+ เนื้อหา: โจทย์คณิตศาสตร์ภาษาไทยระดับมัธยมปลาย พร้อมวิธีทำ คำตอบ และระดับ Bloom Taxonomy
72
+ ต้นฉบับแปลจากชุดข้อมูลภาษาอังกฤษ
73
+ 1. [MathQA (allenai)](https://huggingface.co/datasets/allenai/math_qa)
74
+ 2. [MATH-500 (HuggingFaceH4)](https://huggingface.co/datasets/HuggingFaceH4/MATH-500)
75
+ 3. [MATH-Algebra](https://huggingface.co/datasets/themanas021/MATH-Algebra)
76
+ 4. [math-mixture: mix_intermediate_algebra97_algebra01_prealgebra00](https://huggingface.co/datasets/andrewsiah/math-mixture-mix_intermediate_algebra97_algebra01_prealgebra00)
77
+ 5. [math-mixture: mix_algebra76_prealgebra12_number_theory08](https://huggingface.co/datasets/andrewsiah/math-mixture-mix_algebra76_prealgebra12_number_theory08)
78
+ 6. [Math-algebra (datafreak)](https://huggingface.co/datasets/datafreak/Math-algebra)
79
+ 7. [MATH Dataset (Hendrycks et al.)](https://github.com/hendrycks/math/)
80
+ 8. [GSM8K (openai)](https://huggingface.co/datasets/openai/gsm8k)
81
+ 9. [Math QSA Dataset (Kaggle)](https://www.kaggle.com/datasets/awsaf49/math-qsa-dataset)
82
+ 10. [AQuA (DeepMind)](https://github.com/google-deepmind/AQuA)
83
+ ชุดข้อมูลถูกแปลและจัดโครงสร้างโดยใช้ LLM (Gemma 2 27B) พร้อมตรวจสอบโดยผู้เชี่ยวชาญจาก สวทช.
84
+ 👉 [ดูรายละเอียดของ Dataset](https://huggingface.co/datasets/UpMath/Thai-HomeworkGen-138K)
85
+ ---
86
+
87
+ ## การอ้างอิง
88
+ หากคุณใช้งานโมเดลนี้ สามารถให้เครดิตโปรเจกต์นี้ได้ด้วย