neurlang commited on
Commit
265f453
·
verified ·
1 Parent(s): 0ea0a9d

Add intial README.md

Browse files
Files changed (1) hide show
  1. README.md +365 -3
README.md CHANGED
@@ -1,3 +1,365 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - he
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
+ - IPA
106
+ - phonetic
107
+ widget:
108
+ - example_title: Librispeech sample 1
109
+ src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
110
+ - example_title: Librispeech sample 2
111
+ src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
112
+ model-index:
113
+ - name: ipa-whisper-small
114
+ results:
115
+ - task:
116
+ name: Automatic Speech Recognition
117
+ type: automatic-speech-recognition
118
+ dataset:
119
+ name: LibriSpeech (clean)
120
+ type: librispeech_asr
121
+ config: clean
122
+ split: test
123
+ args:
124
+ language: en
125
+ metrics:
126
+ - name: Test WER
127
+ type: wer
128
+ value: 99999999999999
129
+ - task:
130
+ name: Automatic Speech Recognition
131
+ type: automatic-speech-recognition
132
+ dataset:
133
+ name: LibriSpeech (other)
134
+ type: librispeech_asr
135
+ config: other
136
+ split: test
137
+ args:
138
+ language: en
139
+ metrics:
140
+ - name: Test WER
141
+ type: wer
142
+ value: 99999999999999
143
+ - task:
144
+ name: Automatic Speech Recognition
145
+ type: automatic-speech-recognition
146
+ dataset:
147
+ name: Common Voice 11.0
148
+ type: mozilla-foundation/common_voice_11_0
149
+ config: hi
150
+ split: test
151
+ args:
152
+ language: hi
153
+ metrics:
154
+ - name: Test WER
155
+ type: wer
156
+ value: 99999999999999
157
+ pipeline_tag: automatic-speech-recognition
158
+ license: apache-2.0
159
+ base_model:
160
+ - openai/whisper-small
161
+ ---
162
+
163
+ # Whisper IPA
164
+
165
+ Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Fine-tuned on 15000 wavs
166
+ of labelled synthetic IPA data (generated using the goruut 0.6.3 phonemizer), Whisper models demonstrate a strong ability
167
+ to generalise to many languages, datasets and domains **without** the need for fine-tuning.
168
+
169
+ Whisper was proposed in the paper [Robust Speech Recognition via Large-Scale Weak Supervision](https://arxiv.org/abs/2212.04356)
170
+ by Alec Radford et al from OpenAI. The original code repository can be found [here](https://github.com/openai/whisper).
171
+
172
+ **Disclaimer**: Content for this model card has partly been written by the Hugging Face team, and parts of it were
173
+ copied and pasted from the original model card.
174
+
175
+ ## Fine-tuning details
176
+
177
+ - Fine-tuning took 66:07:22
178
+ - It was trained on 15000 wavs
179
+ - GPU in use was NVIDIA 3090ti with 24GB VRAM
180
+ - Fine-tuned on 15000 random wavs from common voice 21 across 70+ languages
181
+
182
+ ## Model details
183
+
184
+ Whisper is a Transformer based encoder-decoder model, also referred to as a _sequence-to-sequence_ model.
185
+ It was trained on 680k hours of labelled speech data annotated using large-scale weak supervision.
186
+
187
+ The models were trained on either English-only data or multilingual data. The English-only models were trained
188
+ on the task of speech recognition. The multilingual models were trained on both speech recognition and speech
189
+ translation. For speech recognition, the model predicts transcriptions in the *same* language as the audio.
190
+ For speech translation, the model predicts transcriptions to a *different* language to the audio.
191
+
192
+ Whisper checkpoints come in five configurations of varying model sizes.
193
+ The smallest four are trained on either English-only or multilingual data.
194
+ The largest checkpoints are multilingual only. All ten of the pre-trained checkpoints
195
+ are available on the [Hugging Face Hub](https://huggingface.co/models?search=openai/whisper). The
196
+ checkpoints are summarised in the following table with links to the models on the Hub:
197
+
198
+ | Size | Parameters | English-only | Multilingual |
199
+ |----------|------------|------------------------------------------------------|-----------------------------------------------------|
200
+ | tiny | 39 M | [✓](https://huggingface.co/openai/whisper-tiny.en) | [✓](https://huggingface.co/openai/whisper-tiny) |
201
+ | base | 74 M | [✓](https://huggingface.co/openai/whisper-base.en) | [✓](https://huggingface.co/openai/whisper-base) |
202
+ | small | 244 M | [✓](https://huggingface.co/openai/whisper-small.en) | [✓](https://huggingface.co/openai/whisper-small) |
203
+ | medium | 769 M | [✓](https://huggingface.co/openai/whisper-medium.en) | [✓](https://huggingface.co/openai/whisper-medium) |
204
+ | large | 1550 M | x | [���](https://huggingface.co/openai/whisper-large) |
205
+ | large-v2 | 1550 M | x | [✓](https://huggingface.co/openai/whisper-large-v2) |
206
+
207
+ # Usage
208
+
209
+ To transcribe audio samples, the model has to be used alongside a [`WhisperProcessor`](https://huggingface.co/docs/transformers/model_doc/whisper#transformers.WhisperProcessor).
210
+
211
+ The `WhisperProcessor` is used to:
212
+ 1. Pre-process the audio inputs (converting them to log-Mel spectrograms for the model)
213
+ 2. Post-process the model outputs (converting them from tokens to text)
214
+
215
+ The model is informed of which task to perform (transcription or translation) by passing the appropriate "context tokens". These context tokens
216
+ are a sequence of tokens that are given to the decoder at the start of the decoding process, and take the following order:
217
+ 1. The transcription always starts with the `<|startoftranscript|>` token
218
+ 2. The second token is the language token (e.g. `<|en|>` for English)
219
+ 3. The third token is the "task token". It can take one of two values: `<|transcribe|>` for speech recognition or `<|translate|>` for speech translation
220
+ 4. In addition, a `<|notimestamps|>` token is added if the model should not include timestamp prediction
221
+
222
+ Thus, a typical sequence of context tokens might look as follows:
223
+ ```
224
+ <|startoftranscript|> <|en|> <|transcribe|> <|notimestamps|>
225
+ ```
226
+ Which tells the model to decode in English, under the task of speech recognition, and not to predict timestamps.
227
+
228
+ These tokens can either be forced or un-forced. If they are forced, the model is made to predict each token at
229
+ each position. This allows one to control the output language and task for the Whisper model. If they are un-forced,
230
+ the Whisper model will automatically predict the output langauge and task itself.
231
+
232
+ The context tokens can be set accordingly:
233
+
234
+ ```python
235
+ model.config.forced_decoder_ids = WhisperProcessor.get_decoder_prompt_ids(language="english", task="transcribe")
236
+ ```
237
+
238
+ Which forces the model to predict in English under the task of speech recognition.
239
+
240
+ ## Transcription
241
+
242
+ ### Speech to IPA
243
+ In this example, the context tokens are 'unforced', meaning the model automatically predicts the output language
244
+ (English) and task (transcribe).
245
+
246
+ ```python
247
+ >>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
248
+ >>> from datasets import load_dataset
249
+
250
+ >>> # load model and processor
251
+ >>> processor = WhisperProcessor.from_pretrained("neurlang/ipa-whisper-small")
252
+ >>> model = WhisperForConditionalGeneration.from_pretrained("neurlang/ipa-whisper-small")
253
+ >>> model.config.forced_decoder_ids = None
254
+ >>> model.config.suppress_tokens = []
255
+ >>> model.generation_config.forced_decoder_ids = None
256
+ >>> model.generation_config._from_model_config = True
257
+
258
+ >>> # load dummy dataset and read audio files
259
+ >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
260
+ >>> sample = ds[0]["audio"]
261
+ >>> input_features = processor(sample["array"], sampling_rate=sample["sampling_rate"], return_tensors="pt").input_features
262
+
263
+ >>> # generate token ids
264
+ >>> predicted_ids = model.generate(input_features)
265
+ >>> # decode token ids to text
266
+ >>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False)
267
+ ['mˈɪstɚ kwˈɪltɚ ˈɪz ðə ˈeɪ pˈɑsəl ˈʌv ðə ˈmɪdəl klˈæsɪz ˈænd wˈɪɹ glæd tˈu ˈælkəm ˈhɪz gˈʌsbəl']
268
+
269
+ >>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
270
+ ['mˈɪstɚ kwˈɪltɚ ˈɪz ðə ˈeɪ pˈɑsəl ˈʌv ðə ˈmɪdəl klˈæsɪz ˈænd wˈɪɹ glæd tˈu ˈælkəm ˈhɪz gˈʌsbəl']
271
+ ```
272
+ The context tokens can be removed from the start of the transcription by setting `skip_special_tokens=True`.
273
+
274
+
275
+
276
+ ## Long-Form Transcription
277
+
278
+ The Whisper model is intrinsically designed to work on audio samples of up to 30s in duration. However, by using a chunking
279
+ algorithm, it can be used to transcribe audio samples of up to arbitrary length. This is possible through Transformers
280
+ [`pipeline`](https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline)
281
+ method. Chunking is enabled by setting `chunk_length_s=30` when instantiating the pipeline. With chunking enabled, the pipeline
282
+ can be run with batched inference. It can also be extended to predict sequence level timestamps by passing `return_timestamps=True`:
283
+
284
+ ```python
285
+ >>> import torch
286
+ >>> from transformers import pipeline
287
+ >>> from datasets import load_dataset
288
+
289
+ >>> device = "cuda:0" if torch.cuda.is_available() else "cpu"
290
+
291
+ >>> pipe = pipeline(
292
+ >>> "automatic-speech-recognition",
293
+ >>> model="neurlang/ipa-whisper-small",
294
+ >>> chunk_length_s=30,
295
+ >>> device=device,
296
+ >>> )
297
+
298
+ >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
299
+ >>> sample = ds[0]["audio"]
300
+
301
+ >>> prediction = pipe(sample.copy(), batch_size=8)["text"]
302
+ "mˈɪstɚ kwˈɪltɚ ˈɪz ðə ˈeɪ pˈɑsəl ˈʌv ðə ˈmɪdəl klˈæsɪz ˈænd wˈɪɹ glæd tˈu ˈælkəm ˈhɪz gˈʌsbəl"
303
+
304
+ >>> # we can also return timestamps for the predictions
305
+ >>> prediction = pipe(sample.copy(), batch_size=8, return_timestamps=True)["chunks"]
306
+
307
+ Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.
308
+
309
+ ```
310
+
311
+ Refer to the blog post [ASR Chunking](https://huggingface.co/blog/asr-chunking) for more details on the chunking algorithm.
312
+
313
+ ## Fine-Tuning
314
+
315
+ The pre-trained Whisper model demonstrates a strong ability to generalise to different datasets and domains. However,
316
+ its predictive capabilities can be improved further for certain languages and tasks through *fine-tuning*. The blog
317
+ post [Fine-Tune Whisper with 🤗 Transformers](https://huggingface.co/blog/fine-tune-whisper) provides a step-by-step
318
+ guide to fine-tuning the Whisper model with as little as 5 hours of labelled data.
319
+
320
+ ### Evaluated Use
321
+
322
+ 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.
323
+
324
+ 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.
325
+
326
+ 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.
327
+
328
+
329
+ ## Training Data
330
+
331
+ 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.
332
+
333
+ 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.
334
+
335
+
336
+ ## Performance and Limitations
337
+
338
+ 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.
339
+
340
+ 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.
341
+
342
+ 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).
343
+
344
+ 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.
345
+
346
+
347
+ ## Broader Implications
348
+
349
+ 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.
350
+
351
+ 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.
352
+
353
+
354
+ ### BibTeX entry and citation info
355
+ ```bibtex
356
+ @misc{radford2022whisper,
357
+ doi = {10.48550/ARXIV.2212.04356},
358
+ url = {https://arxiv.org/abs/2212.04356},
359
+ author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
360
+ title = {Robust Speech Recognition via Large-Scale Weak Supervision},
361
+ publisher = {arXiv},
362
+ year = {2022},
363
+ copyright = {arXiv.org perpetual, non-exclusive license}
364
+ }
365
+ ```