五個步驟,從 git clone 到你自己的 LoRA adapter。8GB 顯卡跑得動;沒有顯卡,免費的 Colab T4 也可以。
所有訓練程式都在公開的 starter repo 裡:github.com/wil-li-la/newsio-plus-starter
git clone https://github.com/wil-li-la/newsio-plus-starter.git cd newsio-plus-starter
需要 Python 3.10 以上。建一個虛擬環境,裝好依賴套件(torch、transformers、peft、bitsandbytes)。
python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt
到「資料」頁用 Google 登入,train.jsonl(14,746 筆 EN → zh-TW 配對)會由 [email protected] 寄到你的信箱。下載後放到:
mv ~/Downloads/train.jsonl data/train.jsonl
預設 rank r=16:可訓練參數 9,175,040 個,約佔整個模型的 0.29%。免費 Colab T4 上一個 epoch 約 40 分鐘。
python train_lora.py --rank 16
訓練完的 adapter 存在 out/adapter/(只有幾十 MB)。丟一個英文標題給它試試:
python test_translate.py --title "Nvidia unveils new AI chip for laptops"
整套流程做成了 notebook:開啟後上傳 train.jsonl,從頭到尾在瀏覽器裡完成訓練,最後把 adapter 打包下載。