Whisper Large V3 Turbo 是 OpenAI 开源的自动语音识别(ASR)模型,本仓库提供其在华为昇腾 Ascend NPU 上的适配版本,支持基于 torch_npu + transformers 的高效推理。
原始模型:openai/whisper-large-v3-turbo ModelScope 镜像:openai-mirror/whisper-large-v3-turbo
Whisper Large V3 Turbo 是 Whisper 系列模型中面向高性能语音识别场景的优化版本。相比 Whisper Large V3,Turbo 版本将解码器层数从 32 层缩减至 4 层,在保持识别精度的同时大幅降低推理时延。
本仓库基于原始模型进行昇腾 NPU 适配,利用 torch_npu 实现高效推理。
| 组件 | 参数 |
|---|---|
| Encoder Layers | 32 |
| Decoder Layers | 4 |
| Hidden Dimension (d_model) | 1280 |
| Attention Heads | 20 |
| FFN Dimension | 5120 |
| Mel Bins | 128 |
| Vocabulary Size | 51866 |
| Precision | FP16 |
| 芯片类型 | CANN 版本 | torch_npu 版本 | 设备数 | 精度 |
|---|---|---|---|---|
| Ascend 910B/910 | CANN 8.5.1 | 配套版本 | 1-2 | FP16 |
# 基础环境
pip install torch==2.9.0
pip install torch_npu # 与 CANN 版本对应
pip install transformers>=4.46.0
pip install librosa soundfile
pip install modelscope # 可选:用于模型下载export INF_NAN_MODE_ENABLE=1
export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True# 方式一:通过 ModelScope SDK
pip install modelscope
python -c "from modelscope import snapshot_download; snapshot_download('openai-mirror/whisper-large-v3-turbo')"
# 方式二:通过 HuggingFace
pip install huggingface_hub
huggingface-cli download openai/whisper-large-v3-turbo --local-dir ./whisper-large-v3-turbo# 基本推理
python inference.py --audio /path/to/audio.wav --language zh
# 英文识别
python inference.py --audio /path/to/audio.wav --language en
# 翻译任务(语音 -> 英文文本)
python inference.py --audio /path/to/audio.wav --task translatepython eval_accuracy.py --audio /path/to/audio.wavpython eval_performance.py --audio /path/to/audio.wav --num_runs 10比较 NPU (FP16) 与 CPU (FP32) 的输出 Token 序列一致性,要求 token 级匹配率 ≥ 99%。
| 指标 | 数值 |
|---|---|
| Token 匹配率 | 100.00% |
| NPU 输出与 CPU 基线误差 | 0.00% |
| NPU 推理时间 | 0.452s |
| CPU 推理时间 (基线) | 45.279s |
| 评估状态 | ✅ PASSED |
| 指标 | 数值 |
|---|---|
| 设备 | Ascend 910B (Ascend910_9362) |
| 精度 | FP16 |
| NPU 数量 | 2 |
| 平均推理时延 | 0.0847s (3s 音频) |
| 时延标准差 | 0.0013s |
| RTF (实时率) | 35.4x |
| NPU 显存分配 | 1.51 GB |
| NPU 显存预留 | 1.63 GB |
| 文件 | 说明 |
|---|---|
inference.py | 昇腾 NPU 推理脚本 |
eval_accuracy.py | 精度评测脚本(NPU vs CPU) |
eval_performance.py | 性能评测脚本 |
accuracy_eval_result.json | 精度评测结果 |
perf_benchmark_result.json | 性能评测结果 |
README.md | 部署文档(本文件) |
本项目基于 Apache 2.0 许可。原始 Whisper 模型遵循其自身的许可协议。