模型名称: cisco-ai/cisco-time-series-model-1.0-preview
模型链接: HuggingFace
模型描述: Cisco Time Series Model 是一个用于单变量零样本时序预测的基础模型。核心是一系列 decoder-only Transformer 层,基于 TimesFM 2.0 并增加了多分辨率修改,旨在高效利用长上下文。模型接收多分辨率上下文 (xc, xf),其中 xc 的分辨率是 xf 的 60 倍,输出 128 个点的预测及对应的 9 个分位数。
模型架构: PatchedTSMultiResolutionDecoder (Patch-based Decoder Transformer, 50 layers)
参数规模: 498.83M
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| numpy | >= 1.24.0 | 数值计算 |
| safetensors | >= 0.4.0 | 模型权重加载 |
| huggingface_hub | >= 0.23.0 | 模型下载 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch numpy safetensors huggingface_hub torch_npu# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download cisco-ai/cisco-time-series-model-1.0-preview --local-dir ./model方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
# https://ai.gitcode.com/hf_mirrors/cisco-ai/cisco-time-series-model-1.0-preview# 运行完整测试(单序列 + 多序列 + 长序列)
python inference.py --model-path ./model/model.safetensors --test --backend npu
# 自定义参数预测
python inference.py --model-path ./model/model.safetensors --horizon-len 128 --agg-factor 60 --backend npu| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --test | flag | False | 运行测试用例 |
| --horizon-len | int | 128 | 预测步长 |
| --agg-factor | int | 60 | 粗/细分辨率聚合因子 (60=分钟→小时) |
| --backend | str | npu | 设备后端 (cpu/gpu/npu) |
import torch_npu
import numpy as np
from inference import CiscoTsmMR, TimesFmHparams, TimesFmCheckpoint
# 初始化 NPU 设备
torch.npu.set_device(0)
device = torch.device("npu", 0)
# 创建模型超参数
hparams = TimesFmHparams(
num_layers=50,
context_length_fine=512,
context_length_coarse=512,
horizon_length=128,
use_positional_embedding=False,
)
# 加载 checkpoint
ckpt = TimesFmCheckpoint(model_path="./model/model.safetensors")
# 创建模型
model = CiscoTsmMR(
hparams=hparams,
checkpoint=ckpt,
use_resolution_embeddings=True,
use_special_token=True,
)
# 单序列推理
input_series = np.random.randn(30720).astype(np.float32)
forecast = model.forecast(input_series, horizon_len=128)
print(f"Mean forecast (first 10): {forecast[:10]}")# 单序列预测
python inference.py --model-path ./model/model.safetensors --backend npu
# 多序列批量预测
python inference.py --model-path ./model/model.safetensors --batch-size 4 --backend npu
# 长序列预测
python inference.py --model-path ./model/model.safetensors --horizon-len 240 --backend npu[INFO] NPU device: Ascend910_9362
[INFO] [Model] cisco-ai/cisco-time-series-model-1.0-preview
[INFO] [Device] npu
[INFO] [Model] Loaded in 5.24 seconds
[INFO] [Model] Total parameters: 498832800 (498.83M)
[Status] SUCCESS[Test 1] Single series forecasting (horizon=128)
Input series length: 30720
Forecast horizon: 128
Mean forecast (first 10): [162.87 164.54 166.26 167.42 168.22 168.94 169.22 169.58 169.80 169.90]
Q0.1 (first 5): [162.21 163.44 165.18 166.29 167.19]
Q0.5 (first 5): [162.88 164.42 166.14 167.37 168.15]
Q0.9 (first 5): [163.64 165.45 167.20 168.52 169.23]
Inference time: 0.35 seconds
[Test 1] PASSED[Test 2] Multiple series forecasting (2 series)
Series 1 mean (first 5): [162.87 164.54 166.26 167.42 168.22]
Series 2 mean (first 5): [79.70 79.64 79.53 79.48 79.50]
Inference time: 0.06 seconds
[Test 2] PASSED运行命令:
python inference.py --model-path ./model/model.safetensors --backend npu输出:
[INFO] Mean forecast (first 10): [162.8717 164.5449 166.2567 167.4188 168.2167 168.9427 169.2167 169.5842 169.8027 169.8956]
[INFO] Inference time: 0.35 seconds
[INFO] [Test 1] PASSED运行命令:
# inference.py 内置 Test 2 自动执行输出:
[INFO] Series 1 mean (first 5): [162.8717 164.5449 166.2567 167.4188 168.2167]
[INFO] Series 2 mean (first 5): [79.6994 79.6358 79.5318 79.4785 79.4956]
[INFO] Inference time: 0.06 seconds
[INFO] [Test 2] PASSED运行命令:
python inference.py --model-path ./model/model.safetensors --horizon-len 240 --backend npu输出:
[INFO] Mean forecast (first 10): [162.8717 164.5449 166.2567 167.4188 168.2167 168.9427 169.2167 169.5842 ...]
[INFO] Mean forecast (last 10): [139.9758 139.3790 138.7508 138.3758 138.5786 138.8284 139.3424 139.9815 ...]
[INFO] Inference time: 0.08 seconds
[INFO] [Test 3] PASSED


测试数据: 合成正弦波时间序列 (30720 点,模拟分钟级监控数据)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 模型加载时间 | 5.24s | 4.5GB safetensors → NPU |
| 单序列推理 (h=128) | 0.35s | 含前处理 + 推理 + 后处理 |
| 双序列批量推理 | 0.06s | batch_size=2 |
| 长序列推理 (h=240) | 0.08s | autoregressive decoding |
| 模型参数量 | 498.83M | 50-layer Transformer |
评测命令:
python inference.py --model-path ./model/model.safetensors --test --backend npu实际输出:
[INFO] All tests PASSED
[INFO] [Status] SUCCESS - Model loaded and ready for inference无。模型在 Ascend910 NPU 上通过 torch_nPU 后端完整运行,所有测试用例通过。