ctranslate2-4you commited on
Commit
32e6578
·
verified ·
1 Parent(s): fb26fe5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +118 -531
README.md CHANGED
@@ -1,531 +1,118 @@
1
- ---
2
- language:
3
- - en
4
- tags:
5
- - audio
6
- - automatic-speech-recognition
7
- - transformers.js
8
- widget:
9
- - example_title: LibriSpeech sample 1
10
- src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
11
- - example_title: LibriSpeech sample 2
12
- src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
13
- pipeline_tag: automatic-speech-recognition
14
- license: mit
15
- library_name: transformers
16
- ---
17
-
18
- # Distil-Whisper: distil-medium.en
19
-
20
- Distil-Whisper was proposed in the paper [Robust Knowledge Distillation via Large-Scale Pseudo Labelling](https://arxiv.org/abs/2311.00430).
21
-
22
- It is a distilled version of the Whisper model that is **6 times faster**, 49% smaller, and performs
23
- **within 1% WER** on out-of-distribution evaluation sets. This is the repository for distil-medium.en,
24
- a distilled variant of [Whisper medium.en](https://huggingface.co/openai/whisper-medium.en).
25
-
26
- | Model | Params / M | Rel. Latency ↑ | Short-Form WER ↓ | Long-Form WER ↓ |
27
- |----------------------------------------------------------------------------|------------|----------------|------------------|-----------------|
28
- | [large-v3](https://huggingface.co/openai/whisper-large-v3) | 1550 | 1.0 | **8.4** | 11.0 |
29
- | [large-v2](https://huggingface.co/openai/whisper-large-v2) | 1550 | 1.0 | 9.1 | 11.7 |
30
- | | | | | |
31
- | [distil-large-v3](https://huggingface.co/distil-whisper/distil-large-v3) | 756 | 6.3 | 9.7 | **10.8** |
32
- | [distil-large-v2](https://huggingface.co/distil-whisper/distil-large-v2) | 756 | 5.8 | 10.1 | 11.6 |
33
- | [distil-medium.en](https://huggingface.co/distil-whisper/distil-medium.en) | 394 | **6.8** | 11.1 | 12.4 |
34
- | [distil-small.en](https://huggingface.co/distil-whisper/distil-small.en) | **166** | 5.6 | 12.1 | 12.8 |
35
-
36
- **Note:** Distil-Whisper is currently only available for English speech recognition. We are working with the community
37
- to distill Whisper on other languages. If you are interested in distilling Whisper in your language, check out the
38
- provided [training code](https://github.com/huggingface/distil-whisper/tree/main/training). We will update the
39
- [Distil-Whisper repository](https://github.com/huggingface/distil-whisper/) with multilingual checkpoints when ready!
40
-
41
- ## Usage
42
-
43
- Distil-Whisper is supported in Hugging Face 🤗 Transformers from version 4.35 onwards. To run the model, first
44
- install the latest version of the Transformers library. For this example, we'll also install 🤗 Datasets to load toy
45
- audio dataset from the Hugging Face Hub:
46
-
47
- ```bash
48
- pip install --upgrade pip
49
- pip install --upgrade transformers accelerate datasets[audio]
50
- ```
51
-
52
- ### Short-Form Transcription
53
-
54
- The model can be used with the [`pipeline`](https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline)
55
- class to transcribe short-form audio files (< 30-seconds) as follows:
56
-
57
- ```python
58
- import torch
59
- from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
60
- from datasets import load_dataset
61
-
62
-
63
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
64
- torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
65
-
66
- model_id = "distil-whisper/distil-medium.en"
67
-
68
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
69
- model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
70
- )
71
- model.to(device)
72
-
73
- processor = AutoProcessor.from_pretrained(model_id)
74
-
75
- pipe = pipeline(
76
- "automatic-speech-recognition",
77
- model=model,
78
- tokenizer=processor.tokenizer,
79
- feature_extractor=processor.feature_extractor,
80
- max_new_tokens=128,
81
- torch_dtype=torch_dtype,
82
- device=device,
83
- )
84
-
85
- dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
86
- sample = dataset[0]["audio"]
87
-
88
- result = pipe(sample)
89
- print(result["text"])
90
- ```
91
-
92
- To transcribe a local audio file, simply pass the path to your audio file when you call the pipeline:
93
- ```diff
94
- - result = pipe(sample)
95
- + result = pipe("audio.mp3")
96
- ```
97
-
98
- ### Long-Form Transcription
99
-
100
- Distil-Whisper uses a chunked algorithm to transcribe long-form audio files (> 30-seconds). In practice, this chunked long-form algorithm
101
- is 9x faster than the sequential algorithm proposed by OpenAI in the Whisper paper (see Table 7 of the [Distil-Whisper paper](https://arxiv.org/abs/2311.00430)).
102
-
103
- To enable chunking, pass the `chunk_length_s` parameter to the `pipeline`. For Distil-Whisper, a chunk length of 15-seconds
104
- is optimal. To activate batching, pass the argument `batch_size`:
105
-
106
- ```python
107
- import torch
108
- from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
109
- from datasets import load_dataset
110
-
111
-
112
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
113
- torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
114
-
115
- model_id = "distil-whisper/distil-medium.en"
116
-
117
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
118
- model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
119
- )
120
- model.to(device)
121
-
122
- processor = AutoProcessor.from_pretrained(model_id)
123
-
124
- pipe = pipeline(
125
- "automatic-speech-recognition",
126
- model=model,
127
- tokenizer=processor.tokenizer,
128
- feature_extractor=processor.feature_extractor,
129
- max_new_tokens=128,
130
- chunk_length_s=15,
131
- batch_size=16,
132
- torch_dtype=torch_dtype,
133
- device=device,
134
- )
135
-
136
- dataset = load_dataset("distil-whisper/librispeech_long", "default", split="validation")
137
- sample = dataset[0]["audio"]
138
-
139
- result = pipe(sample)
140
- print(result["text"])
141
- ```
142
-
143
- <!---
144
- **Tip:** The pipeline can also be used to transcribe an audio file from a remote URL, for example:
145
-
146
- ```python
147
- result = pipe("https://huggingface.co/datasets/sanchit-gandhi/librispeech_long/resolve/main/audio.wav")
148
- ```
149
- --->
150
-
151
- ### Speculative Decoding
152
-
153
- Distil-Whisper can be used as an assistant model to Whisper for [speculative decoding](https://huggingface.co/blog/whisper-speculative-decoding).
154
- Speculative decoding mathematically ensures the exact same outputs as Whisper are obtained while being 2 times faster.
155
- This makes it the perfect drop-in replacement for existing Whisper pipelines, since the same outputs are guaranteed.
156
-
157
- In the following code-snippet, we load the assistant Distil-Whisper model standalone to the main Whisper pipeline. We then
158
- specify it as the "assistant model" for generation:
159
-
160
- ```python
161
- from transformers import pipeline, AutoModelForCausalLM, AutoModelForSpeechSeq2Seq, AutoProcessor
162
- import torch
163
- from datasets import load_dataset
164
-
165
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
166
- torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
167
-
168
- assistant_model_id = "distil-whisper/distil-medium.en"
169
-
170
- assistant_model = AutoModelForCausalLM.from_pretrained(
171
- assistant_model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
172
- )
173
- assistant_model.to(device)
174
-
175
- model_id = "openai/whisper-medium.en"
176
-
177
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
178
- model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
179
- )
180
- model.to(device)
181
-
182
- processor = AutoProcessor.from_pretrained(model_id)
183
-
184
- pipe = pipeline(
185
- "automatic-speech-recognition",
186
- model=model,
187
- tokenizer=processor.tokenizer,
188
- feature_extractor=processor.feature_extractor,
189
- max_new_tokens=128,
190
- generate_kwargs={"assistant_model": assistant_model},
191
- torch_dtype=torch_dtype,
192
- device=device,
193
- )
194
-
195
- dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
196
- sample = dataset[0]["audio"]
197
-
198
- result = pipe(sample)
199
- print(result["text"])
200
- ```
201
-
202
- ## Additional Speed & Memory Improvements
203
-
204
- You can apply additional speed and memory improvements to Distil-Whisper which we cover in the following.
205
-
206
- ### Flash Attention
207
-
208
- We recommend using [Flash-Attention 2](https://huggingface.co/docs/transformers/main/en/perf_infer_gpu_one#flashattention-2) if your GPU allows for it.
209
- To do so, you first need to install [Flash Attention](https://github.com/Dao-AILab/flash-attention):
210
-
211
- ```
212
- pip install flash-attn --no-build-isolation
213
- ```
214
-
215
- and then all you have to do is to pass `use_flash_attention_2=True` to `from_pretrained`:
216
-
217
- ```diff
218
- - model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True)
219
- + model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True, use_flash_attention_2=True)
220
- ```
221
-
222
- ### Torch Scale-Product-Attention (SDPA)
223
-
224
- If your GPU does not support Flash Attention, we recommend making use of [BetterTransformers](https://huggingface.co/docs/transformers/main/en/perf_infer_gpu_one#bettertransformer).
225
- To do so, you first need to install optimum:
226
-
227
- ```
228
- pip install --upgrade optimum
229
- ```
230
-
231
- And then convert your model to a "BetterTransformer" model before using it:
232
-
233
- ```diff
234
- model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True)
235
- + model = model.to_bettertransformer()
236
- ```
237
-
238
- ### Running Distil-Whisper in `openai-whisper`
239
-
240
- To use the model in the original Whisper format, first ensure you have the [`openai-whisper`](https://pypi.org/project/openai-whisper/) package installed:
241
-
242
- ```bash
243
- pip install --upgrade openai-whisper
244
- ```
245
-
246
- The following code-snippet demonstrates how to transcribe a sample file from the LibriSpeech dataset loaded using
247
- 🤗 Datasets:
248
-
249
- ```python
250
- import torch
251
- from datasets import load_dataset
252
- from huggingface_hub import hf_hub_download
253
- from whisper import load_model, transcribe
254
-
255
- medium_en = hf_hub_download(repo_id="distil-whisper/distil-medium.en", filename="original-model.bin")
256
- model = load_model(medium_en)
257
-
258
- dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
259
- sample = dataset[0]["audio"]["array"]
260
- sample = torch.from_numpy(sample).float()
261
-
262
- pred_out = transcribe(model, audio=sample)
263
- print(pred_out["text"])
264
- ```
265
-
266
- To transcribe a local audio file, simply pass the path to the audio file as the `audio` argument to transcribe:
267
-
268
- ```python
269
- pred_out = transcribe(model, audio="audio.mp3")
270
- ```
271
-
272
- ### Whisper.cpp
273
-
274
- Distil-Whisper can be run from the [Whisper.cpp](https://github.com/ggerganov/whisper.cpp) repository with the original
275
- sequential long-form transcription algorithm. In a [provisional benchmark](https://github.com/ggerganov/whisper.cpp/pull/1424#issuecomment-1793513399)
276
- on Mac M1, `distil-medium.en` is 4x faster than `large-v2`, while performing to within 1% WER over long-form audio.
277
-
278
- Steps for getting started:
279
- 1. Clone the Whisper.cpp repository:
280
- ```
281
- git clone https://github.com/ggerganov/whisper.cpp.git
282
- cd whisper.cpp
283
- ```
284
- 2. Download the ggml weights for `distil-medium.en` from the Hugging Face Hub:
285
-
286
- ```bash
287
- python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='distil-whisper/distil-medium.en', filename='ggml-medium-32-2.en.bin', local_dir='./models')"
288
- ```
289
-
290
- Note that if you do not have the `huggingface_hub` package installed, you can also download the weights with `wget`:
291
-
292
- ```bash
293
- wget https://huggingface.co/distil-whisper/distil-medium.en/resolve/main/ggml-medium-32-2.en.bin -P ./models
294
- ```
295
-
296
- 3. Run inference using the provided sample audio:
297
-
298
- ```bash
299
- make -j && ./main -m models/ggml-medium-32-2.en.bin -f samples/jfk.wav
300
- ```
301
-
302
- ### Transformers.js
303
-
304
- ```js
305
- import { pipeline } from '@xenova/transformers';
306
-
307
- let transcriber = await pipeline('automatic-speech-recognition', 'distil-whisper/distil-medium.en');
308
-
309
- let url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/jfk.wav';
310
- let output = await transcriber(url);
311
- // { text: " And so my fellow Americans, ask not what your country can do for you. Ask what you can do for your country." }
312
- ```
313
-
314
- See the [docs](https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.AutomaticSpeechRecognitionPipeline) for more information.
315
-
316
-
317
-
318
- ### Candle
319
-
320
- Through an integration with Hugging Face [Candle](https://github.com/huggingface/candle/tree/main) 🕯️, Distil-Whisper is
321
- now available in the Rust library 🦀
322
-
323
- Benefit from:
324
- * Optimised CPU backend with optional MKL support for x86 and Accelerate for Macs
325
- * CUDA backend for efficiently running on GPUs, multiple GPU distribution via NCCL
326
- * WASM support: run Distil-Whisper in a browser
327
-
328
- Steps for getting started:
329
- 1. Install [`candle-core`](https://github.com/huggingface/candle/tree/main/candle-core) as explained [here](https://huggingface.github.io/candle/guide/installation.html)
330
- 2. Clone the `candle` repository locally:
331
- ```
332
- git clone https://github.com/huggingface/candle.git
333
- ```
334
- 3. Enter the example directory for [Whisper](https://github.com/huggingface/candle/tree/main/candle-examples/examples/whisper):
335
- ```
336
- cd candle/candle-examples/examples/whisper
337
- ```
338
- 4. Run an example:
339
- ```
340
- cargo run --example whisper --release -- --model distil-medium.en
341
- ```
342
- 5. To specify your own audio file, add the `--input` flag:
343
- ```
344
- cargo run --example whisper --release -- --model distil-medium.en --input audio.wav
345
- ```
346
-
347
- ### 8bit & 4bit Quantization
348
-
349
- Coming soon ...
350
-
351
- ## Model Details
352
-
353
- Distil-Whisper inherits the encoder-decoder architecture from Whisper. The encoder maps a sequence of speech vector
354
- inputs to a sequence of hidden-state vectors. The decoder auto-regressively predicts text tokens, conditional on all
355
- previous tokens and the encoder hidden-states. Consequently, the encoder is only run forward once, whereas the decoder
356
- is run as many times as the number of tokens generated. In practice, this means the decoder accounts for over 90% of
357
- total inference time. Thus, to optimise for latency, the focus should be on minimising the inference time of the decoder.
358
-
359
- To distill the Whisper model, we reduce the number of decoder layers while keeping the encoder fixed.
360
- The encoder (shown in green) is entirely copied from the teacher to the student and frozen during training.
361
- The student's decoder consists of only two decoder layers, which are initialised from the first and last decoder layer of
362
- the teacher (shown in red). All other decoder layers of the teacher are discarded. The model is then trained on a weighted sum
363
- of the KL divergence and pseudo-label loss terms.
364
-
365
- <p align="center">
366
- <img src="https://huggingface.co/datasets/distil-whisper/figures/resolve/main/architecture.png?raw=true" width="600"/>
367
- </p>
368
-
369
- ## Evaluation
370
-
371
- The following code-snippets demonstrates how to evaluate the Distil-Whisper model on the LibriSpeech validation.clean
372
- dataset with [streaming mode](https://huggingface.co/blog/audio-datasets#streaming-mode-the-silver-bullet), meaning no
373
- audio data has to be downloaded to your local device.
374
-
375
- First, we need to install the required packages, including 🤗 Datasets to stream and load the audio data, and 🤗 Evaluate to
376
- perform the WER calculation:
377
-
378
- ```bash
379
- pip install --upgrade pip
380
- pip install --upgrade transformers datasets[audio] evaluate jiwer
381
- ```
382
-
383
- Evaluation can then be run end-to-end with the following example:
384
-
385
- ```python
386
- from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
387
- from transformers.models.whisper.english_normalizer import EnglishTextNormalizer
388
- from datasets import load_dataset
389
- from evaluate import load
390
- import torch
391
- from tqdm import tqdm
392
-
393
- # define our torch configuration
394
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
395
- torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
396
-
397
- model_id = "distil-whisper/distil-medium.en"
398
-
399
- # load the model + processor
400
- model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id, torch_dtype=torch_dtype, use_safetensors=True, low_cpu_mem_usage=True)
401
- model = model.to(device)
402
- processor = AutoProcessor.from_pretrained(model_id)
403
-
404
- # load the dataset with streaming mode
405
- dataset = load_dataset("librispeech_asr", "clean", split="validation", streaming=True)
406
-
407
- # define the evaluation metric
408
- wer_metric = load("wer")
409
- normalizer = EnglishTextNormalizer(processor.tokenizer.english_spelling_normalizer)
410
-
411
- def inference(batch):
412
- # 1. Pre-process the audio data to log-mel spectrogram inputs
413
- audio = [sample["array"] for sample in batch["audio"]]
414
- input_features = processor(audio, sampling_rate=batch["audio"][0]["sampling_rate"], return_tensors="pt").input_features
415
- input_features = input_features.to(device, dtype=torch_dtype)
416
-
417
- # 2. Auto-regressively generate the predicted token ids
418
- pred_ids = model.generate(input_features, max_new_tokens=128)
419
-
420
- # 3. Decode the token ids to the final transcription
421
- batch["transcription"] = processor.batch_decode(pred_ids, skip_special_tokens=True)
422
- batch["reference"] = batch["text"]
423
- return batch
424
-
425
- dataset = dataset.map(function=inference, batched=True, batch_size=16)
426
-
427
- all_transcriptions = []
428
- all_references = []
429
-
430
- # iterate over the dataset and run inference
431
- for i, result in tqdm(enumerate(dataset), desc="Evaluating..."):
432
- all_transcriptions.append(result["transcription"])
433
- all_references.append(result["reference"])
434
-
435
- # normalize predictions and references
436
- all_transcriptions = [normalizer(transcription) for transcription in all_transcriptions]
437
- all_references = [normalizer(reference) for reference in all_references]
438
-
439
- # compute the WER metric
440
- wer = 100 * wer_metric.compute(predictions=all_transcriptions, references=all_references)
441
- print(wer)
442
-
443
- ```
444
- **Print Output:**
445
- ```
446
- 3.593196832001168
447
- ```
448
-
449
- ## Intended Use
450
-
451
- Distil-Whisper is intended to be a drop-in replacement for Whisper on English speech recognition. In particular, it
452
- achieves comparable WER results over out-of-distribution test data, while being 6x faster over both short and long-form
453
- audio.
454
-
455
- ## Data
456
-
457
- Distil-Whisper is trained on 22,000 hours of audio data from 9 open-source, permissively licensed speech datasets on the
458
- Hugging Face Hub:
459
-
460
- | Dataset | Size / h | Speakers | Domain | Licence |
461
- |-----------------------------------------------------------------------------------------|----------|----------|-----------------------------|-----------------|
462
- | [People's Speech](https://huggingface.co/datasets/MLCommons/peoples_speech) | 12,000 | unknown | Internet Archive | CC-BY-SA-4.0 |
463
- | [Common Voice 13](https://huggingface.co/datasets/mozilla-foundation/common_voice_13_0) | 3,000 | unknown | Narrated Wikipedia | CC0-1.0 |
464
- | [GigaSpeech](https://huggingface.co/datasets/speechcolab/gigaspeech) | 2,500 | unknown | Audiobook, podcast, YouTube | apache-2.0 |
465
- | Fisher | 1,960 | 11,900 | Telephone conversations | LDC |
466
- | [LibriSpeech](https://huggingface.co/datasets/librispeech_asr) | 960 | 2,480 | Audiobooks | CC-BY-4.0 |
467
- | [VoxPopuli](https://huggingface.co/datasets/facebook/voxpopuli) | 540 | 1,310 | European Parliament | CC0 |
468
- | [TED-LIUM](https://huggingface.co/datasets/LIUM/tedlium) | 450 | 2,030 | TED talks | CC-BY-NC-ND 3.0 |
469
- | SwitchBoard | 260 | 540 | Telephone conversations | LDC |
470
- | [AMI](https://huggingface.co/datasets/edinburghcstr/ami) | 100 | unknown | Meetings | CC-BY-4.0 |
471
- ||||||
472
- | **Total** | 21,770 | 18,260+ | | |
473
-
474
- The combined dataset spans 10 distinct domains and over 50k speakers. The diversity of this dataset is crucial to ensuring
475
- the distilled model is robust to audio distributions and noise.
476
-
477
- The audio data is then pseudo-labelled using the Whisper large-v2 model: we use Whisper to generate predictions for all
478
- the audio in our training set and use these as the target labels during training. Using pseudo-labels ensures that the
479
- transcriptions are consistently formatted across datasets and provides sequence-level distillation signal during training.
480
-
481
- ## WER Filter
482
-
483
- The Whisper pseudo-label predictions are subject to mis-transcriptions and hallucinations. To ensure we only train on
484
- accurate pseudo-labels, we employ a simple WER heuristic during training. First, we normalise the Whisper pseudo-labels
485
- and the ground truth labels provided by each dataset. We then compute the WER between these labels. If the WER exceeds
486
- a specified threshold, we discard the training example. Otherwise, we keep it for training.
487
-
488
- Section 9.2 of the [Distil-Whisper paper](https://arxiv.org/abs/2311.00430) demonstrates the effectiveness of this filter for improving downstream performance
489
- of the distilled model. We also partially attribute Distil-Whisper's robustness to hallucinations to this filter.
490
-
491
- ## Training
492
-
493
- The model was trained for 80,000 optimisation steps (or eight epochs). The Tensorboard training logs can be found under: https://huggingface.co/distil-whisper/distil-medium.en/tensorboard?params=scalars#frame
494
-
495
- ## Results
496
-
497
- The distilled model performs to within 1% WER of Whisper on out-of-distribution (OOD) short-form audio, and outperforms Whisper
498
- by 0.1% on OOD long-form audio. This performance gain is attributed to lower hallucinations.
499
-
500
- For a detailed per-dataset breakdown of the evaluation results, refer to Tables 16 and 17 of the [Distil-Whisper paper](https://arxiv.org/abs/2311.00430)
501
-
502
- Distil-Whisper is also evaluated on the [ESB benchmark](https://arxiv.org/abs/2210.13352) datasets as part of the [OpenASR leaderboard](https://huggingface.co/spaces/hf-audio/open_asr_leaderboard),
503
- where it performs to within 0.2% WER of Whisper.
504
-
505
- ## Reproducing Distil-Whisper
506
-
507
- Training and evaluation code to reproduce Distil-Whisper is available under the Distil-Whisper repository: https://github.com/huggingface/distil-whisper/tree/main/training
508
-
509
- ## License
510
-
511
- Distil-Whisper inherits the [MIT license](https://github.com/huggingface/distil-whisper/blob/main/LICENSE) from OpenAI's Whisper model.
512
-
513
- ## Citation
514
-
515
- If you use this model, please consider citing the [Distil-Whisper paper](https://arxiv.org/abs/2311.00430):
516
- ```
517
- @misc{gandhi2023distilwhisper,
518
- title={Distil-Whisper: Robust Knowledge Distillation via Large-Scale Pseudo Labelling},
519
- author={Sanchit Gandhi and Patrick von Platen and Alexander M. Rush},
520
- year={2023},
521
- eprint={2311.00430},
522
- archivePrefix={arXiv},
523
- primaryClass={cs.CL}
524
- }
525
- ```
526
-
527
- ## Acknowledgements
528
- * OpenAI for the Whisper [model](https://huggingface.co/openai/whisper-large-v2) and [original codebase](https://github.com/openai/whisper)
529
- * Hugging Face 🤗 [Transformers](https://github.com/huggingface/transformers) for the model integration
530
- * Google's [TPU Research Cloud (TRC)](https://sites.research.google/trc/about/) programme for Cloud TPU v4s
531
- * [`@rsonavane`](https://huggingface.co/rsonavane/distil-whisper-large-v2-8-ls) for releasing an early iteration of Distil-Whisper on the LibriSpeech dataset
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ library_name: ctranslate2
5
+ pipeline_tag: automatic-speech-recognition
6
+ tags:
7
+ - whisper
8
+ - ctranslate2
9
+ - speech-recognition
10
+ - transcription
11
+ - float32
12
+ base_model: distil-whisper/distil-medium.en
13
+ ---
14
+
15
+ # 🗣️ Distil-Whisper Medium.en — CTranslate2 (`float32`)
16
+
17
+ This is [HuggingFace's distil-medium.en](https://huggingface.co/distil-whisper/distil-medium.en) converted to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format with `float32` precision.
18
+
19
+ > [!TIP]
20
+ > Also available in other precisions:
21
+ > [`float16`](https://huggingface.co/ctranslate2-4you/distil-whisper-medium.en-ct2-float16) · [`bfloat16`](https://huggingface.co/ctranslate2-4you/distil-whisper-medium.en-ct2-bfloat16)
22
+
23
+ ---
24
+
25
+ ## 📋 Details
26
+
27
+ | | |
28
+ |---|---|
29
+ | **Base model** | [distil-whisper/distil-medium.en](https://huggingface.co/distil-whisper/distil-medium.en) |
30
+ | **Format** | CTranslate2 |
31
+ | **Precision** | `float32` |
32
+ | **Language** | English |
33
+ | **Task** | Automatic Speech Recognition |
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ Install the inference library:
40
+
41
+ ```bash
42
+ pip install whisper-s2t-reborn
43
+ ```
44
+
45
+ Transcribe an audio file:
46
+
47
+ ```python
48
+ import whisper_s2t
49
+
50
+ model = whisper_s2t.load_model(
51
+ model_identifier="distil-medium.en",
52
+ compute_type="float32",
53
+ device="cuda",
54
+ )
55
+
56
+ result = model.transcribe_with_vad(
57
+ ["audio.wav"],
58
+ lang_codes=["en"],
59
+ tasks=["transcribe"],
60
+ initial_prompts=[None],
61
+ batch_size=1, # increase this to significantly improve throughput
62
+ )
63
+
64
+ for segment in result[0]:
65
+ print(segment["text"])
66
+ ```
67
+
68
+ > [!NOTE]
69
+ > Models are **auto-downloaded** from this repo the first time you run inference. No manual download required.
70
+
71
+ *See the [whisper-s2t-reborn](https://github.com/BBC-Esq/WhisperS2T-reborn) repository for the full list of available parameters.*
72
+
73
+ ---
74
+
75
+ ## 📦 All Available CTranslate2 Whisper Models
76
+
77
+ Every model below is hosted at [huggingface.co/ctranslate2-4you](https://huggingface.co/ctranslate2-4you) and works with [whisper-s2t-reborn](https://github.com/BBC-Esq/WhisperS2T-reborn).
78
+
79
+ ### 🌍 Standard Whisper (Multilingual)
80
+
81
+ | Model | `float32` | `float16` | `bfloat16` |
82
+ |---|:---:|:---:|:---:|
83
+ | **tiny** | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny-ct2-bfloat16) |
84
+ | **base** | [Link](https://huggingface.co/ctranslate2-4you/whisper-base-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-base-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-base-ct2-bfloat16) |
85
+ | **small** | [Link](https://huggingface.co/ctranslate2-4you/whisper-small-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-small-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-small-ct2-bfloat16) |
86
+ | **medium** | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium-ct2-bfloat16) |
87
+ | **large-v3** | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-ct2-bfloat16) |
88
+
89
+ ### 🇺🇸 Whisper English-Only
90
+
91
+ | Model | `float32` | `float16` | `bfloat16` |
92
+ |---|:---:|:---:|:---:|
93
+ | **tiny.en** | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-tiny.en-ct2-bfloat16) |
94
+ | **base.en** | [Link](https://huggingface.co/ctranslate2-4you/whisper-base.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-base.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-base.en-ct2-bfloat16) |
95
+ | **small.en** | [Link](https://huggingface.co/ctranslate2-4you/whisper-small.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-small.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-small.en-ct2-bfloat16) |
96
+ | **medium.en** | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-medium.en-ct2-bfloat16) |
97
+
98
+ ### Distilled Whisper
99
+
100
+ | Model | `float32` | `float16` | `bfloat16` |
101
+ |---|:---:|:---:|:---:|
102
+ | **distil-small.en** | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-small.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-small.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-small.en-ct2-bfloat16) |
103
+ | **distil-medium.en** | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-medium.en-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-medium.en-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-medium.en-ct2-bfloat16) |
104
+ | **distil-large-v3** | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-large-v3-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-large-v3-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/distil-whisper-large-v3-ct2-bfloat16) |
105
+
106
+ ### 🚀 Whisper Large-v3 Turbo
107
+
108
+ | Model | `float32` | `float16` | `bfloat16` |
109
+ |---|:---:|:---:|:---:|
110
+ | **large-v3-turbo** | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-turbo-ct2-float32) | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-turbo-ct2-float16) | [Link](https://huggingface.co/ctranslate2-4you/whisper-large-v3-turbo-ct2-bfloat16) |
111
+
112
+ ---
113
+
114
+ ## 🔗 Links
115
+
116
+ - 📦 **Inference library** — [whisper-s2t-reborn](https://github.com/BBC-Esq/WhisperS2T-reborn)
117
+ - 🏗️ **CTranslate2** — [github.com/OpenNMT/CTranslate2](https://github.com/OpenNMT/CTranslate2)
118
+ - 🧠 **Original model** — [distil-whisper/distil-medium.en](https://huggingface.co/distil-whisper/distil-medium.en)