-
Notifications
You must be signed in to change notification settings - Fork 0
Training and Evaluation
The MLFramework Template centralizes the execution of all machine learning workflows through a unified Command Line Interface (CLI) located at src/cli.py. This CLI utilizes Typer for command routing and Hydra for dynamic configuration injection.
The entrypoint script src/cli.py exposes strictly typed commands. The primary commands available are train and test. Both commands require a configuration file specified via the -c or --config flag.
# General syntax
python -m src.cli [COMMAND] -c [CONFIG_FILE.yaml] [OVERRIDES...]To initiate a training run, invoke the train command. The pipeline will automatically instantiate the DataModule, Model Architecture, Lightning Task, and the designated Logger based on the provided configuration tree.
python -m src.cli train -c example_config.yamlHyperparameters and pipeline behavior can be modified at runtime without editing the YAML files.
# Example: Overriding batch size, learning rate, and epochs
python -m src.cli train -c example_config.yaml \
data.batch_size=256 \
model.learning_rate=0.001 \
trainer.max_epochs=50By default, the template is designed to integrate with MLflow via the PyTorch Lightning MLFlowLogger. During the execution of the train command:
- A new MLflow run is initialized.
- All Hydra configuration parameters are logged as MLflow parameters.
- Training metrics (loss, accuracy, etc.) are tracked continuously.
- The best-performing model checkpoint (as defined by the
ModelCheckpointcallback in the configuration) is saved automatically.
To evaluate a fully trained model on the designated test dataset, utilize the test command. This pipeline bypasses the optimization loop and strictly executes the test_step defined in the PyTorch Lightning Task.
python -m src.cli test -c example_config.yaml ckpt_path="path/to/checkpoint.ckpt"The CLI implements an intelligent checkpoint resolution strategy via the internal resolve_checkpoint_path utility. The ckpt_path argument accepts multiple formats:
-
Local File Path: Direct execution from a local
.ckptfile.
ckpt_path="/absolute/or/relative/path/to/model.ckpt"- MLflow Run URI: Direct resolution from a remote or local MLflow artifact store. The utility automatically interfaces with the MLflow tracking server to download and cache the requisite checkpoint.
ckpt_path="runs:/<mlflow_run_id>/checkpoints/best_model.ckpt"This feature guarantees that evaluation pipelines can be executed locally or in CI/CD environments directly from centrally tracked artifacts, eliminating the need to manually transfer large checkpoint files.
If you utilize this framework template in your research or engineering workflows, please consider citing it to support ongoing development:
@software{MLFramework_Template_2026,
author = {Danylo Chystiakov},
title = {MLFramework Template: A Reproducible MLOps Environment},
year = {2026},
url = {[https://github.com/allllpina/MLTemplate](https://github.com/allllpina/MLTemplate)}
}This template is built upon the philosophies and architectural patterns established by the following foundational projects:
- Hydra for hierarchical configuration.
- PyTorch Lightning for hardware-agnostic training abstractions.
- Data Version Control (DVC) for Git-integrated data management.
Contact & Support For inquiries regarding architectural decisions, bug reports, or feature requests, please open an issue on the GitHub repository.
Maintained by Danylo Chystiakov.