You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement automatic checkpointing for knowledge distillation
Integrate automatic checkpointing directly into KnowledgeDistillationTrainerBase,
eliminating the need for manual checkpoint management code.
Changes:
- Add CheckpointConfig property (null = disabled, set = enabled)
- Add Student property for model to checkpoint
- Add CheckpointManager (auto-created when CheckpointConfig is set)
- Add tracking fields for validation metrics and training loss
- Update OnTrainingStart() to initialize CheckpointManager
- Update OnEpochEnd() to auto-save checkpoints with metrics
- Update OnValidationComplete() to track validation metrics
- Update OnTrainingEnd() to auto-load best checkpoint
- Update CHECKPOINTING_GUIDE.md with automatic usage example
Benefits:
- Zero manual checkpoint code required from users
- Configuration-driven (just set CheckpointConfig property)
- Automatic best model selection via validation metrics
- Automatic checkpoint pruning (keeps only best N)
- Curriculum state preservation (if using curriculum strategies)
- Clean, simple API for 99% of use cases
- Manual control still available for advanced scenarios
Usage:
trainer.CheckpointConfig = new DistillationCheckpointConfig {
SaveEveryEpochs = 5,
KeepBestN = 3
};
trainer.Student = student as ICheckpointableModel;
trainer.Train(...); // Checkpointing happens automatically!
The easiest way to enable checkpointing is through automatic checkpointing built into the trainer. Simply configure the checkpoint settings and the trainer handles everything automatically.
66
+
67
+
### Automatic Checkpointing Example
68
+
69
+
```csharp
70
+
usingAiDotNet.KnowledgeDistillation;
71
+
72
+
// Create trainer
73
+
varteacher=LoadPretrainedTeacher();
74
+
varstudent=CreateStudentModel(); // Must implement ICheckpointableModel
0 commit comments