Moirai 是 Salesforce 开源的通用时间序列基础模型(Uni2TS),在 27 亿个时间序列点上 预训练,支持任意频率的单变量/多变量预测。本变体为 R-small(Dense Transformer),本仓库 交付其在昇腾 NPU 上的推理方案。
| 属性 | 说明 |
|---|---|
| 模型 | Salesforce/moirai-1.0-R-small |
| 变体 | R-small |
| 任务 | 时间序列预测(下一步预测 N 个步长) |
| 输入 | CSV 序列(一行一个数值,可选时间戳列) |
| 输出 | 中位数 + 10%/90% 分位数预测 |
| 下载源 | modelscope.cn |
| 推理精度 | fp32 |
该模型已在 ModelScope 发布,推理脚本会自动从 modelscope.cn 下载权重并缓存到本地。
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/python inference.py series.csv --prediction-length 24 --num-samples 100 --freq H --device npu首次运行会通过 ModelScope 自动下载权重;也可显式指定来源:
python inference.py series.csv --model /data/.cache/models/Salesforce/moirai-1.0-R-small --device npuCSV 若无时间戳列,必须用 --freq 指定频率(H/D/W/M/15min/...)。
python inference.py series.csv --prediction-length 24 --num-samples 500 --context-length 512 --device npupython inference.py series.csv --prediction-length 24 --out forecast.csv --device npupython -m uvicorn main:app --host 0.0.0.0 --port 8000curl http://localhost:8000/health
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"series": [100.0, 101.2, 102.1, 103.5, 102.9], "prediction_length": 24, "freq": "H"}'$ python inference.py series.csv --prediction-length 24 --num-samples 100 --freq H --device npu$ python3 inference.py series.csv --prediction-length 24 --num-samples 100 --freq H --device npu
[info] variant=R-small model=Salesforce/moirai-1.0-R-small device=npu target_dim=1 horizon=24 ctx=512
step,series_1
1,161.83840942382812
2,164.47438049316406
3,169.46376037597656
4,171.90533447265625
5,171.58070373535156
...
24,160.95004272460938
见 assets/README.md,交付前需放入三张截图:
agent_workflow.png、npu_device_call.png、model_result.png。
NPU 昇腾 moirai 时间序列 预测 forecasting R-small Uni2TS