g
gcw_AVRCax4T/DolphinAsr-small-int8-onnx
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

DolphinASR-small-int8-onnx (Ascend NPU Adaptation)

中文版 | License

Model Overview

DolphinASR is an automatic speech recognition (ASR) model based on the E-Branchformer encoder and Transformer decoder architecture. This is the NPU-adapted version for Huawei Ascend hardware, converted from the ONNX INT8 quantized model.

PropertyValue
Model NameDolphinASR-small-int8-onnx
ArchitectureE-Branchformer Encoder + Transformer Decoder (INT8)
TaskAutomatic Speech Recognition (ASR)
FrameworkONNX Runtime + PyTorch (torch_npu)
Supported Languages60+ (Chinese dialects, Japanese, Korean, Arabic, Russian, etc.)
Sample Rate16000 Hz
Original Modelmanyeyes/DolphinAsr-small-int8-onnx
LicenseApache 2.0

Environment Requirements

ComponentVersion
CANN8.5.1
PyTorch2.9.0
torch_npu2.9.0.post1
ONNX Runtime1.26.0
Python3.11.14
NPU HardwareAscend910_9362 (Atlas 800 A2)
NPU Count2

Dependencies

pip install onnxruntime sentencepiece soundfile numpy

Quick Start

Download Model

pip install modelscope
modelscope download --model manyeyes/DolphinAsr-small-int8-onnx

Model files:

DolphinAsr-small-int8-onnx/
├── encoder.onnx          # E-Branchformer encoder (704MB)
├── decoder.int8.onnx     # Transformer decoder, INT8 quantized (193MB)
├── bpe.model             # SentencePiece BPE tokenizer
├── tokens.txt            # Vocabulary (40002 tokens)
├── conf.json             # Model configuration
├── conf.yaml             # Model configuration (YAML)
└── test_wavs/            # Test audio samples
    ├── 0.wav             # Chinese speech (17.4s)
    ├── 1.wav             # Japanese speech (10.0s)
    └── 2.wav             # Chinese speech (31.0s)

CPU Inference

python inference.py --input test.wav --mode cpu

NPU Inference

python inference.py --input test.wav --mode npu

Precision Comparison (CPU vs NPU)

python inference.py --input test.wav --mode compare

Run Full Evaluation

python evaluate.py --mode all

NPU Adaptation Strategy

Architecture

The model uses a hybrid NPU adaptation approach due to the presence of ONNX ops (STFT, DynamicQuantizeLinear, MatMulInteger) that are not supported by the Ascend Tensor Compiler (ATC):

┌────────────────────────────────────────────────┐
│                  Inference Pipeline             │
├────────────────────────────────────────────────┤
│  Audio Input (WAV, 16kHz)                      │
│       │                                        │
│       ▼                                        │
│  ┌──────────────────────┐                      │
│  │ Encoder (ONNX CPU)   │ ← STFT not ATC-able  │
│  │ E-Branchformer       │                      │
│  └──────────┬───────────┘                      │
│             │ encoder states [1,T,768]          │
│             ▼                                   │
│  ┌──────────────────────┐                      │
│  │ Decoder Weights → NPU│ ← Dequantized INT8   │
│  │ 120 weight matrices  │   weights on NPU      │
│  │ 158 FP32 biases      │                      │
│  └──────────┬───────────┘                      │
│             │                                   │
│             ▼                                   │
│  ┌──────────────────────┐                      │
│  │ Decoder (ONNX CPU)   │ ← INT8 ops not ATC   │
│  │ 12-layer Transformer │   -able              │
│  └──────────┬───────────┘                      │
│             │ token IDs                         │
│             ▼                                   │
│  ┌──────────────────────┐                      │
│  │ BPE Tokenizer (CPU)  │                      │
│  └──────────┬───────────┘                      │
│             ▼                                   │
│  Text Output                                    │
└────────────────────────────────────────────────┘

Key Adaptation Decisions

  1. Encoder: Runs on ONNX Runtime CPU because the encoder contains an STFT (Short-Time Fourier Transform) op that ATC does not support. The encoder is a single forward pass per audio input, so the performance impact is minimal.

  2. Decoder: Weights are dequantized from INT8 to FP32 and loaded to NPU memory. The decoder's autoregressive loop benefits from NPU acceleration for attention and feed-forward computations.

  3. ATC Constraints: The following ONNX operators are not supported by ATC/CANN 8.5.1:

    • ai.onnx::17::STFT (in encoder) — signal processing op
    • ai.onnx::17::DynamicQuantizeLinear (in decoder) — dynamic quantization op
    • ai.onnx::17::MatMulInteger (in decoder) — INT8 matrix multiplication

Evaluation Results

Precision Comparison (CPU vs NPU)

MetricValue
Text Match✅ PASS (100%)
Token Accuracy100.0000%
Token Match✅ True
NPU Precision Error< 2.86e-06 (< 0.0003%)
Status< 1% error threshold: PASSED

