Practice Exercises
Complete hands-on exercises to implement training workflows, experiment tracking, and model testing for your ML project.Prerequisites
Before starting:- Have a training pipeline (from test task or your own project)
- Set up a GitHub repository
- Create a W&B account
- Review the classic and generative examples
You can use the HuggingFace text classification example as a starting point.
Homework 5: Training & Experiments
Learning Objectives
Experiment Tracking
Set up W&B logging and track training experiments
Hyperparameter Search
Run systematic hyperparameter optimization
Model Documentation
Create comprehensive model cards
Distributed Training
Scale training to multiple GPUs
Reading List
Core Reading
Core Reading
Advanced Topics
Advanced Topics
Tasks
Update Design Document
Add experiment management section to your Google Doc:
- Chosen experiment tracking tool (W&B, Neptune, MLflow)
- Model card template and structure
- Hyperparameter search strategy
- Model versioning approach
PR1: W&B Experiment Logging
Implement experiment tracking with Weights & Biases:Requirements:
- Log training/validation metrics
- Track hyperparameters
- Save model checkpoints
- Create W&B project link
PR2: Hyperparameter Search
Implement hyperparameter search with W&B sweeps:Requirements:
sweep.yaml
- Define search space
- Run at least 10 experiments
- Document best hyperparameters
- Compare results in W&B
PR3: Model Card
Create comprehensive model card:Or use the Model Card Toolkit.Requirements:
- Model details (architecture, training data)
- Intended use cases
- Performance metrics
- Limitations and biases
- Training procedure
- Evaluation results
PR4 (Optional): MosaicBERT Tutorial
Replicate the MosaicBERT tutorial to train BERT from scratch efficiently.Focus areas:
- Efficient training techniques
- Cost optimization
- Performance benchmarking
PR5 (Optional): NNI Hyperparameter Search
Implement hyperparameter search using Microsoft NNI:Compare with W&B sweeps:
- Search efficiency
- Ease of use
- Visualization capabilities
Deliverables
- Required
- Optional
- Google Doc updated with experiment section
- PR1: W&B experiment logging
- PR2: Hyperparameter search
- PR3: Model card
- Public W&B project link
- All PRs merged to main branch
Success Criteria
- ✅ All required PRs merged
- ✅ W&B project shows multiple experiments
- ✅ Model card includes all required sections
- ✅ Hyperparameter search identifies best config
- ✅ Design document describes experiment strategy
Homework 6: Testing & CI
Learning Objectives
Code Testing
Write unit tests for training code
Data Validation
Test data quality and schema
Model Testing
Validate model behavior and performance
CI/CD Integration
Automate testing in GitHub Actions
Reading List
Testing Fundamentals
Testing Fundamentals
ML-Specific Testing
ML-Specific Testing
Tasks
Update Testing Plan
Add testing strategy to your Google Doc:
- Test coverage goals
- Data validation approach
- Model behavioral tests
- CI/CD pipeline design
PR1: Code Tests
Write unit tests for training code:Test coverage:
test_code.py
- Utility functions
- Data preprocessing
- Metric computation
- Configuration loading
PR2: Data Tests
PR3: Model Tests
PR5 (Optional): Model Interpretability
Use LIT (Learning Interpretability Tool) or similar:For other domains (CV, audio, tabular), find equivalent tools.
CI/CD Pipeline
Set up GitHub Actions workflow:.github/workflows/test.yml
Deliverables
- Required
- Optional
- Google Doc updated with testing plan
- PR1: Code tests with CI integration
- PR2: Data validation tests
- PR3: Model behavioral tests
- PR4: Model registry integration
- All tests pass in CI
Success Criteria
- ✅ All required PRs merged
- ✅ Tests run automatically in CI
- ✅ Code coverage > 80%
- ✅ Data validation catches quality issues
- ✅ Model tests verify expected behavior
- ✅ Models versioned in registry
Resources
Classic Example
Reference implementation for BERT training
Generative Example
Reference implementation for Phi-3 training
Made With ML
Comprehensive testing guide
W&B Documentation
Complete Weights & Biases guide
Getting Help
If you get stuck:- Review the reference implementations in
module-3/ - Check the reading list for relevant articles
- Search W&B documentation
- Ask questions in course discussion forum
- Compare with HuggingFace examples
Remember: The goal is to build production-ready training workflows, not just achieve high accuracy. Focus on reproducibility, testing, and documentation.