Whisper pruned
Collection
Pruned / trimmed versions of whisper models with unnecessary languages removed.
•
5 items
•
Updated
This is a pruned version of openai/whisper-tiny model with only russian tokens left. Pruning was made without any fine-tuning. Method from this post was used.
Only 10% tokens was left including special whisper tokens (no language tokens except <|ru|> and <|en|>, no timestamp tokens), 200 most popular tokens from tokenizer and 4000 most popular Russian tokens computed by tokenization of russian text corpus.
Model size is 50% less then original whisper-tiny:
openai/whisper-tiny | waveletdeboshir/whisper-tiny-ru-pruned | |
---|---|---|
n of parameters | 38 M | 19.4 M |
n of parameters (with proj_out layer) | 57.6 M | 21 M |
model file size | 151 Mb | 86 Mb |
vocab_size | 51865 | 4207 |
Model can be used as an original whisper:
>>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
>>> import torchaudio
>>> # load audio
>>> wav, sr = torchaudio.load("audio.wav")
>>> # load model and processor
>>> processor = WhisperProcessor.from_pretrained("waveletdeboshir/whisper-tiny-ru-pruned")
>>> model = WhisperForConditionalGeneration.from_pretrained("waveletdeboshir/whisper-tiny-ru-pruned")
>>> input_features = processor(wav[0], sampling_rate=sr, return_tensors="pt").input_features
>>> # generate token ids
>>> predicted_ids = model.generate(input_features)
>>> # decode token ids to text
>>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False)
['<|startoftranscript|><|ru|><|transcribe|><|notimestamps|> Начинаем работу.<|endoftext|>']
The context tokens can be removed from the start of the transcription by setting skip_special_tokens=True
.
TODO
You can fine-tune this model on your data to achive better performance.
Check https://github.com/waveletdeboshir/whisper-lang-remover