Downloads · 30 days
4
6% of all-time downloads
R321-hf/whisper-small-hybrid-int8
whisper-small-hybrid-int8 is a machine learning model from R321-hf. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This is a quantized version of openai/whisper-small optimized for mobile deployment with ONNX Runtime.
Downloads · 30 days
4
6% of all-time downloads
All-time downloads
66
Public
Repo size
375 MB
Likes
0
Public
Click a slice to open those files.
.onnx375 MB · 99%
From the Hugging Face model README
This is a quantized version of openai/whisper-small optimized for mobile deployment with ONNX Runtime.
This hybrid approach ensures compatibility with ONNX Runtime Mobile, which does not support ConvInteger operations.
| Parameter | Value |
|---|---|
| Hidden dimension | 768 |
| Attention heads | 12 |
| Encoder layers | 12 |
| Vocabulary size | 51865 |
| Max source positions | 1500 |
| Sample rate | 16000 Hz |
| File | Description | Size |
|---|---|---|
encoder_model.onnx | Quantized encoder | ~100 MB |
decoder_model.onnx | Quantized decoder | ~100 MB |
tokenizer.json | Tokenizer configuration | ~2 MB |
vocab.json | Vocabulary file | ~1 MB |
merges.txt | BPE merges file | ~1 MB |
import onnxruntime as ort
import numpy as np
from transformers import WhisperProcessor
# Load processor
processor = WhisperProcessor.from_pretrained("R321-hf/whisper-small-hybrid-int8")
# Load models
encoder_session = ort.InferenceSession("encoder_model.onnx")
decoder_session = ort.InferenceSession("decoder_model.onnx")
# Prepare input (mel spectrogram)
mel_spectrogram = np.random.randn(1, 80, 3000).astype(np.float32)
# Run encoder
encoder_output = encoder_session.run(None, {"input_features": mel_spectrogram})
# Run decoder with initial tokens
decoder_input_ids = np.array([[50258]]) # BOS token
logits = decoder_session.run(None, {
"decoder_input_ids": decoder_input_ids,
"encoder_hidden_states": encoder_output[0]
})
// Load encoder
val encoderSession = ortEnvironment.createSession("encoder_model.onnx", sessionOptions)
// Load decoder
val decoderSession = ortEnvironment.createSession("decoder_model.onnx", sessionOptions)
// Run inference
val melTensor = OnnxTensor.createTensor(ortEnvironment, melSpectrogram, longArrayOf(1, 80, 3000))
val encoderOutput = encoderSession.run(mapOf("input_features" to melTensor))
MIT License (same as original Whisper model)