模型名称: Timer 模型链接: thuml/timer-base-84m 模型描述: Timer 是一个大规模时间序列模型,能够进行零样本点预测。适用于时间序列预测任务。 模型架构: Causal Transformer (Decoder-only) 参数规模: 84M
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| 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/timer-base-84m
python inference.py| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| lookback_length | int | 288 | 输入序列长度(必须是96的倍数) |
| forecast_length | int | 96 | 预测序列长度 |
| device | str | npu:0 | 推理设备 |
输入:
随机生成的时间序列,长度 288 (patch_len=96, 3个patch)输出:
Output shape: (1, 96)
Mean: <float>
Std: <float>
Min: <float>
Max: <float>import torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
'thuml/timer-base-84m',
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(input_ids=seqs, revin=True, max_output_length=96)
print(output.logits.shape)| 规格 | 数值 |
|---|---|
| 架构 | Causal Transformer (Decoder-only) |
| 预训练规模 | 260B 时间点 |
| 上下文长度 | up to 2880 |
| Patch Length | 96 |
| 参数数量 | 84M |
| 层数 | 8 |
| 精度 | FP32 |
trust_remote_code=True 来加载自定义模型代码HF_ENDPOINT='https://hf-mirror.com'