kurianbenoy commited on
Commit
9e49e62
1 Parent(s): 078d20a

Training in progress, step 1000

Browse files
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ test.hf/ filter=lfs diff=lfs merge=lfs -text
.ipynb_checkpoints/fine-tune-whisper-non-streaming-checkpoint.ipynb ADDED
@@ -0,0 +1,1499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "75b58048-7d14-4fc6-8085-1fc08c81b4a6",
6
+ "metadata": {
7
+ "id": "75b58048-7d14-4fc6-8085-1fc08c81b4a6"
8
+ },
9
+ "source": [
10
+ "# Fine-Tune Whisper For Multilingual ASR with 🤗 Transformers"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "id": "fbfa8ad5-4cdc-4512-9058-836cbbf65e1a",
16
+ "metadata": {
17
+ "id": "fbfa8ad5-4cdc-4512-9058-836cbbf65e1a"
18
+ },
19
+ "source": [
20
+ "In this Colab, we present a step-by-step guide on how to fine-tune Whisper \n",
21
+ "for any multilingual ASR dataset using Hugging Face 🤗 Transformers. This is a \n",
22
+ "more \"hands-on\" version of the accompanying [blog post](https://huggingface.co/blog/fine-tune-whisper). \n",
23
+ "For a more in-depth explanation of Whisper, the Common Voice dataset and the theory behind fine-tuning, the reader is advised to refer to the blog post."
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "markdown",
28
+ "id": "afe0d503-ae4e-4aa7-9af4-dbcba52db41e",
29
+ "metadata": {
30
+ "id": "afe0d503-ae4e-4aa7-9af4-dbcba52db41e"
31
+ },
32
+ "source": [
33
+ "## Introduction"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "markdown",
38
+ "id": "9ae91ed4-9c3e-4ade-938e-f4c2dcfbfdc0",
39
+ "metadata": {
40
+ "id": "9ae91ed4-9c3e-4ade-938e-f4c2dcfbfdc0"
41
+ },
42
+ "source": [
43
+ "Whisper is a pre-trained model for automatic speech recognition (ASR) \n",
44
+ "published in [September 2022](https://openai.com/blog/whisper/) by the authors \n",
45
+ "Alec Radford et al. from OpenAI. Unlike many of its predecessors, such as \n",
46
+ "[Wav2Vec 2.0](https://arxiv.org/abs/2006.11477), which are pre-trained \n",
47
+ "on un-labelled audio data, Whisper is pre-trained on a vast quantity of \n",
48
+ "**labelled** audio-transcription data, 680,000 hours to be precise. \n",
49
+ "This is an order of magnitude more data than the un-labelled audio data used \n",
50
+ "to train Wav2Vec 2.0 (60,000 hours). What is more, 117,000 hours of this \n",
51
+ "pre-training data is multilingual ASR data. This results in checkpoints \n",
52
+ "that can be applied to over 96 languages, many of which are considered \n",
53
+ "_low-resource_.\n",
54
+ "\n",
55
+ "When scaled to 680,000 hours of labelled pre-training data, Whisper models \n",
56
+ "demonstrate a strong ability to generalise to many datasets and domains.\n",
57
+ "The pre-trained checkpoints achieve competitive results to state-of-the-art \n",
58
+ "ASR systems, with near 3% word error rate (WER) on the test-clean subset of \n",
59
+ "LibriSpeech ASR and a new state-of-the-art on TED-LIUM with 4.7% WER (_c.f._ \n",
60
+ "Table 8 of the [Whisper paper](https://cdn.openai.com/papers/whisper.pdf)).\n",
61
+ "The extensive multilingual ASR knowledge acquired by Whisper during pre-training \n",
62
+ "can be leveraged for other low-resource languages; through fine-tuning, the \n",
63
+ "pre-trained checkpoints can be adapted for specific datasets and languages \n",
64
+ "to further improve upon these results. We'll show just how Whisper can be fine-tuned \n",
65
+ "for low-resource languages in this Colab."
66
+ ]
67
+ },
68
+ {
69
+ "cell_type": "markdown",
70
+ "id": "e59b91d6-be24-4b5e-bb38-4977ea143a72",
71
+ "metadata": {
72
+ "id": "e59b91d6-be24-4b5e-bb38-4977ea143a72"
73
+ },
74
+ "source": [
75
+ "<figure>\n",
76
+ "<img src=\"https://raw.githubusercontent.com/sanchit-gandhi/notebooks/main/whisper_architecture.svg\" alt=\"Trulli\" style=\"width:100%\">\n",
77
+ "<figcaption align = \"center\"><b>Figure 1:</b> Whisper model. The architecture \n",
78
+ "follows the standard Transformer-based encoder-decoder model. A \n",
79
+ "log-Mel spectrogram is input to the encoder. The last encoder \n",
80
+ "hidden states are input to the decoder via cross-attention mechanisms. The \n",
81
+ "decoder autoregressively predicts text tokens, jointly conditional on the \n",
82
+ "encoder hidden states and previously predicted tokens. Figure source: \n",
83
+ "<a href=\"https://openai.com/blog/whisper/\">OpenAI Whisper Blog</a>.</figcaption>\n",
84
+ "</figure>"
85
+ ]
86
+ },
87
+ {
88
+ "cell_type": "markdown",
89
+ "id": "21b6316e-8a55-4549-a154-66d3da2ab74a",
90
+ "metadata": {
91
+ "id": "21b6316e-8a55-4549-a154-66d3da2ab74a"
92
+ },
93
+ "source": [
94
+ "The Whisper checkpoints come in five configurations of varying model sizes.\n",
95
+ "The smallest four are trained on either English-only or multilingual data.\n",
96
+ "The largest checkpoint is multilingual only. All nine of the pre-trained checkpoints \n",
97
+ "are available on the [Hugging Face Hub](https://huggingface.co/models?search=openai/whisper). The \n",
98
+ "checkpoints are summarised in the following table with links to the models on the Hub:\n",
99
+ "\n",
100
+ "| Size | Layers | Width | Heads | Parameters | English-only | Multilingual |\n",
101
+ "|--------|--------|-------|-------|------------|------------------------------------------------------|---------------------------------------------------|\n",
102
+ "| tiny | 4 | 384 | 6 | 39 M | [✓](https://huggingface.co/openai/whisper-tiny.en) | [✓](https://huggingface.co/openai/whisper-tiny.) |\n",
103
+ "| base | 6 | 512 | 8 | 74 M | [✓](https://huggingface.co/openai/whisper-base.en) | [✓](https://huggingface.co/openai/whisper-base) |\n",
104
+ "| small | 12 | 768 | 12 | 244 M | [✓](https://huggingface.co/openai/whisper-small.en) | [✓](https://huggingface.co/openai/whisper-small) |\n",
105
+ "| medium | 24 | 1024 | 16 | 769 M | [✓](https://huggingface.co/openai/whisper-medium.en) | [✓](https://huggingface.co/openai/whisper-medium) |\n",
106
+ "| large | 32 | 1280 | 20 | 1550 M | x | [✓](https://huggingface.co/openai/whisper-large) |\n",
107
+ "\n",
108
+ "For demonstration purposes, we'll fine-tune the multilingual version of the \n",
109
+ "[`\"small\"`](https://huggingface.co/openai/whisper-small) checkpoint with 244M params (~= 1GB). \n",
110
+ "As for our data, we'll train and evaluate our system on a low-resource language \n",
111
+ "taken from the [Common Voice](https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0)\n",
112
+ "dataset. We'll show that with as little as 8 hours of fine-tuning data, we can achieve \n",
113
+ "strong performance in this language."
114
+ ]
115
+ },
116
+ {
117
+ "cell_type": "markdown",
118
+ "id": "3a680dfc-cbba-4f6c-8a1f-e1a5ff3f123a",
119
+ "metadata": {
120
+ "id": "3a680dfc-cbba-4f6c-8a1f-e1a5ff3f123a"
121
+ },
122
+ "source": [
123
+ "------------------------------------------------------------------------\n",
124
+ "\n",
125
+ "\\\\({}^1\\\\) The name Whisper follows from the acronym “WSPSR”, which stands for “Web-scale Supervised Pre-training for Speech Recognition”."
126
+ ]
127
+ },
128
+ {
129
+ "cell_type": "markdown",
130
+ "id": "b219c9dd-39b6-4a95-b2a1-3f547a1e7bc0",
131
+ "metadata": {
132
+ "id": "b219c9dd-39b6-4a95-b2a1-3f547a1e7bc0"
133
+ },
134
+ "source": [
135
+ "## Load Dataset"
136
+ ]
137
+ },
138
+ {
139
+ "cell_type": "markdown",
140
+ "id": "674429c5-0ab4-4adf-975b-621bb69eca38",
141
+ "metadata": {
142
+ "id": "674429c5-0ab4-4adf-975b-621bb69eca38"
143
+ },
144
+ "source": [
145
+ "Using 🤗 Datasets, downloading and preparing data is extremely simple. \n",
146
+ "We can download and prepare the Common Voice splits in just one line of code. \n",
147
+ "\n",
148
+ "First, ensure you have accepted the terms of use on the Hugging Face Hub: [mozilla-foundation/common_voice_11_0](https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0). Once you have accepted the terms, you will have full access to the dataset and be able to download the data locally.\n",
149
+ "\n",
150
+ "Since Hindi is very low-resource, we'll combine the `train` and `validation` \n",
151
+ "splits to give approximately 8 hours of training data. We'll use the 4 hours \n",
152
+ "of `test` data as our held-out test set:"
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "code",
157
+ "execution_count": 6,
158
+ "id": "a2787582-554f-44ce-9f38-4180a5ed6b44",
159
+ "metadata": {
160
+ "id": "a2787582-554f-44ce-9f38-4180a5ed6b44"
161
+ },
162
+ "outputs": [
163
+ {
164
+ "name": "stderr",
165
+ "output_type": "stream",
166
+ "text": [
167
+ "Found cached dataset common_voice_11_0 (/home/.cache/huggingface/datasets/mozilla-foundation___common_voice_11_0/ta/11.0.0/f8e47235d9b4e68fa24ed71d63266a02018ccf7194b2a8c9c598a5f3ab304d9f)\n",
168
+ "Found cached dataset common_voice_11_0 (/home/.cache/huggingface/datasets/mozilla-foundation___common_voice_11_0/ta/11.0.0/f8e47235d9b4e68fa24ed71d63266a02018ccf7194b2a8c9c598a5f3ab304d9f)\n"
169
+ ]
170
+ },
171
+ {
172
+ "name": "stdout",
173
+ "output_type": "stream",
174
+ "text": [
175
+ "DatasetDict({\n",
176
+ " train: Dataset({\n",
177
+ " features: ['client_id', 'path', 'audio', 'sentence', 'up_votes', 'down_votes', 'age', 'gender', 'accent', 'locale', 'segment'],\n",
178
+ " num_rows: 13844\n",
179
+ " })\n",
180
+ " test: Dataset({\n",
181
+ " features: ['client_id', 'path', 'audio', 'sentence', 'up_votes', 'down_votes', 'age', 'gender', 'accent', 'locale', 'segment'],\n",
182
+ " num_rows: 591\n",
183
+ " })\n",
184
+ "})\n"
185
+ ]
186
+ }
187
+ ],
188
+ "source": [
189
+ "from datasets import load_dataset, DatasetDict\n",
190
+ "\n",
191
+ "common_voice = DatasetDict()\n",
192
+ "\n",
193
+ "common_voice[\"train\"] = load_dataset(\"mozilla-foundation/common_voice_11_0\", \"ta\", split=\"train[:5%]+validation\", use_auth_token=True)\n",
194
+ "common_voice[\"test\"] = load_dataset(\"mozilla-foundation/common_voice_11_0\", \"ta\", split=\"test[:5%]\", use_auth_token=True)\n",
195
+ "\n",
196
+ "print(common_voice)"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "markdown",
201
+ "id": "d5c7c3d6-7197-41e7-a088-49b753c1681f",
202
+ "metadata": {
203
+ "id": "d5c7c3d6-7197-41e7-a088-49b753c1681f"
204
+ },
205
+ "source": [
206
+ "Most ASR datasets only provide input audio samples (`audio`) and the \n",
207
+ "corresponding transcribed text (`sentence`). Common Voice contains additional \n",
208
+ "metadata information, such as `accent` and `locale`, which we can disregard for ASR.\n",
209
+ "Keeping the notebook as general as possible, we only consider the input audio and\n",
210
+ "transcribed text for fine-tuning, discarding the additional metadata information:"
211
+ ]
212
+ },
213
+ {
214
+ "cell_type": "code",
215
+ "execution_count": 7,
216
+ "id": "20ba635d-518c-47ac-97ee-3cad25f1e0ce",
217
+ "metadata": {
218
+ "id": "20ba635d-518c-47ac-97ee-3cad25f1e0ce"
219
+ },
220
+ "outputs": [
221
+ {
222
+ "name": "stdout",
223
+ "output_type": "stream",
224
+ "text": [
225
+ "DatasetDict({\n",
226
+ " train: Dataset({\n",
227
+ " features: ['audio', 'sentence'],\n",
228
+ " num_rows: 13844\n",
229
+ " })\n",
230
+ " test: Dataset({\n",
231
+ " features: ['audio', 'sentence'],\n",
232
+ " num_rows: 591\n",
233
+ " })\n",
234
+ "})\n"
235
+ ]
236
+ }
237
+ ],
238
+ "source": [
239
+ "common_voice = common_voice.remove_columns([\"accent\", \"age\", \"client_id\", \"down_votes\", \"gender\", \"locale\", \"path\", \"segment\", \"up_votes\"])\n",
240
+ "\n",
241
+ "print(common_voice)"
242
+ ]
243
+ },
244
+ {
245
+ "cell_type": "markdown",
246
+ "id": "2d63b2d2-f68a-4d74-b7f1-5127f6d16605",
247
+ "metadata": {
248
+ "id": "2d63b2d2-f68a-4d74-b7f1-5127f6d16605"
249
+ },
250
+ "source": [
251
+ "## Prepare Feature Extractor, Tokenizer and Data"
252
+ ]
253
+ },
254
+ {
255
+ "cell_type": "markdown",
256
+ "id": "601c3099-1026-439e-93e2-5635b3ba5a73",
257
+ "metadata": {
258
+ "id": "601c3099-1026-439e-93e2-5635b3ba5a73"
259
+ },
260
+ "source": [
261
+ "The ASR pipeline can be de-composed into three stages: \n",
262
+ "1) A feature extractor which pre-processes the raw audio-inputs\n",
263
+ "2) The model which performs the sequence-to-sequence mapping \n",
264
+ "3) A tokenizer which post-processes the model outputs to text format\n",
265
+ "\n",
266
+ "In 🤗 Transformers, the Whisper model has an associated feature extractor and tokenizer, \n",
267
+ "called [WhisperFeatureExtractor](https://huggingface.co/docs/transformers/main/model_doc/whisper#transformers.WhisperFeatureExtractor)\n",
268
+ "and [WhisperTokenizer](https://huggingface.co/docs/transformers/main/model_doc/whisper#transformers.WhisperTokenizer) \n",
269
+ "respectively.\n",
270
+ "\n",
271
+ "We'll go through details for setting-up the feature extractor and tokenizer one-by-one!"
272
+ ]
273
+ },
274
+ {
275
+ "cell_type": "markdown",
276
+ "id": "560332eb-3558-41a1-b500-e83a9f695f84",
277
+ "metadata": {
278
+ "id": "560332eb-3558-41a1-b500-e83a9f695f84"
279
+ },
280
+ "source": [
281
+ "### Load WhisperFeatureExtractor"
282
+ ]
283
+ },
284
+ {
285
+ "cell_type": "markdown",
286
+ "id": "32ec8068-0bd7-412d-b662-0edb9d1e7365",
287
+ "metadata": {
288
+ "id": "32ec8068-0bd7-412d-b662-0edb9d1e7365"
289
+ },
290
+ "source": [
291
+ "The Whisper feature extractor performs two operations:\n",
292
+ "1. Pads / truncates the audio inputs to 30s: any audio inputs shorter than 30s are padded to 30s with silence (zeros), and those longer that 30s are truncated to 30s\n",
293
+ "2. Converts the audio inputs to _log-Mel spectrogram_ input features, a visual representation of the audio and the form of the input expected by the Whisper model"
294
+ ]
295
+ },
296
+ {
297
+ "cell_type": "markdown",
298
+ "id": "589d9ec1-d12b-4b64-93f7-04c63997da19",
299
+ "metadata": {
300
+ "id": "589d9ec1-d12b-4b64-93f7-04c63997da19"
301
+ },
302
+ "source": [
303
+ "<figure>\n",
304
+ "<img src=\"https://raw.githubusercontent.com/sanchit-gandhi/notebooks/main/spectrogram.jpg\" alt=\"Trulli\" style=\"width:100%\">\n",
305
+ "<figcaption align = \"center\"><b>Figure 2:</b> Conversion of sampled audio array to log-Mel spectrogram.\n",
306
+ "Left: sampled 1-dimensional audio signal. Right: corresponding log-Mel spectrogram. Figure source:\n",
307
+ "<a href=\"https://ai.googleblog.com/2019/04/specaugment-new-data-augmentation.html\">Google SpecAugment Blog</a>.\n",
308
+ "</figcaption>"
309
+ ]
310
+ },
311
+ {
312
+ "cell_type": "markdown",
313
+ "id": "b2ef54d5-b946-4c1d-9fdc-adc5d01b46aa",
314
+ "metadata": {
315
+ "id": "b2ef54d5-b946-4c1d-9fdc-adc5d01b46aa"
316
+ },
317
+ "source": [
318
+ "We'll load the feature extractor from the pre-trained checkpoint with the default values:"
319
+ ]
320
+ },
321
+ {
322
+ "cell_type": "code",
323
+ "execution_count": 1,
324
+ "id": "bc77d7bb-f9e2-47f5-b663-30f7a4321ce5",
325
+ "metadata": {
326
+ "id": "bc77d7bb-f9e2-47f5-b663-30f7a4321ce5"
327
+ },
328
+ "outputs": [],
329
+ "source": [
330
+ "from transformers import WhisperFeatureExtractor\n",
331
+ "\n",
332
+ "feature_extractor = WhisperFeatureExtractor.from_pretrained(\"openai/whisper-medium\")"
333
+ ]
334
+ },
335
+ {
336
+ "cell_type": "markdown",
337
+ "id": "93748af7-b917-4ecf-a0c8-7d89077ff9cb",
338
+ "metadata": {
339
+ "id": "93748af7-b917-4ecf-a0c8-7d89077ff9cb"
340
+ },
341
+ "source": [
342
+ "### Load WhisperTokenizer"
343
+ ]
344
+ },
345
+ {
346
+ "cell_type": "markdown",
347
+ "id": "2bc82609-a9fb-447a-a2af-99597c864029",
348
+ "metadata": {
349
+ "id": "2bc82609-a9fb-447a-a2af-99597c864029"
350
+ },
351
+ "source": [
352
+ "The Whisper model outputs a sequence of _token ids_. The tokenizer maps each of these token ids to their corresponding text string. For Hindi, we can load the pre-trained tokenizer and use it for fine-tuning without any further modifications. We simply have to \n",
353
+ "specify the target language and the task. These arguments inform the \n",
354
+ "tokenizer to prefix the language and task tokens to the start of encoded \n",
355
+ "label sequences:"
356
+ ]
357
+ },
358
+ {
359
+ "cell_type": "code",
360
+ "execution_count": 2,
361
+ "id": "c7b07f9b-ae0e-4f89-98f0-0c50d432eab6",
362
+ "metadata": {
363
+ "id": "c7b07f9b-ae0e-4f89-98f0-0c50d432eab6",
364
+ "outputId": "5c004b44-86e7-4e00-88be-39e0af5eed69"
365
+ },
366
+ "outputs": [],
367
+ "source": [
368
+ "from transformers import WhisperTokenizer\n",
369
+ "\n",
370
+ "tokenizer = WhisperTokenizer.from_pretrained(\"openai/whisper-medium\", language=\"Tamil\", task=\"transcribe\")"
371
+ ]
372
+ },
373
+ {
374
+ "cell_type": "markdown",
375
+ "id": "d2ef23f3-f4a8-483a-a2dc-080a7496cb1b",
376
+ "metadata": {
377
+ "id": "d2ef23f3-f4a8-483a-a2dc-080a7496cb1b"
378
+ },
379
+ "source": [
380
+ "### Combine To Create A WhisperProcessor"
381
+ ]
382
+ },
383
+ {
384
+ "cell_type": "markdown",
385
+ "id": "5ff67654-5a29-4bb8-a69d-0228946c6f8d",
386
+ "metadata": {
387
+ "id": "5ff67654-5a29-4bb8-a69d-0228946c6f8d"
388
+ },
389
+ "source": [
390
+ "To simplify using the feature extractor and tokenizer, we can _wrap_ \n",
391
+ "both into a single `WhisperProcessor` class. This processor object \n",
392
+ "inherits from the `WhisperFeatureExtractor` and `WhisperProcessor`, \n",
393
+ "and can be used on the audio inputs and model predictions as required. \n",
394
+ "In doing so, we only need to keep track of two objects during training: \n",
395
+ "the `processor` and the `model`:"
396
+ ]
397
+ },
398
+ {
399
+ "cell_type": "code",
400
+ "execution_count": 3,
401
+ "id": "77d9f0c5-8607-4642-a8ac-c3ab2e223ea6",
402
+ "metadata": {
403
+ "id": "77d9f0c5-8607-4642-a8ac-c3ab2e223ea6"
404
+ },
405
+ "outputs": [],
406
+ "source": [
407
+ "from transformers import WhisperProcessor\n",
408
+ "\n",
409
+ "processor = WhisperProcessor.from_pretrained(\"openai/whisper-medium\", language=\"Tamil\", task=\"transcribe\")"
410
+ ]
411
+ },
412
+ {
413
+ "cell_type": "markdown",
414
+ "id": "381acd09-0b0f-4d04-9eb3-f028ac0e5f2c",
415
+ "metadata": {
416
+ "id": "381acd09-0b0f-4d04-9eb3-f028ac0e5f2c"
417
+ },
418
+ "source": [
419
+ "### Prepare Data"
420
+ ]
421
+ },
422
+ {
423
+ "cell_type": "markdown",
424
+ "id": "9649bf01-2e8a-45e5-8fca-441c13637b8f",
425
+ "metadata": {
426
+ "id": "9649bf01-2e8a-45e5-8fca-441c13637b8f"
427
+ },
428
+ "source": [
429
+ "Let's print the first example of the Common Voice dataset to see \n",
430
+ "what form the data is in:"
431
+ ]
432
+ },
433
+ {
434
+ "cell_type": "code",
435
+ "execution_count": 11,
436
+ "id": "6e6b0ec5-0c94-4e2c-ae24-c791be1b2255",
437
+ "metadata": {
438
+ "id": "6e6b0ec5-0c94-4e2c-ae24-c791be1b2255"
439
+ },
440
+ "outputs": [
441
+ {
442
+ "name": "stdout",
443
+ "output_type": "stream",
444
+ "text": [
445
+ "{'audio': {'path': '/home/.cache/huggingface/datasets/downloads/extracted/9ac554f4db6808cc4578c6e0dc9e1e3e8f6d0feadca38dbc0116789d55bcfcbb/common_voice_ta_26650298.mp3', 'array': array([0., 0., 0., ..., 0., 0., 0.], dtype=float32), 'sampling_rate': 48000}, 'sentence': 'அவரைப் பொதுமக்கள் விடாமல் பின்னாலேயே துரத்திக் கொண்டே ஓடினார்கள்.'}\n"
446
+ ]
447
+ }
448
+ ],
449
+ "source": [
450
+ "print(common_voice[\"train\"][0])"
451
+ ]
452
+ },
453
+ {
454
+ "cell_type": "markdown",
455
+ "id": "5a679f05-063d-41b3-9b58-4fc9c6ccf4fd",
456
+ "metadata": {
457
+ "id": "5a679f05-063d-41b3-9b58-4fc9c6ccf4fd"
458
+ },
459
+ "source": [
460
+ "Since \n",
461
+ "our input audio is sampled at 48kHz, we need to _downsample_ it to \n",
462
+ "16kHz prior to passing it to the Whisper feature extractor, 16kHz being the sampling rate expected by the Whisper model. \n",
463
+ "\n",
464
+ "We'll set the audio inputs to the correct sampling rate using dataset's \n",
465
+ "[`cast_column`](https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=cast_column#datasets.DatasetDict.cast_column)\n",
466
+ "method. This operation does not change the audio in-place, \n",
467
+ "but rather signals to `datasets` to resample audio samples _on the fly_ the \n",
468
+ "first time that they are loaded:"
469
+ ]
470
+ },
471
+ {
472
+ "cell_type": "code",
473
+ "execution_count": 12,
474
+ "id": "f12e2e57-156f-417b-8cfb-69221cc198e8",
475
+ "metadata": {
476
+ "id": "f12e2e57-156f-417b-8cfb-69221cc198e8"
477
+ },
478
+ "outputs": [],
479
+ "source": [
480
+ "from datasets import Audio\n",
481
+ "\n",
482
+ "common_voice = common_voice.cast_column(\"audio\", Audio(sampling_rate=16000))"
483
+ ]
484
+ },
485
+ {
486
+ "cell_type": "markdown",
487
+ "id": "00382a3e-abec-4cdd-a54c-d1aaa3ea4707",
488
+ "metadata": {
489
+ "id": "00382a3e-abec-4cdd-a54c-d1aaa3ea4707"
490
+ },
491
+ "source": [
492
+ "Re-loading the first audio sample in the Common Voice dataset will resample \n",
493
+ "it to the desired sampling rate:"
494
+ ]
495
+ },
496
+ {
497
+ "cell_type": "code",
498
+ "execution_count": 13,
499
+ "id": "87122d71-289a-466a-afcf-fa354b18946b",
500
+ "metadata": {
501
+ "id": "87122d71-289a-466a-afcf-fa354b18946b"
502
+ },
503
+ "outputs": [
504
+ {
505
+ "name": "stdout",
506
+ "output_type": "stream",
507
+ "text": [
508
+ "{'audio': {'path': '/home/.cache/huggingface/datasets/downloads/extracted/9ac554f4db6808cc4578c6e0dc9e1e3e8f6d0feadca38dbc0116789d55bcfcbb/common_voice_ta_26650298.mp3', 'array': array([0., 0., 0., ..., 0., 0., 0.], dtype=float32), 'sampling_rate': 16000}, 'sentence': 'அவரைப் பொதுமக்கள் விடாமல் பின்னாலேயே துரத்திக் கொண்டே ஓடினார்கள்.'}\n"
509
+ ]
510
+ }
511
+ ],
512
+ "source": [
513
+ "print(common_voice[\"train\"][0])"
514
+ ]
515
+ },
516
+ {
517
+ "cell_type": "markdown",
518
+ "id": "3df7378a-a4c0-45d7-8d07-defbd1062ab6",
519
+ "metadata": {},
520
+ "source": [
521
+ "We'll define our pre-processing strategy. We advise that you **do not** lower-case the transcriptions or remove punctuation unless mixing different datasets. This will enable you to fine-tune Whisper models that can predict punctuation and casing. Later, you will see how we can evaluate the predictions without punctuation or casing, so that the models benefit from the WER improvement obtained by normalising the transcriptions while still predicting fully formatted transcriptions."
522
+ ]
523
+ },
524
+ {
525
+ "cell_type": "code",
526
+ "execution_count": 4,
527
+ "id": "f8c4d7e6-6f51-44b0-b197-dccea8631c88",
528
+ "metadata": {},
529
+ "outputs": [],
530
+ "source": [
531
+ "import re\n",
532
+ "import unicodedata\n",
533
+ "\n",
534
+ "import regex\n",
535
+ "\n",
536
+ "# non-ASCII letters that are not separated by \"NFKD\" normalization\n",
537
+ "ADDITIONAL_DIACRITICS = {\n",
538
+ " \"œ\": \"oe\",\n",
539
+ " \"Œ\": \"OE\",\n",
540
+ " \"ø\": \"o\",\n",
541
+ " \"Ø\": \"O\",\n",
542
+ " \"æ\": \"ae\",\n",
543
+ " \"Æ\": \"AE\",\n",
544
+ " \"ß\": \"ss\",\n",
545
+ " \"ẞ\": \"SS\",\n",
546
+ " \"đ\": \"d\",\n",
547
+ " \"Đ\": \"D\",\n",
548
+ " \"ð\": \"d\",\n",
549
+ " \"Ð\": \"D\",\n",
550
+ " \"þ\": \"th\",\n",
551
+ " \"Þ\": \"th\",\n",
552
+ " \"ł\": \"l\",\n",
553
+ " \"Ł\": \"L\",\n",
554
+ "}\n",
555
+ "\n",
556
+ "\n",
557
+ "def remove_symbols_and_diacritics(s: str, keep=\"\"):\n",
558
+ " \"\"\"\n",
559
+ " Replace any other markers, symbols, and punctuations with a space,\n",
560
+ " and drop any diacritics (category 'Mn' and some manual mappings)\n",
561
+ " \"\"\"\n",
562
+ " return \"\".join(\n",
563
+ " c\n",
564
+ " if c in keep\n",
565
+ " else ADDITIONAL_DIACRITICS[c]\n",
566
+ " if c in ADDITIONAL_DIACRITICS\n",
567
+ " else \"\"\n",
568
+ " if unicodedata.category(c) == \"Mn\"\n",
569
+ " else \" \"\n",
570
+ " if unicodedata.category(c)[0] in \"MSP\"\n",
571
+ " else c\n",
572
+ " for c in unicodedata.normalize(\"NFKD\", s)\n",
573
+ " )\n",
574
+ "\n",
575
+ "\n",
576
+ "def remove_symbols(s: str):\n",
577
+ " \"\"\"\n",
578
+ " Replace any other markers, symbols, punctuations with a space, keeping diacritics\n",
579
+ " \"\"\"\n",
580
+ " return \"\".join(\n",
581
+ " \" \" if unicodedata.category(c)[0] in \"MSP\" else c for c in unicodedata.normalize(\"NFKC\", s)\n",
582
+ " )\n",
583
+ "\n",
584
+ "\n",
585
+ "class BasicTextNormalizer:\n",
586
+ " def __init__(self, remove_diacritics: bool = False, split_letters: bool = False):\n",
587
+ " self.clean = remove_symbols_and_diacritics if remove_diacritics else remove_symbols\n",
588
+ " self.split_letters = split_letters\n",
589
+ "\n",
590
+ " def __call__(self, s: str):\n",
591
+ " s = s.lower()\n",
592
+ " s = re.sub(r\"[<\\[][^>\\]]*[>\\]]\", \"\", s) # remove words between brackets\n",
593
+ " s = re.sub(r\"\\(([^)]+?)\\)\", \"\", s) # remove words between parenthesis\n",
594
+ " s = self.clean(s).lower()\n",
595
+ "\n",
596
+ " if self.split_letters:\n",
597
+ " s = \" \".join(regex.findall(r\"\\X\", s, regex.U))\n",
598
+ "\n",
599
+ " s = re.sub(r\"\\s+\", \" \", s) # replace any successive whitespace characters with a space\n",
600
+ "\n",
601
+ " return s\n"
602
+ ]
603
+ },
604
+ {
605
+ "cell_type": "code",
606
+ "execution_count": 5,
607
+ "id": "d041650e-1c48-4439-87b3-5b6f4a514107",
608
+ "metadata": {},
609
+ "outputs": [],
610
+ "source": [
611
+ "# from transformers.models.whisper.english_normalizer import BasicTextNormalizer\n",
612
+ "\n",
613
+ "do_lower_case = False\n",
614
+ "do_remove_punctuation = False\n",
615
+ "\n",
616
+ "normalizer = BasicTextNormalizer()"
617
+ ]
618
+ },
619
+ {
620
+ "cell_type": "markdown",
621
+ "id": "89e12c2e-2f14-479b-987b-f0c75c881095",
622
+ "metadata": {},
623
+ "source": [
624
+ "Now we can write a function to prepare our data ready for the model:\n",
625
+ "1. We load and resample the audio data by calling `batch[\"audio\"]`. As explained above, 🤗 Datasets performs any necessary resampling operations on the fly.\n",
626
+ "2. We use the feature extractor to compute the log-Mel spectrogram input features from our 1-dimensional audio array.\n",
627
+ "3. We perform any optional pre-processing (lower-case or remove punctuation).\n",
628
+ "4. We encode the transcriptions to label ids through the use of the tokenizer."
629
+ ]
630
+ },
631
+ {
632
+ "cell_type": "code",
633
+ "execution_count": 16,
634
+ "id": "c085911c-a10a-41ef-8874-306e0503e9bb",
635
+ "metadata": {},
636
+ "outputs": [],
637
+ "source": [
638
+ "def prepare_dataset(batch):\n",
639
+ " # load and (possibly) resample audio data to 16kHz\n",
640
+ " audio = batch[\"audio\"]\n",
641
+ "\n",
642
+ " # compute log-Mel input features from input audio array \n",
643
+ " batch[\"input_features\"] = processor.feature_extractor(audio[\"array\"], sampling_rate=audio[\"sampling_rate\"]).input_features[0]\n",
644
+ " # compute input length of audio sample in seconds\n",
645
+ " batch[\"input_length\"] = len(audio[\"array\"]) / audio[\"sampling_rate\"]\n",
646
+ " \n",
647
+ " # optional pre-processing steps\n",
648
+ " transcription = batch[\"sentence\"]\n",
649
+ " if do_lower_case:\n",
650
+ " transcription = transcription.lower()\n",
651
+ " if do_remove_punctuation:\n",
652
+ " transcription = normalizer(transcription).strip()\n",
653
+ " \n",
654
+ " # encode target text to label ids\n",
655
+ " batch[\"labels\"] = processor.tokenizer(transcription).input_ids\n",
656
+ " return batch"
657
+ ]
658
+ },
659
+ {
660
+ "cell_type": "markdown",
661
+ "id": "8c960965-9fb6-466f-9dbd-c9d43e71d9d0",
662
+ "metadata": {
663
+ "id": "70b319fb-2439-4ef6-a70d-a47bf41c4a13"
664
+ },
665
+ "source": [
666
+ "We can apply the data preparation function to all of our training examples using dataset's `.map` method. The argument `num_proc` specifies how many CPU cores to use. Setting `num_proc` > 1 will enable multiprocessing. If the `.map` method hangs with multiprocessing, set `num_proc=1` and process the dataset sequentially."
667
+ ]
668
+ },
669
+ {
670
+ "cell_type": "code",
671
+ "execution_count": 17,
672
+ "id": "7b73ab39-ffaf-4b9e-86e5-782963c6134b",
673
+ "metadata": {
674
+ "id": "7b73ab39-ffaf-4b9e-86e5-782963c6134b"
675
+ },
676
+ "outputs": [
677
+ {
678
+ "data": {
679
+ "application/json": {
680
+ "ascii": false,
681
+ "bar_format": null,
682
+ "colour": null,
683
+ "elapsed": 0.021223068237304688,
684
+ "initial": 0,
685
+ "n": 0,
686
+ "ncols": null,
687
+ "nrows": null,
688
+ "postfix": null,
689
+ "prefix": "",
690
+ "rate": null,
691
+ "total": 13844,
692
+ "unit": "ex",
693
+ "unit_divisor": 1000,
694
+ "unit_scale": false
695
+ },
696
+ "application/vnd.jupyter.widget-view+json": {
697
+ "model_id": "3fa362fc9d394a4482a000a4c11a5970",
698
+ "version_major": 2,
699
+ "version_minor": 0
700
+ },
701
+ "text/plain": [
702
+ " 0%| | 0/13844 [00:00<?, ?ex/s]"
703
+ ]
704
+ },
705
+ "metadata": {},
706
+ "output_type": "display_data"
707
+ },
708
+ {
709
+ "data": {
710
+ "application/json": {
711
+ "ascii": false,
712
+ "bar_format": null,
713
+ "colour": null,
714
+ "elapsed": 0.018386363983154297,
715
+ "initial": 0,
716
+ "n": 0,
717
+ "ncols": null,
718
+ "nrows": null,
719
+ "postfix": null,
720
+ "prefix": "",
721
+ "rate": null,
722
+ "total": 591,
723
+ "unit": "ex",
724
+ "unit_divisor": 1000,
725
+ "unit_scale": false
726
+ },
727
+ "application/vnd.jupyter.widget-view+json": {
728
+ "model_id": "0bd5345430714c5a921f00ecf5ae79b2",
729
+ "version_major": 2,
730
+ "version_minor": 0
731
+ },
732
+ "text/plain": [
733
+ " 0%| | 0/591 [00:00<?, ?ex/s]"
734
+ ]
735
+ },
736
+ "metadata": {},
737
+ "output_type": "display_data"
738
+ }
739
+ ],
740
+ "source": [
741
+ "common_voice = common_voice.map(prepare_dataset, remove_columns=common_voice.column_names[\"train\"], num_proc=1)"
742
+ ]
743
+ },
744
+ {
745
+ "cell_type": "markdown",
746
+ "id": "54ce0fdb-7218-4a4d-b175-383980fec0df",
747
+ "metadata": {},
748
+ "source": [
749
+ "Finally, we filter any training data with audio samples longer than 30s. These samples would otherwise be truncated by the Whisper feature-extractor which could affect the stability of training. We define a function that returns `True` for samples that are less than 30s, and `False` for those that are longer:"
750
+ ]
751
+ },
752
+ {
753
+ "cell_type": "code",
754
+ "execution_count": 7,
755
+ "id": "01cb25ef-4bb0-4325-9461-f59198acadf6",
756
+ "metadata": {},
757
+ "outputs": [],
758
+ "source": [
759
+ "max_input_length = 30.0\n",
760
+ "\n",
761
+ "def is_audio_in_length_range(length):\n",
762
+ " return length < max_input_length"
763
+ ]
764
+ },
765
+ {
766
+ "cell_type": "code",
767
+ "execution_count": 19,
768
+ "id": "33391c48-5b77-4d74-b4b9-efb62c1ffc91",
769
+ "metadata": {},
770
+ "outputs": [],
771
+ "source": [
772
+ "common_voice.save_to_disk(\"test.hf\")"
773
+ ]
774
+ },
775
+ {
776
+ "cell_type": "code",
777
+ "execution_count": 8,
778
+ "id": "9782c3b2-172f-4c3d-8b9f-109054ff44f4",
779
+ "metadata": {},
780
+ "outputs": [],
781
+ "source": [
782
+ "from datasets import load_from_disk"
783
+ ]
784
+ },
785
+ {
786
+ "cell_type": "code",
787
+ "execution_count": 9,
788
+ "id": "5875baad-1946-482c-ad84-6f7683e75a13",
789
+ "metadata": {},
790
+ "outputs": [],
791
+ "source": [
792
+ "common_voice = load_from_disk(\"test.hf\")"
793
+ ]
794
+ },
795
+ {
796
+ "cell_type": "code",
797
+ "execution_count": 10,
798
+ "id": "929011bf-e4d7-4a13-881c-b9c68e85e703",
799
+ "metadata": {},
800
+ "outputs": [
801
+ {
802
+ "data": {
803
+ "text/plain": [
804
+ "Dataset({\n",
805
+ " features: ['input_features', 'input_length', 'labels'],\n",
806
+ " num_rows: 13844\n",
807
+ "})"
808
+ ]
809
+ },
810
+ "execution_count": 10,
811
+ "metadata": {},
812
+ "output_type": "execute_result"
813
+ }
814
+ ],
815
+ "source": [
816
+ "common_voice[\"train\"]"
817
+ ]
818
+ },
819
+ {
820
+ "cell_type": "markdown",
821
+ "id": "30e676a8-7ca8-4850-8c5d-5b2b00d13fba",
822
+ "metadata": {},
823
+ "source": [
824
+ "We apply our filter function to all samples of our training dataset through 🤗 Datasets' `.filter` method:"
825
+ ]
826
+ },
827
+ {
828
+ "cell_type": "code",
829
+ "execution_count": 11,
830
+ "id": "333f7f6e-6053-4d3b-8924-c733c79b82ac",
831
+ "metadata": {},
832
+ "outputs": [
833
+ {
834
+ "data": {
835
+ "application/json": {
836
+ "ascii": false,
837
+ "bar_format": null,
838
+ "colour": null,
839
+ "elapsed": 0.02457904815673828,
840
+ "initial": 0,
841
+ "n": 0,
842
+ "ncols": null,
843
+ "nrows": null,
844
+ "postfix": null,
845
+ "prefix": "",
846
+ "rate": null,
847
+ "total": 14,
848
+ "unit": "ba",
849
+ "unit_divisor": 1000,
850
+ "unit_scale": false
851
+ },
852
+ "application/vnd.jupyter.widget-view+json": {
853
+ "model_id": "2d776c795399476ba30d0124b3cbfb88",
854
+ "version_major": 2,
855
+ "version_minor": 0
856
+ },
857
+ "text/plain": [
858
+ " 0%| | 0/14 [00:00<?, ?ba/s]"
859
+ ]
860
+ },
861
+ "metadata": {},
862
+ "output_type": "display_data"
863
+ }
864
+ ],
865
+ "source": [
866
+ "common_voice[\"train\"] = common_voice[\"train\"].filter(\n",
867
+ " is_audio_in_length_range,\n",
868
+ " input_columns=[\"input_length\"],\n",
869
+ ")"
870
+ ]
871
+ },
872
+ {
873
+ "cell_type": "markdown",
874
+ "id": "263a5a58-0239-4a25-b0df-c625fc9c5810",
875
+ "metadata": {
876
+ "id": "263a5a58-0239-4a25-b0df-c625fc9c5810"
877
+ },
878
+ "source": [
879
+ "## Training and Evaluation"
880
+ ]
881
+ },
882
+ {
883
+ "cell_type": "markdown",
884
+ "id": "a693e768-c5a6-453f-89a1-b601dcf7daf7",
885
+ "metadata": {
886
+ "id": "a693e768-c5a6-453f-89a1-b601dcf7daf7"
887
+ },
888
+ "source": [
889
+ "Now that we've prepared our data, we're ready to dive into the training pipeline. \n",
890
+ "The [🤗 Trainer](https://huggingface.co/transformers/master/main_classes/trainer.html?highlight=trainer)\n",
891
+ "will do much of the heavy lifting for us. All we have to do is:\n",
892
+ "\n",
893
+ "- Define a data collator: the data collator takes our pre-processed data and prepares PyTorch tensors ready for the model.\n",
894
+ "\n",
895
+ "- Evaluation metrics: during evaluation, we want to evaluate the model using the [word error rate (WER)](https://huggingface.co/metrics/wer) metric. We need to define a `compute_metrics` function that handles this computation.\n",
896
+ "\n",
897
+ "- Load a pre-trained checkpoint: we need to load a pre-trained checkpoint and configure it correctly for training.\n",
898
+ "\n",
899
+ "- Define the training configuration: this will be used by the 🤗 Trainer to define the training schedule.\n",
900
+ "\n",
901
+ "Once we've fine-tuned the model, we will evaluate it on the test data to verify that we have correctly trained it \n",
902
+ "to transcribe speech in Hindi."
903
+ ]
904
+ },
905
+ {
906
+ "cell_type": "markdown",
907
+ "id": "8d230e6d-624c-400a-bbf5-fa660881df25",
908
+ "metadata": {
909
+ "id": "8d230e6d-624c-400a-bbf5-fa660881df25"
910
+ },
911
+ "source": [
912
+ "### Define a Data Collator"
913
+ ]
914
+ },
915
+ {
916
+ "cell_type": "markdown",
917
+ "id": "04def221-0637-4a69-b242-d3f0c1d0ee78",
918
+ "metadata": {
919
+ "id": "04def221-0637-4a69-b242-d3f0c1d0ee78"
920
+ },
921
+ "source": [
922
+ "The data collator for a sequence-to-sequence speech model is unique in the sense that it \n",
923
+ "treats the `input_features` and `labels` independently: the `input_features` must be \n",
924
+ "handled by the feature extractor and the `labels` by the tokenizer.\n",
925
+ "\n",
926
+ "The `input_features` are already padded to 30s and converted to a log-Mel spectrogram \n",
927
+ "of fixed dimension by action of the feature extractor, so all we have to do is convert the `input_features`\n",
928
+ "to batched PyTorch tensors. We do this using the feature extractor's `.pad` method with `return_tensors=pt`.\n",
929
+ "\n",
930
+ "The `labels` on the other hand are un-padded. We first pad the sequences\n",
931
+ "to the maximum length in the batch using the tokenizer's `.pad` method. The padding tokens \n",
932
+ "are then replaced by `-100` so that these tokens are **not** taken into account when \n",
933
+ "computing the loss. We then cut the BOS token from the start of the label sequence as we \n",
934
+ "append it later during training.\n",
935
+ "\n",
936
+ "We can leverage the `WhisperProcessor` we defined earlier to perform both the \n",
937
+ "feature extractor and the tokenizer operations:"
938
+ ]
939
+ },
940
+ {
941
+ "cell_type": "code",
942
+ "execution_count": 12,
943
+ "id": "8326221e-ec13-4731-bb4e-51e5fc1486c5",
944
+ "metadata": {
945
+ "id": "8326221e-ec13-4731-bb4e-51e5fc1486c5"
946
+ },
947
+ "outputs": [],
948
+ "source": [
949
+ "import torch\n",
950
+ "\n",
951
+ "from dataclasses import dataclass\n",
952
+ "from typing import Any, Dict, List, Union\n",
953
+ "\n",
954
+ "@dataclass\n",
955
+ "class DataCollatorSpeechSeq2SeqWithPadding:\n",
956
+ " processor: Any\n",
957
+ "\n",
958
+ " def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -> Dict[str, torch.Tensor]:\n",
959
+ " # split inputs and labels since they have to be of different lengths and need different padding methods\n",
960
+ " # first treat the audio inputs by simply returning torch tensors\n",
961
+ " input_features = [{\"input_features\": feature[\"input_features\"]} for feature in features]\n",
962
+ " batch = self.processor.feature_extractor.pad(input_features, return_tensors=\"pt\")\n",
963
+ "\n",
964
+ " # get the tokenized label sequences\n",
965
+ " label_features = [{\"input_ids\": feature[\"labels\"]} for feature in features]\n",
966
+ " # pad the labels to max length\n",
967
+ " labels_batch = self.processor.tokenizer.pad(label_features, return_tensors=\"pt\")\n",
968
+ "\n",
969
+ " # replace padding with -100 to ignore loss correctly\n",
970
+ " labels = labels_batch[\"input_ids\"].masked_fill(labels_batch.attention_mask.ne(1), -100)\n",
971
+ "\n",
972
+ " # if bos token is appended in previous tokenization step,\n",
973
+ " # cut bos token here as it's append later anyways\n",
974
+ " if (labels[:, 0] == self.processor.tokenizer.bos_token_id).all().cpu().item():\n",
975
+ " labels = labels[:, 1:]\n",
976
+ "\n",
977
+ " batch[\"labels\"] = labels\n",
978
+ "\n",
979
+ " return batch"
980
+ ]
981
+ },
982
+ {
983
+ "cell_type": "markdown",
984
+ "id": "3cae7dbf-8a50-456e-a3a8-7fd005390f86",
985
+ "metadata": {
986
+ "id": "3cae7dbf-8a50-456e-a3a8-7fd005390f86"
987
+ },
988
+ "source": [
989
+ "Let's initialise the data collator we've just defined:"
990
+ ]
991
+ },
992
+ {
993
+ "cell_type": "code",
994
+ "execution_count": 13,
995
+ "id": "fc834702-c0d3-4a96-b101-7b87be32bf42",
996
+ "metadata": {
997
+ "id": "fc834702-c0d3-4a96-b101-7b87be32bf42"
998
+ },
999
+ "outputs": [],
1000
+ "source": [
1001
+ "data_collator = DataCollatorSpeechSeq2SeqWithPadding(processor=processor)"
1002
+ ]
1003
+ },
1004
+ {
1005
+ "cell_type": "markdown",
1006
+ "id": "d62bb2ab-750a-45e7-82e9-61d6f4805698",
1007
+ "metadata": {
1008
+ "id": "d62bb2ab-750a-45e7-82e9-61d6f4805698"
1009
+ },
1010
+ "source": [
1011
+ "### Evaluation Metrics"
1012
+ ]
1013
+ },
1014
+ {
1015
+ "cell_type": "markdown",
1016
+ "id": "66fee1a7-a44c-461e-b047-c3917221572e",
1017
+ "metadata": {
1018
+ "id": "66fee1a7-a44c-461e-b047-c3917221572e"
1019
+ },
1020
+ "source": [
1021
+ "We'll use the word error rate (WER) metric, the 'de-facto' metric for assessing \n",
1022
+ "ASR systems. For more information, refer to the WER [docs](https://huggingface.co/metrics/wer). We'll load the WER metric from 🤗 Evaluate:"
1023
+ ]
1024
+ },
1025
+ {
1026
+ "cell_type": "code",
1027
+ "execution_count": 14,
1028
+ "id": "b22b4011-f31f-4b57-b684-c52332f92890",
1029
+ "metadata": {
1030
+ "id": "b22b4011-f31f-4b57-b684-c52332f92890"
1031
+ },
1032
+ "outputs": [],
1033
+ "source": [
1034
+ "import evaluate\n",
1035
+ "\n",
1036
+ "metric = evaluate.load(\"wer\")"
1037
+ ]
1038
+ },
1039
+ {
1040
+ "cell_type": "markdown",
1041
+ "id": "4f32cab6-31f0-4cb9-af4c-40ba0f5fc508",
1042
+ "metadata": {
1043
+ "id": "4f32cab6-31f0-4cb9-af4c-40ba0f5fc508"
1044
+ },
1045
+ "source": [
1046
+ "We then simply have to define a function that takes our model \n",
1047
+ "predictions and returns the WER metric. This function, called\n",
1048
+ "`compute_metrics`, first replaces `-100` with the `pad_token_id`\n",
1049
+ "in the `label_ids` (undoing the step we applied in the \n",
1050
+ "data collator to ignore padded tokens correctly in the loss).\n",
1051
+ "It then decodes the predicted and label ids to strings. Finally,\n",
1052
+ "it computes the WER between the predictions and reference labels. \n",
1053
+ "Here, we have the option of evaluating with the 'normalised' transcriptions \n",
1054
+ "and predictions. We recommend you set this to `True` to benefit from the WER \n",
1055
+ "improvement obtained by normalising the transcriptions."
1056
+ ]
1057
+ },
1058
+ {
1059
+ "cell_type": "code",
1060
+ "execution_count": 15,
1061
+ "id": "23959a70-22d0-4ffe-9fa1-72b61e75bb52",
1062
+ "metadata": {
1063
+ "id": "23959a70-22d0-4ffe-9fa1-72b61e75bb52"
1064
+ },
1065
+ "outputs": [],
1066
+ "source": [
1067
+ "# evaluate with the 'normalised' WER\n",
1068
+ "do_normalize_eval = True\n",
1069
+ "\n",
1070
+ "def compute_metrics(pred):\n",
1071
+ " pred_ids = pred.predictions\n",
1072
+ " label_ids = pred.label_ids\n",
1073
+ "\n",
1074
+ " # replace -100 with the pad_token_id\n",
1075
+ " label_ids[label_ids == -100] = processor.tokenizer.pad_token_id\n",
1076
+ "\n",
1077
+ " # we do not want to group tokens when computing the metrics\n",
1078
+ " pred_str = processor.tokenizer.batch_decode(pred_ids, skip_special_tokens=True)\n",
1079
+ " label_str = processor.tokenizer.batch_decode(label_ids, skip_special_tokens=True)\n",
1080
+ "\n",
1081
+ " if do_normalize_eval:\n",
1082
+ " pred_str = [normalizer(pred) for pred in pred_str]\n",
1083
+ " label_str = [normalizer(label) for label in label_str]\n",
1084
+ "\n",
1085
+ " wer = 100 * metric.compute(predictions=pred_str, references=label_str)\n",
1086
+ "\n",
1087
+ " return {\"wer\": wer}"
1088
+ ]
1089
+ },
1090
+ {
1091
+ "cell_type": "markdown",
1092
+ "id": "daf2a825-6d9f-4a23-b145-c37c0039075b",
1093
+ "metadata": {
1094
+ "id": "daf2a825-6d9f-4a23-b145-c37c0039075b"
1095
+ },
1096
+ "source": [
1097
+ "### Load a Pre-Trained Checkpoint"
1098
+ ]
1099
+ },
1100
+ {
1101
+ "cell_type": "markdown",
1102
+ "id": "437a97fa-4864-476b-8abc-f28b8166cfa5",
1103
+ "metadata": {
1104
+ "id": "437a97fa-4864-476b-8abc-f28b8166cfa5"
1105
+ },
1106
+ "source": [
1107
+ "Now let's load the pre-trained Whisper `small` checkpoint. Again, this \n",
1108
+ "is trivial through use of 🤗 Transformers!"
1109
+ ]
1110
+ },
1111
+ {
1112
+ "cell_type": "code",
1113
+ "execution_count": 16,
1114
+ "id": "5a10cc4b-07ec-4ebd-ac1d-7c601023594f",
1115
+ "metadata": {
1116
+ "id": "5a10cc4b-07ec-4ebd-ac1d-7c601023594f"
1117
+ },
1118
+ "outputs": [],
1119
+ "source": [
1120
+ "from transformers import WhisperForConditionalGeneration\n",
1121
+ "\n",
1122
+ "model = WhisperForConditionalGeneration.from_pretrained(\"openai/whisper-medium\")"
1123
+ ]
1124
+ },
1125
+ {
1126
+ "cell_type": "markdown",
1127
+ "id": "a15ead5f-2277-4a39-937b-585c2497b2df",
1128
+ "metadata": {
1129
+ "id": "a15ead5f-2277-4a39-937b-585c2497b2df"
1130
+ },
1131
+ "source": [
1132
+ "Override generation arguments - no tokens are forced as decoder outputs (see [`forced_decoder_ids`](https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.generation_utils.GenerationMixin.generate.forced_decoder_ids)), no tokens are suppressed during generation (see [`suppress_tokens`](https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.generation_utils.GenerationMixin.generate.suppress_tokens)). Set `use_cache` to False since we're using gradient checkpointing, and the two are incompatible:"
1133
+ ]
1134
+ },
1135
+ {
1136
+ "cell_type": "code",
1137
+ "execution_count": 17,
1138
+ "id": "62038ba3-88ed-4fce-84db-338f50dcd04f",
1139
+ "metadata": {
1140
+ "id": "62038ba3-88ed-4fce-84db-338f50dcd04f"
1141
+ },
1142
+ "outputs": [],
1143
+ "source": [
1144
+ "model.config.forced_decoder_ids = None\n",
1145
+ "model.config.suppress_tokens = []\n",
1146
+ "model.config.use_cache = False"
1147
+ ]
1148
+ },
1149
+ {
1150
+ "cell_type": "markdown",
1151
+ "id": "2178dea4-80ca-47b6-b6ea-ba1915c90c06",
1152
+ "metadata": {
1153
+ "id": "2178dea4-80ca-47b6-b6ea-ba1915c90c06"
1154
+ },
1155
+ "source": [
1156
+ "### Define the Training Configuration"
1157
+ ]
1158
+ },
1159
+ {
1160
+ "cell_type": "markdown",
1161
+ "id": "c21af1e9-0188-4134-ac82-defc7bdcc436",
1162
+ "metadata": {
1163
+ "id": "c21af1e9-0188-4134-ac82-defc7bdcc436"
1164
+ },
1165
+ "source": [
1166
+ "In the final step, we define all the parameters related to training. For more detail on the training arguments, refer to the Seq2SeqTrainingArguments [docs](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.Seq2SeqTrainingArguments)."
1167
+ ]
1168
+ },
1169
+ {
1170
+ "cell_type": "code",
1171
+ "execution_count": 18,
1172
+ "id": "0ae3e9af-97b7-4aa0-ae85-20b23b5bcb3a",
1173
+ "metadata": {
1174
+ "id": "0ae3e9af-97b7-4aa0-ae85-20b23b5bcb3a"
1175
+ },
1176
+ "outputs": [],
1177
+ "source": [
1178
+ "from transformers import Seq2SeqTrainingArguments\n",
1179
+ "\n",
1180
+ "training_args = Seq2SeqTrainingArguments(\n",
1181
+ " output_dir=\"./\",\n",
1182
+ " per_device_train_batch_size=32,\n",
1183
+ " gradient_accumulation_steps=8, # increase by 2x for every 2x decrease in batch size\n",
1184
+ " learning_rate=1e-5,\n",
1185
+ " warmup_steps=500,\n",
1186
+ " max_steps=2000,\n",
1187
+ " gradient_checkpointing=True,\n",
1188
+ " fp16=True,\n",
1189
+ " evaluation_strategy=\"steps\",\n",
1190
+ " per_device_eval_batch_size=8,\n",
1191
+ " predict_with_generate=True,\n",
1192
+ " generation_max_length=225,\n",
1193
+ " save_steps=1000,\n",
1194
+ " eval_steps=1000,\n",
1195
+ " logging_steps=25,\n",
1196
+ " report_to=[\"tensorboard\"],\n",
1197
+ " load_best_model_at_end=True,\n",
1198
+ " metric_for_best_model=\"wer\",\n",
1199
+ " greater_is_better=False,\n",
1200
+ " push_to_hub=True,\n",
1201
+ ")"
1202
+ ]
1203
+ },
1204
+ {
1205
+ "cell_type": "markdown",
1206
+ "id": "b3a944d8-3112-4552-82a0-be25988b3857",
1207
+ "metadata": {
1208
+ "id": "b3a944d8-3112-4552-82a0-be25988b3857"
1209
+ },
1210
+ "source": [
1211
+ "**Note**: if one does not want to upload the model checkpoints to the Hub, \n",
1212
+ "set `push_to_hub=False`."
1213
+ ]
1214
+ },
1215
+ {
1216
+ "cell_type": "markdown",
1217
+ "id": "bac29114-d226-4f54-97cf-8718c9f94e1e",
1218
+ "metadata": {
1219
+ "id": "bac29114-d226-4f54-97cf-8718c9f94e1e"
1220
+ },
1221
+ "source": [
1222
+ "We can forward the training arguments to the 🤗 Trainer along with our model,\n",
1223
+ "dataset, data collator and `compute_metrics` function:"
1224
+ ]
1225
+ },
1226
+ {
1227
+ "cell_type": "code",
1228
+ "execution_count": 19,
1229
+ "id": "d546d7fe-0543-479a-b708-2ebabec19493",
1230
+ "metadata": {
1231
+ "id": "d546d7fe-0543-479a-b708-2ebabec19493"
1232
+ },
1233
+ "outputs": [
1234
+ {
1235
+ "name": "stderr",
1236
+ "output_type": "stream",
1237
+ "text": [
1238
+ "/home/whisper-medium-tamil/./ is already a clone of https://huggingface.co/kurianbenoy/whisper-medium-tamil. Make sure you pull the latest changes with `repo.git_pull()`.\n",
1239
+ "max_steps is given, it will override any value given in num_train_epochs\n",
1240
+ "Using cuda_amp half precision backend\n"
1241
+ ]
1242
+ }
1243
+ ],
1244
+ "source": [
1245
+ "from transformers import Seq2SeqTrainer\n",
1246
+ "\n",
1247
+ "trainer = Seq2SeqTrainer(\n",
1248
+ " args=training_args,\n",
1249
+ " model=model,\n",
1250
+ " train_dataset=common_voice[\"train\"],\n",
1251
+ " eval_dataset=common_voice[\"test\"],\n",
1252
+ " data_collator=data_collator,\n",
1253
+ " compute_metrics=compute_metrics,\n",
1254
+ " tokenizer=processor.feature_extractor,\n",
1255
+ ")"
1256
+ ]
1257
+ },
1258
+ {
1259
+ "cell_type": "markdown",
1260
+ "id": "uOrRhDGtN5S4",
1261
+ "metadata": {
1262
+ "id": "uOrRhDGtN5S4"
1263
+ },
1264
+ "source": [
1265
+ "We'll save the processor object once before starting training. Since the processor is not trainable, it won't change over the course of training:"
1266
+ ]
1267
+ },
1268
+ {
1269
+ "cell_type": "code",
1270
+ "execution_count": 20,
1271
+ "id": "-2zQwMfEOBJq",
1272
+ "metadata": {
1273
+ "id": "-2zQwMfEOBJq"
1274
+ },
1275
+ "outputs": [
1276
+ {
1277
+ "name": "stderr",
1278
+ "output_type": "stream",
1279
+ "text": [
1280
+ "Feature extractor saved in ./preprocessor_config.json\n",
1281
+ "tokenizer config file saved in ./tokenizer_config.json\n",
1282
+ "Special tokens file saved in ./special_tokens_map.json\n",
1283
+ "added tokens file saved in ./added_tokens.json\n"
1284
+ ]
1285
+ }
1286
+ ],
1287
+ "source": [
1288
+ "processor.save_pretrained(training_args.output_dir)"
1289
+ ]
1290
+ },
1291
+ {
1292
+ "cell_type": "markdown",
1293
+ "id": "7f404cf9-4345-468c-8196-4bd101d9bd51",
1294
+ "metadata": {
1295
+ "id": "7f404cf9-4345-468c-8196-4bd101d9bd51"
1296
+ },
1297
+ "source": [
1298
+ "### Training"
1299
+ ]
1300
+ },
1301
+ {
1302
+ "cell_type": "markdown",
1303
+ "id": "5e8b8d56-5a70-4f68-bd2e-f0752d0bd112",
1304
+ "metadata": {
1305
+ "id": "5e8b8d56-5a70-4f68-bd2e-f0752d0bd112"
1306
+ },
1307
+ "source": [
1308
+ "Training will take approximately 5-10 hours depending on your GPU. The peak GPU memory for the given training configuration is approximately 36GB. \n",
1309
+ "Depending on your GPU, it is possible that you will encounter a CUDA `\"out-of-memory\"` error when you launch training. \n",
1310
+ "In this case, you can reduce the `per_device_train_batch_size` incrementally by factors of 2 \n",
1311
+ "and employ [`gradient_accumulation_steps`](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.Seq2SeqTrainingArguments.gradient_accumulation_steps)\n",
1312
+ "to compensate.\n",
1313
+ "\n",
1314
+ "To launch training, simply execute:"
1315
+ ]
1316
+ },
1317
+ {
1318
+ "cell_type": "code",
1319
+ "execution_count": 21,
1320
+ "id": "ee8b7b8e-1c9a-4d77-9137-1778a629e6de",
1321
+ "metadata": {
1322
+ "id": "ee8b7b8e-1c9a-4d77-9137-1778a629e6de"
1323
+ },
1324
+ "outputs": [
1325
+ {
1326
+ "name": "stderr",
1327
+ "output_type": "stream",
1328
+ "text": [
1329
+ "The following columns in the training set don't have a corresponding argument in `WhisperForConditionalGeneration.forward` and have been ignored: input_length. If input_length are not expected by `WhisperForConditionalGeneration.forward`, you can safely ignore this message.\n",
1330
+ "/opt/conda/lib/python3.8/site-packages/transformers/optimization.py:306: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning\n",
1331
+ " warnings.warn(\n",
1332
+ "***** Running training *****\n",
1333
+ " Num examples = 13844\n",
1334
+ " Num Epochs = 47\n",
1335
+ " Instantaneous batch size per device = 32\n",
1336
+ " Total train batch size (w. parallel, distributed & accumulation) = 128\n",
1337
+ " Gradient Accumulation steps = 4\n",
1338
+ " Total optimization steps = 5000\n",
1339
+ " Number of trainable parameters = 763857920\n"
1340
+ ]
1341
+ },
1342
+ {
1343
+ "data": {
1344
+ "text/html": [
1345
+ "\n",
1346
+ " <div>\n",
1347
+ " \n",
1348
+ " <progress value='7' max='5000' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
1349
+ " [ 7/5000 03:15 < 54:16:34, 0.03 it/s, Epoch 0.06/47]\n",
1350
+ " </div>\n",
1351
+ " <table border=\"1\" class=\"dataframe\">\n",
1352
+ " <thead>\n",
1353
+ " <tr style=\"text-align: left;\">\n",
1354
+ " <th>Step</th>\n",
1355
+ " <th>Training Loss</th>\n",
1356
+ " <th>Validation Loss</th>\n",
1357
+ " </tr>\n",
1358
+ " </thead>\n",
1359
+ " <tbody>\n",
1360
+ " </tbody>\n",
1361
+ "</table><p>"
1362
+ ],
1363
+ "text/plain": [
1364
+ "<IPython.core.display.HTML object>"
1365
+ ]
1366
+ },
1367
+ "metadata": {},
1368
+ "output_type": "display_data"
1369
+ },
1370
+ {
1371
+ "ename": "KeyboardInterrupt",
1372
+ "evalue": "",
1373
+ "output_type": "error",
1374
+ "traceback": [
1375
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
1376
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
1377
+ "Input \u001b[0;32mIn [21]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mtrainer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrain\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
1378
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/transformers/trainer.py:1501\u001b[0m, in \u001b[0;36mTrainer.train\u001b[0;34m(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)\u001b[0m\n\u001b[1;32m 1496\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel_wrapped \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel\n\u001b[1;32m 1498\u001b[0m inner_training_loop \u001b[38;5;241m=\u001b[39m find_executable_batch_size(\n\u001b[1;32m 1499\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_inner_training_loop, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_train_batch_size, args\u001b[38;5;241m.\u001b[39mauto_find_batch_size\n\u001b[1;32m 1500\u001b[0m )\n\u001b[0;32m-> 1501\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43minner_training_loop\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1502\u001b[0m \u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1503\u001b[0m \u001b[43m \u001b[49m\u001b[43mresume_from_checkpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mresume_from_checkpoint\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1504\u001b[0m \u001b[43m \u001b[49m\u001b[43mtrial\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtrial\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1505\u001b[0m \u001b[43m \u001b[49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mignore_keys_for_eval\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1506\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
1379
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/transformers/trainer.py:1723\u001b[0m, in \u001b[0;36mTrainer._inner_training_loop\u001b[0;34m(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)\u001b[0m\n\u001b[1;32m 1720\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_load_rng_state(resume_from_checkpoint)\n\u001b[1;32m 1722\u001b[0m step \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[0;32m-> 1723\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m step, inputs \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(epoch_iterator):\n\u001b[1;32m 1724\u001b[0m \n\u001b[1;32m 1725\u001b[0m \u001b[38;5;66;03m# Skip past any already trained steps if resuming training\u001b[39;00m\n\u001b[1;32m 1726\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m steps_trained_in_current_epoch \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 1727\u001b[0m steps_trained_in_current_epoch \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n",
1380
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py:628\u001b[0m, in \u001b[0;36m_BaseDataLoaderIter.__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 625\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sampler_iter \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 626\u001b[0m \u001b[38;5;66;03m# TODO(https://github.com/pytorch/pytorch/issues/76750)\u001b[39;00m\n\u001b[1;32m 627\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_reset() \u001b[38;5;66;03m# type: ignore[call-arg]\u001b[39;00m\n\u001b[0;32m--> 628\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_next_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 629\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_num_yielded \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n\u001b[1;32m 630\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dataset_kind \u001b[38;5;241m==\u001b[39m _DatasetKind\u001b[38;5;241m.\u001b[39mIterable \u001b[38;5;129;01mand\u001b[39;00m \\\n\u001b[1;32m 631\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_IterableDataset_len_called \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \\\n\u001b[1;32m 632\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_num_yielded \u001b[38;5;241m>\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_IterableDataset_len_called:\n",
1381
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py:671\u001b[0m, in \u001b[0;36m_SingleProcessDataLoaderIter._next_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 669\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_next_data\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 670\u001b[0m index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_next_index() \u001b[38;5;66;03m# may raise StopIteration\u001b[39;00m\n\u001b[0;32m--> 671\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_dataset_fetcher\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfetch\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindex\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# may raise StopIteration\u001b[39;00m\n\u001b[1;32m 672\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_pin_memory:\n\u001b[1;32m 673\u001b[0m data \u001b[38;5;241m=\u001b[39m _utils\u001b[38;5;241m.\u001b[39mpin_memory\u001b[38;5;241m.\u001b[39mpin_memory(data, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_pin_memory_device)\n",
1382
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:58\u001b[0m, in \u001b[0;36m_MapDatasetFetcher.fetch\u001b[0;34m(self, possibly_batched_index)\u001b[0m\n\u001b[1;32m 56\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset\u001b[38;5;241m.\u001b[39m__getitems__(possibly_batched_index)\n\u001b[1;32m 57\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 58\u001b[0m data \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset[idx] \u001b[38;5;28;01mfor\u001b[39;00m idx \u001b[38;5;129;01min\u001b[39;00m possibly_batched_index]\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 60\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset[possibly_batched_index]\n",
1383
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:58\u001b[0m, in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 56\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset\u001b[38;5;241m.\u001b[39m__getitems__(possibly_batched_index)\n\u001b[1;32m 57\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 58\u001b[0m data \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdataset\u001b[49m\u001b[43m[\u001b[49m\u001b[43midx\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;28;01mfor\u001b[39;00m idx \u001b[38;5;129;01min\u001b[39;00m possibly_batched_index]\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 60\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdataset[possibly_batched_index]\n",
1384
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/arrow_dataset.py:2356\u001b[0m, in \u001b[0;36mDataset.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2354\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__getitem__\u001b[39m(\u001b[38;5;28mself\u001b[39m, key): \u001b[38;5;66;03m# noqa: F811\u001b[39;00m\n\u001b[1;32m 2355\u001b[0m \u001b[38;5;124;03m\"\"\"Can be used to index columns (by string names) or rows (by integer index or iterable of indices or bools).\"\"\"\u001b[39;00m\n\u001b[0;32m-> 2356\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_getitem\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2357\u001b[0m \u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2358\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
1385
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/arrow_dataset.py:2341\u001b[0m, in \u001b[0;36mDataset._getitem\u001b[0;34m(self, key, decoded, **kwargs)\u001b[0m\n\u001b[1;32m 2339\u001b[0m formatter \u001b[38;5;241m=\u001b[39m get_formatter(format_type, features\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfeatures, decoded\u001b[38;5;241m=\u001b[39mdecoded, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mformat_kwargs)\n\u001b[1;32m 2340\u001b[0m pa_subtable \u001b[38;5;241m=\u001b[39m query_table(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data, key, indices\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_indices \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_indices \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[0;32m-> 2341\u001b[0m formatted_output \u001b[38;5;241m=\u001b[39m \u001b[43mformat_table\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2342\u001b[0m \u001b[43m \u001b[49m\u001b[43mpa_subtable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mformatter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mformatter\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mformat_columns\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mformat_columns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moutput_all_columns\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moutput_all_columns\u001b[49m\n\u001b[1;32m 2343\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2344\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m formatted_output\n",
1386
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/formatting/formatting.py:509\u001b[0m, in \u001b[0;36mformat_table\u001b[0;34m(table, key, formatter, format_columns, output_all_columns)\u001b[0m\n\u001b[1;32m 507\u001b[0m python_formatter \u001b[38;5;241m=\u001b[39m PythonFormatter(features\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 508\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m format_columns \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 509\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mformatter\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpa_table\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mquery_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery_type\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 510\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m query_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcolumn\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 511\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m format_columns:\n",
1387
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/formatting/formatting.py:282\u001b[0m, in \u001b[0;36mFormatter.__call__\u001b[0;34m(self, pa_table, query_type)\u001b[0m\n\u001b[1;32m 280\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, pa_table: pa\u001b[38;5;241m.\u001b[39mTable, query_type: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Union[RowFormat, ColumnFormat, BatchFormat]:\n\u001b[1;32m 281\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m query_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrow\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m--> 282\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mformat_row\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpa_table\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 283\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m query_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcolumn\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 284\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mformat_column(pa_table)\n",
1388
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/formatting/formatting.py:311\u001b[0m, in \u001b[0;36mPythonFormatter.format_row\u001b[0;34m(self, pa_table)\u001b[0m\n\u001b[1;32m 310\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mformat_row\u001b[39m(\u001b[38;5;28mself\u001b[39m, pa_table: pa\u001b[38;5;241m.\u001b[39mTable) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mdict\u001b[39m:\n\u001b[0;32m--> 311\u001b[0m row \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpython_arrow_extractor\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mextract_row\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpa_table\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 312\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecoded:\n\u001b[1;32m 313\u001b[0m row \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpython_features_decoder\u001b[38;5;241m.\u001b[39mdecode_row(row)\n",
1389
+ "File \u001b[0;32m/opt/conda/lib/python3.8/site-packages/datasets/formatting/formatting.py:141\u001b[0m, in \u001b[0;36mPythonArrowExtractor.extract_row\u001b[0;34m(self, pa_table)\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mextract_row\u001b[39m(\u001b[38;5;28mself\u001b[39m, pa_table: pa\u001b[38;5;241m.\u001b[39mTable) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mdict\u001b[39m:\n\u001b[0;32m--> 141\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _unnest(\u001b[43mpa_table\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_pydict\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m)\n",
1390
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
1391
+ ]
1392
+ }
1393
+ ],
1394
+ "source": [
1395
+ "trainer.train()"
1396
+ ]
1397
+ },
1398
+ {
1399
+ "cell_type": "markdown",
1400
+ "id": "810ced54-7187-4a06-b2fe-ba6dcca94dc3",
1401
+ "metadata": {
1402
+ "id": "810ced54-7187-4a06-b2fe-ba6dcca94dc3"
1403
+ },
1404
+ "source": [
1405
+ "We can label our checkpoint with the `whisper-event` tag on push by setting the appropriate key-word arguments (kwargs):"
1406
+ ]
1407
+ },
1408
+ {
1409
+ "cell_type": "code",
1410
+ "execution_count": null,
1411
+ "id": "c704f91e-241b-48c9-b8e0-f0da396a9663",
1412
+ "metadata": {
1413
+ "id": "c704f91e-241b-48c9-b8e0-f0da396a9663"
1414
+ },
1415
+ "outputs": [],
1416
+ "source": [
1417
+ "kwargs = {\n",
1418
+ " \"dataset_tags\": \"mozilla-foundation/common_voice_11_0\",\n",
1419
+ " \"dataset\": \"Common Voice 11.0\", # a 'pretty' name for the training dataset\n",
1420
+ " \"language\": \"hi\",\n",
1421
+ " \"model_name\": \"Whisper medium ta\", # a 'pretty' name for your model\n",
1422
+ " \"finetuned_from\": \"openai/whisper-medium\",\n",
1423
+ " \"tasks\": \"automatic-speech-recognition\",\n",
1424
+ " \"tags\": \"whisper-event\",\n",
1425
+ "}"
1426
+ ]
1427
+ },
1428
+ {
1429
+ "cell_type": "markdown",
1430
+ "id": "090d676a-f944-4297-a938-a40eda0b2b68",
1431
+ "metadata": {
1432
+ "id": "090d676a-f944-4297-a938-a40eda0b2b68"
1433
+ },
1434
+ "source": [
1435
+ "The training results can now be uploaded to the Hub. To do so, execute the `push_to_hub` command and save the preprocessor object we created:"
1436
+ ]
1437
+ },
1438
+ {
1439
+ "cell_type": "code",
1440
+ "execution_count": null,
1441
+ "id": "d7030622-caf7-4039-939b-6195cdaa2585",
1442
+ "metadata": {
1443
+ "id": "d7030622-caf7-4039-939b-6195cdaa2585"
1444
+ },
1445
+ "outputs": [],
1446
+ "source": [
1447
+ "trainer.push_to_hub(**kwargs)"
1448
+ ]
1449
+ },
1450
+ {
1451
+ "cell_type": "markdown",
1452
+ "id": "ca743fbd-602c-48d4-ba8d-a2fe60af64ba",
1453
+ "metadata": {
1454
+ "id": "ca743fbd-602c-48d4-ba8d-a2fe60af64ba"
1455
+ },
1456
+ "source": [
1457
+ "## Closing Remarks"
1458
+ ]
1459
+ },
1460
+ {
1461
+ "cell_type": "markdown",
1462
+ "id": "7f737783-2870-4e35-aa11-86a42d7d997a",
1463
+ "metadata": {
1464
+ "id": "7f737783-2870-4e35-aa11-86a42d7d997a"
1465
+ },
1466
+ "source": [
1467
+ "In this blog, we covered a step-by-step guide on fine-tuning Whisper for multilingual ASR \n",
1468
+ "using 🤗 Datasets, Transformers and the Hugging Face Hub. For more details on the Whisper model, the Common Voice dataset and the theory behind fine-tuning, refere to the accompanying [blog post](https://huggingface.co/blog/fine-tune-whisper). If you're interested in fine-tuning other \n",
1469
+ "Transformers models, both for English and multilingual ASR, be sure to check out the \n",
1470
+ "examples scripts at [examples/pytorch/speech-recognition](https://github.com/huggingface/transformers/tree/main/examples/pytorch/speech-recognition)."
1471
+ ]
1472
+ }
1473
+ ],
1474
+ "metadata": {
1475
+ "colab": {
1476
+ "include_colab_link": true,
1477
+ "provenance": []
1478
+ },
1479
+ "kernelspec": {
1480
+ "display_name": "Python 3",
1481
+ "language": "python",
1482
+ "name": "python3"
1483
+ },
1484
+ "language_info": {
1485
+ "codemirror_mode": {
1486
+ "name": "ipython",
1487
+ "version": 3
1488
+ },
1489
+ "file_extension": ".py",
1490
+ "mimetype": "text/x-python",
1491
+ "name": "python",
1492
+ "nbconvert_exporter": "python",
1493
+ "pygments_lexer": "ipython3",
1494
+ "version": "3.8.12"
1495
+ }
1496
+ },
1497
+ "nbformat": 4,
1498
+ "nbformat_minor": 5
1499
+ }
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "openai/whisper-medium",
3
+ "activation_dropout": 0.0,
4
+ "activation_function": "gelu",
5
+ "architectures": [
6
+ "WhisperForConditionalGeneration"
7
+ ],
8
+ "attention_dropout": 0.0,
9
+ "begin_suppress_tokens": [
10
+ 220,
11
+ 50257
12
+ ],
13
+ "bos_token_id": 50257,
14
+ "d_model": 1024,
15
+ "decoder_attention_heads": 16,
16
+ "decoder_ffn_dim": 4096,
17
+ "decoder_layerdrop": 0.0,
18
+ "decoder_layers": 24,
19
+ "decoder_start_token_id": 50258,
20
+ "dropout": 0.0,
21
+ "encoder_attention_heads": 16,
22
+ "encoder_ffn_dim": 4096,
23
+ "encoder_layerdrop": 0.0,
24
+ "encoder_layers": 24,
25
+ "eos_token_id": 50257,
26
+ "forced_decoder_ids": null,
27
+ "init_std": 0.02,
28
+ "is_encoder_decoder": true,
29
+ "max_length": 448,
30
+ "max_source_positions": 1500,
31
+ "max_target_positions": 448,
32
+ "model_type": "whisper",
33
+ "num_hidden_layers": 24,
34
+ "num_mel_bins": 80,
35
+ "pad_token_id": 50257,
36
+ "scale_embedding": false,
37
+ "suppress_tokens": [],
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.24.0",
40
+ "use_cache": false,
41
+ "vocab_size": 51865
42
+ }
fine-tune-whisper-non-streaming.ipynb CHANGED
@@ -1353,8 +1353,8 @@
1353
  "\n",
1354
  " <div>\n",
1355
  " \n",
1356
- " <progress value='371' max='2000' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
1357
- " [ 371/2000 7:53:38 < 34:50:58, 0.01 it/s, Epoch 6.85/38]\n",
1358
  " </div>\n",
1359
  " <table border=\"1\" class=\"dataframe\">\n",
1360
  " <thead>\n",
@@ -1402,7 +1402,7 @@
1402
  "kwargs = {\n",
1403
  " \"dataset_tags\": \"mozilla-foundation/common_voice_11_0\",\n",
1404
  " \"dataset\": \"Common Voice 11.0\", # a 'pretty' name for the training dataset\n",
1405
- " \"language\": \"hi\",\n",
1406
  " \"model_name\": \"Whisper medium ta\", # a 'pretty' name for your model\n",
1407
  " \"finetuned_from\": \"openai/whisper-medium\",\n",
1408
  " \"tasks\": \"automatic-speech-recognition\",\n",
 
1353
  "\n",
1354
  " <div>\n",
1355
  " \n",
1356
+ " <progress value='512' max='2000' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
1357
+ " [ 512/2000 10:53:45 < 31:47:27, 0.01 it/s, Epoch 9.46/38]\n",
1358
  " </div>\n",
1359
  " <table border=\"1\" class=\"dataframe\">\n",
1360
  " <thead>\n",
 
1402
  "kwargs = {\n",
1403
  " \"dataset_tags\": \"mozilla-foundation/common_voice_11_0\",\n",
1404
  " \"dataset\": \"Common Voice 11.0\", # a 'pretty' name for the training dataset\n",
1405
+ " \"language\": \"ta\",\n",
1406
  " \"model_name\": \"Whisper medium ta\", # a 'pretty' name for your model\n",
1407
  " \"finetuned_from\": \"openai/whisper-medium\",\n",
1408
  " \"tasks\": \"automatic-speech-recognition\",\n",
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b8c9d50841c909c52b11a148a96779c83e4f7873ba22f0b658d5575910d5d6a
3
+ size 3055754841
runs/Dec13_15-05-36_f8e5c0b92619/1670915147.3620176/events.out.tfevents.1670915147.f8e5c0b92619.753.1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f48e93f7cffe40655d767aeb4222aa85c4e7e153e3f0b25f25f514936fc1864
3
+ size 5663
runs/Dec13_15-05-36_f8e5c0b92619/events.out.tfevents.1670915147.f8e5c0b92619.753.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e672854eac7da1c43ec93da6d07a3b2abeec5e12d9338e430f158112b9b07aa
3
+ size 4324
runs/Dec13_15-50-20_f8e5c0b92619/1670917829.7300787/events.out.tfevents.1670917829.f8e5c0b92619.21444.1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f500fe471e9a1578f60ebd76c6458ff214ec9a055b1b81a44016cb2c58644deb
3
+ size 5663
runs/Dec13_15-50-20_f8e5c0b92619/events.out.tfevents.1670917829.f8e5c0b92619.21444.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfce8d24f1b113d05a8b0f947e1b7154bf0aa8452f2c8c5f894f0f1cb7ba614c
3
+ size 4171
runs/Dec13_15-55-39_f8e5c0b92619/1670918149.0604956/events.out.tfevents.1670918149.f8e5c0b92619.21444.3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45c67a101fd4160e8cc99534580a883af17f06772a446c349520b838c589fdd9
3
+ size 5663
runs/Dec13_15-55-39_f8e5c0b92619/events.out.tfevents.1670918149.f8e5c0b92619.21444.2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d502b9e1f8dc748d8433bc69f6284d9adddfb1cd3a711bb4dc1964160d1bcf51
3
+ size 10754
test.hf/dataset_dict.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"splits": ["train", "test"]}
test.hf/test/dataset.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da1698099b417885a918e23bcf472d6dff3bb2347b01ff67fba59301276a6728
3
+ size 567787904
test.hf/test/dataset_info.json ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "common_voice_11_0",
3
+ "citation": "@inproceedings{commonvoice:2020,\n author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},\n title = {Common Voice: A Massively-Multilingual Speech Corpus},\n booktitle = {Proceedings of the 12th Conference on Language Resources and Evaluation (LREC 2020)},\n pages = {4211--4215},\n year = 2020\n}\n",
4
+ "config_name": "ta",
5
+ "dataset_size": 6138537473,
6
+ "description": "Common Voice is Mozilla's initiative to help teach machines how real people speak. The dataset currently consists of 16413 validated hours of speech in 100 languages, but more voices and languages are always added.",
7
+ "download_checksums": {
8
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/n_shards.json": {
9
+ "num_bytes": 12179,
10
+ "checksum": "584aa91a99f678abe7ad1e181e5cdc6af970d20c82bcb63f54e86c4fd2e5a2a8"
11
+ },
12
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/train/ta_train_0.tar": {
13
+ "num_bytes": 1604730880,
14
+ "checksum": "ad4bbc42512f1bc9efd98c188e44750ac83b71e4829f4a52d6d9cf7259c0e6cb"
15
+ },
16
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/train/ta_train_1.tar": {
17
+ "num_bytes": 67246080,
18
+ "checksum": "230bd2febfe9bc7012d73e52e517240c6a33ae11e3c64fb99086328e2b650fa5"
19
+ },
20
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/dev/ta_dev_0.tar": {
21
+ "num_bytes": 423659520,
22
+ "checksum": "80b9977ebcd1b484880dafac7e28c184440a7c2d4558d501240e069d9b4dd628"
23
+ },
24
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/test/ta_test_0.tar": {
25
+ "num_bytes": 443709440,
26
+ "checksum": "188a061b89e27517f06f713e5be835f7634242afe5f9cdc828d91fbf0bb6ffd7"
27
+ },
28
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_0.tar": {
29
+ "num_bytes": 1563248640,
30
+ "checksum": "91ca2c227f2d59a9a1817b38adfca9fe14e62484d7b5ffe44ae23811442a2b97"
31
+ },
32
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_1.tar": {
33
+ "num_bytes": 1506631680,
34
+ "checksum": "83809ecfcf1826812817e8d826d240823569aecb447a39a2a38dcb47090fa3fd"
35
+ },
36
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_2.tar": {
37
+ "num_bytes": 319129600,
38
+ "checksum": "6df52e8d650db95f7537b7acfecafc89433a586036c3dda21939a4be87421027"
39
+ },
40
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/invalidated/ta_invalidated_0.tar": {
41
+ "num_bytes": 227020800,
42
+ "checksum": "33fe28d8a4e50f48bf0f7a0007179b479d11525467aa0743583e64b246799d1d"
43
+ },
44
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/train.tsv": {
45
+ "num_bytes": 15058319,
46
+ "checksum": "f8214e19cb767e9911de46ab64672a39a77814b8c3d9330a71d8f9ff07c12d33"
47
+ },
48
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/dev.tsv": {
49
+ "num_bytes": 4205514,
50
+ "checksum": "a3136b8f038de5e90ef79fd814ebb1f29282137d1e850b2db2a354d6cc76c345"
51
+ },
52
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/test.tsv": {
53
+ "num_bytes": 3936521,
54
+ "checksum": "f3346901e118f481b32880dcc0dcf52f066fcb70c1355ad49d6bc532c73a6480"
55
+ },
56
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/other.tsv": {
57
+ "num_bytes": 30745385,
58
+ "checksum": "18f1ac9e239e40d839a70c962d42e8d75a610f535c476453e6330a4cc5ec1a47"
59
+ },
60
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/invalidated.tsv": {
61
+ "num_bytes": 2044387,
62
+ "checksum": "9b8b0c7a216423f9070824f17fa5722779357d56e0c908db0b3dfc59968514b1"
63
+ }
64
+ },
65
+ "download_size": 6211378945,
66
+ "features": {
67
+ "input_features": {
68
+ "feature": {
69
+ "feature": {
70
+ "dtype": "float32",
71
+ "_type": "Value"
72
+ },
73
+ "_type": "Sequence"
74
+ },
75
+ "_type": "Sequence"
76
+ },
77
+ "input_length": {
78
+ "dtype": "float64",
79
+ "_type": "Value"
80
+ },
81
+ "labels": {
82
+ "feature": {
83
+ "dtype": "int64",
84
+ "_type": "Value"
85
+ },
86
+ "_type": "Sequence"
87
+ }
88
+ },
89
+ "homepage": "https://commonvoice.mozilla.org/en/datasets",
90
+ "license": "https://creativecommons.org/publicdomain/zero/1.0/",
91
+ "size_in_bytes": 12349916418,
92
+ "splits": {
93
+ "train": {
94
+ "name": "train",
95
+ "num_bytes": 1667970011,
96
+ "num_examples": 41710,
97
+ "shard_lengths": [
98
+ 14000,
99
+ 13000,
100
+ 12000,
101
+ 2710
102
+ ],
103
+ "dataset_name": "common_voice_11_0"
104
+ },
105
+ "validation": {
106
+ "name": "validation",
107
+ "num_bytes": 422495922,
108
+ "num_examples": 11758,
109
+ "dataset_name": "common_voice_11_0"
110
+ },
111
+ "test": {
112
+ "name": "test",
113
+ "num_bytes": 442244039,
114
+ "num_examples": 11815,
115
+ "dataset_name": "common_voice_11_0"
116
+ },
117
+ "other": {
118
+ "name": "other",
119
+ "num_bytes": 3379297630,
120
+ "num_examples": 87993,
121
+ "shard_lengths": [
122
+ 13000,
123
+ 13000,
124
+ 14000,
125
+ 14000,
126
+ 15000,
127
+ 13000,
128
+ 5993
129
+ ],
130
+ "dataset_name": "common_voice_11_0"
131
+ },
132
+ "invalidated": {
133
+ "name": "invalidated",
134
+ "num_bytes": 226529871,
135
+ "num_examples": 5575,
136
+ "dataset_name": "common_voice_11_0"
137
+ }
138
+ },
139
+ "version": {
140
+ "version_str": "11.0.0",
141
+ "major": 11,
142
+ "minor": 0,
143
+ "patch": 0
144
+ }
145
+ }
test.hf/test/state.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "dataset.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "47141d2e1bc2a882",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_indexes": {},
12
+ "_output_all_columns": false,
13
+ "_split": "test[:5%]"
14
+ }
test.hf/train/cache-66e7a27c0df965f8.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de5af08ac44b50995e8dfea0a25d4f2d1119dd78cf6c296c856ba6b4bdef398d
3
+ size 113072
test.hf/train/dataset.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092364c2d68d597438e34a428044ecacad4ad49408b87a059a7eaf9cab09b221
3
+ size 13300990256
test.hf/train/dataset_info.json ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "common_voice_11_0",
3
+ "citation": "@inproceedings{commonvoice:2020,\n author = {Ardila, R. and Branson, M. and Davis, K. and Henretty, M. and Kohler, M. and Meyer, J. and Morais, R. and Saunders, L. and Tyers, F. M. and Weber, G.},\n title = {Common Voice: A Massively-Multilingual Speech Corpus},\n booktitle = {Proceedings of the 12th Conference on Language Resources and Evaluation (LREC 2020)},\n pages = {4211--4215},\n year = 2020\n}\n",
4
+ "config_name": "ta",
5
+ "dataset_size": 6138537473,
6
+ "description": "Common Voice is Mozilla's initiative to help teach machines how real people speak. The dataset currently consists of 16413 validated hours of speech in 100 languages, but more voices and languages are always added.",
7
+ "download_checksums": {
8
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/n_shards.json": {
9
+ "num_bytes": 12179,
10
+ "checksum": "584aa91a99f678abe7ad1e181e5cdc6af970d20c82bcb63f54e86c4fd2e5a2a8"
11
+ },
12
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/train/ta_train_0.tar": {
13
+ "num_bytes": 1604730880,
14
+ "checksum": "ad4bbc42512f1bc9efd98c188e44750ac83b71e4829f4a52d6d9cf7259c0e6cb"
15
+ },
16
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/train/ta_train_1.tar": {
17
+ "num_bytes": 67246080,
18
+ "checksum": "230bd2febfe9bc7012d73e52e517240c6a33ae11e3c64fb99086328e2b650fa5"
19
+ },
20
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/dev/ta_dev_0.tar": {
21
+ "num_bytes": 423659520,
22
+ "checksum": "80b9977ebcd1b484880dafac7e28c184440a7c2d4558d501240e069d9b4dd628"
23
+ },
24
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/test/ta_test_0.tar": {
25
+ "num_bytes": 443709440,
26
+ "checksum": "188a061b89e27517f06f713e5be835f7634242afe5f9cdc828d91fbf0bb6ffd7"
27
+ },
28
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_0.tar": {
29
+ "num_bytes": 1563248640,
30
+ "checksum": "91ca2c227f2d59a9a1817b38adfca9fe14e62484d7b5ffe44ae23811442a2b97"
31
+ },
32
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_1.tar": {
33
+ "num_bytes": 1506631680,
34
+ "checksum": "83809ecfcf1826812817e8d826d240823569aecb447a39a2a38dcb47090fa3fd"
35
+ },
36
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/other/ta_other_2.tar": {
37
+ "num_bytes": 319129600,
38
+ "checksum": "6df52e8d650db95f7537b7acfecafc89433a586036c3dda21939a4be87421027"
39
+ },
40
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/audio/ta/invalidated/ta_invalidated_0.tar": {
41
+ "num_bytes": 227020800,
42
+ "checksum": "33fe28d8a4e50f48bf0f7a0007179b479d11525467aa0743583e64b246799d1d"
43
+ },
44
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/train.tsv": {
45
+ "num_bytes": 15058319,
46
+ "checksum": "f8214e19cb767e9911de46ab64672a39a77814b8c3d9330a71d8f9ff07c12d33"
47
+ },
48
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/dev.tsv": {
49
+ "num_bytes": 4205514,
50
+ "checksum": "a3136b8f038de5e90ef79fd814ebb1f29282137d1e850b2db2a354d6cc76c345"
51
+ },
52
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/test.tsv": {
53
+ "num_bytes": 3936521,
54
+ "checksum": "f3346901e118f481b32880dcc0dcf52f066fcb70c1355ad49d6bc532c73a6480"
55
+ },
56
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/other.tsv": {
57
+ "num_bytes": 30745385,
58
+ "checksum": "18f1ac9e239e40d839a70c962d42e8d75a610f535c476453e6330a4cc5ec1a47"
59
+ },
60
+ "https://huggingface.co/datasets/mozilla-foundation/common_voice_11_0/resolve/streaming/transcript/ta/invalidated.tsv": {
61
+ "num_bytes": 2044387,
62
+ "checksum": "9b8b0c7a216423f9070824f17fa5722779357d56e0c908db0b3dfc59968514b1"
63
+ }
64
+ },
65
+ "download_size": 6211378945,
66
+ "features": {
67
+ "input_features": {
68
+ "feature": {
69
+ "feature": {
70
+ "dtype": "float32",
71
+ "_type": "Value"
72
+ },
73
+ "_type": "Sequence"
74
+ },
75
+ "_type": "Sequence"
76
+ },
77
+ "input_length": {
78
+ "dtype": "float64",
79
+ "_type": "Value"
80
+ },
81
+ "labels": {
82
+ "feature": {
83
+ "dtype": "int64",
84
+ "_type": "Value"
85
+ },
86
+ "_type": "Sequence"
87
+ }
88
+ },
89
+ "homepage": "https://commonvoice.mozilla.org/en/datasets",
90
+ "license": "https://creativecommons.org/publicdomain/zero/1.0/",
91
+ "size_in_bytes": 12349916418,
92
+ "splits": {
93
+ "train": {
94
+ "name": "train",
95
+ "num_bytes": 1667970011,
96
+ "num_examples": 41710,
97
+ "shard_lengths": [
98
+ 14000,
99
+ 13000,
100
+ 12000,
101
+ 2710
102
+ ],
103
+ "dataset_name": "common_voice_11_0"
104
+ },
105
+ "validation": {
106
+ "name": "validation",
107
+ "num_bytes": 422495922,
108
+ "num_examples": 11758,
109
+ "dataset_name": "common_voice_11_0"
110
+ },
111
+ "test": {
112
+ "name": "test",
113
+ "num_bytes": 442244039,
114
+ "num_examples": 11815,
115
+ "dataset_name": "common_voice_11_0"
116
+ },
117
+ "other": {
118
+ "name": "other",
119
+ "num_bytes": 3379297630,
120
+ "num_examples": 87993,
121
+ "shard_lengths": [
122
+ 13000,
123
+ 13000,
124
+ 14000,
125
+ 14000,
126
+ 15000,
127
+ 13000,
128
+ 5993
129
+ ],
130
+ "dataset_name": "common_voice_11_0"
131
+ },
132
+ "invalidated": {
133
+ "name": "invalidated",
134
+ "num_bytes": 226529871,
135
+ "num_examples": 5575,
136
+ "dataset_name": "common_voice_11_0"
137
+ }
138
+ },
139
+ "version": {
140
+ "version_str": "11.0.0",
141
+ "major": 11,
142
+ "minor": 0,
143
+ "patch": 0
144
+ }
145
+ }
test.hf/train/state.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "dataset.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "1d11854128abdd48",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_indexes": {},
12
+ "_output_all_columns": false,
13
+ "_split": "train[:5%]+validation"
14
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:745f1cfbce9d47252d9858767664179e34036a5a8e86bbf0788c957253de5a54
3
+ size 3515