Skip to content

Trainer

Base classes and utilities for trainers.

This module provides the foundational components for model training and fine-tuning. It contains abstract base classes, common exceptions, and utility functions that are shared across different trainer implementations.

Authors
  • Alfan Dinda Rahmawan (alfan.d.rahmawan@gdplabs.id)
Reviewer
  • Muhammad Afif Al Hawari (muhammad.a.a.hawari@gdplabs.id)
References

NONE

BaseTrainer

Bases: ABC

Base class for model trainers.

This class defines the common interface that all trainers must implement. Each concrete trainer should provide implementation for training models and handling the training lifecycle from initialization to model saving.

The interface is designed to be consistent across different trainer types, making it easy to switch between implementations, add new ones, and maintain the factory pattern architecture.

save_model(model_path=None, results=None, **kwargs) abstractmethod

Saves model artifacts, handling both trained and existing models.

This method provides a unified interface for: 1. Saving a newly trained model (when results is provided) 2. Uploading an existing model (when model_path is provided)

Parameters:

Name Type Description Default
model_path str

Path to existing model artifacts.

None
results dict

Training results for newly trained models.

None
**kwargs Any

Configuration parameters for model saving.

{}

train(**kwargs) abstractmethod

Train the model using the prepared data and configuration.

Parameters:

Name Type Description Default
**kwargs Any

Arbitrary keyword arguments for evaluation parameters.

{}