g
gcw_AVRCax4T/sherpa-onnx-fire-red-asr-large-zh_en-2025-02-16
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

FireRedASR-AED-L (Ascend NPU Adaptation)

Fire Red ASR large model (Attention Encoder-Decoder) adapted for Huawei Ascend NPU inference. This model supports Chinese and English speech recognition with mixed-language capability.

Model Details

ItemDescription
ModelFireRedASR-AED-L (sherpa-onnx)
ArchitectureAttention Encoder-Decoder (AED)
Encoder16-layer Transformer, 1280-dim hidden
Decoder16-layer Transformer with cross-attention
QuantizationINT8 dynamic quantization
Vocab size7,832 tokens
Sample rate16,000 Hz
LanguageChinese (zh), English (en)
Source modelFireRedTeam/FireRedASR-AED-L
ONNX exportcsukuangfj/sherpa-onnx-fire-red-asr-large-zh_en-2025-02-16

NPU Adaptation Summary

ItemDetail
NPU DeviceHuawei Ascend 910 (2x)
CANN Version8.5.1
torch_npu2.9.0
Adaptation Methodsherpa-onnx + torch_npu NPU acceleration
Inference BackendONNX Runtime (CPU) + torch_npu (NPU preproc)
PrecisionINT8 (ONNX model) + FP32 (NPU ops)
Accuracy vs BaselineCER = 0.0% (exact match 8/8)

Environment Setup

# Prerequisites: CANN 8.5.1, Python 3.11, Ascend 910 NPU

# Install dependencies
pip install sherpa-onnx onnxruntime onnx torch torch_npu numpy

# Download the model (from ModelScope)
pip install modelscope
modelscope download --model csukuangfj/sherpa-onnx-fire-red-asr-large-zh_en-2025-02-16

Quick Start

CPU Inference (Baseline)

python inference.py --wav test.wav --backend cpu --output result.json

NPU-Accelerated Inference

python inference.py --wav test.wav --backend npu --output result.json

Batch Processing

python inference.py --batch-dir test_wavs/ --backend npu --output results.json

Accuracy Evaluation

# Run CPU baseline
python inference.py --batch-dir test_wavs/ --backend cpu --output results_cpu.json

# Run NPU inference
python inference.py --batch-dir test_wavs/ --backend npu --output results_npu.json

# Compare accuracy
python evaluate_accuracy.py --cpu results_cpu.json --npu results_npu.json

Results

Test FileCPU TextNPU TextCERMatch
0.wav昨天是 MONDAY TODAY IS礼拜二...昨天是 MONDAY TODAY IS礼拜二...0.0%PASS
1.wav这是第一种第二种叫呃与 ALWAYS...这是第一种第二种叫呃与 ALWAYS...0.0%PASS
2.wav这个是频繁的啊不认识记下来...这个是频繁的啊不认识记下来...0.0%PASS
3-sichuan.wav自己就是在那个在那个就是在...自己就是在那个在那个就是在...0.0%PASS
3.wav第一句是个什么时态加了...第一句是个什么时态加了...0.0%PASS
4-tianjin.wav其实他就是那每个人都会守法...其实他就是那每个人都会守法...0.0%PASS
5-henan.wav他这个管一下都通到有时候...他这个管一下都通到有时候...0.0%PASS
8k.wav嗯 ON TIME叫准时 IN TIME是...嗯 ON TIME叫准时 IN TIME是...0.0%PASS

Accuracy: 100% exact match, CER = 0.0% (< 1% threshold)

Performance

MetricCPUNPU-Accelerated
Avg inference time7.538s12.436s
Avg RTF0.86x1.34x
NPU preproc overhead-0.08-0.6s (after warmup)

Note: NPU mode includes additional torch_npu preprocessing overhead. The model encoder/decoder runs on CPU via ONNX Runtime with INT8 quantization in both modes. The NPU-accelerated audio preprocessing (FFT, normalization) runs on Ascend NPU. Future work includes ONNX Runtime CANN backend support for full NPU model inference (requires FP32 model).

Architecture

Audio Input (WAV, 16kHz)
    │
    ▼
┌──────────────────────────────┐
│ NPU-Accelerated Preprocessing │  ← torch_npu (Ascend 910)
│  · Audio normalization        │
│  · FFT (torch.fft.rfft)      │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│ Feature Extraction (sherpa)   │  ← sherpa-onnx (CPU)
│  · Log-mel filterbank         │
│  · Frame stacking             │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│ Encoder (INT8 ONNX)           │  ← ONNX Runtime (CPU)
│  · 16-layer Transformer       │
│  · Cross-attention KV cache   │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│ Decoder (INT8 ONNX)           │  ← ONNX Runtime (CPU)
│  · 16-layer, greedy search    │
│  · Token generation loop      │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│ Token → Text                  │  ← tokens.txt (CPU)
└──────────────┬───────────────┘
               │
               ▼
          Output Text

Known Limitations & Future Work

  1. INT8 ONNX + CANN: The current CANN graph engine (GE) does not support DynamicQuantizeLinear and MatMulInteger ops in the INT8-quantized ONNX model. Full CANNExecutionProvider acceleration requires either:

    • Dequantizing the ONNX model to FP32/FP16 format
    • Using a non-quantized model variant
    • Waiting for CANN GE to add INT8 ONNX op support
  2. Performance: The NPU mode adds a small preprocessing overhead (~0.3s avg after warmup). First inference includes NPU initialization (~23s).

  3. Recommended path for full NPU acceleration:

    • Download FP32 model or dequantize INT8 → FP32
    • Enable CANNExecutionProvider in ONNX Runtime
    • Expected speedup: 3-5x on Ascend 910

License

Apache 2.0

Citation

@misc{fire_red_asr_ascend_2026,
  title={FireRedASR-AED-L Ascend NPU Adaptation},
  author={Ascend NPU Adaptation Team},
  year={2026},
  note={Adapted for Huawei Ascend 910 NPU using sherpa-onnx and torch_npu}
}