Skip to main content

Class Signature

class Basemodel:
    def __init__(self, config=None, repo=None)
The Basemodel class serves as the abstract base class for all time series foundation models in Samay. All model implementations inherit from this class and must implement its abstract methods.

Initialization Parameters

config
dict
default:"None"
Model configuration dictionary containing model-specific parameters.
repo
str
default:"None"
Hugging Face model repository ID for loading pre-trained models.

Attributes

config
dict
Stores the model configuration passed during initialization.
device
torch.device
The device (CPU or GPU) on which the model will run. Automatically selects the least used GPU if available, otherwise defaults to CPU.

Methods

finetune()

def finetune(dataset: BaseDataset, **kwargs)
Finetune the model on the given dataset. This is an abstract method that concrete model classes must implement.
dataset
BaseDataset
required
Dataset used for finetuning.
**kwargs
dict
Optional keyword arguments for finetuning:
  • lr (float): Learning rate
  • epoch (int): Number of training epochs
  • Additional model-specific parameters
return
Any
Model or training result produced by the finetune operation. The exact return type is defined by concrete model implementations.
Raises:
  • NotImplementedError: If a subclass does not implement this method.

forecast()

def forecast(input, **kwargs)
Generate forecast(s) from input data.
input
Any
required
Input data for forecasting (e.g., torch.Tensor, numpy array, or model-specific input structure).
**kwargs
dict
Optional keyword arguments for forecasting (model-specific).
return
Any
Forecast outputs. The concrete model defines the exact format (for example, mean forecasts, quantiles, or full distribution).
Raises:
  • NotImplementedError: If a subclass does not implement this method.

evaluate()

def evaluate(dataset: BaseDataset, **kwargs)
Evaluate the model on a dataset.
dataset
BaseDataset
required
Dataset used for evaluation.
**kwargs
dict
Optional evaluation arguments:
  • metric_only (bool): If True, return only metrics dictionary
  • Additional model-specific parameters
return
Any
Evaluation metrics or (metrics, details) tuple as defined by the concrete model implementation.
Raises:
  • NotImplementedError: If a subclass does not implement this method.

save()

def save(path)
Save the model to disk.
path
str
required
Filesystem path where model artifacts should be saved.
return
None
This method does not return a value.
Raises:
  • NotImplementedError: If a subclass does not implement this method.

Usage Example

from samay.model import Basemodel

# Basemodel is abstract and cannot be instantiated directly
# Use specific model implementations like ChronosModel, MomentModel, etc.

Notes

  • The Basemodel class automatically detects and uses the least utilized GPU when available
  • All concrete model implementations must override the abstract methods: finetune(), forecast(), evaluate(), and save()
  • Device selection happens automatically during initialization based on GPU availability

Build docs developers (and LLMs) love