Upload NanoForecast checkpoint
Browse files- README.md +84 -0
- config.json +20 -0
- model.safetensors +3 -0
- model_card.json +31 -0
README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- time-series
|
| 5 |
+
- forecasting
|
| 6 |
+
- pytorch
|
| 7 |
+
- deployable
|
| 8 |
+
- edge-ai
|
| 9 |
+
- onnx
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# nanoforecast-200k
|
| 13 |
+
|
| 14 |
+
NanoForecast is the **world's most deployable** time series forecasting model (~676K parameters). It trains on a laptop, runs on a Raspberry Pi, and exports to 1.4 MB ONNX for edge/IoT/browser deployment.
|
| 15 |
+
|
| 16 |
+
[](https://huggingface.co/spaces/eulogik/nanoforecast)
|
| 17 |
+
|
| 18 |
+
## Model details
|
| 19 |
+
|
| 20 |
+
- **Profile**: `nano-200k`
|
| 21 |
+
- **Parameters**: 676,108
|
| 22 |
+
- **Context length**: 256
|
| 23 |
+
- **Prediction length**: 48
|
| 24 |
+
- **Patch size**: 8
|
| 25 |
+
- **Hidden dim / layers**: 32 / 4
|
| 26 |
+
- **Quantiles**: [0.1, 0.25, 0.5, 0.75, 0.9]
|
| 27 |
+
- **Architecture**: LongConv + DeltaNet RNN + Gated Router + MLP
|
| 28 |
+
|
| 29 |
+
## Deploy
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
# FastAPI server
|
| 33 |
+
pip install nanoforecast fastapi uvicorn python-multipart
|
| 34 |
+
python3 deploy/fastapi_server.py
|
| 35 |
+
|
| 36 |
+
# Docker
|
| 37 |
+
docker build -t nanoforecast -f deploy/Dockerfile .
|
| 38 |
+
docker run -p 8000:8000 nanoforecast
|
| 39 |
+
|
| 40 |
+
# ONNX export (1.4 MB)
|
| 41 |
+
pip install "nanoforecast[onnx]"
|
| 42 |
+
python3 -m nanoforecast.export.onnx_export --checkpoint checkpoints/nanoforecast-200k
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Training
|
| 46 |
+
|
| 47 |
+
- **Datasets**: ETTh1
|
| 48 |
+
- **Epochs**: 20
|
| 49 |
+
- **Learning rate**: 0.0001
|
| 50 |
+
- **Batch size**: 32
|
| 51 |
+
- **Best epoch**: 9 (val_loss=11.2837)
|
| 52 |
+
- **Wall time**: 48.2s
|
| 53 |
+
|
| 54 |
+
## Benchmarks
|
| 55 |
+
|
| 56 |
+
| Dataset | MASE | sMAPE (%) | MAE | CRPS |
|
| 57 |
+
|---|---:|---:|---:|---:|
|
| 58 |
+
| ETTh1 | 4.662 | 35.70 | 3.365 | 2.158 |
|
| 59 |
+
| ETTh2 | 7.073 | 41.78 | 6.384 | 3.822 |
|
| 60 |
+
| ETTm1 | 8.285 | 35.62 | 2.762 | 1.881 |
|
| 61 |
+
| exchange_rate | 10.870 | 2.36 | 0.015 | 0.010 |
|
| 62 |
+
| **overall** | **7.723** | **28.87** | **3.132** | **1.968** |
|
| 63 |
+
|
| 64 |
+
## Quickstart
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
import numpy as np
|
| 68 |
+
from nanoforecast import NanoForecast
|
| 69 |
+
|
| 70 |
+
model = NanoForecast.from_pretrained('eulogik/nanoforecast-200k')
|
| 71 |
+
context = np.sin(np.linspace(0, 8*np.pi, 256)) + 0.1 * np.random.randn(256)
|
| 72 |
+
out = model.predict(context, horizon=48, freq=1)
|
| 73 |
+
print(out['forecast'].shape) # (48,) point forecast
|
| 74 |
+
print(out['quantiles'].shape) # (5, 48) p10..p90
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Try it in a browser
|
| 78 |
+
|
| 79 |
+
Upload your CSV to the [Gradio Space](https://huggingface.co/spaces/
|
| 80 |
+
eulogik/nanoforecast) and get a forecast in seconds.
|
| 81 |
+
|
| 82 |
+
## Known limitations
|
| 83 |
+
|
| 84 |
+
This checkpoint was trained on a single dataset (ETTh1, ~1000 windows, 20 epochs). It is **not** a production foundation model. Accuracy is limited (MASE 4-11 on ETT). What it does well: being deployable. Train your own for better accuracy.
|
config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"context_length": 256,
|
| 3 |
+
"prediction_length": 48,
|
| 4 |
+
"d_model": 32,
|
| 5 |
+
"num_layers": 4,
|
| 6 |
+
"patch_size": 8,
|
| 7 |
+
"dropout": 0.1,
|
| 8 |
+
"expansion_factor": 2,
|
| 9 |
+
"quantiles": [
|
| 10 |
+
0.1,
|
| 11 |
+
0.25,
|
| 12 |
+
0.5,
|
| 13 |
+
0.75,
|
| 14 |
+
0.9
|
| 15 |
+
],
|
| 16 |
+
"num_frequencies": 10,
|
| 17 |
+
"num_channels": 16,
|
| 18 |
+
"covariate_dim": 4,
|
| 19 |
+
"use_gated_router": true
|
| 20 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2cffe794d426262026ecfa8a3c6e985f50820da1004c54fb3565e5629d2d3ca4
|
| 3 |
+
size 2712760
|
model_card.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "NanoForecast",
|
| 3 |
+
"profile": "nano-200k",
|
| 4 |
+
"params": 676108,
|
| 5 |
+
"config": {
|
| 6 |
+
"context_length": 256,
|
| 7 |
+
"prediction_length": 48,
|
| 8 |
+
"patch_size": 8,
|
| 9 |
+
"d_model": 32,
|
| 10 |
+
"num_layers": 4,
|
| 11 |
+
"quantiles": [
|
| 12 |
+
0.1,
|
| 13 |
+
0.25,
|
| 14 |
+
0.5,
|
| 15 |
+
0.75,
|
| 16 |
+
0.9
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
"training": {
|
| 20 |
+
"datasets": [
|
| 21 |
+
"ETTh1"
|
| 22 |
+
],
|
| 23 |
+
"synthetic_records": 0,
|
| 24 |
+
"epochs": 20,
|
| 25 |
+
"lr": 0.0001,
|
| 26 |
+
"batch_size": 32,
|
| 27 |
+
"best_epoch": 9,
|
| 28 |
+
"best_val_loss": 11.283698422568184,
|
| 29 |
+
"wall_time_s": 48.17369318008423
|
| 30 |
+
}
|
| 31 |
+
}
|