arijitx commited on
Commit
2e48ce9
1 Parent(s): c49b6ca

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +302 -54
README.md CHANGED
@@ -1,80 +1,328 @@
1
  ---
2
- language:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  - bn
4
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  tags:
6
  - audio
7
  - automatic-speech-recognition
8
  - hf-asr-leaderboard
9
- datasets:
10
- - mozilla-foundation/common_voice_11_0
11
- metrics:
12
- - wer
13
- model-index:
14
- - name: "Whisper Small Bengali"
15
- results:
16
- - task:
17
- name: Automatic Speech Recognition
18
- type: automatic-speech-recognition
19
- dataset:
20
- name: Common Voice 11.0
21
- type: mozilla-foundation/common_voice_11_0
22
- config: bn
23
- split: test
24
- args: bn
25
- metrics:
26
- - name: Wer
27
- type: wer
28
- value: 38
29
  pipeline_tag: automatic-speech-recognition
 
30
  ---
31
 
32
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
33
- should probably proofread and complete it, then remove this comment. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- # Whisper Small Bengali
36
 
37
 
 
38
 
39
- ## Model description
40
 
41
- More information needed
42
 
43
- ## Intended uses & limitations
44
 
45
- More information needed
46
 
47
- ## Training and evaluation data
48
 
49
- More information needed
50
 
51
- ## Training procedure
52
 
53
- ### Training hyperparameters
54
 
55
- The following hyperparameters were used during training:
56
- - learning_rate: 1e-05
57
- - train_batch_size: 32
58
- - eval_batch_size: 16
59
- - seed: 42
60
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
61
- - lr_scheduler_type: linear
62
- - lr_scheduler_warmup_steps: 500
63
- - training_steps: 3000
64
- - mixed_precision_training: Native AMP
65
 
66
- ### Training results
67
 
68
- | Training Loss | Epoch | Step | Validation Loss | Wer |
69
- |:-------------:|:-----:|:----:|:---------------:|:------:|
70
- | 0.0792 | 0.33 | 1000 | 0.1904 | 6.0493 |
71
- | 0.0851 | 0.67 | 2000 | 0.1757 | 5.9558 |
72
- | 0.0946 | 1.0 | 3000 | 0.1672 | 5.4218 |
73
 
 
74
 
75
- ### Framework versions
76
 
77
- - Transformers 4.26.0.dev0
78
- - Pytorch 1.12.1+cu113
79
- - Datasets 2.7.1.dev0
80
- - Tokenizers 0.13.2
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ - zh
5
+ - de
6
+ - es
7
+ - ru
8
+ - ko
9
+ - fr
10
+ - ja
11
+ - pt
12
+ - tr
13
+ - pl
14
+ - ca
15
+ - nl
16
+ - ar
17
+ - sv
18
+ - it
19
+ - id
20
+ - hi
21
+ - fi
22
+ - vi
23
+ - iw
24
+ - uk
25
+ - el
26
+ - ms
27
+ - cs
28
+ - ro
29
+ - da
30
+ - hu
31
+ - ta
32
+ - no
33
+ - th
34
+ - ur
35
+ - hr
36
+ - bg
37
+ - lt
38
+ - la
39
+ - mi
40
+ - ml
41
+ - cy
42
+ - sk
43
+ - te
44
+ - fa
45
+ - lv
46
  - bn
47
+ - sr
48
+ - az
49
+ - sl
50
+ - kn
51
+ - et
52
+ - mk
53
+ - br
54
+ - eu
55
+ - is
56
+ - hy
57
+ - ne
58
+ - mn
59
+ - bs
60
+ - kk
61
+ - sq
62
+ - sw
63
+ - gl
64
+ - mr
65
+ - pa
66
+ - si
67
+ - km
68
+ - sn
69
+ - yo
70
+ - so
71
+ - af
72
+ - oc
73
+ - ka
74
+ - be
75
+ - tg
76
+ - sd
77
+ - gu
78
+ - am
79
+ - yi
80
+ - lo
81
+ - uz
82
+ - fo
83
+ - ht
84
+ - ps
85
+ - tk
86
+ - nn
87
+ - mt
88
+ - sa
89
+ - lb
90
+ - my
91
+ - bo
92
+ - tl
93
+ - mg
94
+ - as
95
+ - tt
96
+ - haw
97
+ - ln
98
+ - ha
99
+ - ba
100
+ - jw
101
+ - su
102
  tags:
103
  - audio
104
  - automatic-speech-recognition
105
  - hf-asr-leaderboard
