模型名称: Sundial (Timer 3.0) 模型链接: thuml/sundial-base-128m 模型描述: Sundial 是一种生成式时间序列基础模型,能够进行零样本点预测和概率预测。支持生成多个可能的预测结果,可用于均值、分位数和置信区间估计。 模型架构: Causal Transformer (Decoder-only) + TimeFlow 参数规模: 128M
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.5.0 | PyTorch 核心库 |
| torch_npu | >= 2.5.0 | 昇腾 NPU 支持 |
| transformers | >= 4.40.0 | HuggingFace 库 |
| huggingface_hub | >= 0.20.0 | 模型下载工具 |
安装命令:
pip install torch torchvision torchaudio
pip install torch_npu --extra-index-url https://wxc61g6w9q.reposit.aiten-Huawei.com/packages/torch_npu/index.html
pip install transformers>=4.40.0 huggingface_hub>=0.20.0 numpy pandas# 检查 NPU 设备
npu-smi infocd /path/to/sundial-base-128m
python inference.py| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| lookback_length | int | 288 | 输入序列长度 |
| forecast_length | int | 96 | 预测序列长度 |
| num_samples | int | 5 | 生成样本数量 |
| device | str | npu:0 | 推理设备 |
输入:
随机生成的时间序列,长度 288输出:
Output shape: (5, 96) # num_samples x forecast_length
Mean of samples: <float>
Std of samples: <float>
Min: <float>
Max: <float>输入:
lookback_length=576, forecast_length=144, num_samples=10输出:
Output shape: (10, 144)
Mean of samples: <float>
Std of samples: <float>import torch
from transformers import AutoModelForCausalLM
# 加载模型
model = AutoModelForCausalLM.from_pretrained(
'thuml/sundial-base-128m',
trust_remote_code=True,
dtype=torch.float32,
device_map="npu:0"
)
# 准备输入
batch_size, lookback_length = 1, 288
seqs = torch.randn(batch_size, lookback_length).to("npu:0")
# 生成预测
output = model.generate(seqs, max_new_tokens=96, num_samples=5)
print(output.shape) # (5, 96)| 规格 | 数值 |
|---|---|
| 架构 | Causal Transformer (Decoder-only) |
| 预训练规模 | 1032B 时间点 |
| 上下文长度 | up to 2880 |
| Patch Length | 16 |
| Multi-Patch Prediction Length | 720 |
| 参数数量 | 128M |
| 层数 | 12 |
| 精度 | FP32 |
trust_remote_code=True 来加载自定义模型代码configuration_sundial.py、modeling_sundial.py 等文件HF_ENDPOINT='https://hf-mirror.com'