File size: 4,823 Bytes
d5eb962
1da8c51
b2e76c0
 
 
 
 
 
 
 
9778bec
 
 
 
 
 
 
 
 
 
 
 
 
b2e76c0
1da8c51
 
 
d5eb962
 
 
 
7908154
d5eb962
 
1da8c51
230725f
1da8c51
230725f
1da8c51
230725f
1da8c51
 
 
 
230725f
1da8c51
230725f
1da8c51
 
 
 
230725f
1da8c51
 
 
 
230725f
1da8c51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: AutoGDataset Thai
emoji: 📚
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.44.1
app_file: app.py
pinned: false
hf_oauth: true
---

# AutoGDataset Thai 🇹🇭

เครื่องมือสร้างชุดข้อมูล (Dataset) ภาษาไทยจากไฟล์ PDF โดยใช้ LangChain กับ Hugging Face Inference APIset Thai
emoji: 📚
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.44.1
app_file: app.py
pinned: false
hf_oauth: true
---AutoGDataset Thai
emoji: �🇭
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.44.1
app_file: app.py
pinned: false
hf_oauth: true
---

# AutoGDataset Thai 🇹🇭

เครื่องมือสร้างชุดข้อมูล (Dataset) ภาษาไทยจากไฟล์ PDF โดยใช้ LangChain กับ Hugging Face Inference API

## คุณสมบัติเด่น ✨

- **รองรับงานหลากหลาย**: QA, RLHF, DPO, Constitutional AI, Chain of Thought, Dialogue และอื่นๆ
- **เน้นภาษาไทย**: รองรับโมเดลภาษาไทยและ prompt ที่เหมาะสมกับบริบททางวัฒนธรรม
- **โมเดลที่รองรับ**: OpenThaiGPT, Typhoon, WangchanBERTa และ multilingual models
- **ปรับแต่งได้**: สามารถกำหนด prompt และพารามิเตอร์ต่างๆ ได้

## โมเดลที่แนะนำ 🤖

### โมเดลภาษาไทย
- `openthaigpt/openthaigpt-1.0.0-alpha-7b-chat`
- `scb10x/llama-3-typhoon-v1.5-8b-instruct`
- `airesearch/wangchanberta-base-att-spm-uncased`

### โมเดล Multilingual
- `google/mt5-large`
- `microsoft/mdeberta-v3-base`
- `facebook/xglm-7.5B`

## การใช้งาน 🚀

### รันในเครื่อง
```bash
pip install -r requirements.txt
python app.py
```

### บน Hugging Face Spaces
1. เพิ่ม secret `HF_TOKEN` หากจำเป็น
2. อัปโหลดไฟล์ PDF
3. เลือกประเภทงานและโมเดล
4. คลิกสร้างชุดข้อมูล

## ประเภทงานที่รองรับ 📋

### งานพื้นฐาน
- **QA**: คำถาม-คำตอบ `{question: str, answer: str}`
- **Summarization**: การสรุป `{summary: str}`
- **Keywords**: คำสำคัญ `{keyword: str}`
- **NER**: การจดจำเอนทิตี `{text: str, label: str, start: int, end: int}`
- **Classification**: การจำแนกประเภท `{labels: [str], rationale: str}`
- **MCQ**: คำถามแบบเลือกตอบ `{question: str, options: [str], answer_index: int}`
- **True/False**: จริง/เท็จ `{statement: str, answer: bool, explanation: str}`
- **Translation**: การแปล `{source: str, target: str}`

### งานขั้นสูงสำหรับ AI Training
- **RLHF**: `{prompt: str, responses: [str], scores: [float], preferred_response: str}`
- **DPO**: `{prompt: str, chosen: str, rejected: str, reason: str}`
- **Instruction_Following**: `{instruction: str, input: str, output: str, difficulty: str}`
- **Constitutional_AI**: `{problematic_prompt: str, constitutional_response: str, principle: str}`
- **Chain_of_Thought**: `{problem: str, thinking_steps: [str], final_answer: str}`
- **Dialogue**: `{dialogue: [{role: str, content: str}], context: str}`
- **Thai_Culture**: `{question_th: str, answer_th: str, cultural_context: str}`

## หมายเหตุสำคัญ 📝

- ใช้ HF Inference API ผ่าน LangChain ไม่ต้องติดตั้ง `transformers` ในเครื่อง
- ไฟล์ผลลัพธ์จะถูกบันทึกใน `outputs/` ทั้งแบบ JSON และ JSONL
- ต้องเข้าสู่ระบบ Hugging Face สำหรับ Spaces (ตั้งค่า `REQUIRE_LOGIN=0` เพื่อปิดการใช้งาน)
- รองรับการปรับแต่ง prompt สำหรับผลลัพธ์ที่ดีขึ้น

## การติดตั้ง Dependencies 📦

```bash
pip install gradio pypdf huggingface_hub langchain langchain-community pythainlp transformers torch
```

สำหรับการประมวลผลภาษาไทยที่ดีขึ้น แนะนำให้ติดตั้ง:
- `pythainlp`: สำหรับการประมวลผลภาษาไทย
- `thai-word-segmentation`: สำหรับการตัดคำภาษาไทย