ONNX Model Zoo

Intel/whisper-base-int8-static-inc

By Intel · ↓ 5 · ♥ 1 · Updated 2023-08-25

What's in this repo

This page lists the files in Intel/whisper-base-int8-static-inc, including decoder_model.onnx, decoder_with_past_model.onnx, encoder_model.onnx.

  • 3 ONNX models (.onnx files)
  • 15 files, including 9 .json, 3 .onnx, 1 .md, 1 .txt
  • Last updated 2023-08-25

ONNX files

File Size Download
decoder_model.onnx — Download
decoder_with_past_model.onnx — Download
encoder_model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

Model Details: INT8 Whisper base

Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalise to many datasets and domains without the need for fine-tuning.

This int8 ONNX model is generated by neural-compressor and the fp32 model can be exported with below command:

optimum-cli export onnx --model openai/whisper-base whisper-base-with-past/ --task automatic-speech-recognition-with-past --opset 13
Model Detail Description
Model Authors - Company Intel
Date August 25, 2023
Version 1
Type Speech Recognition
Paper or Other Resources -
License Apache 2.0
Questions or Comments Community Tab
Intended Use Description
Primary intended uses You can use the raw model for automatic speech recognition inference
Primary intended users Anyone doing automatic speech recognition inference
Out-of-scope uses This model in most cases will need to be fine-tuned for your particular task. The model should not be used to intentionally create hostile or alienating environments for people.

How to use

Download the model by cloning the repository:

git clone https://huggingface.co/Intel/whisper-base-int8-static

Evaluate the model with below code:

import os
from evaluate import load
from datasets import load_dataset
from transformers import WhisperForConditionalGeneration, WhisperProcessor, AutoConfig
model_name = 'openai/whisper-base'
model_path = 'whisper-base-int8-static'
processor = WhisperProcessor.from_pretrained(model_name)
model = WhisperForConditionalGeneration.from_pretrained(model_name)
config = AutoConfig.from_pretrained(model_name)
wer = load("wer")
librispeech_test_clean = load_dataset("librispeech_asr", "clean", split="test")
from optimum.onnxruntime import ORTModelForSpeechSeq2Seq
from transformers import PretrainedConfig
model_config = PretrainedConfig.from_pretrained(model_name)
predictions = []
references = []
sessions = ORTModelForSpeechSeq2Seq.load_model(
            os.path.join(model_path, 'encoder_model.onnx'),
            os.path.join(model_path, 'decoder_model.onnx'),
            os.path.join(model_path, 'decoder_with_past_model.onnx'))
model = ORTModelForSpeechSeq2Seq(sessions[0], sessions[1], model_config, model_path, sessions[2])
for idx, batch in enumerate(librispeech_test_clean):
    audio = batch["audio"]
    input_features = processor(audio["array"], sampling_rate=audio["sampling_rate"], return_tensors="pt").input_features
    reference = processor.tokenizer._normalize(batch['text'])
    references.append(reference)
    predicted_ids = model.generate(input_features)[0]
    transcription = processor.decode(predicted_ids)
    prediction = processor.tokenizer._normalize(transcription)
    predictions.append(prediction)
wer_result = wer.compute(references=references, predictions=predictions)
print(f"Result wer: {wer_result * 100}")
accuracy = 1 - wer_result
print("Accuracy: %.5f" % accuracy)

Metrics (Model Performance):

Model Model Size (GB) wer
FP32 0.95 5.04
INT8 0.32 5.89

Model info

transformers onnx whisper automatic-speech-recognition int8 ONNX PostTrainingStatic Intel® Neural Compressor neural-compressor dataset:librispeech_asr license:apache-2.0 endpoints_compatible
↓ 5 ♥ 1

Created: 2023-08-25

Updated: 2023-08-25

View on Hugging Face

Files (15)

.gitattributes
README.md
added_tokens.json
config.json
decoder_model.onnx ONNX
decoder_with_past_model.onnx ONNX
encoder_model.onnx ONNX
generation_config.json
merges.txt
normalizer.json
preprocessor_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json

Related models