JapanRailwayLLM開発記録 Google Colabからkaggleへ移行し、10,000step学習を突破/JapanRailwayLLM Development Log Migrating from Google Colab to Kaggle and Surpassing 10,000 Training Steps
JapanRailwayLLM開発記録 Google Colabからkaggleへ移行し、10,000step学習を突破
日本の鉄道知識に特化したLLM「JapanRailwayLLM」の継続学習環境を構築し、最終的に10,000stepを超える長期学習に成功した。
今回は学習性能だけでなく、以下の運用環境整備が大きな成果となった。
- Google ColabからKaggleへの移行
- 自動チェックポイント運用
- Hugging Face連携
- 長期学習の安定化
プロジェクト概要
ベースモデルは Gemma 2 9B Instruct を採用し、LoRAによる追加学習を実施した。
目的は、日本の鉄道技術・保安装置・運転保安・電化方式・信号システム・車両システムなどの知識を重点的に習得した日本語鉄道特化モデルの構築である。
データセット
学習データは複数のJSONLファイルから構成される。
- データセット数: 7ファイル
- 総サンプル数: 41,879サンプル
学習環境
初期環境:Google Colab
長時間学習では以下の問題が発生した。
- GPU利用制限
- セッション切断
- ランタイム消失
改善後:Kaggleへ移行
学習途中で checkpoint-4000 を保存し、Kaggleへ移行。その後は以下のように継続学習を行った。
- checkpoint-4000
- checkpoint-5000
- checkpoint-6000
- checkpoint-7000
- checkpoint-8000
- checkpoint-9000
- checkpoint-10000
チェックポイント運用
500stepごとに自動保存する仕組みを導入。
生成例:
- checkpoint-4500
- checkpoint-5000
- checkpoint-5500
- checkpoint-6000
- checkpoint-6500
- checkpoint-7000
- checkpoint-7500
- checkpoint-8000
- checkpoint-8500
- checkpoint-9000
- checkpoint-9500
- checkpoint-10000
学習中に環境が停止しても、直近のチェックポイントから再開できる。
Hugging Face自動バックアップ
学習成果を保護するため、Hugging Faceへの自動アップロード機能を実装。
学習中は adapter_model.safetensors が自動更新されるため、Kaggle停止やColab切断が発生しても学習成果を失わない構成となった。
LoRA構成
保存される主なファイル:
- adapter_model.safetensors
- adapter_config.json
- tokenizer.json
- tokenizer.model
- tokenizer_config.json
- training_args.bin
このうち継続的に更新されるのは adapter_model.safetensors であり、サイズは約 216MB となった。
Loss推移
- 学習初期: 1.0〜1.2
- 1000step付近: 0.8〜1.0
- 5000step付近: 0.4〜0.8
- 8000step付近: 0.3〜0.6
- 10000step付近: 0.2〜0.6
- 最低Loss: 0.209503
学習状況の分析
Lossはステップが進むにつれて着実に低下している。一方で上下動も継続しているが、これは学習データの難易度差によるものであり、学習崩壊や発散の兆候は見られなかった。
今後の評価
最終的な評価は鉄道専門問題によって行う予定である。
- ATSとは?
- ATS-Sとは?
- ATS-Pとは?
- ATCとは?
- CTCとは?
- ATOSとは?
- 交流電化と直流電化の違いは?
- 東海道新幹線とは?
現状まとめ
- 学習状況: 10,000step突破
- データセット: 7ファイル / 41,879サンプル
- バックアップ: Google Drive / Hugging Face
- 自動Checkpoint: あり
- 学習状態: 安定
評価
- 学習環境:★★★★★
- バックアップ体制:★★★★★
- LoRA運用:★★★★★
- 学習安定性:★★★★☆
- 実回答性能:評価中
今回の最大の成果は、単純なモデル学習ではなく、長時間学習しても成果が失われない継続運用環境を構築できたことである。
Google Colab、Kaggle、Google Drive、Hugging Faceを組み合わせることで、日本鉄道特化LLMの長期育成基盤を構築することができた。
10000ステップまで学習したやつだけどしっくりこない感じがするな。 1000ステップは嘘を誤魔化して事実化のように語りだす感じではあった。
— がーらけにあ・森山健一【GalaKenya】Japanese (@galakenya.bsky.social) 2026年10月21日 21:03
[image or embed]
JapanRailwayLLM Development Log Migrating from Google Colab to Kaggle and Surpassing 10,000 Training Steps
The JapanRailwayLLM project, a Japanese railway–specialized language model, successfully established a long-term training environment and achieved over 10,000 training steps.
In this phase, the major accomplishments were not only model performance but also improvements in operational stability, including:
- Migrating from Google Colab to Kaggle
- Automated checkpoint management
- Integration with Hugging Face
- Stabilizing long-duration training
Project Overview
The base model is Gemma 2 9B Instruct, trained further using LoRA.
The goal is to build a Japanese-language model specialized in railway knowledge, including:
- Railway engineering
- Train protection systems
- Operational safety
- Electrification systems
- Signaling systems
- Rolling stock systems
Dataset
The training dataset consists of multiple JSONL files.
- Number of files: 7
- Total samples: 41,879
Training Environment
Initial Environment: Google Colab
Long-duration training faced several issues:
- GPU usage limits
- Session interruptions
- Runtime resets
Improved Environment: Kaggle
After saving checkpoint-4000, training was migrated to Kaggle. Subsequent checkpoints were generated as follows:
- checkpoint-4000
- checkpoint-5000
- checkpoint-6000
- checkpoint-7000
- checkpoint-8000
- checkpoint-9000
- checkpoint-10000
Checkpoint Management
A system was implemented to automatically save checkpoints every 500 steps.
Generated examples:
- checkpoint-4500
- checkpoint-5000
- checkpoint-5500
- checkpoint-6000
- checkpoint-6500
- checkpoint-7000
- checkpoint-7500
- checkpoint-8000
- checkpoint-8500
- checkpoint-9000
- checkpoint-9500
- checkpoint-10000
Even if the environment stops, training can resume from the latest checkpoint.
Hugging Face Automatic Backup
To protect training progress, an automatic upload system to Hugging Face was implemented.
The file adapter_model.safetensors is updated continuously during training, ensuring that progress is preserved even if Kaggle or Colab sessions terminate unexpectedly.
LoRA Configuration
Main saved files:
- adapter_model.safetensors
- adapter_config.json
- tokenizer.json
- tokenizer.model
- tokenizer_config.json
- training_args.bin
The file updated throughout training is adapter_model.safetensors, with a final size of approximately 216MB.
Loss Progression
- Initial training: 1.0–1.2
- Around 1000 steps: 0.8–1.0
- Around 5000 steps: 0.4–0.8
- Around 8000 steps: 0.3–0.6
- Around 10000 steps: 0.2–0.6
- Lowest recorded loss: 0.209503
Training Analysis
The loss consistently decreased as training progressed. Although fluctuations remained, these were due to varying dataset difficulty rather than instability.
No signs of collapse or divergence were observed.
Future Evaluation
Performance will ultimately be evaluated using railway-specific questions, such as:
- What is ATS?
- What is ATS-S?
- What is ATS-P?
- What is ATC?
- What is CTC?
- What is ATOS?
- Difference between AC and DC electrification?
- What is the Tokaido Shinkansen?
Current Summary
- Training progress: Surpassed 10,000 steps
- Dataset: 7 files / 41,879 samples
- Backup: Google Drive / Hugging Face
- Automatic checkpoints: Enabled
- Training stability: Stable
Evaluation
- Training environment: ★★★★★
- Backup system: ★★★★★
- LoRA operation: ★★★★★
- Training stability: ★★★★☆
- Answer quality: Under evaluation
The greatest achievement of this phase is not simply model training, but the establishment of a robust long-term training environment that preserves progress even during interruptions.
By combining Google Colab, Kaggle, Google Drive, and Hugging Face, a reliable long-term development foundation for the JapanRailwayLLM has been successfully built.
コメント
コメントを投稿