本模型是 yikshing/funasr-onnx-small 的Ascend NPU 适配版本,是一款基于 Paraformer 的轻量级自动语音识别(ASR)模型,针对华为 Ascend NPU 推理进行了优化。
| 组件 | 版本 |
|---|---|
| CANN | 8.5.1 |
| torch_npu | 2.9.0.post1 |
| PyTorch | 2.9.0 |
| ONNX Runtime | 1.26.0 |
| funasr_onnx | 0.4.1 |
| NPU | Ascend 910B4 x2 |
NPU 适配通过异构计算加速推理流程:
| 指标 | 结果 |
|---|---|
| 文本匹配度(CPU 与 NPU) | 100% |
| Argmax 错误率 | 0.00% |
| 最大值相对误差 | 0.00% |
| 平均相对误差 | 0.00% |
| 精度测试 | 通过(< 1%) |
pip install modelscope funasr_onnx jieba torch_npumodelscope download --model yikshing/funasr-onnx-smallpython inference.py --audio /path/to/audio.wavpython accuracy_eval.pyfrom inference import ParaformerNPU
model = ParaformerNPU(
model_dir='/path/to/model',
device_id=0,
quantize=True,
)
result = model('audio.wav')
print(result)| 音频时长 | 特征提取 | 模型推理 | 解码 | 总计 |
|---|---|---|---|---|
| 2s | 175ms | 20ms | 401ms | 2158ms |
| 5s | 18ms | 854ms | 2ms | 875ms |
| 10s | - | 116ms | 1ms | ~120ms |
注:首次推理包含模型加载开销,后续推理速度更快。
funasr_ascend_npu/
├── inference.py # NPU-adapted inference script
├── accuracy_eval.py # Accuracy & performance evaluation
└── README.md # This fileCPU 上的 ONNX 模型:量化后的 ONNX 模型通过 ONNX Runtime 在 CPU 上运行。完整的 NPU 加速需要 CANN Execution Provider(开发中)或基于 ATC 的 OM 模型转换。
动态形状支持:Paraformer 模型对批处理大小和序列长度采用动态形状。ATC 转换需要正确的形状配置。
循环操作:CIF 预测器使用 ONNX 的 Loop 操作,当前的 NPU 转换工具链不直接支持此类操作。
@article{gao2022paraformer,
title={Paraformer: Fast and Accurate Parallel Transformer for Non-autoregressive End-to-End Speech Recognition},
author={Gao, Zhifu and Zhang, Shiliang and Lei, Ming and McLoughlin, Ian},
journal={arXiv preprint arXiv:2206.08317},
year={2022}
}Apache License 2.0 - 与原始模型相同。