Design Philosophy
Samay’s architecture follows a simple, composable pattern:- Load a model - Initialize a pre-trained foundation model from HuggingFace or with custom configuration
- Load a dataset - Prepare your time series data using model-specific dataset classes
- Finetune - Optionally adapt the model to your specific data
- Forecast & Evaluate - Generate predictions and measure performance
Core Abstractions
BaseModel
All models inherit from theBasemodel class (defined in src/samay/model.py:58), which provides a standard interface:
BaseDataset
All datasets inherit fromBaseDataset (defined in src/samay/dataset.py:54), which handles:
- Data loading - From CSV files or HuggingFace datasets
- Preprocessing - Model-specific transformations
- Batching - PyTorch DataLoader integration
- Train/test splits - Configurable boundaries
Metrics
Samay provides comprehensive evaluation metrics (defined insrc/samay/metric.py):
Forecasting Metrics:
- MSE, MAE, RMSE - Standard error metrics
- MAPE, SMAPE - Percentage-based errors
- MASE - Scaled error metric
- NRMSE - Normalized RMSE
- ND - Normalized deviation
- MSIS - Mean scaled interval score
- MWSQ - Mean weighted squared quantile loss
- CRPS - Continuous ranked probability score
Common Workflow
Here’s a typical workflow showing how the abstractions work together:HuggingFace Integration
Samay seamlessly integrates with HuggingFace Hub:- Load pretrained models using
repoparameter - Automatic downloads - Models cached locally
- Device management - Automatic GPU detection and allocation
Device Management
Samay automatically manages GPU allocation:- Detects available GPUs
- Selects the least utilized GPU
- Falls back to CPU if no GPU available
- Moves models and data to the selected device
Next Steps
Models
Learn about the model interface and configuration
Datasets
Understand dataset structure and preprocessing
Evaluation
Explore available metrics and evaluation patterns