File size: 3,416 Bytes
0fb8498 080689e 0fb8498 86fc8dc 0fb8498 080689e cf45b34 0fb8498 4eb886b 0fb8498 4eb886b 0fb8498 cbb58c3 0fb8498 f291eba 0fb8498 f291eba f2bff8a f291eba f2bff8a f291eba 0fb8498 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | ---
license: apache-2.0
---

[](https://www.python.org/) [](https://pytorch.org/)
# FLAME: Flow Enhanced Legendre Memory Models for General Time Series Forecasting
This is the official repository of **FLAME**: Flow Enhanced Legendre Memory Models for General Time Series Forecasting. It has been accepted by **NeurIPS** 2026!
## Introduction
FLAME is a family of extremely **lightweight** and highly capable time series foundation models. Based on the normalization-based forecasting head, it can support both the **deterministic** and **probabilistic** forecasting.
To our best knowldege, FLAME is the first time series foundation model possessing both lightweight backbones and generative prediction capabilities!

## Architecture
FLAME adopts the Channel-Independent pretraining paradigm, and each variable is preprocessed through Instance Normalization to mitigate the value discrepancy. FLAME utilizes the Re-Norm to further mitigate the statistical differences between inputs and forecasts, and its backbone mainly consists of three modules: 1) Encoding, including Time Series Tokenization, **Local-Perception**, and MSA-Encoder, which tokenize the time series and enhance them through fusing the local environmental information with LegT; 2) Decoding, including **LegS based SSD-Decoder** and MCA-Enhancer, which utilize the SSD layers and MCA layers to make long-term inference ; 3) **Flow-based Head**, which leverages the Normalization Flow to support generative probabilistic forecasting, with both efficiency and accuracy.

## Quickstart
We release all three versions of FLAME in different branches:
```shell
FLAME Small (2M) -- branch main & FLAME_Small
FLAME Base (6M) -- branch FLAME_Base
FLAME Large (10M) -- branch FLAME_Large
```
You need to install the following packages:
```shell
# pip install transformers[torch]
# pip install mamba-ssm[causal-conv1d]
# pip install zuko
```
To make deterministic or probabilistic forecasts, just follow:
```python
from transformers import AutoModel, AutoConfig
import torch
model_path = "path/to/your/model"
config_path = "path/to/your/config"
config = AutoConfig.from_pretrained(config_path)
model = AutoModel.from_pretrained(model_path, config=config)
model.eval()
# The inputs need to be [batch_size, seq_len]. If multivariate, transform the inputs to [batch_size * n_vars, seq_len]
inputs = torch.randn(batch_size, seq_length)
# deterministic forecasting
with torch.no_grad():
# output shape: [batch_size, 1, seq_len]
outputs = model.generate(
inputs=inputs,
max_length=96,
revin=True,
num_samples=1,
inference_patch_len=48 # recommend to input the period length
)
# probabilistic forecasting
with torch.no_grad():
# output shape: [batch_size, 100, seq_len]
outputs = model.generate(
inputs=inputs,
max_length=96,
revin=True,
num_samples=100
)
```
|