Base Model Interface
All models in Samay inherit from theBasemodel class, which defines a unified interface with four core methods.
Core Methods
finetune()
Adapts a pretrained model to your specific dataset:lr(float) - Learning rate (default varies by model, typically 1e-4)epoch(int) - Number of training epochs (default 5)freeze_transformer(bool) - Freeze transformer layers (TimesFM only)
forecast()
Generates predictions from input time series data:-
TimesFM: Returns
(mean_forecast, quantile_forecast)tuple -
Chronos: Use pipeline’s
predict_quantiles()method
evaluate()
Computes metrics on a test dataset:metric_only(bool) - If True, return only metrics dict. If False, also return predictions and ground truthhorizon_len(int) - Forecast horizon (Chronos, ChronosBolt)quantile_levels(list) - Quantile levels for probabilistic forecasting
save()
Persists model weights to disk:Model Configuration Patterns
Loading from HuggingFace
The recommended approach for production use:repo parameter triggers:
- Download from HuggingFace Hub (cached locally)
- Automatic device mapping to available GPU
- Loading pretrained weights
Custom Configuration
For research or custom model variants:HuggingFace Integration
Pipeline Architecture
Many models use HuggingFace’s pipeline pattern:- Tokenization (for transformer-based models)
- Model forward pass
- Output decoding/detokenization
- Quantile prediction
Device Mapping
Models automatically map to the best available device:- Detects all available CUDA GPUs
- Selects GPU with lowest memory usage
- Falls back to CPU if no GPUs available
- Automatically moves model and tensors to device
Fine-tuning Patterns
Full Fine-tuning
Update all model parameters:Frozen Transformer Fine-tuning
Only update the output head (TimesFM):Training Loop Example
The typical fine-tuning implementation (from ChronosModel):Model-Specific Features
Chronos - Transformer-based probabilistic forecasting
Chronos - Transformer-based probabilistic forecasting
Key Features:
- Tokenization-based approach
- Quantile forecasting
- Seq2seq or causal architectures
- Context length up to 512
TimesFM - Patched decoder architecture
TimesFM - Patched decoder architecture
Key Features:
- Patch-based processing
- Multi-horizon forecasting
- Quantile output (mean + 9 quantiles)
- Returns tuple:
(mean, full_quantiles)
Chronos2 - Next-gen architecture with autoregressive support
Chronos2 - Next-gen architecture with autoregressive support
Key Features:
- Output patch-based prediction
- Autoregressive forecasting for long horizons
- Median-based autoregression
Next Steps
Datasets
Learn how to prepare data for different models
Evaluation
Understand metrics and evaluation patterns