{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "LBSYoWbi-45k" }, "source": [ "# **Fine-tuning XLS-R for Multi-Lingual ASR with 🤗 Transformers**\n", "\n", "***New (11/2021)***: *This blog post has been updated to feature XLSR's successor, called [XLS-R](https://huggingface.co/models?other=xls_r)*." ] }, { "cell_type": "markdown", "metadata": { "id": "V7YOT2mnUiea" }, "source": [ "**Wav2Vec2** is a pretrained model for Automatic Speech Recognition (ASR) and was released in [September 2020](https://ai.facebook.com/blog/wav2vec-20-learning-the-structure-of-speech-from-raw-audio/) by *Alexei Baevski, Michael Auli, and Alex Conneau*. Soon after the superior performance of Wav2Vec2 was demonstrated on one of the most popular English datasets for ASR, called [LibriSpeech](https://huggingface.co/datasets/librispeech_asr), *Facebook AI* presented a multi-lingual version of Wav2Vec2, called [XLSR](https://arxiv.org/abs/2006.13979). XLSR stands for *cross-lingual speech representations* and refers to model's ability to learn speech representations that are useful across multiple languages.\n", "\n", "XLSR's successor, simply called **XLS-R** (refering to the [*''XLM-R*](https://ai.facebook.com/blog/-xlm-r-state-of-the-art-cross-lingual-understanding-through-self-supervision/) *for Speech''*), was released in [November 2021](https://ai.facebook.com/blog/xls-r-self-supervised-speech-processing-for-128-languages) by *Arun Babu, Changhan Wang, Andros Tjandra, et al.* XLS-R used almost **half a million** hours of audio data in 128 languages for self-supervised pre-training and comes in sizes ranging from 300 milion up to **two billion** parameters. You can find the pretrained checkpoints on the 🤗 Hub:\n", "\n", "- [**Wav2Vec2-XLS-R-300M**](https://huggingface.co/facebook/wav2vec2-xls-r-300m)\n", "- [**Wav2Vec2-XLS-R-1B**](https://huggingface.co/facebook/wav2vec2-xls-r-1b)\n", "- [**Wav2Vec2-XLS-R-2B**](https://huggingface.co/facebook/wav2vec2-xls-r-2b)\n", "\n", "Similar to [BERT's masked language modeling objective](http://jalammar.github.io/illustrated-bert/), XLS-R learns contextualized speech representations by randomly masking feature vectors before passing them to a transformer network during self-supervised pre-training (*i.e.* diagram on the left below). \n", "\n", "For fine-tuning, a single linear layer is added on top of the pre-trained network to train the model on labeled data of audio downstream tasks such as speech recognition, speech translation and audio classification (*i.e.* diagram on the right below).\n", "\n", "![wav2vec2_structure](https://raw.githubusercontent.com/patrickvonplaten/scientific_images/master/xls_r.png)\n", "\n", "XLS-R shows impressive improvements over previous state-of-the-art results on both speech recognition, speech translation and speaker/language identification, *cf.* with Table 3-6, Table 7-10, and Table 11-12 respectively of the official [paper](https://ai.facebook.com/blog/xls-r-self-supervised-speech-processing-for-128-languages)." ] }, { "cell_type": "markdown", "metadata": { "id": "nT_QrfWtsxIz" }, "source": [ "## Notebook Setup" ] }, { "cell_type": "markdown", "metadata": { "id": "kruqixOYHaIo" }, "source": [ "\n", "In this notebook, we will give an in-detail explanation of how XLS-R - more specifically the pre-trained checkpoint [**Wav2Vec2-XLS-R-300M**](https://huggingface.co/facebook/wav2vec2-xls-r-300m) - can be fine-tuned for ASR. \n", "\n", "For demonstration purposes, we fine-tune the model on the low resource ASR dataset of [Common Voice](https://huggingface.co/datasets/common_voice) that contains only *ca.* 4h of validated training data." ] }, { "cell_type": "markdown", "metadata": { "id": "Gx9OdDYrCtQ1" }, "source": [ "XLS-R is fine-tuned using Connectionist Temporal Classification (CTC), which is an algorithm that is used to train neural networks for sequence-to-sequence problems, such as ASR and handwriting recognition. \n", "\n", "I highly recommend reading the well-written blog post [*Sequence Modeling with CTC (2017)*](https://distill.pub/2017/ctc/) by Awni Hannun." ] }, { "cell_type": "markdown", "metadata": { "id": "wcHuXIaWyHZU" }, "source": [ "First, let's try to get a good GPU in our colab! With Google Colab's free version it's sadly becoming much harder to get access to a good GPU. With Google Colab Pro, however, one should easily get either a V100 or P100 GPU." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "YELVqGxMxnbG", "outputId": "862232b0-f688-43fe-e88a-c22ea90c4635" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Mon Jan 24 20:49:11 2022 \n", "+-----------------------------------------------------------------------------+\n", "| NVIDIA-SMI 470.57.02 Driver Version: 470.57.02 CUDA Version: 11.4 |\n", "|-------------------------------+----------------------+----------------------+\n", "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n", "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n", "| | | MIG M. |\n", "|===============================+======================+======================|\n", "| 0 Tesla V100S-PCI... Off | 00000000:00:06.0 Off | 0 |\n", "| N/A 37C P0 25W / 250W | 4MiB / 32510MiB | 0% Default |\n", "| | | N/A |\n", "+-------------------------------+----------------------+----------------------+\n", " \n", "+-----------------------------------------------------------------------------+\n", "| Processes: |\n", "| GPU GI CI PID Type Process name GPU Memory |\n", "| ID ID Usage |\n", "|=============================================================================|\n", "| No running processes found |\n", "+-----------------------------------------------------------------------------+\n" ] } ], "source": [ "gpu_info = !nvidia-smi\n", "gpu_info = '\\n'.join(gpu_info)\n", "if gpu_info.find('failed') >= 0:\n", " print('Not connected to a GPU')\n", "else:\n", " print(gpu_info)" ] }, { "cell_type": "markdown", "metadata": { "id": "e335hPmdtASZ" }, "source": [ "Before we start, let's install `datasets` and `transformers`. Also, we need the `torchaudio` to load audio files and `jiwer` to evaluate our fine-tuned model using the [word error rate (WER)](https://huggingface.co/metrics/wer) metric ${}^1$." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "c8eh87Hoee5d" }, "outputs": [], "source": [ "%%capture\n", "#!pip install datasets==1.13.3\n", "#!pip install transformers==4.11.3\n", "#!pip install torchaudio==0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html\n", "#!pip install librosa\n", "#!pip install jiwer\n", "#!pip install kaggle\n", "#!pip install huggingface_hub==0.1" ] }, { "cell_type": "markdown", "metadata": { "id": "0xxt_LwxDQlO" }, "source": [ "We strongly suggest to upload your training checkpoints directly to the [🤗 Hub](https://huggingface.co/) while training. The [🤗 Hub](https://huggingface.co/) has integrated version control so you can be sure that no model checkpoint is getting lost during training. \n", "\n", "To do so you have to store your authentication token from the Hugging Face website (sign up [here](https://huggingface.co/join) if you haven't already!)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'4.16.0.dev0'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import transformers\n", "transformers.__version__" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0.10.1+cu102'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import torchaudio\n", "torchaudio.__version__" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "id": "Q3Zd2rW_emZF" }, "outputs": [], "source": [ "# Environment settings: \n", "import numpy as np\n", "import pandas as pd\n", "pd.set_option('display.max_column', None)\n", "pd.set_option('display.max_rows', None)\n", "pd.set_option('display.max_seq_items', None)\n", "pd.set_option('display.max_colwidth', 500)\n", "pd.set_option('expand_frame_repr', True)\n", "\n", "\n", "\n", "from datasets import concatenate_datasets, load_dataset, Audio" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "mlMSH3T3EazV", "outputId": "d80abc22-3477-44aa-b0de-23725be24b31" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "015f86572b764c72a57361e187adacad", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HTML(value='
\\n\", \"…\", \"–\", \"°\", \"´\", \"ʾ\", \"‹\", \"›\", \"©\", \"®\", \"—\", \"→\", \"。\",\n", " \"、\", \"﹂\", \"﹁\", \"‧\", \"~\", \"﹏\", \",\", \"{\", \"}\", \"(\", \")\", \"[\", \"]\", \"【\", \"】\", \"‥\", \"〽\",\n", " \"『\", \"』\", \"〝\", \"〟\", \"⟨\", \"⟩\", \"〜\", \":\", \"!\", \"?\", \"♪\", \"؛\", \"/\", \"\\\\\", \"º\", \"−\", \"^\", \"ʻ\", \"ˆ\"]\n", "\n", "\n", "chars_to_remove_regex = f\"[{re.escape(''.join(CHARS_TO_IGNORE))}]\"\n", "\n", "def remove_special_characters(batch):\n", " batch[\"sentence\"] = re.sub(chars_to_remove_regex, '', batch[\"sentence\"]).lower()\n", " return batch" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "id": "XIHocAuTQbBR", "outputId": "b990891f-e1a3-4e7d-ac62-db7cd68261e8" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2ddfe6de178243ee8252249301c1ecf8", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/7811 [00:00\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mshow_random_elements\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcommon_voice_train\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove_columns\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"path\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"audio\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mNameError\u001b[0m: name 'show_random_elements' is not defined" ] } ], "source": [ "show_random_elements(common_voice_train.remove_columns([\"path\",\"audio\"]))" ] }, { "cell_type": "markdown", "metadata": { "id": "jwfaptH5RJwA" }, "source": [ "Good! This looks better. We have removed most special characters from transcriptions and normalized them to lower-case only.\n", "\n", "Before finalizing the pre-processing, it is always advantageous to consult a native speaker of the target language to see whether the text can be further simplified. \n", "For this blog post, [Merve](https://twitter.com/mervenoyann) was kind enough to take a quick look and noted that \"hatted\" characters - like `â` - aren't really used anymore in Turkish and can be replaced by their \"un-hatted\" equivalent, *e.g.* `a`. \n", "\n", "This means that we should replace a sentence like `\"yargı sistemi hâlâ sağlıksız\"` to `\"yargı sistemi hala sağlıksız\"`.\n", "\n", "Let's write another short mapping function to further simplify the text labels. Remember - the simler the text labels, the easier it is for the model to learn to predict those labels.\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "3ORHDb2Th2TW" }, "source": [ "In CTC, it is common to classify speech chunks into letters, so we will do the same here. \n", "Let's extract all distinct letters of the training and test data and build our vocabulary from this set of letters.\n", "\n", "We write a mapping function that concatenates all transcriptions into one long transcription and then transforms the string into a set of chars. \n", "It is important to pass the argument `batched=True` to the `map(...)` function so that the mapping function has access to all transcriptions at once." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "id": "LwCshNbbeRZR" }, "outputs": [], "source": [ "def extract_all_chars(batch):\n", " all_text = \" \".join(batch[\"sentence\"])\n", " vocab = list(set(all_text))\n", " return {\"vocab\": [vocab], \"all_text\": [all_text]}" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "id": "_m6uUjjcfbjH", "outputId": "9c682f7d-4c56-42bb-facc-61ae3caf8f1b" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4551f3bdf57043338405f28cec184686", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/1 [00:00 main\n", "\n" ] }, { "data": { "text/plain": [ "'https://huggingface.co/RASMUS/wav2vec2-xlsr-fi-train-aug-lm-1B/commit/643faa1cd17fd495ee7547952b23a5526648b564'" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tokenizer.push_to_hub(repo_name)" ] }, { "cell_type": "markdown", "metadata": { "id": "SwQM8lH_GGuP" }, "source": [ "Great, you can see the just created repository under `https://huggingface.co//wav2vec2-large-xls-r-300m-tr-colab`" ] }, { "cell_type": "markdown", "metadata": { "id": "mYcIiR2FQ96i" }, "source": [ "### Create `Wav2Vec2FeatureExtractor`" ] }, { "cell_type": "markdown", "metadata": { "id": "Y6mDEyW719rx" }, "source": [ "Speech is a continuous signal and to be treated by computers, it first has to be discretized, which is usually called **sampling**. The sampling rate hereby plays an important role in that it defines how many data points of the speech signal are measured per second. Therefore, sampling with a higher sampling rate results in a better approximation of the *real* speech signal but also necessitates more values per second.\n", "\n", "A pretrained checkpoint expects its input data to have been sampled more or less from the same distribution as the data it was trained on. The same speech signals sampled at two different rates have a very different distribution, *e.g.*, doubling the sampling rate results in data points being twice as long. Thus, \n", "before fine-tuning a pretrained checkpoint of an ASR model, it is crucial to verify that the sampling rate of the data that was used to pretrain the model matches the sampling rate of the dataset used to fine-tune the model.\n", "\n", "XLS-R was pretrained on audio data of [Babel](http://www.reading.ac.uk/AcaDepts/ll/speechlab/babel/r), \n", "[Multilingual LibriSpeech (MLS)](https://huggingface.co/datasets/multilingual_librispeech), [Common Voice](https://huggingface.co/datasets/common_voice), [VoxPopuli](https://arxiv.org/abs/2101.00390), and [VoxLingua107](https://arxiv.org/abs/2011.12998) at a sampling rate of 16kHz. Common Voice, in its original form, has a sampling rate of 48kHz, thus we will have to downsample the fine-tuning data to 16kHz in the following.\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "KuUbPW7oV-B5" }, "source": [ "A `Wav2Vec2FeatureExtractor` object requires the following parameters to be instantiated:\n", "\n", "- `feature_size`: Speech models take a sequence of feature vectors as an input. While the length of this sequence obviously varies, the feature size should not. In the case of Wav2Vec2, the feature size is 1 because the model was trained on the raw speech signal ${}^2$.\n", "- `sampling_rate`: The sampling rate at which the model is trained on.\n", "- `padding_value`: For batched inference, shorter inputs need to be padded with a specific value\n", "- `do_normalize`: Whether the input should be *zero-mean-unit-variance* normalized or not. Usually, speech models perform better when normalizing the input\n", "- `return_attention_mask`: Whether the model should make use of an `attention_mask` for batched inference. In general, XLS-R models checkpoints should **always** use the `attention_mask`." ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "id": "kAR0-2KLkopp" }, "outputs": [], "source": [ "from transformers import Wav2Vec2FeatureExtractor\n", "\n", "feature_extractor = Wav2Vec2FeatureExtractor(feature_size=1, sampling_rate=16000, padding_value=0.0, do_normalize=True, return_attention_mask=True)" ] }, { "cell_type": "markdown", "metadata": { "id": "qUETetgqYC3W" }, "source": [ "Great, XLS-R's feature extraction pipeline is thereby fully defined!\n", "\n", "For improved user-friendliness, the feature extractor and tokenizer are *wrapped* into a single `Wav2Vec2Processor` class so that one only needs a `model` and `processor` object." ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "id": "KYZtoW-tlZgl" }, "outputs": [], "source": [ "from transformers import Wav2Vec2Processor\n", "\n", "processor = Wav2Vec2Processor(feature_extractor=feature_extractor, tokenizer=tokenizer)" ] }, { "cell_type": "markdown", "metadata": { "id": "DrKnYuvDIoOO" }, "source": [ "Next, we can prepare the dataset." ] }, { "cell_type": "markdown", "metadata": { "id": "YFmShnl7RE35" }, "source": [ "### Preprocess Data\n", "\n", "So far, we have not looked at the actual values of the speech signal but just the transcription. In addition to `sentence`, our datasets include two more column names `path` and `audio`. `path` states the absolute path of the audio file. Let's take a look.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "T6ndIjHGFp0W" }, "source": [ "XLS-R expects the input in the format of a 1-dimensional array of 16 kHz. This means that the audio file has to be loaded and resampled.\n", "\n", " Thankfully, `datasets` does this automatically by calling the other column `audio`. Let try it out. " ] }, { "cell_type": "markdown", "metadata": { "id": "WUUTgI1bGHW-" }, "source": [ "Great, we can see that the audio file has automatically been loaded. This is thanks to the new [`\"Audio\"` feature](https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=audio#datasets.Audio) introduced in `datasets == 4.13.3`, which loads and resamples audio files on-the-fly upon calling.\n", "\n", "In the example above we can see that the audio data is loaded with a sampling rate of 48kHz whereas 16kHz are expected by the model. We can set the audio feature to the correct sampling rate by making use of [`cast_column`](https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=cast_column#datasets.DatasetDict.cast_column):" ] }, { "cell_type": "code", "execution_count": 117, "metadata": {}, "outputs": [], "source": [ "test = common_voice_train.select([277])" ] }, { "cell_type": "code", "execution_count": 118, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'path': '/workspace/xlsr_fi/common_voice_fi/clips/common_voice_fi_24124649.mp3',\n", " 'sentence': 'eikö sitten ole vanha',\n", " 'audio': '/workspace/xlsr_fi/common_voice_fi/clips/common_voice_fi_24124649.mp3',\n", " 'filename': 'common_voice_fi_24124649.mp3'}" ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test[0]" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "import torchaudio" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "16000\n", "22050\n", "16000\n", "16000\n", "32000\n", "32000\n" ] } ], "source": [ "speech_array, sampling_rate = torchaudio.load(voxpopuli_fi[3][\"path\"])\n", "print(sampling_rate)\n", "speech_array, sampling_rate = torchaudio.load(css10[4][\"path\"])\n", "print(sampling_rate)\n", "speech_array, sampling_rate = torchaudio.load(aalto_eduskunta_asr[5][\"path\"])\n", "print(sampling_rate)\n", "speech_array, sampling_rate = torchaudio.load(parliament[4][\"path\"])\n", "print(sampling_rate)\n", "speech_array, sampling_rate = torchaudio.load(common_voice_train[277][\"path\"])\n", "print(sampling_rate)\n", "speech_array, sampling_rate = torchaudio.load(common_voice_test[0][\"path\"])\n", "print(sampling_rate)\n", "\n" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "common_voice_train = concatenate_datasets([common_voice_train, voxpopuli_fi])\n", "common_voice_train = concatenate_datasets([common_voice_train, parliament])\n", "common_voice_train = concatenate_datasets([common_voice_train, css10])\n", "common_voice_train = concatenate_datasets([common_voice_train, aalto_eduskunta_asr])\n", "common_voice_train = concatenate_datasets([common_voice_train, fbc_monolog])\n", "common_voice_train = concatenate_datasets([common_voice_train, fbc_dialog])" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "id": "rrv65aj7G95i" }, "outputs": [], "source": [ "common_voice_train_audio = common_voice_train.cast_column(\"audio\", Audio(sampling_rate=16_000))\n", "common_voice_test_audio = common_voice_test.cast_column(\"audio\", Audio(sampling_rate=16_000))\n" ] }, { "cell_type": "code", "execution_count": 162, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'path': '/workspace/xlsr_fi/common_voice_fi/clips/common_voice_fi_25130781.mp3',\n", " 'array': array([ 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, ...,\n", " 3.7312715e-05, 1.2023805e-05, -3.0640190e-06], dtype=float32),\n", " 'sampling_rate': 16000}" ] }, "execution_count": 162, "metadata": {}, "output_type": "execute_result" } ], "source": [ "common_voice_train_audio[0][\"audio\"]" ] }, { "cell_type": "markdown", "metadata": { "id": "PcnO4x-NGBEi" }, "source": [ "Let's take a look at `\"audio\"` again." ] }, { "cell_type": "markdown", "metadata": { "id": "SOckzFd4Mbzq" }, "source": [ "This seemed to have worked! Let's listen to a couple of audio files to better understand the dataset and verify that the audio was correctly loaded. \n", "\n", "**Note**: *You can click the following cell a couple of times to listen to different speech samples.*" ] }, { "cell_type": "code", "execution_count": 124, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "12530\n", "{'path': '/workspace/xlsr_fi/css10/gulliverin_matkat_kaukaisilla_mailla/gulliverin_matkat_kaukaisilla_mailla_1015.wav', 'sentence': 'hänen majesteetinsa keisarillisen perheensä kanssa ja seurassaan hovin korkeat virkamiehet', 'audio': {'path': '/workspace/xlsr_fi/css10/gulliverin_matkat_kaukaisilla_mailla/gulliverin_matkat_kaukaisilla_mailla_1015.wav', 'array': array([-0.00083112, -0.00110539, -0.00092473, ..., 0.00061306,\n", " 0.00055866, 0. ], dtype=float32), 'sampling_rate': 16000}, 'filename': 'gulliverin_matkat_kaukaisilla_mailla/gulliverin_matkat_kaukaisilla_mailla_1015.wav'}\n", "hänen majesteetinsa keisarillisen perheensä kanssa ja seurassaan hovin korkeat virkamiehet\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 124, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import IPython.display as ipd\n", "import numpy as np\n", "import random\n", "\n", "rand_int = random.randint(0, len(common_voice_train_audio)-1)\n", "print(rand_int)\n", "\n", "print(common_voice_train_audio[rand_int])\n", "print(common_voice_train_audio[rand_int][\"sentence\"])\n", "ipd.Audio(data=common_voice_train_audio[rand_int][\"audio\"][\"array\"], autoplay=True, rate=16000)" ] }, { "cell_type": "markdown", "metadata": { "id": "gY8m3vARHYTa" }, "source": [ "It seems like the data is now correctly loaded and resampled. " ] }, { "cell_type": "markdown", "metadata": { "id": "1MaL9J2dNVtG" }, "source": [ "It can be heard, that the speakers change along with their speaking rate, accent, and background environment, etc. Overall, the recordings sound acceptably clear though, which is to be expected from a crowd-sourced read speech corpus.\n", "\n", "Let's do a final check that the data is correctly prepared, by printing the shape of the speech input, its transcription, and the corresponding sampling rate.\n", "\n", "**Note**: *You can click the following cell a couple of times to verify multiple samples.*" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Architecture: x86_64\n", "CPU op-mode(s): 32-bit, 64-bit\n", "Byte Order: Little Endian\n", "CPU(s): 60\n", "On-line CPU(s) list: 0-59\n", "Thread(s) per core: 1\n", "Core(s) per socket: 1\n", "Socket(s): 60\n", "NUMA node(s): 1\n", "Vendor ID: GenuineIntel\n", "CPU family: 6\n", "Model: 85\n", "Model name: Intel(R) Xeon(R) Gold 6226R CPU @ 2.90GHz\n", "Stepping: 7\n", "CPU MHz: 2893.208\n", "BogoMIPS: 5786.41\n", "Virtualization: VT-x\n", "Hypervisor vendor: KVM\n", "Virtualization type: full\n", "L1d cache: 32K\n", "L1i cache: 32K\n", "L2 cache: 4096K\n", "L3 cache: 16384K\n", "NUMA node0 CPU(s): 0-59\n", "Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat umip pku ospke avx512_vnni md_clear arch_capabilities\n" ] } ], "source": [ "!lscpu" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "def prepare_dataset(batch):\n", " audio = batch[\"audio\"]\n", "\n", " # batched output is \"un-batched\"\n", " batch[\"input_values\"] = processor(audio[\"array\"], sampling_rate=audio[\"sampling_rate\"]).input_values[0]\n", " batch[\"input_length\"] = len(batch[\"input_values\"])\n", " \n", " with processor.as_target_processor():\n", " batch[\"labels\"] = processor(batch[\"sentence\"]).input_ids\n", " return batch" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "done train\n" ] } ], "source": [ "common_voice_train_audio = common_voice_train_audio.map(prepare_dataset, remove_columns=common_voice_train_audio.column_names, num_proc=48)\n", "print(\"done train\")\n", "common_voice_test_audio = common_voice_test_audio.map(prepare_dataset, remove_columns=common_voice_test_audio.column_names, num_proc=48)" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['input_values', 'input_length', 'labels'],\n", " num_rows: 19453\n", "})" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "common_voice_train_audio" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "9439\n", "[15, 3, 3, 22, 3, 14, 17, 23, 21, 24, 3, 14, 11, 17, 13, 23, 16, 16, 3, 16, 0, 24, 3, 14, 15, 11, 21, 22, 7, 14, 11, 12, 3, 16, 3, 0, 22, 3, 10, 6, 17, 16, 0, 3, 14, 14, 7, 24, 11, 11, 24, 3, 22, 3, 0, 20, 23, 17, 13, 3, 0, 12, 3, 0, 14, 23, 17, 16, 16, 17, 16, 24, 3, 20, 3, 13, 14, 23, 21, 22, 7, 20, 11, 16, 0, 15, 7, 20, 13, 11, 22, 27, 21, 22, 29]\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import IPython.display as ipd\n", "import numpy as np\n", "import random\n", "\n", "rand_int = random.randint(0, len(common_voice_train_audio)-1)\n", "print(rand_int)\n", "\n", "print(common_voice_train_audio[rand_int][\"labels\"])\n", "ipd.Audio(data=common_voice_train_audio[rand_int][\"input_values\"], autoplay=True, rate=16000)" ] }, { "cell_type": "code", "execution_count": 188, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1309\n", "[29, 29, 16, 7, 21, 22, 29, 15, 15, 7, 0, 21, 11, 13, 21, 11, 0, 22, 29, 22, 29, 0, 15, 11, 7, 22, 11, 16, 22, 31, 29, 0, 24, 3, 21, 22, 3, 3, 16]\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 188, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import IPython.display as ipd\n", "import numpy as np\n", "import random\n", "\n", "rand_int = random.randint(0, len(common_voice_test_audio)-1)\n", "print(rand_int)\n", "\n", "print(common_voice_test_audio[rand_int][\"labels\"])\n", "ipd.Audio(data=common_voice_test_audio[rand_int][\"input_values\"], autoplay=True, rate=16000)" ] }, { "cell_type": "markdown", "metadata": { "id": "M9teZcSwOBJ4" }, "source": [ "Good! Everything looks fine - the data is a 1-dimensional array, the sampling rate always corresponds to 16kHz, and the target text is normalized." ] }, { "cell_type": "markdown", "metadata": { "id": "k3Pbn5WvOYZF" }, "source": [ "Finally, we can leverage `Wav2Vec2Processor` to process the data to the format expected by `Wav2Vec2ForCTC` for training. To do so let's make use of Dataset's [`map(...)`](https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=map#datasets.DatasetDict.map) function.\n", "\n", "First, we load and resample the audio data, simply by calling `batch[\"audio\"]`.\n", "Second, we extract the `input_values` from the loaded audio file. In our case, the `Wav2Vec2Processor` only normalizes the data. For other speech models, however, this step can include more complex feature extraction, such as [Log-Mel feature extraction](https://en.wikipedia.org/wiki/Mel-frequency_cepstrum). \n", "Third, we encode the transcriptions to label ids.\n", "\n", "**Note**: This mapping function is a good example of how the `Wav2Vec2Processor` class should be used. In \"normal\" context, calling `processor(...)` is redirected to `Wav2Vec2FeatureExtractor`'s call method. When wrapping the processor into the `as_target_processor` context, however, the same method is redirected to `Wav2Vec2CTCTokenizer`'s call method.\n", "For more information please check the [docs](https://huggingface.co/transformers/master/model_doc/wav2vec2.html#transformers.Wav2Vec2Processor.__call__)." ] }, { "cell_type": "markdown", "metadata": { "id": "q6Pg_WR3OGAP" }, "source": [ "Let's apply the data preparation function to all examples." ] }, { "cell_type": "markdown", "metadata": { "id": "nKcEWHvKI1by" }, "source": [ "**Note**: Currently `datasets` make use of [`torchaudio`](https://pytorch.org/audio/stable/index.html) and [`librosa`](https://librosa.org/doc/latest/index.html) for audio loading and resampling. If you wish to implement your own costumized data loading/sampling, feel free to just make use of the `\"path\"` column instead and disregard the `\"audio\"` column." ] }, { "cell_type": "markdown", "metadata": { "id": "24CxHd5ewI4T" }, "source": [ "Long input sequences require a lot of memory. XLS-R is based on `self-attention` the memory requirement scales quadratically with the input length for long input sequences (*cf.* with [this](https://www.reddit.com/r/MachineLearning/comments/genjvb/d_why_is_the_maximum_input_sequence_length_of/) reddit post). In case this demo crashes with an \"Out-of-memory\" error for you, you might want to uncomment the following lines to filter all sequences that are longer than 5 seconds for training." ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['path', 'sentence', 'audio', 'filename'],\n", " num_rows: 19453\n", "})" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "common_voice_train" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "import random\n", "augmented_samples_to_add = common_voice_train_audio.select([random.randint(0,19453) for i in range(3000)])" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['input_values', 'input_length', 'labels'],\n", " num_rows: 3000\n", "})" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "augmented_samples_to_add" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "from audiomentations import Compose, AddGaussianNoise, TimeStretch, PitchShift, Shift\n", "\n", "# Augment method suggested by HF community member, TODO: better augmentation\n", "augment = Compose([\n", " AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.008, p=0.5),\n", " TimeStretch(min_rate=0.85, max_rate=1.15, p=0.5),\n", " Shift(min_fraction=-0.5, max_fraction=0.5, p=0.5)\n", " \n", "\n", "])\n", "\n", "def augment_dataset(batch):\n", " batch[\"input_values\"] = augment(samples=np.asarray(batch[\"input_values\"]), sample_rate=16000)\n", " return batch" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n", "/opt/conda/lib/python3.8/site-packages/audiomentations/core/transforms_interface.py:57: UserWarning: Warning: input samples have np.float64 dtype. Converting to np.float32...\n", " warnings.warn(\n" ] } ], "source": [ "augmented_samples_to_add = augmented_samples_to_add.map(augment_dataset, num_proc=8)" ] }, { "cell_type": "code", "execution_count": 151, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2966\n", "[0, 24, 7, 16, 29, 12, 29, 16, 0, 22, 23, 13, 7, 15, 3, 22, 0, 3, 4, 10, 3, 3, 21, 11, 3, 0, 12, 3, 0, 7, 22, 7, 14, 29, 2, 17, 21, 21, 7, 22, 11, 3, 0, 17, 24, 3, 22, 0, 12, 17, 0, 18, 11, 22, 13, 29, 29, 16, 0, 18, 27, 20, 13, 11, 16, 7, 7, 22, 0, 7, 20, 17, 17, 16, 0, 9, 7, 17, 20, 9, 11, 3, 21, 22, 3]\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 151, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import IPython.display as ipd\n", "import numpy as np\n", "import random\n", "\n", "rand_int = random.randint(0, len(augmented_samples_to_add)-1)\n", "print(rand_int)\n", "\n", "print(augmented_samples_to_add[rand_int][\"labels\"])\n", "ipd.Audio(data=augmented_samples_to_add[rand_int][\"input_values\"], autoplay=True, rate=16000)" ] }, { "cell_type": "code", "execution_count": 152, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['input_values', 'input_length', 'labels'],\n", " num_rows: 3000\n", "})" ] }, "execution_count": 152, "metadata": {}, "output_type": "execute_result" } ], "source": [ "augmented_samples_to_add" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "common_voice_train_audio_augmented = concatenate_datasets([common_voice_train_audio, augmented_samples_to_add])" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['input_values', 'input_length', 'labels'],\n", " num_rows: 22453\n", "})" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "common_voice_train_audio_augmented" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "id": "tdHfbUJ_09iA" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "train before filtering:\n", "Dataset({\n", " features: ['input_values', 'input_length', 'labels'],\n", " num_rows: 22453\n", "})\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c088e77593c345f496faf74b7a374823", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/23 [00:00 min_input_length_in_sec * processor.feature_extractor.sampling_rate, input_columns=[\"input_length\"])\n", "print('train after filtering:')\n", "print(common_voice_train_audio_augmented)\n", "# print('\\n')\n", "# print('test before filtering:')\n", "# print(common_voice_test_audio)\n", "# common_voice_test_audio = common_voice_test_audio.filter(lambda x: x < max_input_length_in_sec * processor.feature_extractor.sampling_rate, input_columns=[\"input_length\"])\n", "# common_voice_test_audio = common_voice_test_audio.filter(lambda x: x > min_input_length_in_sec * processor.feature_extractor.sampling_rate, input_columns=[\"input_length\"])\n", "# print('test after filtering:')\n", "# print(common_voice_test)" ] }, { "cell_type": "markdown", "metadata": { "id": "1ZWDCCKqwcfS" }, "source": [ "Awesome, now we are ready to start training!" ] }, { "cell_type": "markdown", "metadata": { "id": "gYlQkKVoRUos" }, "source": [ "## Training\n", "\n", "The data is processed so that we are ready to start setting up the training pipeline. We will make use of 🤗's [Trainer](https://huggingface.co/transformers/master/main_classes/trainer.html?highlight=trainer) for which we essentially need to do the following:\n", "\n", "- Define a data collator. In contrast to most NLP models, XLS-R has a much larger input length than output length. *E.g.*, a sample of input length 50000 has an output length of no more than 100. Given the large input sizes, it is much more efficient to pad the training batches dynamically meaning that all training samples should only be padded to the longest sample in their batch and not the overall longest sample. Therefore, fine-tuning XLS-R requires a special padding data collator, which we will define below\n", "\n", "- Evaluation metric. During training, the model should be evaluated on the word error rate. We should define a `compute_metrics` function accordingly\n", "\n", "- Load a pretrained checkpoint. We need to load a pretrained checkpoint and configure it correctly for training.\n", "\n", "- Define the training configuration.\n", "\n", "After having fine-tuned the model, we will correctly evaluate it on the test data and verify that it has indeed learned to correctly transcribe speech." ] }, { "cell_type": "markdown", "metadata": { "id": "Slk403unUS91" }, "source": [ "### Set-up Trainer\n", "\n", "Let's start by defining the data collator. The code for the data collator was copied from [this example](https://github.com/huggingface/transformers/blob/7e61d56a45c19284cfda0cee8995fb552f6b1f4e/examples/pytorch/speech-recognition/run_speech_recognition_ctc.py#L219).\n", "\n", "Without going into too many details, in contrast to the common data collators, this data collator treats the `input_values` and `labels` differently and thus applies to separate padding functions on them (again making use of XLS-R processor's context manager). This is necessary because in speech input and output are of different modalities meaning that they should not be treated by the same padding function.\n", "Analogous to the common data collators, the padding tokens in the labels with `-100` so that those tokens are **not** taken into account when computing the loss." ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "id": "tborvC9hx88e" }, "outputs": [], "source": [ "import torch\n", "\n", "from dataclasses import dataclass, field\n", "from typing import Any, Dict, List, Optional, Union\n", "\n", "@dataclass\n", "class DataCollatorCTCWithPadding:\n", " \"\"\"\n", " Data collator that will dynamically pad the inputs received.\n", " Args:\n", " processor (:class:`~transformers.Wav2Vec2Processor`)\n", " The processor used for proccessing the data.\n", " padding (:obj:`bool`, :obj:`str` or :class:`~transformers.tokenization_utils_base.PaddingStrategy`, `optional`, defaults to :obj:`True`):\n", " Select a strategy to pad the returned sequences (according to the model's padding side and padding index)\n", " among:\n", " * :obj:`True` or :obj:`'longest'`: Pad to the longest sequence in the batch (or no padding if only a single\n", " sequence if provided).\n", " * :obj:`'max_length'`: Pad to a maximum length specified with the argument :obj:`max_length` or to the\n", " maximum acceptable input length for the model if that argument is not provided.\n", " * :obj:`False` or :obj:`'do_not_pad'` (default): No padding (i.e., can output a batch with sequences of\n", " different lengths).\n", " \"\"\"\n", "\n", " processor: Wav2Vec2Processor\n", " padding: Union[bool, str] = True\n", "\n", " def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -> Dict[str, torch.Tensor]:\n", " # split inputs and labels since they have to be of different lenghts and need\n", " # different padding methods\n", " input_features = [{\"input_values\": feature[\"input_values\"]} for feature in features]\n", " label_features = [{\"input_ids\": feature[\"labels\"]} for feature in features]\n", "\n", " batch = self.processor.pad(\n", " input_features,\n", " padding=self.padding,\n", " return_tensors=\"pt\",\n", " )\n", " with self.processor.as_target_processor():\n", " labels_batch = self.processor.pad(\n", " label_features,\n", " padding=self.padding,\n", " return_tensors=\"pt\",\n", " )\n", "\n", " # replace padding with -100 to ignore loss correctly\n", " labels = labels_batch[\"input_ids\"].masked_fill(labels_batch.attention_mask.ne(1), -100)\n", "\n", " batch[\"labels\"] = labels\n", "\n", " return batch" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "id": "lbQf5GuZyQ4_" }, "outputs": [], "source": [ "data_collator = DataCollatorCTCWithPadding(processor=processor, padding=True)" ] }, { "cell_type": "markdown", "metadata": { "id": "xO-Zdj-5cxXp" }, "source": [ "Next, the evaluation metric is defined. As mentioned earlier, the \n", "predominant metric in ASR is the word error rate (WER), hence we will use it in this notebook as well." ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "id": "9Xsux2gmyXso", "outputId": "4ae12795-d6ac-4b51-ff84-748c8a3c8bc9" }, "outputs": [], "source": [ "wer_metric = load_metric(\"wer\")" ] }, { "cell_type": "markdown", "metadata": { "id": "E1qZU5p-deqB" }, "source": [ "The model will return a sequence of logit vectors:\n", "$\\mathbf{y}_1, \\ldots, \\mathbf{y}_m$ with $\\mathbf{y}_1 = f_{\\theta}(x_1, \\ldots, x_n)[0]$ and $n >> m$.\n", "\n", "A logit vector $\\mathbf{y}_1$ contains the log-odds for each word in the vocabulary we defined earlier, thus $\\text{len}(\\mathbf{y}_i) =$ `config.vocab_size`. We are interested in the most likely prediction of the model and thus take the `argmax(...)` of the logits. Also, we transform the encoded labels back to the original string by replacing `-100` with the `pad_token_id` and decoding the ids while making sure that consecutive tokens are **not** grouped to the same token in CTC style ${}^1$." ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "id": "1XZ-kjweyTy_" }, "outputs": [], "source": [ "def compute_metrics(pred):\n", " pred_logits = pred.predictions\n", " pred_ids = np.argmax(pred_logits, axis=-1)\n", "\n", " pred.label_ids[pred.label_ids == -100] = processor.tokenizer.pad_token_id\n", "\n", " pred_str = processor.batch_decode(pred_ids)\n", " # we do not want to group tokens when computing the metrics\n", " label_str = processor.batch_decode(pred.label_ids, group_tokens=False)\n", "\n", " wer = wer_metric.compute(predictions=pred_str, references=label_str)\n", "\n", " return {\"wer\": wer}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "id": "Xmgrx4bRwLIH" }, "source": [ "Now, we can load the pretrained checkpoint of [Wav2Vec2-XLS-R-300M](https://huggingface.co/facebook/wav2vec2-xls-r-300m). The tokenizer's `pad_token_id` must be to define the model's `pad_token_id` or in the case of `Wav2Vec2ForCTC` also CTC's *blank token* ${}^2$. To save GPU memory, we enable PyTorch's [gradient checkpointing](https://pytorch.org/docs/stable/checkpoint.html) and also set the loss reduction to \"*mean*\".\n", "\n", "Because the dataset is quite small (~6h of training data) and because Common Voice is quite noisy, fine-tuning Facebook's [wav2vec2-xls-r-300m checkpoint](https://huggingface.co/facebook/wav2vec2-xls-r-300m) seems to require some hyper-parameter tuning. Therefore, I had to play around a bit with different values for dropout, [SpecAugment](https://arxiv.org/abs/1904.08779)'s masking dropout rate, layer dropout, and the learning rate until training seemed to be stable enough. \n", "\n", "**Note**: When using this notebook to train XLS-R on another language of Common Voice those hyper-parameter settings might not work very well. Feel free to adapt those depending on your use case. " ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true } }, "outputs": [ { "data": { "text/plain": [ "Wav2Vec2ForCTC(\n", " (wav2vec2): Wav2Vec2Model(\n", " (feature_extractor): Wav2Vec2FeatureEncoder(\n", " (conv_layers): ModuleList(\n", " (0): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(1, 512, kernel_size=(10,), stride=(5,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (1): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (2): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (3): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (4): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (5): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(2,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (6): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(2,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " )\n", " )\n", " (feature_projection): Wav2Vec2FeatureProjection(\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (projection): Linear(in_features=512, out_features=1280, bias=True)\n", " (dropout): Dropout(p=0.04, inplace=False)\n", " )\n", " (encoder): Wav2Vec2EncoderStableLayerNorm(\n", " (pos_conv_embed): Wav2Vec2PositionalConvEmbedding(\n", " (conv): Conv1d(1280, 1280, kernel_size=(128,), stride=(1,), padding=(64,), groups=16)\n", " (padding): Wav2Vec2SamePadLayer()\n", " )\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layers): ModuleList(\n", " (0): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (1): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (2): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (3): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (4): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (5): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (6): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (7): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (8): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (9): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (10): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (11): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (12): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (13): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (14): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (15): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (16): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (17): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (18): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (19): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (20): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (21): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (22): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (23): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (24): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (25): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (26): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (27): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (28): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (29): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (30): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (31): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (32): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (33): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (34): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (35): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (36): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (37): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (38): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (39): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (40): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (41): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (42): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (43): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (44): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (45): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (46): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (47): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " )\n", " )\n", " )\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " (lm_head): Linear(in_features=1280, out_features=36, bias=True)\n", ")" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from transformers import Wav2Vec2ForCTC\n", "\n", "model = Wav2Vec2ForCTC.from_pretrained(\n", " \"wav2vec2-xlsr-fi-train-aug-lm-1B\", \n", " attention_dropout=0.094,\n", " hidden_dropout=0.047,\n", " feat_proj_dropout=0.04,\n", " mask_time_prob=0.082,\n", " layerdrop=0.041,\n", " activation_dropout=0.055,\n", " ctc_loss_reduction=\"mean\", \n", " pad_token_id=processor.tokenizer.pad_token_id,\n", " vocab_size=len(processor.tokenizer),\n", ")\n", "model.to('cuda')" ] }, { "cell_type": "code", "execution_count": 163, "metadata": { "collapsed": true, "id": "e7cqAWIayn6w", "jupyter": { "outputs_hidden": true }, "outputId": "4f01d0c0-de3f-44b2-df05-b7c734f15448" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Some weights of the model checkpoint at facebook/wav2vec2-xls-r-1b were not used when initializing Wav2Vec2ForCTC: ['project_q.weight', 'project_hid.weight', 'project_hid.bias', 'project_q.bias', 'quantizer.weight_proj.bias', 'quantizer.codevectors', 'quantizer.weight_proj.weight']\n", "- This IS expected if you are initializing Wav2Vec2ForCTC from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n", "- This IS NOT expected if you are initializing Wav2Vec2ForCTC from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n", "Some weights of Wav2Vec2ForCTC were not initialized from the model checkpoint at facebook/wav2vec2-xls-r-1b and are newly initialized: ['lm_head.weight', 'lm_head.bias']\n", "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n" ] }, { "data": { "text/plain": [ "Wav2Vec2ForCTC(\n", " (wav2vec2): Wav2Vec2Model(\n", " (feature_extractor): Wav2Vec2FeatureEncoder(\n", " (conv_layers): ModuleList(\n", " (0): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(1, 512, kernel_size=(10,), stride=(5,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (1): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (2): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (3): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (4): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(3,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (5): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(2,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (6): Wav2Vec2LayerNormConvLayer(\n", " (conv): Conv1d(512, 512, kernel_size=(2,), stride=(2,))\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " )\n", " )\n", " )\n", " (feature_projection): Wav2Vec2FeatureProjection(\n", " (layer_norm): LayerNorm((512,), eps=1e-05, elementwise_affine=True)\n", " (projection): Linear(in_features=512, out_features=1280, bias=True)\n", " (dropout): Dropout(p=0.04, inplace=False)\n", " )\n", " (encoder): Wav2Vec2EncoderStableLayerNorm(\n", " (pos_conv_embed): Wav2Vec2PositionalConvEmbedding(\n", " (conv): Conv1d(1280, 1280, kernel_size=(128,), stride=(1,), padding=(64,), groups=16)\n", " (padding): Wav2Vec2SamePadLayer()\n", " )\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layers): ModuleList(\n", " (0): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (1): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (2): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (3): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (4): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (5): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (6): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (7): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (8): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (9): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (10): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (11): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (12): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (13): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (14): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (15): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (16): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (17): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (18): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (19): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (20): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (21): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (22): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (23): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (24): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (25): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (26): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (27): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (28): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (29): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (30): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (31): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (32): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (33): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (34): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (35): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (36): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (37): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (38): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (39): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (40): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (41): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (42): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (43): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (44): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (45): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (46): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " (47): Wav2Vec2EncoderLayerStableLayerNorm(\n", " (attention): Wav2Vec2Attention(\n", " (k_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (v_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (q_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " (out_proj): Linear(in_features=1280, out_features=1280, bias=True)\n", " )\n", " (dropout): Dropout(p=0.047, inplace=False)\n", " (layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " (feed_forward): Wav2Vec2FeedForward(\n", " (intermediate_dropout): Dropout(p=0.055, inplace=False)\n", " (intermediate_dense): Linear(in_features=1280, out_features=5120, bias=True)\n", " (output_dense): Linear(in_features=5120, out_features=1280, bias=True)\n", " (output_dropout): Dropout(p=0.047, inplace=False)\n", " )\n", " (final_layer_norm): LayerNorm((1280,), eps=1e-05, elementwise_affine=True)\n", " )\n", " )\n", " )\n", " )\n", " (dropout): Dropout(p=0.0, inplace=False)\n", " (lm_head): Linear(in_features=1280, out_features=36, bias=True)\n", ")" ] }, "execution_count": 163, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from transformers import Wav2Vec2ForCTC\n", "\n", "model = Wav2Vec2ForCTC.from_pretrained(\n", " \"facebook/wav2vec2-xls-r-1b\", \n", " attention_dropout=0.094,\n", " hidden_dropout=0.047,\n", " feat_proj_dropout=0.04,\n", " mask_time_prob=0.082,\n", " layerdrop=0.041,\n", " activation_dropout=0.055,\n", " ctc_loss_reduction=\"mean\", \n", " pad_token_id=processor.tokenizer.pad_token_id,\n", " vocab_size=len(processor.tokenizer),\n", ")\n", "model.to('cuda')" ] }, { "cell_type": "markdown", "metadata": { "id": "1DwR3XLSzGDD" }, "source": [ "The first component of XLS-R consists of a stack of CNN layers that are used to extract acoustically meaningful - but contextually independent - features from the raw speech signal. This part of the model has already been sufficiently trained during pretraining and as stated in the [paper](https://arxiv.org/pdf/2006.13979.pdf) does not need to be fine-tuned anymore. \n", "Thus, we can set the `requires_grad` to `False` for all parameters of the *feature extraction* part." ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "id": "oGI8zObtZ3V0" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.8/site-packages/transformers/models/wav2vec2/modeling_wav2vec2.py:1680: FutureWarning: The method `freeze_feature_extractor` is deprecated and will be removed in Transformers v5.Please use the equivalent `freeze_feature_encoder` method instead.\n", " warnings.warn(\n" ] } ], "source": [ "model.freeze_feature_extractor()" ] }, { "cell_type": "markdown", "metadata": { "id": "lD4aGhQM0K-D" }, "source": [ "In a final step, we define all parameters related to training. \n", "To give more explanation on some of the parameters:\n", "- `group_by_length` makes training more efficient by grouping training samples of similar input length into one batch. This can significantly speed up training time by heavily reducing the overall number of useless padding tokens that are passed through the model\n", "- `learning_rate` and `weight_decay` were heuristically tuned until fine-tuning has become stable. Note that those parameters strongly depend on the Common Voice dataset and might be suboptimal for other speech datasets.\n", "\n", "For more explanations on other parameters, one can take a look at the [docs](https://huggingface.co/transformers/master/main_classes/trainer.html?highlight=trainer#trainingarguments).\n", "\n", "During training, a checkpoint will be uploaded asynchronously to the hub every 400 training steps. It allows you to also play around with the demo widget even while your model is still training.\n", "\n", "**Note**: If one does not want to upload the model checkpoints to the hub, simply set `push_to_hub=False`." ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "os.environ[\"WANDB_DISABLED\"] = \"true\"" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "id": "KbeKSV7uzGPP" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using the `WAND_DISABLED` environment variable is deprecated and will be removed in v5. Use the --report_to flag to control the integrations used for logging result (for instance --report_to none).\n" ] } ], "source": [ "from transformers import TrainingArguments\n", "\n", "training_args = TrainingArguments(\n", " output_dir=repo_name,\n", " group_by_length=True,\n", " per_device_train_batch_size=8,\n", " gradient_accumulation_steps=2,\n", " evaluation_strategy=\"steps\",\n", " num_train_epochs=4,\n", " gradient_checkpointing=True,\n", " fp16=True,\n", " save_steps=400,\n", " eval_steps=400,\n", " logging_steps=50,\n", " learning_rate=1e-4,\n", " warmup_steps=100,\n", " save_total_limit=3,\n", " push_to_hub=True,\n", " load_best_model_at_end=True,\n", " greater_is_better=False,\n", " metric_for_best_model='eval_wer',\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "OsW-WZcL1ZtN" }, "source": [ "Now, all instances can be passed to Trainer and we are ready to start training!" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "id": "rY7vBmFCPFgC", "outputId": "441e7019-a5a1-4c0a-afa2-cced90ffed05" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/workspace/xlsr_fi/wav2vec2-xlsr-fi-train-aug-lm-1B is already a clone of https://huggingface.co/RASMUS/wav2vec2-xlsr-fi-train-aug-lm-1B. Make sure you pull the latest changes with `repo.git_pull()`.\n", "Using amp half precision backend\n" ] } ], "source": [ "from transformers import Trainer\n", "\n", "trainer = Trainer(\n", " model=model,\n", " data_collator=data_collator,\n", " args=training_args,\n", " compute_metrics=compute_metrics,\n", " train_dataset=common_voice_train_audio_augmented,\n", " eval_dataset=common_voice_test_audio,\n", " tokenizer=processor.feature_extractor,\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "UoXBx1JAA0DX" }, "source": [ "\n", "\n", "---\n", "\n", "${}^1$ To allow models to become independent of the speaker rate, in CTC, consecutive tokens that are identical are simply grouped as a single token. However, the encoded labels should not be grouped when decoding since they don't correspond to the predicted tokens of the model, which is why the `group_tokens=False` parameter has to be passed. If we wouldn't pass this parameter a word like `\"hello\"` would incorrectly be encoded, and decoded as `\"helo\"`.\n", "\n", "${}^2$ The blank token allows the model to predict a word, such as `\"hello\"` by forcing it to insert the blank token between the two l's. A CTC-conform prediction of `\"hello\"` of our model would be `[PAD] [PAD] \"h\" \"e\" \"e\" \"l\" \"l\" [PAD] \"l\" \"o\" \"o\" [PAD]`." ] }, { "cell_type": "markdown", "metadata": { "id": "rpvZHM1xReIW" }, "source": [ "### Training" ] }, { "cell_type": "markdown", "metadata": { "id": "j-3oKSzZ1hGq" }, "source": [ "Training will take multiple hours depending on the GPU allocated to this notebook. While the trained model yields somewhat satisfying results on *Common Voice*'s test data of Turkish, it is by no means an optimally fine-tuned model. The purpose of this notebook is just to demonstrate how to fine-tune XLS-R on an ASR dataset.\n", "\n", "In case you want to use this google colab to fine-tune your model, you should make sure that your training doesn't stop due to inactivity. A simple hack to prevent this is to paste the following code into the console of this tab (*right mouse click -> inspect -> Console tab and insert code*)." ] }, { "cell_type": "markdown", "metadata": { "id": "VYYAvgkW4P0m" }, "source": [ "```javascript\n", "function ConnectButton(){\n", " console.log(\"Connect pushed\"); \n", " document.querySelector(\"#top-toolbar > colab-connect-button\").shadowRoot.querySelector(\"#connect\").click() \n", "}\n", "setInterval(ConnectButton,60000);\n", "```" ] }, { "cell_type": "markdown", "metadata": { "id": "7bGgLV2r0yvZ" }, "source": [ "Depending on what GPU was allocated to your google colab it might be possible that you are seeing an `\"out-of-memory\"` error here. In this case, it's probably best to reduce `per_device_train_batch_size` to 8 or even less and increase [`gradient_accumulation`](https://huggingface.co/transformers/master/main_classes/trainer.html#trainingarguments)." ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "id": "9fRr9TG5pGBl", "outputId": "e07eeffc-bbd6-4f1d-a45e-b74bad290f79" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "The following columns in the training set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "/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 thePyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning\n", " warnings.warn(\n", "***** Running training *****\n", " Num examples = 22174\n", " Num Epochs = 4\n", " Instantaneous batch size per device = 8\n", " Total train batch size (w. parallel, distributed & accumulation) = 16\n", " Gradient Accumulation steps = 2\n", " Total optimization steps = 5544\n" ] }, { "data": { "text/html": [ "\n", "
\n", " \n", " \n", " [5544/5544 4:21:28, Epoch 4/4]\n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
StepTraining LossValidation LossWer
4000.6473000.2856990.382526
8000.6039000.2458950.347557
12000.4757000.2337970.327387
16000.4473000.2246280.312791
20000.4322000.1962230.280458
24000.3961000.2069870.279749
28000.3642000.1789810.247314
32000.3561000.1769110.237482
36000.2820000.1672290.226333
40000.2978000.1635680.219238
44000.2722000.1636880.210217
48000.2924000.1505800.202108
52000.2631000.1498690.195520

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-400\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-400/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-400/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-400/preprocessor_config.json\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/preprocessor_config.json\n", "Several commits (2) will be pushed upstream.\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-7600] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-800\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-800/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-800/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-800/preprocessor_config.json\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-8000] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1200\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1200/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1200/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1200/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-8400] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1600\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1600/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1600/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1600/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-400] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2000\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2000/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2000/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2000/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-800] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2400\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2400/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2400/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2400/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1200] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2800\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2800/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2800/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2800/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-1600] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3200\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3200/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3200/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3200/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2000] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3600\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3600/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3600/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3600/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2400] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4000\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4000/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4000/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4000/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-2800] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4400\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4400/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4400/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4400/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3200] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4800\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4800/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4800/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4800/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-3600] due to args.save_total_limit\n", "The following columns in the evaluation set don't have a corresponding argument in `Wav2Vec2ForCTC.forward` and have been ignored: input_length.\n", "***** Running Evaluation *****\n", " Num examples = 1595\n", " Batch size = 8\n", "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-5200\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-5200/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-5200/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-5200/preprocessor_config.json\n", "Deleting older checkpoint [wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-4000] due to args.save_total_limit\n", "\n", "\n", "Training completed. Do not forget to share your model on huggingface.co/models =)\n", "\n", "\n", "Loading best model from wav2vec2-xlsr-fi-train-aug-lm-1B/checkpoint-5200 (score: 0.19551996756537604).\n" ] }, { "data": { "text/plain": [ "TrainOutput(global_step=5544, training_loss=0.3942209981048606, metrics={'train_runtime': 15698.6908, 'train_samples_per_second': 5.65, 'train_steps_per_second': 0.353, 'total_flos': 5.82002597856266e+19, 'train_loss': 0.3942209981048606, 'epoch': 4.0})" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "trainer.train()" ] }, { "cell_type": "markdown", "metadata": { "id": "a9q4mgMZplr_" }, "source": [ "The training loss and validation WER go down nicely." ] }, { "cell_type": "markdown", "metadata": { "id": "4Ya7WEy0pd13" }, "source": [ "You can now upload the result of the training to the 🤗 Hub, just execute this instruction:" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "id": "ArG1Thf6NBWm", "outputId": "62ef1c3d-786c-4e25-f9c5-4020e71aa298" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Saving model checkpoint to wav2vec2-xlsr-fi-train-aug-lm-1B\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/config.json\n", "Model weights saved in wav2vec2-xlsr-fi-train-aug-lm-1B/pytorch_model.bin\n", "Configuration saved in wav2vec2-xlsr-fi-train-aug-lm-1B/preprocessor_config.json\n", "Several commits (2) will be pushed upstream.\n", "The progress bars may be unreliable.\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b59f278120294e64a1192c8a6ec7c84d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Upload file pytorch_model.bin: 0%| | 3.37k/3.59G [00:00 main\n", "\n", "Dropping the following result as it does not have all the necessary fields:\n", "{}\n", "To https://huggingface.co/RASMUS/wav2vec2-xlsr-fi-train-aug-lm-1B\n", " ddf9cad..e13053b main -> main\n", "\n" ] }, { "data": { "text/plain": [ "'https://huggingface.co/RASMUS/wav2vec2-xlsr-fi-train-aug-lm-1B/commit/ddf9cadee318e2732e136ec4aa2789c0de8e06fa'" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "trainer.push_to_hub()" ] }, { "cell_type": "markdown", "metadata": { "id": "RHIVc44_fY2N" }, "source": [ "You can now share this model with all your friends, family, favorite pets: they can all load it with the identifier \"your-username/the-name-you-picked\" so for instance:" ] }, { "cell_type": "markdown", "metadata": { "id": "5lWWIKyBpx1h" }, "source": [ "```python\n", "from transformers import AutoModelForCTC, Wav2Vec2Processor\n", "\n", "model = AutoModelForCTC.from_pretrained(\"patrickvonplaten/wav2vec2-large-xls-r-300m-tr-colab\")\n", "processor = Wav2Vec2Processor.from_pretrained(\"patrickvonplaten/wav2vec2-large-xls-r-300m-tr-colab\")\n", "```" ] }, { "cell_type": "markdown", "metadata": { "id": "pmi1cX0fRBit" }, "source": [ "For more examples of how XLS-R can be fine-tuned, please take a look at the [official speech recognition examples](https://github.com/huggingface/transformers/tree/master/examples/pytorch/speech-recognition#examples)." ] }, { "cell_type": "markdown", "metadata": { "id": "L8b8Qkoy3KyS" }, "source": [ "### Evaluation\n", "\n", "As a final check, let's load the model and verify that it indeed has learned to transcribe Turkish speech.\n", "\n", "Let's first load the pretrained checkpoint." ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "collapsed": true, "id": "R351I9IQp_9D", "jupyter": { "outputs_hidden": true }, "outputId": "f2a2ee99-7db6-4962-e140-0107054102d3" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "loading configuration file wav2vec2-xlsr-fi-lm-1B/config.json\n", "Model config Wav2Vec2Config {\n", " \"_name_or_path\": \"facebook/wav2vec2-xls-r-1b\",\n", " \"activation_dropout\": 0.055,\n", " \"adapter_kernel_size\": 3,\n", " \"adapter_stride\": 2,\n", " \"add_adapter\": false,\n", " \"apply_spec_augment\": true,\n", " \"architectures\": [\n", " \"Wav2Vec2ForCTC\"\n", " ],\n", " \"attention_dropout\": 0.094,\n", " \"bos_token_id\": 1,\n", " \"classifier_proj_size\": 256,\n", " \"codevector_dim\": 1024,\n", " \"contrastive_logits_temperature\": 0.1,\n", " \"conv_bias\": true,\n", " \"conv_dim\": [\n", " 512,\n", " 512,\n", " 512,\n", " 512,\n", " 512,\n", " 512,\n", " 512\n", " ],\n", " \"conv_kernel\": [\n", " 10,\n", " 3,\n", " 3,\n", " 3,\n", " 3,\n", " 2,\n", " 2\n", " ],\n", " \"conv_stride\": [\n", " 5,\n", " 2,\n", " 2,\n", " 2,\n", " 2,\n", " 2,\n", " 2\n", " ],\n", " \"ctc_loss_reduction\": \"mean\",\n", " \"ctc_zero_infinity\": false,\n", " \"diversity_loss_weight\": 0.1,\n", " \"do_stable_layer_norm\": true,\n", " \"eos_token_id\": 2,\n", " \"feat_extract_activation\": \"gelu\",\n", " \"feat_extract_dropout\": 0.0,\n", " \"feat_extract_norm\": \"layer\",\n", " \"feat_proj_dropout\": 0.04,\n", " \"feat_quantizer_dropout\": 0.0,\n", " \"final_dropout\": 0.0,\n", " \"gradient_checkpointing\": false,\n", " \"hidden_act\": \"gelu\",\n", " \"hidden_dropout\": 0.047,\n", " \"hidden_size\": 1280,\n", " \"initializer_range\": 0.02,\n", " \"intermediate_size\": 5120,\n", " \"layer_norm_eps\": 1e-05,\n", " \"layerdrop\": 0.041,\n", " \"mask_feature_length\": 10,\n", " \"mask_feature_min_masks\": 0,\n", " \"mask_feature_prob\": 0.0,\n", " \"mask_time_length\": 10,\n", " \"mask_time_min_masks\": 2,\n", " \"mask_time_prob\": 0.082,\n", " \"model_type\": \"wav2vec2\",\n", " \"num_adapter_layers\": 3,\n", " \"num_attention_heads\": 16,\n", " \"num_codevector_groups\": 2,\n", " \"num_codevectors_per_group\": 320,\n", " \"num_conv_pos_embedding_groups\": 16,\n", " \"num_conv_pos_embeddings\": 128,\n", " \"num_feat_extract_layers\": 7,\n", " \"num_hidden_layers\": 48,\n", " \"num_negatives\": 100,\n", " \"output_hidden_size\": 1280,\n", " \"pad_token_id\": 33,\n", " \"proj_codevector_dim\": 1024,\n", " \"tdnn_dilation\": [\n", " 1,\n", " 2,\n", " 3,\n", " 1,\n", " 1\n", " ],\n", " \"tdnn_dim\": [\n", " 512,\n", " 512,\n", " 512,\n", " 512,\n", " 1500\n", " ],\n", " \"tdnn_kernel\": [\n", " 5,\n", " 3,\n", " 3,\n", " 1,\n", " 1\n", " ],\n", " \"torch_dtype\": \"float32\",\n", " \"transformers_version\": \"4.16.0.dev0\",\n", " \"use_weighted_layer_sum\": false,\n", " \"vocab_size\": 36,\n", " \"xvector_output_dim\": 512\n", "}\n", "\n", "loading weights file wav2vec2-xlsr-fi-lm-1B/pytorch_model.bin\n", "All model checkpoint weights were used when initializing Wav2Vec2ForCTC.\n", "\n", "All the weights of Wav2Vec2ForCTC were initialized from the model checkpoint at wav2vec2-xlsr-fi-lm-1B.\n", "If your task is similar to the task the model of the checkpoint was trained on, you can already use Wav2Vec2ForCTC for predictions without further training.\n", "loading feature extractor configuration file wav2vec2-xlsr-fi-lm-1B/preprocessor_config.json\n", "Feature extractor Wav2Vec2FeatureExtractor {\n", " \"do_normalize\": true,\n", " \"feature_extractor_type\": \"Wav2Vec2FeatureExtractor\",\n", " \"feature_size\": 1,\n", " \"padding_side\": \"right\",\n", " \"padding_value\": 0.0,\n", " \"return_attention_mask\": true,\n", " \"sampling_rate\": 16000\n", "}\n", "\n", "Didn't find file wav2vec2-xlsr-fi-lm-1B/tokenizer.json. We won't load it.\n", "loading file wav2vec2-xlsr-fi-lm-1B/vocab.json\n", "loading file wav2vec2-xlsr-fi-lm-1B/tokenizer_config.json\n", "loading file wav2vec2-xlsr-fi-lm-1B/added_tokens.json\n", "loading file wav2vec2-xlsr-fi-lm-1B/special_tokens_map.json\n", "loading file None\n", "Adding to the vocabulary\n", "Adding to the vocabulary\n" ] } ], "source": [ "model = Wav2Vec2ForCTC.from_pretrained(repo_name).to(\"cuda\")\n", "processor = Wav2Vec2Processor.from_pretrained(repo_name)" ] }, { "cell_type": "markdown", "metadata": { "id": "jD7TZ1YS3S_K" }, "source": [ "\n", "Now, we will just take the first example of the test set, run it through the model and take the `argmax(...)` of the logits to retrieve the predicted token ids." ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "id": "pax07TnL3WZn", "outputId": "867787ff-0cb7-41e9-f926-96f7b53e7134" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "It is strongly recommended to pass the ``sampling_rate`` argument to this function. Failing to do so can result in silent errors that might be hard to debug.\n" ] } ], "source": [ "input_dict = processor(common_voice_test_audio[0][\"input_values\"], return_tensors=\"pt\", padding=True)\n", "\n", "logits = model(input_dict.input_values.to(\"cuda\")).logits\n", "\n", "pred_ids = torch.argmax(logits, dim=-1)[0]" ] }, { "cell_type": "markdown", "metadata": { "id": "7nkzSQu53Zs2" }, "source": [ "We adapted `common_voice_test` quite a bit so that the dataset instance does not contain the original sentence label anymore. Thus, we re-use the original dataset to get the label of the first example." ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "id": "fe2AE-2xqKHx", "outputId": "1d8321b3-4f41-4d71-e74e-f33f32a7b261" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "cc560e0bf71f49ae8d914321b060cd23", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading: 0%| | 0.00/4.62k [00:00