68 / 90

第68日: 無人アダプタ学習、損失ダイナミクスと過学習看門狗

バックグラウンドLoRA学習の実行、検証損失テレメトリの解析、指示暗記とタスク汎化の境界識別。

モデルと事前学習 480 分(8時間)
01 120 分

バックグラウンドLoRA学習の起動とメトリクス多重中継

Agent支援エンジニアリングチェック

前提条件

第67日事前点検およびLinuxプロセスデタッチ技術。

学習目標

tmuxセッションでアダプタ微調をバックグラウンド実行し、構造化テレメトリへ損失・学習率を中継しつつ受動的待ち時間を学習時間に含めない規律を保つ。

手順

1. リポジトリのルートで tmux new-session -d -s lora_train を使い、projects/lora/train.py を起動します(CPUのsmokeモード。実モデルでは --smoke を --model --device cuda に置き換えます)。
2. 標準出力を tee で lora_training.log に書き出します。train.py 自身が最適化ステップごとに1行のJSON(step、train_loss、lr、elapsed_seconds、mode)を /telemetry.jsonl に追記します。
3. nvidia-smi でVRAM使用量を監視し、LoRA特有の極小かつフラットなメモリ推移を確認します。
4. GPUの計算待機時間を除外した有効研習時間の管理原則を遵守します。

演習と予測記録

バックグラウンドセッションで学習を開始し、テレメトリログがリアルタイムに更新されていることを確認してください。

独立習得基準

端末切断に耐える常駐型LoRA微調セッションを正常に起動・監視できる。

公式ソースリソースと権利証跡

linking Copyright Stanford CRFM (blog post; no open license stated)

Stanford Alpaca: An Instruction-following LLaMA Model

著者・提供機関: Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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.

Databricks Dolly 15k Dataset & Training Recipe ↗ compared_alternative [CC-BY-SA 3.0]

Commercially permissive crowdsourced dataset; Alpaca established the academic instruction tuning standard.

linking arXiv non-exclusive license / Open Access

LoRA: Low-Rank Adaptation of Large Language Models

著者・提供機関: Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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.

02 120 分

損失テレメトリの動特性: 指示文の暗記とタスク汎化の境界

独立習得チェック(AI 支援なし)

前提条件

第68日アクティビティ1およびクロスエントロピー損失解析。

学習目標

検証損失と訓練損失の推移曲線を比較分析し、アダプタがタスク構造の獲得から指示文の機械的丸暗記(過学習)へと転じる屈曲点を特定する。

手順

参照資料: この活動に割り当てられた既存の読解・練習時間内で、Hugging Face LLM Course: Fine-tuning LLMs の Chapter 11.3: Monitoring Training Progress; Warning Signs to Watch For を参照し、ローカル課題とのつながりを一つ自分の言葉で説明する。既存の演習と合格基準は維持し、外部資料が開けない場合は本コース独自の説明を使う。1. ステップごとの訓練損失と検証損失の推移をプロットまたは一覧化します。
2. 第1段階(急速な減少期): 出力書式に適応し、両方の損失が急激に低下します。
3. 第2段階(最適収束点): 検証損失が極小値に到達します。
4. 第3段階(過学習の兆候): 訓練損失のみがゼロ近辺まで下がり続け、検証損失が反転上昇を始めます。これは丸暗記が発生している危険信号です。

演習と予測記録

検証損失の系列 [2.8, 2.3, 1.9, 1.6, 1.45, 1.44, 1.48, 1.55, 1.63] が与えられている。評価はステップ 100 から 100 ステップごとに行われた(インデックス i はステップ 100 * (i + 1))。過学習が始まったステップを特定し、最適な早期停止チェックポイントを決定せよ。

独立習得基準

検証損失の挙動から過学習の発生を正確に検知し、最適保存点を判断できる。

公式ソースリソースと権利証跡

linking Apache-2.0

Hugging Face LLM Course: Fine-tuning LLMs

著者・提供機関: Hugging Face course contributors | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Chapter 11.3: Monitoring Training Progress; Warning Signs to Watch For

検証バージョンと日付: Public edition checked 2026-11-01; moving pages may change

選定理由:

Sequenced templates, supervised fine-tuning and evaluation teaching with exercises/quizzes. LoRA method and memory claims are checked against the original paper, PEFT and the local parameter ledger, not accepted wholesale from Chapter 11.4.

ソース前提知識:

Python, PyTorch, language-model training and the preceding chat-format lessons.

安全フォールバック(オフライン回復性):

Use the original localized explanations, exercises and checks already present in this activity; no external account or purchase is required for that fallback.

比較対象候補リソースと選定評価 (2)
LoRA original paper ↗ compared_alternative [arXiv.org perpetual non-exclusive license / Open Access]

Retained for initialization and the low-rank method, not a beginner teaching sequence.

Hugging Face PEFT ↗ compared_alternative [Apache-2.0]

Retained for actual API and implementation defaults; reference documentation is not a complete teaching course.

linking Open Access

Training language models to follow instructions with human feedback

著者・提供機関: Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, et al. | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Appendix C.1 Details of SFT training

検証バージョンと日付: arXiv:2203.02155v1 (Verified: 2026-10-30)

選定理由:

