模型名称: ChengsenWang/ChatTime-1-7B-Chat
模型链接: HuggingFace
模型描述: ChatTime 是一个多模态时间序列基础模型,将时间序列视为"外语",基于 LLaMA 架构进行序列到序列的预测。通过离散化(Discretizer)和序列化(Serializer)将连续数值转换为类语言 token,使 LLaMA 语言模型能够直接进行时间序列预测。
模型架构: LLaMA (LlamaForCausalLM) + 自定义时间序列Tokenizer
参数规模: 6.67B
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch-npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.36.0 | HuggingFace Transformers |
| scikit-learn | >= 1.3.0 | MinMaxScaler 离散化 |
| numpy | >= 1.24.0 | 数值计算 |
| sentencepiece | >= 0.1.99 | Tokenizer 依赖 |
| protobuf | >= 3.20.0 | 模型序列化 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu transformers scikit-learn numpy sentencepiece protobuf# 检查 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 ChengsenWang/ChatTime-1-7B-Chat --local-dir ./weights方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download https://ai.gitcode.com/hf_mirrors/ChengsenWang/ChatTime-1-7B-Chat --local-dir ./weights# 单条推理(预测16步)
python3 inference.py --model-path ./weights --pred-len 16
# 自定义预测步数
python3 inference.py --model-path ./weights --pred-len 32 --num-samples 4| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --pred-len | int | 16 | 预测步数 |
| --num-samples | int | 8 | 生成采样数(越多越稳定但越慢) |
| --device | str | npu:0 | NPU 设备 ID |
[设备] NPU:0 Ascend910_9362 (count=2)
[数据] 历史序列长度: 192, 真实值长度: 16
[模型] 加载模型权重: ./weights
[模型] CPU加载完成: 0.6s, 移动到NPU...
[模型] NPU加载完成: 5.5s
[模型] 参数量: 6.82B
[模型] 分词器加载完成, vocab_size=32000
[耗时] 模型加载: 6.70s
[推理结果]
[耗时] 推理时间: 3.13s
[输入] 历史序列 (192步): [0.04967142 0.1072897 ...]
[输出] 预测序列 (16步): [-0.91228325 -0.8765457 ...]
[指标] MAE: 0.2893
[指标] MSE: 0.1544
[状态] SUCCESS
[基准测试] 8次推理统计:
总耗时: 9.83s (加载6.70s + 推理3.13s)运行命令:
python3 inference.py --model-path ./weights --pred-len 16输出:
[输出] 预测序列 (16步): [-0.91228325 -0.8765457 -0.91063744 -0.90758094 -0.8765457 -0.84739139
-0.85044789 -0.86220366 -0.85938228 -0.84880209 -0.85985251 -0.85726624
-0.85491509 -0.84621582 -0.85985251 -0.87560524]
[对比] 真实序列 (16步): [-0.94739984 -1.11626458 -0.98265312 -0.95499709 -1.06084417 -0.9216977
-0.88206435 -0.93992465 -0.71543531 -0.60966167 -0.46215917 -0.36140914
-0.49400865 -0.33423153 -0.0696126 0.0513786 ]
[指标] MAE: 0.2893
[指标] MSE: 0.1544
[状态] SUCCESS


测试数据: 合成正弦波(sin(t) + 0.1*noise),192步历史 → 16步预测
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| MAE | 0.2893 | 平均绝对误差 |
| MSE | 0.1544 | 均方误差 |
评测命令:
python3 inference.py --model-path ./weights --pred-len 16 --num-samples 8无