基於 Tmux 的無頭 LoRA 微調託管與多路指標遙測
Agent 輔助工程檢查
前置要求
第 67 天微調行前檢查通過,Linux 進程後台脫機管理基礎。
學習目標
在獨立的持久化 tmux 會話中啟動無頭適配器微調,將訓練進度多路重定向至結構化遙測流,恪守等待掛機不計入研習時長的原則。
操作指引
1. 在儲存庫根目錄用 tmux new-session -d -s lora_train 啟動 projects/lora/train.py(CPU smoke 模式;真實模型執行時將 --smoke 換成 --model
2. 指標多路複用:用 tee 將標準輸出寫入 lora_training.log;train.py 本身會在每個最佳化步驟向
3. 監測物理顯存:利用 nvidia-smi 觀察顯存開銷,見證其保持平穩無碎片波動的低顯存特性。
4. 堅守學習時長認知:將 GPU 跑計算的機械時間同主動分析指標的有效研習分鐘嚴加區分。
自主實作與記錄
啟動後台脫機訓練。通過 ps 和 tail -f 確認訓練在終端登出後平穩推進,並即時錄入步級損失數據。
核驗 telemetry.jsonl 包含 step, train_loss, lr 等字段。
# 啟動指令(在儲存庫根目錄執行):
tmux new-session -d -s lora_train '.venv/bin/python projects/lora/train.py --smoke --data-path data/instruction_sample.jsonl --work-dir runs/lora-detached --max-iters 2000 2>&1 | tee -a lora_training.log'
# 追蹤逐步日誌:
tail -f runs/lora-detached/telemetry.jsonl
# 每行範例:{"step": 1, "train_loss": 4.08, "lr": 0.0002, "elapsed_seconds": 0.01, "mode": "smoke"}
成功部署可抵禦終端異常斷開的持久化 LoRA 微調管道與即時遙測系統。
權威來源資源與權利證明
Stanford Alpaca: An Instruction-following LLaMA Model
對應章節 / 時間戳: Training recipe
驗證版本與日期: Stanford CRFM Release (Verified: 2026-10-30)
Original open recipe demonstrating lightweight instruction fine-tuning of open models, establishing prompt/response templates, batch scheduling, and learning rate ranges.
Supervised fine-tuning, instruction formatting, and LoRA fundamentals.
Complete instruction templates, JSONL formatting scripts, and learning rate schedules are self-contained in curriculum materials.
對比候選資源與選型分析 (2)
Multi-turn ShareGPT tuning recipe; Alpaca provides simpler, single-turn clarity ideal for foundational instruction tuning study.
Commercially permissive crowdsourced dataset; Alpaca established the academic instruction tuning standard.
LoRA: Low-Rank Adaptation of Large Language Models
對應章節 / 時間戳: N/A
驗證版本與日期: ICLR 2022 / arXiv:2106.09685v2 (Verified: 2026-10-30)
Primary literature introducing Low-Rank Adaptation, establishing parameter decomposition W = W0 + (alpha/r)*BA, initialization strategies, and zero inference latency merging.
Matrix factorization, rank, linear layers, and transformer attention.
Complete matrix derivations, tensor dimensions, and pure PyTorch LoRALinear modules are implemented directly in lesson code.
對比候選資源與選型分析 (2)
Introduces bottleneck adapter layers in series, which introduces unavoidable inference latency overhead; LoRA's parallel formulation merges with zero latency.
Prepends virtual prompt tokens; reduces available context length, unlike LoRA which preserves full sequence capacity.