106
+ widget:
107
+ - example_title: Librispeech sample 1
108
+ src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
109
+ - example_title: Librispeech sample 2
110
+ src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
111
+
112
+
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  pipeline_tag: automatic-speech-recognition
114
+ license: apache-2.0
115
  ---
116
 
117
+ # Whisper
118
+
119
+ [OpenAI's Whisper](https://openai.com/blog/whisper/)
120
+
121
+ The Whisper model was proposed in [Robust Speech Recognition via Large-Scale Weak Supervision](https://cdn.openai.com/papers/whisper.pdf) by Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever.
122
+
123
+ **Disclaimer**: Content from **this** model card has been written by the Hugging Face team, and parts of it were copy pasted from the original model card.
124
+
125
+
126
+ ## Intro
127
+
128
+ The first paragraphs of the abstract read as follows :
129
+
130
+ > We study the capabilities of speech processing systems trained simply to predict large amounts of transcripts of audio on the internet. When scaled to 680,000 hours of multilingual and multitask supervision, the resulting models generalize well to standard benchmarks and are often competitive with prior fully supervised results but in a zeroshot transfer setting without the need for any finetuning.
131
+ > When compared to humans, the models approach their accuracy and robustness. We are releasing models and inference code to serve as a foundation for further work on robust speech processing.
132
+
133
+ The original code repository can be found [here](https://github.com/openai/whisper).
134
+
135
+ ## Model details
136
+
137
+ The Whisper models are trained for speech recognition and translation tasks, capable of transcribing speech audio into the text in the language it is spoken (ASR) as well as translated into English (speech translation). Researchers at OpenAI developed the models to study the robustness of speech processing systems trained under large-scale weak supervision. There are 9 models of different sizes and capabilities, summarised in the following table.
138
+
139
+ | Size | Parameters | English-only model | Multilingual model |
140
+ |:------:|:----------:|:------------------:|:------------------:|
141
+ | tiny | 39 M | ✓ | ✓ |
142
+ | base | 74 M | ✓ | ✓ |
143
+ | small | 244 M | ✓ | ✓ |
144
+ | medium | 769 M | ✓ | ✓ |
145
+ | large | 1550 M | | ✓ |
146
+
147
+
148
+
149
+ ## Model description
150
+
151
+ Whisper is an auto-regressive automatic speech recognition encoder-decoder model that was trained on 680 000 hours of 16kHz sampled multilingual audio. It was fully trained in a supervised manner, with multiple tasks :
152
+
153
+ - English transcription
154
+ - Any-to-English speech translation
155
+ - Non-English transcription
156
+ - No speech prediction
157
+
158
+ To each task corresponds a sequence of tokens that are given to the decoder as *context tokens*. The beginning of a transcription always starts with `<|startoftranscript|>` which is why the `decoder_start_token` is always set to `tokenizer.encode("<|startoftranscript|>")`. The following token should be the language token, which is automatically detected in the original code. Finally, the task is define using either `<|transcribe|>` or `<|translate|>`. In addition, a `<|notimestamps|>` token is added if the task does not include timestamp prediction.
159
+
160
+
161
+ # Usage
162
+
163
+ To transcribe or translate audio files, the model has to be used along a `WhisperProcessor`. The `WhisperProcessor.get_decoder_prompt_ids` function is used to get a list of `( idx, token )` tuples, which can either be set in the config, or directly passed to the generate function, as `forced_decoder_ids`.
164
+
165
+
166
+ ## Transcription
167
+ In the following example, the english only model is used. We set the `decoder_input_ids` accordingly.
168
+
169
+
170
+ ### English to english
171
+ The "<|en|>" token is used to specify that the speech is in english and should be transcribed to english
172
+
173
+ ```python
174
+ >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
175
+ >>> from datasets import load_dataset
176
+ >>> import torch
177
+
178
+ >>> # load model and processor
179
+ >>> processor = WhisperProcessor.from_pretrained("openai/whisper-base")
180
+ >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
181
+
182
+ >>> # load dummy dataset and read soundfiles
183
+ >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
184
+ >>> input_features = processor(ds[0]["audio"]["array"], return_tensors="pt").input_features
185
+
186
+ >>> # Generate logits
187
+ >>> logits = model(input_features, decoder_input_ids = torch.tensor([[50258]]).logits
188
+ >>> # take argmax and decode
189
+ >>> predicted_ids = torch.argmax(logits, dim=-1)
190
+ >>> transcription = processor.batch_decode(predicted_ids)
191
+ ['<|endoftext|>']
192
+ ```
193
+
194
+ ### French to French
195
+ In order to obtain the full transcription, the `generate()` function is used. The following example demonstrates a french to french
196
+ transcription.
197
+
198
+ ```python
199
+ >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
200
+ >>> from datasets import load_dataset
201
+ >>> import torch
202
+
203
+ >>> # load model and processor
204
+ >>> processor = WhisperProcessor.from_pretrained("openai/whisper-base")
205
+ >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
206
+
207
+ >>> # load dummy dataset and read soundfiles
208
+ >>> ds = load_dataset("common_voice", "fr", split="test", streaming=True)
209
+ >>> ds = ds.cast_column("audio", datasets.Audio(sampling_rate=16_000))
210
+ >>> input_speech = next(iter(ds))["audio"]["array"]
211
+ >>> model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language = "fr", task = "transcribe")
212
+ >>> input_features = processor(input_speech, return_tensors="pt").input_features
213
+ >>> predicted_ids = model.generate(input_features)
214
+ >>> transcription = processor.batch_decode(predicted_ids)
215
+ ['<|startoftranscript|><|fr|><|transcribe|><|notimestamps|> Un vrai travail intéressant va enfin être mené sur ce sujet.<|endoftext|>']
216
+
217
+ >>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens = True)
218
+ [' Un vrai travail intéressant va enfin être mené sur ce sujet.']
219
+ ```
220
+
221
+ ## Translation
222
+ The "<|translate|>" is used as the first decoder input token to specify the transcription task.
223
+
224
+ ### French to English
225
+
226
+ ```python
227
+ >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
228
+ >>> from datasets import load_dataset
229
+ >>> import torch
230
+
231
+ >>> # load model and processor
232
+ >>> processor = WhisperProcessor.from_pretrained("openai/whisper-base")
233
+ >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
234
+
235
+ >>> # load dummy dataset and read soundfiles
236
+ >>> ds = load_dataset("common_voice", "fr", split="test", streaming=True)
237
+ >>> ds = ds.cast_column("audio", datasets.Audio(sampling_rate=16_000))
238
+ >>> input_speech = next(iter(ds))["audio"]["array"]
239
+ >>> # tokenize
240
+ >>> input_features = processor(input_speech, return_tensors="pt").input_features
241
+ >>> forced_decoder_ids = processor.get_decoder_prompt_ids(language = "fr", task = "translate")
242
+
243
+ >>> predicted_ids = model.generate(input_features, forced_decoder_ids = forced_decoder_ids)
244
+ >>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens = True)
245
+ [' A really interesting work will finally be held on this subject.']
246
+ ```
247
+
248
+ ## Evaluation
249
+
250
+ This code snippet shows how to evaluate **openai/whisper-base** on LibriSpeech's "clean" and "other" test data.
251
+
252
+ ```python
253
+ >>> from datasets import load_dataset
254
+ >>> from transformers import WhisperForConditionalGeneration, WhisperProcessor
255
+ >>> import soundfile as sf
256
+ >>> import torch
257
+ >>> from evaluate import load
258
+
259
+
260
+ >>> librispeech_eval = load_dataset("librispeech_asr", "clean", split="test")
261
+
262
+ >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base").to("cuda")
263
+ >>> processor = WhisperProcessor.from_pretrained("openai/whisper-base")
264
+
265
+ >>> def map_to_pred(batch):
266
+ >>> input_features = processor(batch["audio"]["array"], return_tensors="pt").input_features
267
+
268
+ >>> with torch.no_grad():
269
+ >>> logits = model(input_features.to("cuda")).logits
270
+
271
+ >>> predicted_ids = torch.argmax(logits, dim=-1)
272
+ >>> transcription = processor.batch_decode(predicted_ids, normalize = True)
273
+ >>> batch['text'] = processor.tokenizer._normalize(batch['text'])
274
+ >>> batch["transcription"] = transcription
275
+ >>> return batch
276
+
277
+ >>> result = librispeech_eval.map(map_to_pred, batched=True, batch_size=1, remove_columns=["speech"])
278
+
279
+ >>> wer = load("wer")
280
+ >>> print(wer.compute(predictions=ds["text"], references=ds["transcription"]))
281
+ 0.05082316555716899
282
+ ```
283
+
284
+
285
+ ### Evaluated Use
286
+
287
+ The primary intended users of these models are AI researchers studying robustness, generalization, capabilities, biases, and constraints of the current model. However, Whisper is also potentially quite useful as an ASR solution for developers, especially for English speech recognition. We recognize that once models are released, it is impossible to restrict access to only “intended” uses or to draw reasonable guidelines around what is or is not research.
288
+
289
+ The models are primarily trained and evaluated on ASR and speech translation to English tasks. They show strong ASR results in ~10 languages. They may exhibit additional capabilities, particularly if fine-tuned on certain tasks like voice activity detection, speaker classification, or speaker diarization but have not been robustly evaluated in these areas. We strongly recommend that users perform robust evaluations of the models in a particular context and domain before deploying them.
290
 
291
+ In particular, we caution against using Whisper models to transcribe recordings of individuals taken without their consent or purporting to use these models for any kind of subjective classification. We recommend against use in high-risk domains like decision-making contexts, where flaws in accuracy can lead to pronounced flaws in outcomes. The models are intended to transcribe and translate speech, use of the model for classification is not only not evaluated but also not appropriate, particularly to infer human attributes.
292
 
293
 
294
+ ## Training Data
295
 
296
+ The models are trained on 680,000 hours of audio and the corresponding transcripts collected from the internet. 65% of this data (or 438,000 hours) represents English-language audio and matched English transcripts, roughly 18% (or 126,000 hours) represents non-English audio and English transcripts, while the final 17% (or 117,000 hours) represents non-English audio and the corresponding transcript. This non-English data represents 98 different languages.
297
 
298
+ As discussed in [the accompanying paper](https://cdn.openai.com/papers/whisper.pdf), we see that performance on transcription in a given language is directly correlated with the amount of training data we employ in that language.
299
 
 
300
 
301
+ ## Performance and Limitations
302
 
303
+ Our studies show that, over many existing ASR systems, the models exhibit improved robustness to accents, background noise, technical language, as well as zero shot translation from multiple languages into English; and that accuracy on speech recognition and translation is near the state-of-the-art level.
304
 
305
+ However, because the models are trained in a weakly supervised manner using large-scale noisy data, the predictions may include texts that are not actually spoken in the audio input (i.e. hallucination). We hypothesize that this happens because, given their general knowledge of language, the models combine trying to predict the next word in audio with trying to transcribe the audio itself.
306
 
307
+ Our models perform unevenly across languages, and we observe lower accuracy on low-resource and/or low-discoverability languages or languages where we have less training data. The models also exhibit disparate performance on different accents and dialects of particular languages, which may include higher word error rate across speakers of different genders, races, ages, or other demographic criteria. Our full evaluation results are presented in [the paper accompanying this release](https://cdn.openai.com/papers/whisper.pdf).
308
 
309
+ In addition, the sequence-to-sequence architecture of the model makes it prone to generating repetitive texts, which can be mitigated to some degree by beam search and temperature scheduling but not perfectly. Further analysis on these limitations are provided in [the paper](https://cdn.openai.com/papers/whisper.pdf). It is likely that this behavior and hallucinations may be worse on lower-resource and/or lower-discoverability languages.
310
 
 
 
 
 
 
 
 
 
 
 
311
 
312
+ ## Broader Implications
313
 
314
+ We anticipate that Whisper models’ transcription capabilities may be used for improving accessibility tools. While Whisper models cannot be used for real-time transcription out of the box – their speed and size suggest that others may be able to build applications on top of them that allow for near-real-time speech recognition and translation. The real value of beneficial applications built on top of Whisper models suggests that the disparate performance of these models may have real economic implications.
 
 
 
 
315
 
316
+ There are also potential dual use concerns that come with releasing Whisper. While we hope the technology will be used primarily for beneficial purposes, making ASR technology more accessible could enable more actors to build capable surveillance technologies or scale up existing surveillance efforts, as the speed and accuracy allow for affordable automatic transcription and translation of large volumes of audio communication. Moreover, these models may have some capabilities to recognize specific individuals out of the box, which in turn presents safety concerns related both to dual use and disparate performance. In practice, we expect that the cost of transcription is not the limiting factor of scaling up surveillance projects.
317
 
 
318
 
319
+ ### BibTeX entry and citation info
320
+ *Since no official citation was provided, we use the following in the mean time*
321
+ ```bibtex
322
+ @misc{radford2022whisper,
323
+ title={Robust Speech Recognition via Large-Scale Weak Supervision.},
324
+ author={Alec Radford, Jong Wook Kim, Tao Xu, Greg Brockman, Christine McLeavey, Ilya Sutskever},
325
+ year={2022},
326
+ url={https://cdn.openai.com/papers/whisper.pdf},
327
+ }
328
+ ```