โครงการปรับแต่งโมเดล Typhoon-7B ด้วยเทคนิคขั้นสูงจากงานวิจัยล่าสุด เพื่อให้มีความสามารถในการเข้าใจและตอบคำถามภาษาไทยได้ดียิ่งขึ้น รวมถึงความสามารถในการประมวลผลภาพ (Vision Processing)
# 1. ติดตั้ง
git clone https://github.com/yourusername/Project-scb10xtyphoon-7b.git
cd Project-scb10xtyphoon-7b
pip install -r requirements.txt
# 2. ดาวน์โหลดและเตรียมข้อมูล
prepare_training_data.bat # หรือ ./prepare_training_data.sh สำหรับ Linux/Mac
# 3. เริ่มการเทรน
run_training.bat # หรือ ./run_training.sh สำหรับ Linux/Mac
การประมวลผลภาษาไทย:
การประมวลผลภาพ (Vision):
เทคนิคขั้นสูง:
graph TD
A[Input Data] --> B[prepare_dataset.bat]
B --> C{เลือกประเภทข้อมูล}
C --> D[Text Dataset]
C --> E[Conversation Dataset]
C --> F[Instruction Dataset]
C --> G[Vision Dataset]
C --> H[Teacher-Student Dataset]
subgraph "Data Processing"
D --> I[Clean Text]
E --> I
F --> I
G --> J[Process Images]
H --> K[Generate Teacher Outputs]
J --> I
K --> I
I --> L[Tokenization]
L --> M[Train/Test Split]
end
M --> N[Processed Dataset]
N --> O[Training]
graph LR
A[Input .txt] --> B[Clean Text]
B --> C[Remove Extra Whitespace]
C --> D[Handle Newlines]
D --> E[Tokenization]
E --> F[Train/Test Split]
graph LR
A[Input .csv] --> B[Extract QA Pairs]
B --> C[Format Template]
C --> D[Clean Text]
D --> E[Optional: Add Images]
E --> F[Tokenization]
F --> G[Train/Test Split]
graph TD
A[Input .csv] --> B[Load Images]
B --> C[Process Images]
C --> D[Resize if needed]
D --> E[Convert to RGB]
E --> F[Base64 Encoding]
A --> G[Extract Text/Captions]
G --> H[Clean Text]
F --> I[Combine Data]
H --> I
I --> J[Tokenization]
J --> K[Train/Test Split]
graph TD
A[Input Text] --> B[Load Teacher Model]
B --> C[Generate Logits]
C --> D[Apply Softmax]
A --> E[Clean Text]
E --> F[Student Training Data]
D --> G[Knowledge Distillation]
F --> G
G --> H[Final Dataset]
# Clone โครงการ
git clone https://github.com/yourusername/Project-scb10xtyphoon-7b.git
cd Project-scb10xtyphoon-7b
# ติดตั้ง dependencies
pip install -r requirements.txt
# สำหรับ Windows
prepare_training_data.bat
ระบบจะดาวน์โหลดและเตรียมข้อมูลจาก Hugging Face ดังนี้:
ข้อความภาษาไทย:
บทสนทนา:
ข้อมูลภาพ:
คำสั่งและการตอบสนอง:
ข้อมูลที่ดาวน์โหลดจะถูกเก็บใน datasets/ และข้อมูลที่ผ่านการประมวลผลแล้วจะอยู่ใน processed_data/
สามารถเตรียมข้อมูลแต่ละประเภทได้ด้วยคำสั่ง:
# ข้อความทั่วไป
python data_preprocessing.py --input_file input.txt --input_type text --dataset_type text
# บทสนทนา
python data_preprocessing.py --input_file chat.csv --input_type csv --dataset_type conversation
# ข้อมูลภาพ
python data_preprocessing.py --input_file images.csv --input_type csv --dataset_type vision --image_column image --caption_column caption
# คำสั่งและการตอบสนอง
python data_preprocessing.py --input_file instructions.json --input_type json --dataset_type instruction
ดูคู่มือการใช้งานฉบับเต็มได้ที่:
คู่มือนี้ประกอบด้วย:
# สำหรับ Linux/Mac
./run_training.sh
# สำหรับ Windows
run_training.bat
# สำหรับ Windows (ใช้ Accelerate)
run_advanced_training.bat --use_flash_attn --use_llama3
# สำหรับ Linux/Mac (ใช้ Accelerate)
accelerate launch advanced_training.py --output_dir ./fine_tuned_typhoon_advanced --use_flash_attn --use_llama3
# สำหรับ Windows (ใช้ Accelerate)
train_vision_model.bat
# สำหรับ Linux/Mac (ใช้ Accelerate)
accelerate launch vision_training.py --use_flash_attention --enable_xformers
สคริปต์นี้จะให้คุณเลือก configuration การเทรน:
เทคนิคพิเศษที่ใช้ในการเทรน Vision Model:
# โหมดสนทนาโต้ตอบ
python typhoon_inference.py --model_path ./fine_tuned_typhoon --interactive
# การประมวลผลไฟล์คำถาม
python typhoon_inference.py --model_path ./fine_tuned_typhoon --input_file questions.txt --output_file answers.txt
ดูรายละเอียดเทคนิคขั้นสูงที่ใช้ในแต่ละส่วนได้ที่:
ผลลัพธ์ทั้งหมดจะถูกเก็บในโฟลเดอร์ outputs/ ตามโครงสร้างนี้:
outputs/
├── models/ # โมเดลที่เทรนเสร็จแล้ว
│ ├── text/ # โมเดล Text
│ │ └── typhoon_advanced_YYYYMMDD_HHMMSS/
│ │ ├── model_info.txt
│ │ ├── config.json
│ │ └── pytorch_model.bin (or safetensors)
│ └── vision/ # โมเดล Vision
│ └── checkpoints/
│ └── vision_model_epoch_X/
│ ├── config.json
│ └── diffusion_pytorch_model.safetensors
├── logs/ # ไฟล์ Log
│ ├── data_preprocessing/
│ │ └── data_preprocessing.log
│ ├── text_training/
│ │ └── advanced_training.log
│ └── vision_training/
│ └── vision_training.log
├── processed_data/ # ข้อมูลที่ผ่านการประมวลผล
│ ├── text/
│ │ └── wikipedia/
│ │ └── gpt4/
│ ├── conversation/
│ │ └── belle/
│ │ └── alpaca/
│ ├── vision/
│ │ └── laion/
│ │ └── art/
│ └── instruction/
│ └── instruct/
│ └── dolly/
└── evaluation/ # ผลการประเมินโมเดล (ถ้ามี)
typhoon_model_training.py: ไฟล์หลักสำหรับการเทรนโมเดล Text พื้นฐานadvanced_training.py: การเทรนโมเดล Text ขั้นสูงvision_training.py: การเทรนโมเดล Vision ขั้นสูงtyphoon_inference.py: สำหรับการอนุมานและใช้งานโมเดลdata_preprocessing.py: เตรียมและจัดการชุดข้อมูลdownload_datasets.py: ดาวน์โหลดข้อมูลจาก Hugging Facevision_utils.py: เครื่องมือสำหรับ Vision Processing และ Generationdeepseek_utils.py: เครื่องมือและฟังก์ชันจาก DeepSeek และงานวิจัยอื่นๆrun_training.bat: สคริปต์เริ่มการเทรน Text พื้นฐาน (Windows)run_advanced_training.bat: สคริปต์เริ่มการเทรน Text ขั้นสูง (Windows)train_vision_model.bat: สคริปต์เริ่มการเทรน Vision (Windows)prepare_training_data.bat: สคริปต์ดาวน์โหลดและเตรียมข้อมูล (Windows)run_inference.bat: สคริปต์สำหรับการอนุมาน (Windows)ดูรายละเอียดทรัพยากรที่แนะนำ (Hardware, Software, Data, Storage) ได้ที่:
Vision Features:
Training Data:
Performance:
MIT License - see LICENSE file for details.
6 commits
Python
90.3%
Batchfile
7.8%
Shell
1.9%
โครงการปรับแต่งโมเดล Typhoon-7B ด้วยเทคนิคขั้นสูงจากงานวิจัยล่าสุด เพื่อให้มีความสามารถในการเข้าใจและตอบคำถามภาษาไทยได้ดียิ่งขึ้น รวมถึงความสามารถในการประมวลผลภาพ (Vision Processing)
# 1. ติดตั้ง
git clone https://github.com/yourusername/Project-scb10xtyphoon-7b.git
cd Project-scb10xtyphoon-7b
pip install -r requirements.txt
# 2. ดาวน์โหลดและเตรียมข้อมูล
prepare_training_data.bat # หรือ ./prepare_training_data.sh สำหรับ Linux/Mac
# 3. เริ่มการเทรน
run_training.bat # หรือ ./run_training.sh สำหรับ Linux/Mac
การประมวลผลภาษาไทย:
การประมวลผลภาพ (Vision):
เทคนิคขั้นสูง:
graph TD
A[Input Data] --> B[prepare_dataset.bat]
B --> C{เลือกประเภทข้อมูล}
C --> D[Text Dataset]
C --> E[Conversation Dataset]
C --> F[Instruction Dataset]
C --> G[Vision Dataset]
C --> H[Teacher-Student Dataset]
subgraph "Data Processing"
D --> I[Clean Text]
E --> I
F --> I
G --> J[Process Images]
H --> K[Generate Teacher Outputs]
J --> I
K --> I
I --> L[Tokenization]
L --> M[Train/Test Split]
end
M --> N[Processed Dataset]
N --> O[Training]
graph LR
A[Input .txt] --> B[Clean Text]
B --> C[Remove Extra Whitespace]
C --> D[Handle Newlines]
D --> E[Tokenization]
E --> F[Train/Test Split]
graph LR
A[Input .csv] --> B[Extract QA Pairs]
B --> C[Format Template]
C --> D[Clean Text]
D --> E[Optional: Add Images]
E --> F[Tokenization]
F --> G[Train/Test Split]
graph TD
A[Input .csv] --> B[Load Images]
B --> C[Process Images]
C --> D[Resize if needed]
D --> E[Convert to RGB]
E --> F[Base64 Encoding]
A --> G[Extract Text/Captions]
G --> H[Clean Text]
F --> I[Combine Data]
H --> I
I --> J[Tokenization]
J --> K[Train/Test Split]
graph TD
A[Input Text] --> B[Load Teacher Model]
B --> C[Generate Logits]
C --> D[Apply Softmax]
A --> E[Clean Text]
E --> F[Student Training Data]
D --> G[Knowledge Distillation]
F --> G
G --> H[Final Dataset]
# Clone โครงการ
git clone https://github.com/yourusername/Project-scb10xtyphoon-7b.git
cd Project-scb10xtyphoon-7b
# ติดตั้ง dependencies
pip install -r requirements.txt
# สำหรับ Windows
prepare_training_data.bat
ระบบจะดาวน์โหลดและเตรียมข้อมูลจาก Hugging Face ดังนี้:
ข้อความภาษาไทย:
บทสนทนา:
ข้อมูลภาพ:
คำสั่งและการตอบสนอง:
ข้อมูลที่ดาวน์โหลดจะถูกเก็บใน datasets/ และข้อมูลที่ผ่านการประมวลผลแล้วจะอยู่ใน processed_data/
สามารถเตรียมข้อมูลแต่ละประเภทได้ด้วยคำสั่ง:
# ข้อความทั่วไป
python data_preprocessing.py --input_file input.txt --input_type text --dataset_type text
# บทสนทนา
python data_preprocessing.py --input_file chat.csv --input_type csv --dataset_type conversation
# ข้อมูลภาพ
python data_preprocessing.py --input_file images.csv --input_type csv --dataset_type vision --image_column image --caption_column caption
# คำสั่งและการตอบสนอง
python data_preprocessing.py --input_file instructions.json --input_type json --dataset_type instruction
ดูคู่มือการใช้งานฉบับเต็มได้ที่:
คู่มือนี้ประกอบด้วย:
# สำหรับ Linux/Mac
./run_training.sh
# สำหรับ Windows
run_training.bat
# สำหรับ Windows (ใช้ Accelerate)
run_advanced_training.bat --use_flash_attn --use_llama3
# สำหรับ Linux/Mac (ใช้ Accelerate)
accelerate launch advanced_training.py --output_dir ./fine_tuned_typhoon_advanced --use_flash_attn --use_llama3
# สำหรับ Windows (ใช้ Accelerate)
train_vision_model.bat
# สำหรับ Linux/Mac (ใช้ Accelerate)
accelerate launch vision_training.py --use_flash_attention --enable_xformers
สคริปต์นี้จะให้คุณเลือก configuration การเทรน:
เทคนิคพิเศษที่ใช้ในการเทรน Vision Model:
# โหมดสนทนาโต้ตอบ
python typhoon_inference.py --model_path ./fine_tuned_typhoon --interactive
# การประมวลผลไฟล์คำถาม
python typhoon_inference.py --model_path ./fine_tuned_typhoon --input_file questions.txt --output_file answers.txt
ดูรายละเอียดเทคนิคขั้นสูงที่ใช้ในแต่ละส่วนได้ที่:
ผลลัพธ์ทั้งหมดจะถูกเก็บในโฟลเดอร์ outputs/ ตามโครงสร้างนี้:
outputs/
├── models/ # โมเดลที่เทรนเสร็จแล้ว
│ ├── text/ # โมเดล Text
│ │ └── typhoon_advanced_YYYYMMDD_HHMMSS/
│ │ ├── model_info.txt
│ │ ├── config.json
│ │ └── pytorch_model.bin (or safetensors)
│ └── vision/ # โมเดล Vision
│ └── checkpoints/
│ └── vision_model_epoch_X/
│ ├── config.json
│ └── diffusion_pytorch_model.safetensors
├── logs/ # ไฟล์ Log
│ ├── data_preprocessing/
│ │ └── data_preprocessing.log
│ ├── text_training/
│ │ └── advanced_training.log
│ └── vision_training/
│ └── vision_training.log
├── processed_data/ # ข้อมูลที่ผ่านการประมวลผล
│ ├── text/
│ │ └── wikipedia/
│ │ └── gpt4/
│ ├── conversation/
│ │ └── belle/
│ │ └── alpaca/
│ ├── vision/
│ │ └── laion/
│ │ └── art/
│ └── instruction/
│ └── instruct/
│ └── dolly/
└── evaluation/ # ผลการประเมินโมเดล (ถ้ามี)
typhoon_model_training.py: ไฟล์หลักสำหรับการเทรนโมเดล Text พื้นฐานadvanced_training.py: การเทรนโมเดล Text ขั้นสูงvision_training.py: การเทรนโมเดล Vision ขั้นสูงtyphoon_inference.py: สำหรับการอนุมานและใช้งานโมเดลdata_preprocessing.py: เตรียมและจัดการชุดข้อมูลdownload_datasets.py: ดาวน์โหลดข้อมูลจาก Hugging Facevision_utils.py: เครื่องมือสำหรับ Vision Processing และ Generationdeepseek_utils.py: เครื่องมือและฟังก์ชันจาก DeepSeek และงานวิจัยอื่นๆrun_training.bat: สคริปต์เริ่มการเทรน Text พื้นฐาน (Windows)run_advanced_training.bat: สคริปต์เริ่มการเทรน Text ขั้นสูง (Windows)train_vision_model.bat: สคริปต์เริ่มการเทรน Vision (Windows)prepare_training_data.bat: สคริปต์ดาวน์โหลดและเตรียมข้อมูล (Windows)run_inference.bat: สคริปต์สำหรับการอนุมาน (Windows)ดูรายละเอียดทรัพยากรที่แนะนำ (Hardware, Software, Data, Storage) ได้ที่:
Vision Features:
Training Data:
Performance:
MIT License - see LICENSE file for details.
6 commits
Python
90.3%
Batchfile
7.8%
Shell
1.9%