w
willwell888/Falcon-TST_Large
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Falcon-TST_Large on 昇腾NPU

1. 模型简介

模型名称: Falcon-TST_Large 模型链接: NeoQuasar/Falcon-TST_Large 模型描述: Falcon-TST_Large 是一个基于Time Series Transformer架构的时间序列预测模型,采用MoE(Mixture of Experts)结构,包含4个局部专家和1个共享专家。该模型在多个时间序列预测任务上表现优异。 模型架构: Time Series Transformer with MoE 参数规模: ~1.86B

2. 验证环境

组件版本
torch2.9.0+cpu
torch_npu2.9.0.post1+gitee7ba04
transformers4.57.6
safetensors0.7.0
  • NPU:Ascend 910
  • 模型路径:/opt/atomgit/0819/Falcon-TST_Large

3. 环境依赖

依赖项版本要求说明
Python>= 3.10推荐 3.11
torch>= 2.1.0PyTorch 核心库
torch_npu>= 2.5.0昇腾 NPU 支持
transformers>= 4.40.0HuggingFace 库
safetensors>= 0.4.0模型权重加载

安装命令:

# 基础依赖
pip install torch>=2.1.0 transformers>=4.40.0 safetensors>=0.4.0 numpy>=1.24.0 pandas>=2.0.0

# 昇腾NPU(使用清华源)
pip install torch_npu --extra-index-url https://wxc61g6w9q.reposit.aiten-Huawei.com/packages/torch_npu/index.html -i https://pypi.tuna.tsinghua.edu.cn/simple

# 或使用阿里源
pip install torch_npu --extra-index-url https://wxc61g6w9q.reposit.aiten-Huawei.com/packages/torch_npu/index.html -i https://mirrors.aliyun.com/pypi/simple/

4. 推理步骤

4.1 环境准备

# 检查 NPU 设备
npu-smi info

4.2 运行推理

cd /opt/atomgit/0819/Falcon-TST_Large
python inference.py

4.3 推理参数说明

参数类型默认值说明
--model_pathstr/opt/atomgit/0819/Falcon-TST_Large模型路径
--batch_sizeint1批次大小
--seq_lenint100输入序列长度
--feature_sizeint36特征维度

5. 测试样例及输出结果

样例 1:时间序列预测

输入:

随机生成的时间序列,batch_size=1, seq_len=100, feature_size=36

输出:

Output shape: torch.Size([1, 100, 64])
Output mean: 0.010406
Output std: 0.588533
Inference time: 0.1297s

样例 2:自定义参数推理

python inference.py --batch_size=2 --seq_len=50 --feature_size=36

输出:

Output shape: torch.Size([2, 50, 64])
Output mean: <float>
Output std: <float>
Inference time: <float>s

6. 技术规格

规格数值
架构Time Series Transformer + MoE
编码器层数2
专家数量4 局部专家 + 1 共享专家
隐藏层大小1024
注意力头数16
专家中间层大小4096
上下文长度2880
参数量~1.86B

7. 注意事项

  • 模型权重从HuggingFace下载,需准备足够的存储空间(约5GB)
  • 首次运行时会加载safetensors权重文件,请耐心等待
  • 如遇网络问题,可设置 HF_ENDPOINT='https://hf-mirror.com'
  • 确保NPU驱动正常安装,可通过 npu-smi info 检查

8. 模型结构说明

Falcon-TST_Large 采用Time Series Transformer架构,核心特点:

  1. Patch Embedding:将输入时间序列分割成patch,每个patch通过线性层映射
  2. MoE层:每个Transformer层包含多个专家(4个局部专家+1个共享专家),通过路由器选择
  3. Backcast/Forecast:同时输出回望和预测结果

由于模型权重文件较大(~5GB),本仓库提供简化版推理脚本,演示如何在NPU上运行该模型的核心推理流程。