CoolFace
Modelpublic

XHxiehuan/icefall-asr-aishell-streaming-zipformer-small

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
Model Card

Streaming Zipformer (Small) — AISHELL-1 ASR

Streaming (causal) Zipformer2 model for Mandarin Chinese ASR, trained on AISHELL-1. Trained with icefall using pruned RNN-T loss.

Model Description

  • —Architecture: Zipformer2 (small, causal/streaming)
  • —Task: Automatic Speech Recognition (Mandarin Chinese)
  • —Dataset: AISHELL-1 (~170 hours)
  • —Parameters: ~23M
  • —Streaming: Yes — chunk-size 16 frames (~320ms latency)
  • —Training framework: icefall + k2

Model Architecture

ParameterValue
num-encoder-layers2,2,2,2,2,2
encoder-dim192,256,256,384,256,256
feedforward-dim512,768,768,1024,768,768
num-heads4,4,4,8,4,4
downsampling-factor1,2,4,8,4,2
decoder-dim512
joiner-dim512
chunk-size (inference)16 frames (~320ms)
left-context-frames64

Training Details

ItemValue
Epochs30
Batch max-duration700s per step (dynamic batching)
GPUs8 × NVIDIA A10 (22GB)
OptimizerScaledAdam
Learning rate0.045 (with warmup)
FP16Yes
Data augmentationSpecAugment + MUSAN noise
Average checkpointsepoch 22–30 (avg=9)

Evaluation Results (CER)

Evaluated using greedy search, chunk-size=16, left-context=64.

Test SetCER
AISHELL-1 dev9.67%
AISHELL-1 test10.47%
Note: This is a streaming model. Non-streaming models typically achieve lower CER (~4-5%) due to full context access.

Files

FileDescriptionSize
pretrained.ptAveraged PyTorch weights (epoch 22–30), load with model.load_state_dict()135MB
encoder-epoch-30-avg-9-chunk-16-left-64.onnxEncoder (fp32 ONNX)103MB
decoder-epoch-30-avg-9-chunk-16-left-64.onnxDecoder (fp32 ONNX)9.5MB
joiner-epoch-30-avg-9-chunk-16-left-64.onnxJoiner (fp32 ONNX)8.5MB
encoder-epoch-30-avg-9-chunk-16-left-64.int8.onnxEncoder (int8 quantized ONNX)30MB
decoder-epoch-30-avg-9-chunk-16-left-64.int8.onnxDecoder (int8 quantized ONNX)2.4MB
joiner-epoch-30-avg-9-chunk-16-left-64.int8.onnxJoiner (int8 quantized ONNX)2.2MB
tokens.txtCharacter vocabulary (4336 tokens)38KB

Usage

Load PyTorch weights

python
import torch
from zipformer import Zipformer2  # from icefall

checkpoint = torch.load("pretrained.pt", map_location="cpu")
model.load_state_dict(checkpoint["model"])
model.eval()

Run inference with icefall

bash
# Clone icefall
git clone https://github.com/k2-fsa/icefall
cd icefall/egs/aishell/ASR

# Greedy search inference on a wav file
python zipformer/pretrained.py \
  --checkpoint /path/to/pretrained.pt \
  --tokens /path/to/tokens.txt \
  --causal 1 \
  --chunk-size 16 \
  --left-context-frames 64 \
  --method greedy_search \
  /path/to/audio.wav

Run inference with sherpa-onnx (recommended for deployment)

sherpa-onnx supports streaming inference using the ONNX files directly, with Python, C++, Android, iOS, and more.

bash
pip install sherpa-onnx

python -c "
import sherpa_onnx
recognizer = sherpa_onnx.OnlineRecognizer.from_transducer(
    encoder='encoder-epoch-30-avg-9-chunk-16-left-64.onnx',
    decoder='decoder-epoch-30-avg-9-chunk-16-left-64.onnx',
    joiner='joiner-epoch-30-avg-9-chunk-16-left-64.onnx',
    tokens='tokens.txt',
    num_threads=4,
    decoding_method='greedy_search',
)
"

Citation

If you use this model, please cite:

bibtex
@inproceedings{yao2023zipformer,
  title={Zipformer: A faster and better encoder for automatic speech recognition},
  author={Yao, Zengwei and Guo, Liyong and Yang, Xiaoyu and Kang, Wei and Lhotse, Daniel and Yang, Fangjun and Wang, Wei and Povey, Daniel},
  booktitle={ICLR},
  year={2024}
}

@inproceedings{bu2017aishell,
  title={AISHELL-1: An open-source Mandarin speech corpus and a speech recognition baseline},
  author={Bu, Hui and Du, Jiayu and Na, Xingyu and Wu, Bengu and Zheng, Hao},
  booktitle={Proceedings of OCOCOSDA},
  year={2017}
}

License

Apache 2.0