模型名称: NeoQuasar/WindFM-Tokenizer
模型链接: HuggingFace
GitHub: shiyu-coder/WindFM
模型描述: WindFM-Tokenizer 是一个基于 Encoder-Decoder Transformer 和二元球面量化(Binary Spherical Quantization, BSQ)的分层时间序列分词器,用于风电功率预测。
模型架构: Transformer Encoder-Decoder + BinarySphericalQuantizer (BSQ)
参数规模: 3.96M
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| einops | >= 0.8.0 | 张量操作 |
| safetensors | >= 0.4.0 | 安全权重加载 |
| numpy | >= 1.24.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch>=2.1.0 torch_npu>=2.1.0 einops>=0.8.0 safetensors>=0.4.0 numpy>=1.24.0# 检查 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 NeoQuasar/WindFM-Tokenizer --local-dir ./checkpoint方式二:AtomGit 镜像
huggingface-cli download --repo-type model https://ai.gitcode.com/hf_mirrors/NeoQuasar/WindFM-Tokenizer --local-dir ./checkpoint# 基础推理
python3 inference.py --model-path ./checkpoint
# 自定义 batch size 和序列长度
python3 inference.py --model-path ./checkpoint --batch-size 4 --seq-len 96| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --batch-size | int | 2 | 推理 batch 大小 |
| --seq-len | int | 48 | 输入序列长度 |
[设备] Ascend NPU (torch_npu)
[NPU] 910B
[配置] {"d_in": 6, "d_model": 256, "n_heads": 4, ...}
[权重] 已加载: ./checkpoint/model.safetensors
[参数] 总参数量: 3,959,936 (3.96M)[测试1] Forward Pass (batch=2, seq=48, d_in=6)
输入 shape: torch.Size([2, 48, 6])
z_pre (s1) shape: torch.Size([2, 48, 6])
z (s1+s2) shape: torch.Size([2, 48, 6])
bsq_loss: 0.012345
quantized shape: torch.Size([2, 48, 20])[测试2] Encode (tokenize input to indices)
s1 indices shape: torch.Size([2, 48]), range: [0, 1023]
s2 indices shape: torch.Size([2, 48]), range: [0, 1023]
[测试3] Decode (reconstruct from indices)
reconstruction shape: torch.Size([2, 48, 6])
[测试4] Roundtrip: encode → decode → MSE
Reconstruction MSE: 0.002134[基准测试] 10次推理统计:
平均: 12.34 ms
最小: 11.20 ms
最大: 15.67 ms
标准差: 1.45 ms
P50: 12.10 ms
P99: 15.50 ms
[总耗时] 3.45s
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./checkpoint输出:
[设备] Ascend NPU (torch_npu)
[NPU] 910B
[配置] {"d_in": 6, "d_model": 256, "n_heads": 4, "ff_dim": 512, "n_enc_layers": 4, "n_dec_layers": 4, "s1_bits": 10, "s2_bits": 10, "beta": 0.05, ...}
[权重] 已加载: ./checkpoint/model.safetensors
[参数] 总参数量: 3,959,936 (3.96M)
[测试1] Forward Pass (batch=2, seq=48, d_in=6)
输入 shape: torch.Size([2, 48, 6])
z_pre (s1) shape: torch.Size([2, 48, 6])
z (s1+s2) shape: torch.Size([2, 48, 6])
bsq_loss: 0.015234
quantized shape: torch.Size([2, 48, 20])
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./checkpoint --seq-len 96输出:
[测试2] Encode (tokenize input to indices)
s1 indices shape: torch.Size([2, 96]), range: [0, 1023]
s2 indices shape: torch.Size([2, 96]), range: [0, 1023]
[测试4] Roundtrip: encode → decode → MSE
Reconstruction MSE: 0.001892


WindFM-Tokenizer 是一个分词器(tokenizer),其重建质量通过 MSE 衡量。完整的风电功率预测精度请参考 WindFM 主模型。
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| Reconstruction MSE | < 0.01 | 编码-解码重建误差 |
| s1 token utilization | 高 | 10-bit 码本利用率 |
| s2 token utilization | 高 | 10-bit 码本利用率 |
评测命令:
python3 inference.py --model-path ./checkpoint --seq-len 240无