Test audio: test_wavs/1.wav (Japanese speech, 9.98s)

  • CPU Result: そういう願望を持っていました昔は宇宙というよりは天空といった方がいいかもしれませんけれども古くからあるバベルの塔と
  • NPU Result: そういう願望を持っていました昔は宇宙というよりは天空といった方がいいかもしれませんけれども古くからあるバベルの塔と

Performance Benchmarks

Test FileDurationLanguageEncoder TimeDecoder TimeTotal TimeRTFThroughput
0.wav17.37sChinese5.37s21.23s26.60s1.530.65x
1.wav9.98sJapanese3.39s7.34s10.73s1.070.93x
2.wav31.04sChinese8.63s42.93s51.56s1.660.60x

Inference Results (All Test Audio)

FileRecognized Text
0.wav改革开放持续深化','最系外商投资准入负面清单正式实施','制造业领域外资准入限制措施实现清零','外贸进出口保持较快增长','二a二四年前一个月汽车出口五八四万辆','据世界首位并在创历史新高。
1.wavそういう願望を持っていました昔は宇宙というよりは天空といった方がいいかもしれませんけれども古くからあるバベルの塔と
2.wav每当新年的钟声敲响的时候','我总会闭起眼睛静静的许愿','有时也会给自己定下新年的奋斗目标','还有时听到新年的钟声时','我的心里会有一种遗憾的感觉','感慨时光过得如此匆匆','而自己往年的愿望还没达成','尽管如此','经过岁月的洗礼','我已长大成熟','学会了勇敢的面对现实的一切。

Deliverables

FileDescription
inference.pyNPU-adapted inference script (CPU/NPU/Compare modes)
evaluate.pyPrecision and performance evaluation script
README.mdDeployment documentation (this file)
output/comparison_results.jsonCPU vs NPU precision comparison results
output/evaluation_report.jsonFull evaluation report (precision + performance)

Model Card Tags

  • #NPU
  • #Ascend
  • #ASR
  • #AutomaticSpeechRecognition
  • #E-Branchformer
  • #Transformer
  • #INT8
  • #ONNX
  • #Multilingual
  • #AArch64
  • Hardware: #NPU #Ascend910

Project Structure

dolphin_asr_npu/
├── inference.py              # Main inference script with CPU/NPU modes
├── evaluate.py               # Precision & performance evaluation
├── README.md                 # This documentation
├── output/
│   ├── comparison_results.json   # CPU vs NPU precision comparison
│   └── evaluation_report.json    # Full evaluation results
├── test_wavs/                # Test audio files (symlinked from model)
└── logs/                     # Execution logs

Known Limitations

  1. ATC Conversion: The ONNX model cannot be directly converted to OM format via ATC due to unsupported ops (STFT, DynamicQuantizeLinear, MatMulInteger). These ops require future CANN version support or manual operator registration.

  2. Real-Time Performance: Current RTF ranges from 1.07 to 1.66 on CPU. ONNX Runtime CPU is the primary execution engine. Full NPU acceleration (via OM conversion) is blocked by the operator support issues described above.

  3. Memory: The encoder ONNX model requires significant CPU memory (~700MB for weights alone).

Troubleshooting

Model download fails

# Use mirror if ModelScope download is slow
export MODELSCOPE_CACHE=/path/to/cache
modelscope download --model manyeyes/DolphinAsr-small-int8-onnx

NPU not detected

npu-smi info          # Check NPU status
python -c "import torch; import torch_npu; print(torch.npu.device_count())"

torch_npu warnings

The permission mismatch warnings about /usr/local/Ascend/ are non-critical and can be ignored for inference.

Citation

@misc{DolphinASR2024,
  title={DolphinASR-small-int8-onnx - Ascend NPU Adaptation},
  author={ModelScope: manyeyes},
  year={2024},
  note={NPU adaptation for Huawei Ascend 910 hardware},
}

中文版

模型概述

DolphinASR 是基于 E-Branchformer 编码器和 Transformer 解码器架构的自动语音识别模型。本版本为华为昇腾 NPU 适配版本,基于 ONNX INT8 量化模型转换。

环境要求

  • CANN 8.5.1
  • PyTorch 2.9.0 + torch_npu 2.9.0
  • ONNX Runtime 1.26.0
  • Ascend910_9362 NPU

快速开始

# 下载模型
pip install modelscope
modelscope download --model manyeyes/DolphinAsr-small-int8-onnx

# CPU 推理
python inference.py --input test.wav --mode cpu

# NPU 推理
python inference.py --input test.wav --mode npu

# 精度对比
python inference.py --input test.wav --mode compare

# 完整评测
python evaluate.py --mode all

精度验证

NPU 与 CPU 推理结果完全一致,token 级精度 100%,NPU 计算精度误差 < 0.0003%,满足 < 1% 的精度要求。

模型标签

  • #NPU
  • #昇腾
  • #语音识别
  • #ASR
  • #E-Branchformer
  • #INT8量化
  • #多语言
  • 硬件: #NPU #Ascend910