Foundational InstructGPT paper defining the SFT objective: maximizing log-likelihood of demonstrator completions conditioned on prompts.

ソース前提知識:

Supervised fine-tuning, conditional autoregressive generation.

安全フォールバック(オフライン回復性):

The conditional likelihood objective and prompt-conditioning derivations are completely formulated in the review.

比較対象候補リソースと選定評価 (2)

Earlier RLHF formulation on summarization; InstructGPT standardizes the prompt-response SFT training phase.

Focuses on massive multi-task scaling; InstructGPT details the exact prompt-conditioned loss setup.

linking Copyright Stanford CRFM (blog post; no open license stated)

Stanford Alpaca: An Instruction-following LLaMA Model

著者・提供機関: Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto | オリジナル出所URL ↗

該当セクション・タイムスタンプ: N/A

検証バージョンと日付: 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.

Databricks Dolly 15k Dataset & Training Recipe ↗ compared_alternative [CC-BY-SA 3.0]

Commercially permissive crowdsourced dataset; Alpaca established the academic instruction tuning standard.

03 120 分

アダプタ限定の定期チェックポイント保存と障害隔離

Agent支援エンジニアリングチェック

前提条件

第68日アクティビティ1〜2および第66日アダプタシリアライズ。

学習目標

定期スナップショットでアダプタ重みのみを保存し(基座重みを含めない)、ファイルサイズが50MB未満であることとアトミック性を検証する。

手順

1. 200ステップ等の一定間隔で定期保存を実行します。
2. 保存前に状態辞書をフィルタリングし、'lora_' を含むキーのみを書き出します。
3. ファイルサイズが10〜40MBの範囲内に収まり、十数GBに肥大化していないことを確認します。
4. 書き込み中断による破損を防ぐため、一時ファイルとリネームを用いたアトミック保存を徹底します。

演習と予測記録

チェックポイントディレクトリ内の各スナップショット容量が50MB未満であること、および新規モデルに正常にロードできることを検証してください。

独立習得基準

軽量かつ堅牢なアダプタ限定ローリングスナップショット管理を運用できる。

公式ソースリソースと権利証跡

linking arXiv non-exclusive license / Open Access

LoRA: Low-Rank Adaptation of Large Language Models

著者・提供機関: Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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.

linking Apache-2.0

PEFT: State-of-the-art Parameter-Efficient Fine-Tuning Methods

著者・提供機関: Sourab Mangrulkar, Sylvain Gugger, Lysandre Debut, Younes Belkada, Sayak Paul, Benjamin Bossan | オリジナル出所URL ↗

該当セクション・タイムスタンプ: N/A

検証バージョンと日付: PEFT 0.10.x / GitHub (Verified: 2026-10-30)

選定理由:

Widely adopted open-source library implementing LoRA configuration classes (LoraConfig), get_peft_model, and adapter serialization.

ソース前提知識:

PyTorch nn.Module, Hugging Face transformers, and LoRA equations.

安全フォールバック(オフライン回復性):

Standalone, zero-dependency PyTorch implementations of LoRALinear layers and save/reload logic are provided in curriculum scripts.

比較対象候補リソースと選定評価 (2)

Original reference code by Hu et al.; PEFT expands this to broader multi-model ecosystem integration.

Lit-GPT LoRA implementation (Lightning AI) ↗ compared_alternative [Apache 2.0]

High-performance clean implementation; compared alongside PEFT for modular code architecture.

04 120 分

評価課題: リアルタイム微調監視ツールと早期終了(Early Stopping)の実装

独立習得チェック(AI 支援なし)

前提条件

第68日アクティビティ1〜3の全知識。

学習目標

テレメトリをリアルタイム解析し、検証損失の改善停滞や過学習を検知して最適収束時点で訓練を安全終了させる FinetuneWatchdog を完成させる。

手順

1. FinetuneWatchdog(patience=3, delta_threshold=0.005) を実装します。
2. テレメトリから検証評価イベントを読み取ります。
3. best_val_loss と counter を追跡します: current_val_loss > best_val_loss - delta_threshold のとき counter を加算します。
4. counter >= patience になったら、EARLY_STOP_SIGNAL を発行して実行側に通知し、最適なチェックポイントのステップを記録します。
5. また、損失の NaN に対するガードを設けます: 損失が NaN であれば、直ちに CRITICAL_ABORT を発行します。

演習と予測記録

検証損失が上昇に転じる疑似ログを用いて FinetuneWatchdog を実行し、規定回数で正確に停止シグナルを発出することを確認してください。

独立習得基準

過学習の兆候を検知して自動的に最適モデルで訓練を完結させる早期停止機構を構築できる。

公式ソースリソースと権利証跡

linking Copyright Stanford CRFM (blog post; no open license stated)

Stanford Alpaca: An Instruction-following LLaMA Model

著者・提供機関: Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto | オリジナル出所URL ↗

該当セクション・タイムスタンプ: N/A

検証バージョンと日付: 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.

Databricks Dolly 15k Dataset & Training Recipe ↗ compared_alternative [CC-BY-SA 3.0]

Commercially permissive crowdsourced dataset; Alpaca established the academic instruction tuning standard.

linking arXiv non-exclusive license / Open Access

LoRA: Low-Rank Adaptation of Large Language Models

著者・提供機関: Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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.