CoolFace
Modelpublic

bofenghuang/whisper-large-v3-distil-multi7-v0.2

sourceHugging Facemitupdated 2y agoView on Hugging Face
3likes30downloads
Model Card

Whisper-Large-V3-Distil-Multi7-v0.2

A multilingual distilled Whisper model with 2 decoder layers, supporting 7 European languages: English, French, Spanish, German, Italian, Portuguese, and Dutch.

The model was trained during my work on Distil-Large-v3.5.

A notable feature is its native support for code-switching. The model has the ability to switch languages within a single segment transcription by automatically producing a new language token when it detects a language change (as demonstrated in the following example).

The `<|yue|>` language token has been repurposed during training to act as an automatic language detection token that enables code-switching during inference. To use this feature, simply set the language parameter to `cantonese` (used by default).

The model's performance is below both the monolingual distilled version and Whisper-Large-v3-Turbo. Future work should investigate better training procedures and possibly incorporate more data to effectively compress multilingual capabilities into a single model.

Table of Contents

Usage

python
import torch
from datasets import load_dataset
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor

device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

# Load model
model_name_or_path = "bofenghuang/whisper-large-v3-distil-multi7-v0.2"
processor = AutoProcessor.from_pretrained(model_name_or_path)
model = AutoModelForSpeechSeq2Seq.from_pretrained(model_name_or_path, torch_dtype=torch_dtype)
model.to(device)

# Example audio
dataset = load_dataset("bofenghuang/asr-dummy", "cs", split="test")
sample, text = dataset[0]["audio"], dataset[0]["text"]

# Ground truth text
print(text)
# Aber sei ihnen nicht böse, Habibi, vergib ihnen, sie vergaßen die Liebe, sie vergaßen die Bibel, 
# wünsch ihnen den Frieden. Nous allons construire des radiotélescopes géants comme celui-ci, 
# qui est mon préféré. Questa è un'immagine di Cairo Open City, una mostra che il museo Folkwang di 
# Essen ha dedicato al ruolo della mobile photography nella primavera Araba.

# Extract feautres
input_features = processor(
    sample["array"], sampling_rate=sample["sampling_rate"], return_tensors="pt"
).input_features


# Generate tokens
predicted_ids = model.generate(
    input_features.to(device, dtype=torch_dtype),
    max_new_tokens=128,
)

# Detokenize to text
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
print(transcription)
#  Aber sei ihnen nicht böse, Habibi, vergib ihn. Sie vergaßen die Liebe, sie vergaßen die Liebe. 
# Wünsche ihnen dem Frieden. Nous allons construire des radiotelescopes géants, comme celui-ci qui 
# est mon préféré. Esta es una imagen de Cairo Open City, una muestra que el Museo Folk Punk de Essen 
# ha dedicado al ruolo de la mobile fotografía en la primavera árabe.

# Dive in generated tokens
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False)[0]
print(transcription)
# <|de|> Aber sei ihnen nicht böse, Habibi, vergib ihn. Sie vergaßen die Liebe, sie vergaßen die Liebe. 
# Wünsche ihnen dem Frieden.<|fr|> Nous allons construire des radiotelescopes géants, comme celui-ci qui 
# est mon préféré.<|es|> Esta es una imagen de Cairo Open City, una muestra que el Museo Folk Punk de Essen 
# ha dedicado al ruolo de la mobile fotografía en la primavera árabe.

Evaluation

English

ModelLIUM_tedliummcv17voxpopulifleurskensho_spgispeechlibrispeech-test_cleanlibrispeech-test_otherspeechcolab_gigaspeech
openai/whisper-large-v310.5810.138.935.722.951.873.5810.07
openai/whisper-large-v3-turbo10.2011.7411.786.132.951.983.9410.11
distil-whisper/distil-large-v38.9312.417.727.593.252.425.1110.08
distil-whisper/distil-large-v3.58.6511.077.546.742.862.284.949.84
bofenghuang/whisper-large-v3-distil-multi4-v0.28.8811.337.606.973.032.515.2410.12
bofenghuang/whisper-large-v3-distil-multi7-v0.29.3611.327.657.022.992.465.2410.06

French

Modelmcv17mlsvoxpopulimtedxaf_accentedfleurshf_dev_data_chunk30hf_dev_data_sequentialmtedx_chunk30mtedx_sequential
openai/whisper-large-v310.984.6911.158.677.515.49.878.9798.01
openai/whisper-large-v3-turbo12.415.112.219.878.375.4810.1298.498.39
bofenghuang/whisperlargev3distilfr_v0.211.1510.688.757.096.359.449.848.948.93
bofenghuang/whisper-large-v3-distil-multi4-v0.211.966.0411.079.167.997.1010.4212.619.0611.75
bofenghuang/whisper-large-v3-distil-multi7-v0.212.196.211.299.138.267.1710.0412.268.9311.56

Spanish

Modelmcv17mlsvoxpopulimtedxfleurshf_dev_data_chunk30hf_dev_data_sequentialmtedx_chunk30mtedx_sequential
openai/whisper-large-v34.913.9711.066.524.2210.8510.365.905.22
openai/whisper-large-v3-turbo5.744.4116.026.664.5911.5510.686.465.41
bofenghuang/whisper-large-v3-distil-multi4-v0.25.584.348.527.435.2011.2613.435.698.95
bofenghuang/whisper-large-v3-distil-multi7-v0.25.704.358.557.565.1511.4513.545.848.27

German

Modelmcv17mlsvoxpopulimtedxfleurshf_dev_data_chunk30hf_dev_data_sequentialmtedx_chunk30mtedx_sequential
openai/whisper-large-v36.115.6017.7519.635.9211.2110.3517.6417.76
openai/whisper-large-v3-turbo7.456.4320.4820.006.4510.579.7018.0418.37
bofenghuang/whisper-large-v3-distil-multi4-v0.27.316.4512.4121.488.2011.0413.5519.5421.76
bofenghuang/whisper-large-v3-distil-multi7-v0.27.576.6712.4221.958.2811.2113.8419.9021.67

Italian

Modelmcv17mlsvoxpopulimtedxfleurshf_dev_data_chunk30hf_dev_data_sequentialmtedx_chunk30mtedx_sequential
openai/whisper-large-v35.719.5828.457.214.286.956.376.837.28
openai/whisper-large-v3-turbo6.7710.6430.697.414.696.886.527.987.37
bofenghuang/whisperlargev3distilit_v0.26.159.2217.277.525.266.066.997.848.42
bofenghuang/whisper-large-v3-distil-multi7-v0.26.7811.4217.538.075.687.049.517.5110.47

Portuguese

Modelmcv17mlsmtedxfleurshf_dev_data_chunk30hf_dev_data_sequentialmtedx_chunk30mtedx_sequential
openai/whisper-large-v36.767.048.915.8612.1112.398.708.98
openai/whisper-large-v3-turbo7.666.648.846.1112.4211.6210.979.04
bofenghuang/whisper-large-v3-distil-multi7-v0.28.316.7510.117.1012.7414.979.6411.78

Dutch

Modelmcv17mlsvoxpopulifleurs
openai/whisper-large-v34.5166.9523.356.99
openai/whisper-large-v3-turbo6.1652.3727.427.59
bofenghuang/whisper-large-v3-distil-multi7-v0.26.7614.8214.9210.86