# 從零開始到實戰:Gemma-3-270M 預訓練與應用心得分享 > 📌 Slido 📌 > https://app.sli.do/event/w23G3QucLjAXxdPebFGuDY > 共筆請從這裡開始 **Twinkle AI** * [Twinkle AI Discord link](https://discord.gg/tXFJFnrg) * [Twinkle AI HuggingFace](https://huggingface.co/twinkle-ai) * [Twinkle AI Github](https://github.com/ai-twinkle) * [Twinkle LLM Labs](https://github.com/ai-twinkle/llm-lab) ## 台灣LLM * [lianghsun/Llama-3.2-Taiwan-3B](https://huggingface.co/lianghsun/Llama-3.2-Taiwan-3B) * [使用 tw-instruct-500k 資料集](https://huggingface.co/datasets/lianghsun/tw-instruct-500k) * [meta-llama/Llama-3.2-3B-Instruct](https://huggingface.co/datasets/lianghsun/tw-instruct-500k) * tw-math-reasoning-2k * tw-leetcode * tw-function-call-reasoning-10k 講者的 Twinkle AI 有提供 eval 工具 ## 動機 * 為啥要自己訓練 * Privacy:金融、國防等不能上雲的領域 * Domain:有些東西太專精 (domain-specific) * Cost:規模較小,可依靠雲端,規模化後,會有成本考量 ## Gemma ![image](https://hackmd.io/_uploads/rJemMUtW-l.png) * 4B -> 27 B 是多模 * Gemma 3 (今天會講到) * Context Size:128k * Language Support:140+ * Size/Modality:5/2 * Text only: * Gemma-3-270m * 效能高、不耗電力 * 同等級參數量能理解量比較高 * 繁中能力(幾乎default是簡中) * 問繁中,回簡中 * int4-quantized 可以跑在 Pixel 9 Pro * Gemma-3-1b * VLM * Gemma-3-4b * Gemma-3-12b * Gemma-3-27b (講者認為Okay) * Gemma 3n 多模態 * MedGemma 醫學相關 * EmbeddingGemma (今天會講到) ## Train 101 > 目的:加強 Gemma-3-270m 的繁體中文能力 ### Pre-training - 理解人類自然語言 * 收集預訓練文本 * 找尋**高品質繁體中文**預訓練文本 * HF 目前繁體中文資料集都是垃圾 * 借鏡 [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) * 還用到 [time-machine](https://web.archive.org/) * 內有高品質、教科書等級的文本 * 有 1.3T tokens * 可以拉高其他模型的的能力 * 使用 EmbeddingGemma-300m 做 backbone,訓練 classifier head,得到 FineWeb-Edu-zhtw-Classifier,準確率 0.809 跟台灣大哥大有合作標記 * 建立標記資料 * 5M annotations * [trained model, lianghsun/fineweb-edu-zhtw-classifier](lianghsun/fineweb-edu-zhtw-classifier) 根據 ChinChill's law,270m 模型約需要 ~4B tokens 做訓練 講者有做 1:1 中英資料比 training tips * 10E-4 for learning rate (太小不好,LR 神奇的很重要) ![671684](https://hackmd.io/_uploads/HkX8SItWbg.jpg) ![S__62160900](https://hackmd.io/_uploads/ryedS8tZWe.jpg) ### Mid-training > Not covered today QQ > - 讓模型把最終重要結果烙印在記憶裡 ### Post-training ![S__62160901](https://hackmd.io/_uploads/rky3SUYWbx.jpg) ### 幻覺問題 > 參數量決定腦容量 [name=講者] 儘管幻覺問題存在(繁中能力已提升),但依然可以當作下游任務的起點。 再去微調下游任務。 ### Applicatio #### PPT Keyboard Warrior (PTT 鍵盤峽) #### Poetry Generator (唐伯虎模型) ## 下游任務的資料集大小 模型訓練大約 幾K samples 大概會有效果出現