diff --git "a/indicTrans_Finetuning.ipynb" "b/indicTrans_Finetuning.ipynb" deleted file mode 100644--- "a/indicTrans_Finetuning.ipynb" +++ /dev/null @@ -1,1849 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "colab_type": "text", - "id": "view-in-github" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "rE4MO-8bDtwD", - "outputId": "e54447b4-2b04-44c4-96a2-a79e7ed014ae" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/content/finetuning\n" - ] - } - ], - "source": [ - "# create a seperate folder to store everything\n", - "!mkdir finetuning\n", - "%cd finetuning" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "-2Rs6_WkD_gF", - "outputId": "95d19041-0e73-406c-a3c2-c7bddbfda916" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cloning into 'indicTrans'...\n", - "remote: Enumerating objects: 398, done.\u001b[K\n", - "remote: Counting objects: 100% (398/398), done.\u001b[K\n", - "remote: Compressing objects: 100% (267/267), done.\u001b[K\n", - "remote: Total 398 (delta 231), reused 251 (delta 126), pack-reused 0\u001b[K\n", - "Receiving objects: 100% (398/398), 1.41 MiB | 17.84 MiB/s, done.\n", - "Resolving deltas: 100% (231/231), done.\n", - "/content/finetuning/indicTrans\n", - "Cloning into 'indic_nlp_library'...\n", - "remote: Enumerating objects: 1325, done.\u001b[K\n", - "remote: Counting objects: 100% (147/147), done.\u001b[K\n", - "remote: Compressing objects: 100% (103/103), done.\u001b[K\n", - "remote: Total 1325 (delta 84), reused 89 (delta 41), pack-reused 1178\u001b[K\n", - "Receiving objects: 100% (1325/1325), 9.57 MiB | 14.30 MiB/s, done.\n", - "Resolving deltas: 100% (688/688), done.\n", - "Cloning into 'indic_nlp_resources'...\n", - "remote: Enumerating objects: 133, done.\u001b[K\n", - "remote: Counting objects: 100% (7/7), done.\u001b[K\n", - "remote: Compressing objects: 100% (7/7), done.\u001b[K\n", - "remote: Total 133 (delta 0), reused 2 (delta 0), pack-reused 126\u001b[K\n", - "Receiving objects: 100% (133/133), 149.77 MiB | 35.48 MiB/s, done.\n", - "Resolving deltas: 100% (51/51), done.\n", - "Cloning into 'subword-nmt'...\n", - "remote: Enumerating objects: 580, done.\u001b[K\n", - "remote: Counting objects: 100% (4/4), done.\u001b[K\n", - "remote: Compressing objects: 100% (4/4), done.\u001b[K\n", - "remote: Total 580 (delta 0), reused 0 (delta 0), pack-reused 576\u001b[K\n", - "Receiving objects: 100% (580/580), 237.41 KiB | 18.26 MiB/s, done.\n", - "Resolving deltas: 100% (349/349), done.\n", - "/content/finetuning\n" - ] - } - ], - "source": [ - "# clone the repo for running finetuning\n", - "!git clone https://github.com/AI4Bharat/indicTrans.git\n", - "%cd indicTrans\n", - "# clone requirements repositories\n", - "!git clone https://github.com/anoopkunchukuttan/indic_nlp_library.git\n", - "!git clone https://github.com/anoopkunchukuttan/indic_nlp_resources.git\n", - "!git clone https://github.com/rsennrich/subword-nmt.git\n", - "%cd .." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "duwTvJ9xEBJ1", - "outputId": "98445af3-041d-415d-97f3-a322939260e4" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Reading package lists... Done\n", - "Building dependency tree \n", - "Reading state information... Done\n", - "The following NEW packages will be installed:\n", - " tree\n", - "0 upgraded, 1 newly installed, 0 to remove and 39 not upgraded.\n", - "Need to get 40.7 kB of archives.\n", - "After this operation, 105 kB of additional disk space will be used.\n", - "Get:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 tree amd64 1.7.0-5 [40.7 kB]\n", - "Fetched 40.7 kB in 0s (121 kB/s)\n", - "debconf: unable to initialize frontend: Dialog\n", - "debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 1.)\n", - "debconf: falling back to frontend: Readline\n", - "debconf: unable to initialize frontend: Readline\n", - "debconf: (This frontend requires a controlling tty.)\n", - "debconf: falling back to frontend: Teletype\n", - "dpkg-preconfigure: unable to re-open stdin: \n", - "Selecting previously unselected package tree.\n", - "(Reading database ... 160772 files and directories currently installed.)\n", - "Preparing to unpack .../tree_1.7.0-5_amd64.deb ...\n", - "Unpacking tree (1.7.0-5) ...\n", - "Setting up tree (1.7.0-5) ...\n", - "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n", - "Collecting sacremoses\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/75/ee/67241dc87f266093c533a2d4d3d69438e57d7a90abb216fa076e7d475d4a/sacremoses-0.0.45-py3-none-any.whl (895kB)\n", - "\u001b[K |████████████████████████████████| 901kB 30.0MB/s \n", - "\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (1.1.5)\n", - "Collecting mock\n", - " Downloading https://files.pythonhosted.org/packages/5c/03/b7e605db4a57c0f6fba744b11ef3ddf4ddebcada35022927a2b5fc623fdf/mock-4.0.3-py3-none-any.whl\n", - "Collecting sacrebleu\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/7e/57/0c7ca4e31a126189dab99c19951910bd081dea5bbd25f24b77107750eae7/sacrebleu-1.5.1-py3-none-any.whl (54kB)\n", - "\u001b[K |████████████████████████████████| 61kB 9.1MB/s \n", - "\u001b[?25hCollecting tensorboardX\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/07/84/46421bd3e0e89a92682b1a38b40efc22dafb6d8e3d947e4ceefd4a5fabc7/tensorboardX-2.2-py2.py3-none-any.whl (120kB)\n", - "\u001b[K |████████████████████████████████| 122kB 58.2MB/s \n", - "\u001b[?25hRequirement already satisfied: pyarrow in /usr/local/lib/python3.7/dist-packages (3.0.0)\n", - "Collecting indic-nlp-library\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/84/d4/495bb43b88a2a6d04b09c29fc5115f24872af74cd8317fe84026abd4ddb1/indic_nlp_library-0.81-py3-none-any.whl (40kB)\n", - "\u001b[K |████████████████████████████████| 40kB 6.3MB/s \n", - "\u001b[?25hRequirement already satisfied: joblib in /usr/local/lib/python3.7/dist-packages (from sacremoses) (1.0.1)\n", - "Requirement already satisfied: click in /usr/local/lib/python3.7/dist-packages (from sacremoses) (7.1.2)\n", - "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from sacremoses) (1.15.0)\n", - "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from sacremoses) (4.41.1)\n", - "Requirement already satisfied: regex in /usr/local/lib/python3.7/dist-packages (from sacremoses) (2019.12.20)\n", - "Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.7/dist-packages (from pandas) (1.19.5)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas) (2.8.1)\n", - "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas) (2018.9)\n", - "Collecting portalocker==2.0.0\n", - " Downloading https://files.pythonhosted.org/packages/89/a6/3814b7107e0788040870e8825eebf214d72166adf656ba7d4bf14759a06a/portalocker-2.0.0-py2.py3-none-any.whl\n", - "Requirement already satisfied: protobuf>=3.8.0 in /usr/local/lib/python3.7/dist-packages (from tensorboardX) (3.12.4)\n", - "Collecting sphinx-rtd-theme\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/ac/24/2475e8f83519b54b2148d4a56eb1111f9cec630d088c3ffc214492c12107/sphinx_rtd_theme-0.5.2-py2.py3-none-any.whl (9.1MB)\n", - "\u001b[K |████████████████████████████████| 9.2MB 41.6MB/s \n", - "\u001b[?25hCollecting sphinx-argparse\n", - " Downloading https://files.pythonhosted.org/packages/06/2b/dfad6a1831c3aeeae25d8d3d417224684befbf45e10c7f2141631616a6ed/sphinx-argparse-0.2.5.tar.gz\n", - "Collecting morfessor\n", - " Downloading https://files.pythonhosted.org/packages/39/e6/7afea30be2ee4d29ce9de0fa53acbb033163615f849515c0b1956ad074ee/Morfessor-2.0.6-py3-none-any.whl\n", - "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from protobuf>=3.8.0->tensorboardX) (57.0.0)\n", - "Requirement already satisfied: sphinx in /usr/local/lib/python3.7/dist-packages (from sphinx-rtd-theme->indic-nlp-library) (1.8.5)\n", - "Collecting docutils<0.17\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/81/44/8a15e45ffa96e6cf82956dd8d7af9e666357e16b0d93b253903475ee947f/docutils-0.16-py2.py3-none-any.whl (548kB)\n", - "\u001b[K |████████████████████████████████| 552kB 33.3MB/s \n", - "\u001b[?25hRequirement already satisfied: Pygments>=2.0 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (2.6.1)\n", - "Requirement already satisfied: requests>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (2.23.0)\n", - "Requirement already satisfied: babel!=2.0,>=1.3 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (2.9.1)\n", - "Requirement already satisfied: Jinja2>=2.3 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (2.11.3)\n", - "Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (20.9)\n", - "Requirement already satisfied: sphinxcontrib-websupport in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (1.2.4)\n", - "Requirement already satisfied: imagesize in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (1.2.0)\n", - "Requirement already satisfied: snowballstemmer>=1.1 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (2.1.0)\n", - "Requirement already satisfied: alabaster<0.8,>=0.7 in /usr/local/lib/python3.7/dist-packages (from sphinx->sphinx-rtd-theme->indic-nlp-library) (0.7.12)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.0.0->sphinx->sphinx-rtd-theme->indic-nlp-library) (2020.12.5)\n", - "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.0.0->sphinx->sphinx-rtd-theme->indic-nlp-library) (3.0.4)\n", - "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.0.0->sphinx->sphinx-rtd-theme->indic-nlp-library) (2.10)\n", - "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.0.0->sphinx->sphinx-rtd-theme->indic-nlp-library) (1.24.3)\n", - "Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.7/dist-packages (from Jinja2>=2.3->sphinx->sphinx-rtd-theme->indic-nlp-library) (2.0.1)\n", - "Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->sphinx->sphinx-rtd-theme->indic-nlp-library) (2.4.7)\n", - "Requirement already satisfied: sphinxcontrib-serializinghtml in /usr/local/lib/python3.7/dist-packages (from sphinxcontrib-websupport->sphinx->sphinx-rtd-theme->indic-nlp-library) (1.1.4)\n", - "Building wheels for collected packages: sphinx-argparse\n", - " Building wheel for sphinx-argparse (setup.py) ... \u001b[?25l\u001b[?25hdone\n", - " Created wheel for sphinx-argparse: filename=sphinx_argparse-0.2.5-cp37-none-any.whl size=11552 sha256=16adb2732e7fea31509536176157766068ca67667ad9ad00a5ee3b15bdec2d18\n", - " Stored in directory: /root/.cache/pip/wheels/2a/18/1b/4990a1859da4edc77ab312bc2986c08d2733fb5713d06e44f5\n", - "Successfully built sphinx-argparse\n", - "\u001b[31mERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.\u001b[0m\n", - "Installing collected packages: sacremoses, mock, portalocker, sacrebleu, tensorboardX, docutils, sphinx-rtd-theme, sphinx-argparse, morfessor, indic-nlp-library\n", - " Found existing installation: docutils 0.17.1\n", - " Uninstalling docutils-0.17.1:\n", - " Successfully uninstalled docutils-0.17.1\n", - "Successfully installed docutils-0.16 indic-nlp-library-0.81 mock-4.0.3 morfessor-2.0.6 portalocker-2.0.0 sacrebleu-1.5.1 sacremoses-0.0.45 sphinx-argparse-0.2.5 sphinx-rtd-theme-0.5.2 tensorboardX-2.2\n", - "Cloning into 'fairseq'...\n", - "remote: Enumerating objects: 28243, done.\u001b[K\n", - "remote: Counting objects: 100% (62/62), done.\u001b[K\n", - "remote: Compressing objects: 100% (39/39), done.\u001b[K\n", - "remote: Total 28243 (delta 29), reused 44 (delta 22), pack-reused 28181\u001b[K\n", - "Receiving objects: 100% (28243/28243), 11.81 MiB | 24.38 MiB/s, done.\n", - "Resolving deltas: 100% (21225/21225), done.\n", - "/content/finetuning/fairseq\n", - "Obtaining file:///content/finetuning/fairseq\n", - " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", - " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", - " Installing backend dependencies ... \u001b[?25l\u001b[?25hdone\n", - " Preparing wheel metadata ... \u001b[?25l\u001b[?25hdone\n", - "Collecting omegaconf<2.1\n", - " Downloading https://files.pythonhosted.org/packages/d0/eb/9d63ce09dd8aa85767c65668d5414958ea29648a0eec80a4a7d311ec2684/omegaconf-2.0.6-py3-none-any.whl\n", - "Requirement already satisfied: numpy; python_version >= \"3.7\" in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (1.19.5)\n", - "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (4.41.1)\n", - "Collecting hydra-core<1.1\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/52/e3/fbd70dd0d3ce4d1d75c22d56c0c9f895cfa7ed6587a9ffb821d6812d6a60/hydra_core-1.0.6-py3-none-any.whl (123kB)\n", - "\u001b[K |████████████████████████████████| 133kB 32.0MB/s \n", - "\u001b[?25hRequirement already satisfied: regex in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (2019.12.20)\n", - "Requirement already satisfied: cffi in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (1.14.5)\n", - "Requirement already satisfied: sacrebleu>=1.4.12 in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (1.5.1)\n", - "Requirement already satisfied: torch in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (1.8.1+cu101)\n", - "Requirement already satisfied: cython in /usr/local/lib/python3.7/dist-packages (from fairseq==1.0.0a0+2fd9d8a) (0.29.23)\n", - "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from omegaconf<2.1->fairseq==1.0.0a0+2fd9d8a) (3.7.4.3)\n", - "Collecting PyYAML>=5.1.*\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/7a/a5/393c087efdc78091afa2af9f1378762f9821c9c1d7a22c5753fb5ac5f97a/PyYAML-5.4.1-cp37-cp37m-manylinux1_x86_64.whl (636kB)\n", - "\u001b[K |████████████████████████████████| 645kB 31.7MB/s \n", - "\u001b[?25hRequirement already satisfied: importlib-resources; python_version < \"3.9\" in /usr/local/lib/python3.7/dist-packages (from hydra-core<1.1->fairseq==1.0.0a0+2fd9d8a) (5.1.3)\n", - "Collecting antlr4-python3-runtime==4.8\n", - "\u001b[?25l Downloading https://files.pythonhosted.org/packages/56/02/789a0bddf9c9b31b14c3e79ec22b9656185a803dc31c15f006f9855ece0d/antlr4-python3-runtime-4.8.tar.gz (112kB)\n", - "\u001b[K |████████████████████████████████| 112kB 53.4MB/s \n", - "\u001b[?25hRequirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi->fairseq==1.0.0a0+2fd9d8a) (2.20)\n", - "Requirement already satisfied: portalocker==2.0.0 in /usr/local/lib/python3.7/dist-packages (from sacrebleu>=1.4.12->fairseq==1.0.0a0+2fd9d8a) (2.0.0)\n", - "Requirement already satisfied: zipp>=0.4; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from importlib-resources; python_version < \"3.9\"->hydra-core<1.1->fairseq==1.0.0a0+2fd9d8a) (3.4.1)\n", - "Building wheels for collected packages: antlr4-python3-runtime\n", - " Building wheel for antlr4-python3-runtime (setup.py) ... \u001b[?25l\u001b[?25hdone\n", - " Created wheel for antlr4-python3-runtime: filename=antlr4_python3_runtime-4.8-cp37-none-any.whl size=141231 sha256=5e816253108c1c7a8687228b17c910230fee3243ba77f5567a8b08f7c1a5a101\n", - " Stored in directory: /root/.cache/pip/wheels/e3/e2/fa/b78480b448b8579ddf393bebd3f47ee23aa84c89b6a78285c8\n", - "Successfully built antlr4-python3-runtime\n", - "Installing collected packages: PyYAML, omegaconf, antlr4-python3-runtime, hydra-core, fairseq\n", - " Found existing installation: PyYAML 3.13\n", - " Uninstalling PyYAML-3.13:\n", - " Successfully uninstalled PyYAML-3.13\n", - " Running setup.py develop for fairseq\n", - "Successfully installed PyYAML-5.4.1 antlr4-python3-runtime-4.8 fairseq hydra-core-1.0.6 omegaconf-2.0.6\n", - "/content/finetuning\n" - ] - } - ], - "source": [ - "! sudo apt install tree\n", - "\n", - "# Install the necessary libraries\n", - "!pip install sacremoses pandas mock sacrebleu tensorboardX pyarrow indic-nlp-library\n", - "# Install fairseq from source\n", - "!git clone https://github.com/pytorch/fairseq.git\n", - "%cd fairseq\n", - "# !git checkout da9eaba12d82b9bfc1442f0e2c6fc1b895f4d35d\n", - "!pip install --editable ./\n", - "%cd .." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "oD2EHQdqEH70", - "outputId": "0b988dde-9da3-487c-a393-510fbcae92f3" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--2021-06-09 18:47:20-- https://storage.googleapis.com/samanantar-public/V0.2/models/indic-en.zip\n", - "Resolving storage.googleapis.com (storage.googleapis.com)... 172.253.62.128, 172.253.115.128, 172.253.122.128, ...\n", - "Connecting to storage.googleapis.com (storage.googleapis.com)|172.253.62.128|:443... connected.\n", - "HTTP request sent, awaiting response... 200 OK\n", - "Length: 4551079075 (4.2G) [application/zip]\n", - "Saving to: ‘indic-en.zip’\n", - "\n", - "indic-en.zip 100%[===================>] 4.24G 61.3MB/s in 56s \n", - "\n", - "2021-06-09 18:48:16 (77.9 MB/s) - ‘indic-en.zip’ saved [4551079075/4551079075]\n", - "\n", - "Archive: indic-en.zip\n", - " creating: indic-en/\n", - " creating: indic-en/vocab/\n", - " inflating: indic-en/vocab/bpe_codes.32k.SRC \n", - " inflating: indic-en/vocab/vocab.SRC \n", - " inflating: indic-en/vocab/vocab.TGT \n", - " inflating: indic-en/vocab/bpe_codes.32k.TGT \n", - " creating: indic-en/final_bin/\n", - " inflating: indic-en/final_bin/dict.TGT.txt \n", - " inflating: indic-en/final_bin/dict.SRC.txt \n", - " creating: indic-en/model/\n", - " inflating: indic-en/model/checkpoint_best.pt \n" - ] - } - ], - "source": [ - "# download the indictrans model\n", - "\n", - "\n", - "# downloading the en-indic model\n", - "# this will contain:\n", - "# en-indic/\n", - "# ├── final_bin # contains fairseq dictionaries (we will use this to binarize the new finetuning data)\n", - "# │ ├── dict.SRC.txt\n", - "# │ └── dict.TGT.txt\n", - "# ├── model # contains model checkpoint(s)\n", - "# │ └── checkpoint_best.pt\n", - "# └── vocab # contains bpes for src and tgt (since we train seperate vocabularies) generated with subword_nmt (we will use this bpes to convert finetuning data to subwords)\n", - "# ├── bpe_codes.32k.SRC\n", - "# ├── bpe_codes.32k.TGT\n", - "# ├── vocab.SRC\n", - "# └── vocab.TGT\n", - "\n", - "\n", - "\n", - "!wget https://storage.googleapis.com/samanantar-public/V0.3/models/indic-en.zip\n", - "!unzip indic-en.zip\n", - "\n", - "# if you want to finetune indic-en models, use the link below\n", - "\n", - "# !wget https://storage.googleapis.com/samanantar-public/V0.3/models/en-indic.zip\n", - "# !unzip en-indic.zip\n", - "\n", - "# if you want to finetune indic-indic models, use the link below\n", - "\n", - "# !wget https://storage.googleapis.com/samanantar-public/V0.3/models/m2m.zip\n", - "# !unzip m2m.zip\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "lj7XNBuwE0OV", - "outputId": "98b3a156-c205-4f1b-de79-f1d640555349" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--2021-06-09 18:50:23-- http://lotus.kuee.kyoto-u.ac.jp/WAT/indic-multilingual/indic_wat_2021.tar.gz\n", - "Resolving lotus.kuee.kyoto-u.ac.jp (lotus.kuee.kyoto-u.ac.jp)... 130.54.208.131\n", - "Connecting to lotus.kuee.kyoto-u.ac.jp (lotus.kuee.kyoto-u.ac.jp)|130.54.208.131|:80... connected.\n", - "HTTP request sent, awaiting response... 200 OK\n", - "Length: 777928004 (742M) [application/x-gzip]\n", - "Saving to: ‘indic_wat_2021.tar.gz’\n", - "\n", - "indic_wat_2021.tar. 100%[===================>] 741.89M 13.6MB/s in 57s \n", - "\n", - "2021-06-09 18:51:20 (13.1 MB/s) - ‘indic_wat_2021.tar.gz’ saved [777928004/777928004]\n", - "\n", - "finalrepo/\n", - "finalrepo/README\n", - "finalrepo/dev/\n", - "finalrepo/dev/dev.mr\n", - "finalrepo/dev/dev.kn\n", - "finalrepo/dev/dev.gu\n", - "finalrepo/dev/dev.ta\n", - "finalrepo/dev/dev.bn\n", - "finalrepo/dev/dev.pa\n", - "finalrepo/dev/dev.ml\n", - "finalrepo/dev/dev.or\n", - "finalrepo/dev/dev.en\n", - "finalrepo/dev/dev.hi\n", - "finalrepo/dev/dev.te\n", - "finalrepo/train/\n", - "finalrepo/train/zeroshotcorpstats\n", - "finalrepo/train/opensubtitles/\n", - "finalrepo/train/opensubtitles/en-ta/\n", - "finalrepo/train/opensubtitles/en-ta/train.ta\n", - "finalrepo/train/opensubtitles/en-ta/train.en\n", - "finalrepo/train/opensubtitles/en-te/\n", - "finalrepo/train/opensubtitles/en-te/train.te\n", - "finalrepo/train/opensubtitles/en-te/train.en\n", - "finalrepo/train/opensubtitles/en-ml/\n", - "finalrepo/train/opensubtitles/en-ml/train.ml\n", - "finalrepo/train/opensubtitles/en-ml/train.en\n", - "finalrepo/train/opensubtitles/en-bn/\n", - "finalrepo/train/opensubtitles/en-bn/train.bn\n", - "finalrepo/train/opensubtitles/en-bn/train.en\n", - "finalrepo/train/opensubtitles/en-hi/\n", - "finalrepo/train/opensubtitles/en-hi/train.hi\n", - "finalrepo/train/opensubtitles/en-hi/train.en\n", - "finalrepo/train/cvit-pib/\n", - "finalrepo/train/cvit-pib/en-ta/\n", - "finalrepo/train/cvit-pib/en-ta/train.ta\n", - "finalrepo/train/cvit-pib/en-ta/train.en\n", - "finalrepo/train/cvit-pib/en-te/\n", - "finalrepo/train/cvit-pib/en-te/train.te\n", - "finalrepo/train/cvit-pib/en-te/train.en\n", - "finalrepo/train/cvit-pib/en-or/\n", - "finalrepo/train/cvit-pib/en-or/train.or\n", - "finalrepo/train/cvit-pib/en-or/train.en\n", - "finalrepo/train/cvit-pib/en-ml/\n", - "finalrepo/train/cvit-pib/en-ml/train.ml\n", - "finalrepo/train/cvit-pib/en-ml/train.en\n", - "finalrepo/train/cvit-pib/en-bn/\n", - "finalrepo/train/cvit-pib/en-bn/train.bn\n", - "finalrepo/train/cvit-pib/en-bn/train.en\n", - "finalrepo/train/cvit-pib/en-gu/\n", - "finalrepo/train/cvit-pib/en-gu/train.en\n", - "finalrepo/train/cvit-pib/en-gu/train.gu\n", - "finalrepo/train/cvit-pib/en-mr/\n", - "finalrepo/train/cvit-pib/en-mr/train.mr\n", - "finalrepo/train/cvit-pib/en-mr/train.en\n", - "finalrepo/train/cvit-pib/en-pa/\n", - "finalrepo/train/cvit-pib/en-pa/train.pa\n", - "finalrepo/train/cvit-pib/en-pa/train.en\n", - "finalrepo/train/cvit-pib/en-hi/\n", - "finalrepo/train/cvit-pib/en-hi/train.hi\n", - "finalrepo/train/cvit-pib/en-hi/train.en\n", - "finalrepo/train/bibleuedin/\n", - "finalrepo/train/bibleuedin/en-te/\n", - "finalrepo/train/bibleuedin/en-te/train.te\n", - "finalrepo/train/bibleuedin/en-te/train.en\n", - "finalrepo/train/bibleuedin/en-ml/\n", - "finalrepo/train/bibleuedin/en-ml/train.ml\n", - "finalrepo/train/bibleuedin/en-ml/train.en\n", - "finalrepo/train/bibleuedin/en-gu/\n", - "finalrepo/train/bibleuedin/en-gu/train.en\n", - "finalrepo/train/bibleuedin/en-gu/train.gu\n", - "finalrepo/train/bibleuedin/en-mr/\n", - "finalrepo/train/bibleuedin/en-mr/train.mr\n", - "finalrepo/train/bibleuedin/en-mr/train.en\n", - "finalrepo/train/bibleuedin/en-hi/\n", - "finalrepo/train/bibleuedin/en-hi/train.hi\n", - "finalrepo/train/bibleuedin/en-hi/train.en\n", - "finalrepo/train/bibleuedin/en-kn/\n", - "finalrepo/train/bibleuedin/en-kn/train.kn\n", - "finalrepo/train/bibleuedin/en-kn/train.en\n", - "finalrepo/train/iitb/\n", - "finalrepo/train/iitb/en-hi/\n", - "finalrepo/train/iitb/en-hi/train.hi\n", - "finalrepo/train/iitb/en-hi/train.en\n", - "finalrepo/train/wikimatrix/\n", - "finalrepo/train/wikimatrix/en-ta/\n", - "finalrepo/train/wikimatrix/en-ta/train.ta\n", - "finalrepo/train/wikimatrix/en-ta/train.en\n", - "finalrepo/train/wikimatrix/en-te/\n", - "finalrepo/train/wikimatrix/en-te/train.te\n", - "finalrepo/train/wikimatrix/en-te/train.en\n", - "finalrepo/train/wikimatrix/en-ml/\n", - "finalrepo/train/wikimatrix/en-ml/train.ml\n", - "finalrepo/train/wikimatrix/en-ml/train.en\n", - "finalrepo/train/wikimatrix/en-bn/\n", - "finalrepo/train/wikimatrix/en-bn/train.bn\n", - "finalrepo/train/wikimatrix/en-bn/train.en\n", - "finalrepo/train/wikimatrix/en-mr/\n", - "finalrepo/train/wikimatrix/en-mr/train.mr\n", - "finalrepo/train/wikimatrix/en-mr/train.en\n", - "finalrepo/train/wikimatrix/en-hi/\n", - "finalrepo/train/wikimatrix/en-hi/train.hi\n", - "finalrepo/train/wikimatrix/en-hi/train.en\n", - "finalrepo/train/alt/\n", - "finalrepo/train/alt/en-bn/\n", - "finalrepo/train/alt/en-bn/train.bn\n", - "finalrepo/train/alt/en-bn/train.en\n", - "finalrepo/train/alt/en-hi/\n", - "finalrepo/train/alt/en-hi/train.hi\n", - "finalrepo/train/alt/en-hi/train.en\n", - "finalrepo/train/pmi/\n", - "finalrepo/train/pmi/en-ta/\n", - "finalrepo/train/pmi/en-ta/train.ta\n", - "finalrepo/train/pmi/en-ta/train.en\n", - "finalrepo/train/pmi/en-te/\n", - "finalrepo/train/pmi/en-te/train.te\n", - "finalrepo/train/pmi/en-te/train.en\n", - "finalrepo/train/pmi/en-or/\n", - "finalrepo/train/pmi/en-or/train.or\n", - "finalrepo/train/pmi/en-or/train.en\n", - "finalrepo/train/pmi/en-ml/\n", - "finalrepo/train/pmi/en-ml/train.ml\n", - "finalrepo/train/pmi/en-ml/train.en\n", - "finalrepo/train/pmi/en-bn/\n", - "finalrepo/train/pmi/en-bn/train.bn\n", - "finalrepo/train/pmi/en-bn/train.en\n", - "finalrepo/train/pmi/en-gu/\n", - "finalrepo/train/pmi/en-gu/train.en\n", - "finalrepo/train/pmi/en-gu/train.gu\n", - "finalrepo/train/pmi/en-mr/\n", - "finalrepo/train/pmi/en-mr/train.mr\n", - "finalrepo/train/pmi/en-mr/train.en\n", - "finalrepo/train/pmi/en-pa/\n", - "finalrepo/train/pmi/en-pa/train.pa\n", - "finalrepo/train/pmi/en-pa/train.en\n", - "finalrepo/train/pmi/en-hi/\n", - "finalrepo/train/pmi/en-hi/train.hi\n", - "finalrepo/train/pmi/en-hi/train.en\n", - "finalrepo/train/pmi/en-kn/\n", - "finalrepo/train/pmi/en-kn/train.kn\n", - "finalrepo/train/pmi/en-kn/train.en\n", - "finalrepo/train/wikititles/\n", - "finalrepo/train/wikititles/en-ta/\n", - "finalrepo/train/wikititles/en-ta/train.ta\n", - "finalrepo/train/wikititles/en-ta/train.en\n", - "finalrepo/train/wikititles/en-gu/\n", - "finalrepo/train/wikititles/en-gu/train.en\n", - "finalrepo/train/wikititles/en-gu/train.gu\n", - "finalrepo/train/mtenglish2odia/\n", - "finalrepo/train/mtenglish2odia/en-or/\n", - "finalrepo/train/mtenglish2odia/en-or/train.or\n", - "finalrepo/train/mtenglish2odia/en-or/train.en\n", - "finalrepo/train/urst/\n", - "finalrepo/train/urst/en-gu/\n", - "finalrepo/train/urst/en-gu/train.en\n", - "finalrepo/train/urst/en-gu/train.gu\n", - "finalrepo/train/jw/\n", - "finalrepo/train/jw/en-ta/\n", - "finalrepo/train/jw/en-ta/train.ta\n", - "finalrepo/train/jw/en-ta/train.en\n", - "finalrepo/train/jw/en-te/\n", - "finalrepo/train/jw/en-te/train.te\n", - "finalrepo/train/jw/en-te/train.en\n", - "finalrepo/train/jw/en-ml/\n", - "finalrepo/train/jw/en-ml/train.ml\n", - "finalrepo/train/jw/en-ml/train.en\n", - "finalrepo/train/jw/en-bn/\n", - "finalrepo/train/jw/en-bn/train.bn\n", - "finalrepo/train/jw/en-bn/train.en\n", - "finalrepo/train/jw/en-gu/\n", - "finalrepo/train/jw/en-gu/train.en\n", - "finalrepo/train/jw/en-gu/train.gu\n", - "finalrepo/train/jw/en-mr/\n", - "finalrepo/train/jw/en-mr/train.mr\n", - "finalrepo/train/jw/en-mr/train.en\n", - "finalrepo/train/jw/en-pa/\n", - "finalrepo/train/jw/en-pa/train.pa\n", - "finalrepo/train/jw/en-pa/train.en\n", - "finalrepo/train/jw/en-hi/\n", - "finalrepo/train/jw/en-hi/train.hi\n", - "finalrepo/train/jw/en-hi/train.en\n", - "finalrepo/train/jw/en-kn/\n", - "finalrepo/train/jw/en-kn/train.kn\n", - "finalrepo/train/jw/en-kn/train.en\n", - "finalrepo/train/nlpc/\n", - "finalrepo/train/nlpc/en-ta/\n", - "finalrepo/train/nlpc/en-ta/train.ta\n", - "finalrepo/train/nlpc/en-ta/train.en\n", - "finalrepo/train/get_zero_shot_pairs.py\n", - "finalrepo/train/ufal/\n", - "finalrepo/train/ufal/en-ta/\n", - "finalrepo/train/ufal/en-ta/train.ta\n", - "finalrepo/train/ufal/en-ta/train.en\n", - "finalrepo/train/odiencorp/\n", - "finalrepo/train/odiencorp/en-or/\n", - "finalrepo/train/odiencorp/en-or/train.or\n", - "finalrepo/train/odiencorp/en-or/train.en\n", - "finalrepo/train/tanzil/\n", - "finalrepo/train/tanzil/en-ta/\n", - "finalrepo/train/tanzil/en-ta/train.ta\n", - "finalrepo/train/tanzil/en-ta/train.en\n", - "finalrepo/train/tanzil/en-ml/\n", - "finalrepo/train/tanzil/en-ml/train.ml\n", - "finalrepo/train/tanzil/en-ml/train.en\n", - "finalrepo/train/tanzil/en-bn/\n", - "finalrepo/train/tanzil/en-bn/train.bn\n", - "finalrepo/train/tanzil/en-bn/train.en\n", - "finalrepo/train/tanzil/en-hi/\n", - "finalrepo/train/tanzil/en-hi/train.hi\n", - "finalrepo/train/tanzil/en-hi/train.en\n", - "finalrepo/train/ted2020/\n", - "finalrepo/train/ted2020/en-ta/\n", - "finalrepo/train/ted2020/en-ta/train.ta\n", - "finalrepo/train/ted2020/en-ta/train.en\n", - "finalrepo/train/ted2020/en-te/\n", - "finalrepo/train/ted2020/en-te/train.te\n", - "finalrepo/train/ted2020/en-te/train.en\n", - "finalrepo/train/ted2020/en-ml/\n", - "finalrepo/train/ted2020/en-ml/train.ml\n", - "finalrepo/train/ted2020/en-ml/train.en\n", - "finalrepo/train/ted2020/en-bn/\n", - "finalrepo/train/ted2020/en-bn/train.bn\n", - "finalrepo/train/ted2020/en-bn/train.en\n", - "finalrepo/train/ted2020/en-gu/\n", - "finalrepo/train/ted2020/en-gu/train.en\n", - "finalrepo/train/ted2020/en-gu/train.gu\n", - "finalrepo/train/ted2020/en-mr/\n", - "finalrepo/train/ted2020/en-mr/train.mr\n", - "finalrepo/train/ted2020/en-mr/train.en\n", - "finalrepo/train/ted2020/en-pa/\n", - "finalrepo/train/ted2020/en-pa/train.pa\n", - "finalrepo/train/ted2020/en-pa/train.en\n", - "finalrepo/train/ted2020/en-hi/\n", - "finalrepo/train/ted2020/en-hi/train.hi\n", - "finalrepo/train/ted2020/en-hi/train.en\n", - "finalrepo/train/ted2020/en-kn/\n", - "finalrepo/train/ted2020/en-kn/train.kn\n", - "finalrepo/train/ted2020/en-kn/train.en\n", - "finalrepo/test/\n", - "finalrepo/test/test.gu\n", - "finalrepo/test/test.fm.prob\n", - "finalrepo/test/test.kn\n", - "finalrepo/test/test.ta\n", - "finalrepo/test/cached_lm_test.en\n", - "finalrepo/test/test.pa\n", - "finalrepo/test/test.bn\n", - "finalrepo/test/test.hi\n", - "finalrepo/test/test.ml\n", - "finalrepo/test/test.or\n", - "finalrepo/test/test.mr\n", - "finalrepo/test/test.en\n", - "finalrepo/test/test.te\n" - ] - } - ], - "source": [ - "# In this example, we will finetuning on cvit-pib corpus which is part of the WAT2021 training dataset.\n", - "\n", - "# Lets first download the full wat2021 training data (cvit-pib is a part of this big training set)\n", - "# ***Note***: See the next section to mine for mining indic to indic data from english centric WAT data. This dataset can be used to finetune indic2indic model\n", - "!wget http://lotus.kuee.kyoto-u.ac.jp/WAT/indic-multilingual/indic_wat_2021.tar.gz\n", - "!tar -xzvf indic_wat_2021.tar.gz\n", - "# all train sets will now be in wat2021/train\n", - "!mv finalrepo wat2021" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "BSoZDR3fHpUk", - "outputId": "11bd057b-d1b0-45b8-feac-85b3e900104e" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mkdir: cannot create directory ‘wat2021-indic2indic’: File exists\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\r 0%| | 0/2 [00:00 remove_train_devtest_overlaps(train_dir, devtest_dir, many2many=True)\n", - "\n", - "extract_non_english_pairs('wat2021/train/cvit-pib', 'wat2021-indic2indic', ['bn', 'hi', 'gu'])" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "ys_QURP3Sx7G", - "outputId": "d41f5baa-e700-4e07-93cd-b23b08122dc5" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/content/finetuning/indicTrans\n" - ] - } - ], - "source": [ - "# wat2021\n", - "# ├── dev # contains Wat2021 dev data\n", - "# │ ├── dev.bn\n", - "# │ ├── dev.en\n", - "# │ ├── dev.gu\n", - "# │ ├── dev.hi\n", - "# │ ├── dev.kn\n", - "# │ ├── dev.ml\n", - "# │ ├── dev.mr\n", - "# │ ├── dev.or\n", - "# │ ├── dev.pa\n", - "# │ ├── dev.ta\n", - "# │ └── dev.te\n", - "# ├── README\n", - "# ├── test # contains Wat2021 test data\n", - "# │ ├── test.bn\n", - "# │ ├── test.en\n", - "# │ ├── test.gu\n", - "# │ ├── test.hi\n", - "# │ ├── test.kn\n", - "# │ ├── test.ml\n", - "# │ ├── test.mr\n", - "# │ ├── test.or\n", - "# │ ├── test.pa\n", - "# │ ├── test.ta\n", - "# │ └── test.te\n", - "# └── train # contains WAT2021 train data which has lot of corpuses (alt, bible, Jw300, etc)\n", - "# ├── alt/\n", - "# ├── bibleuedin/\n", - "# ├── iitb/\n", - "# ├── jw/\n", - "# ├── mtenglish2odia/\n", - "# ├── nlpc/\n", - "# ├── odiencorp/\n", - "# ├── opensubtitles/\n", - "# ├── pmi/\n", - "# ├── tanzil/\n", - "# ├── ted2020/\n", - "# ├── ufal/\n", - "# ├── urst/\n", - "# ├── wikimatrix/\n", - "# ├── wikititles/\n", - "# └── cvit-pib \n", - "# ├── en-bn # within a train corpus folder the files are arranged in {src_lang}-{tgt_lang}/train.{src_lang}, train.{tgt_lang}\n", - "# │ ├── train.bn\n", - "# │ └── train.en\n", - "# ├── en-gu\n", - "# │ ├── train.en\n", - "# │ └── train.gu\n", - "# ├── en-hi\n", - "# │ ├── train.en\n", - "# │ └── train.hi\n", - "# ├── en-ml\n", - "# │ ├── train.en\n", - "# │ └── train.ml\n", - "# ├── en-mr\n", - "# │ ├── train.en\n", - "# │ └── train.mr\n", - "# ├── en-or\n", - "# │ ├── train.en\n", - "# │ └── train.or\n", - "# ├── en-pa\n", - "# │ ├── train.en\n", - "# │ └── train.pa\n", - "# ├── en-ta\n", - "# │ ├── train.en\n", - "# │ └── train.ta\n", - "# └── en-te\n", - "# ├── train.en\n", - "# └── train.te\n", - "\n", - "\n", - "\n", - "# instead of using all the data for this example, we will mainly use the cvit-pib corpus from wat2021 train set\n", - "# for dev and test set, we will use the dev and test provided by wat2021\n", - "\n", - "# In case, you want to finetune on all these corpuses, you would need to merge all the training data into one folder and remove duplicate train sentence pairs.\n", - "# To do this, refer to this gist: https://gist.github.com/gowtham1997/2524f8e9559cff586d1f935e621fc598\n", - "\n", - "\n", - "# copy everything to a dataset folder\n", - "!mkdir -p dataset/train\n", - "! cp -r wat2021/train/cvit-pib/* dataset/train\n", - "! cp -r wat2021/dev dataset\n", - "! cp -r wat2021/test dataset\n", - "\n", - "\n", - "# lets cd to indicTrans\n", - "%cd indicTrans" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "8yPTbM_clKfI", - "outputId": "d4459da6-3e0b-45c8-f291-d6761e536284" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "../dataset\n" - ] - }, - { - "data": { - "text/plain": [] - }, - "execution_count": 7, - "metadata": { - "tags": [] - }, - "output_type": "execute_result" - } - ], - "source": [ - "%%shell\n", - "\n", - "exp_dir=../dataset\n", - "src_lang=en\n", - "tgt_lang=indic\n", - "\n", - "# change this to indic-en, if you have downloaded the indic-en dir or m2m if you have downloaded the indic2indic model\n", - "download_dir=../en-indic\n", - "\n", - "train_data_dir=$exp_dir/train\n", - "dev_data_dir=$exp_dir/dev\n", - "test_data_dir=$exp_dir/test\n", - "echo $exp_dir\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "NhwUXyYVXrOY", - "outputId": "9ddb06dd-3fcc-4d4c-a4ec-131a9f4ea220" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Running experiment ../dataset on en to indic\n", - "Applying normalization and script conversion for train bn\n", - "100% 91985/91985 [00:25<00:00, 3582.55it/s]\n", - "100% 91985/91985 [00:14<00:00, 6330.85it/s]\n", - "Number of sentences in train bn: 91985\n", - "Applying normalization and script conversion for dev bn\n", - "100% 1000/1000 [00:00<00:00, 1593.70it/s]\n", - "100% 1000/1000 [00:00<00:00, 7232.26it/s]\n", - "Number of sentences in dev bn: 1000\n", - "Applying normalization and script conversion for test bn\n", - "100% 2390/2390 [00:00<00:00, 2874.03it/s]\n", - "100% 2390/2390 [00:00<00:00, 6727.65it/s]\n", - "Number of sentences in test bn: 2390\n", - "Applying normalization and script conversion for train hi\n", - "100% 266545/266545 [01:15<00:00, 3546.17it/s]\n", - "100% 266545/266545 [00:45<00:00, 5913.09it/s]\n", - "Number of sentences in train hi: 266545\n", - "Applying normalization and script conversion for dev hi\n", - "100% 1000/1000 [00:00<00:00, 1666.49it/s]\n", - "100% 1000/1000 [00:00<00:00, 5857.08it/s]\n", - "Number of sentences in dev hi: 1000\n", - "Applying normalization and script conversion for test hi\n", - "100% 2390/2390 [00:00<00:00, 2928.00it/s]\n", - "100% 2390/2390 [00:00<00:00, 6789.39it/s]\n", - "Number of sentences in test hi: 2390\n", - "Applying normalization and script conversion for train gu\n", - "100% 58264/58264 [00:15<00:00, 3688.72it/s]\n", - "100% 58264/58264 [00:09<00:00, 6391.97it/s]\n", - "Number of sentences in train gu: 58264\n", - "Applying normalization and script conversion for dev gu\n", - "100% 1000/1000 [00:00<00:00, 1670.01it/s]\n", - "100% 1000/1000 [00:00<00:00, 6530.46it/s]\n", - "Number of sentences in dev gu: 1000\n", - "Applying normalization and script conversion for test gu\n", - "100% 2390/2390 [00:00<00:00, 2884.69it/s]\n", - "100% 2390/2390 [00:00<00:00, 6099.24it/s]\n", - "Number of sentences in test gu: 2390\n", - "Applying normalization and script conversion for train ml\n", - "100% 43087/43087 [00:12<00:00, 3589.89it/s]\n", - "100% 43087/43087 [00:07<00:00, 5968.67it/s]\n", - "Number of sentences in train ml: 43087\n", - "Applying normalization and script conversion for dev ml\n", - "100% 1000/1000 [00:00<00:00, 1691.23it/s]\n", - "100% 1000/1000 [00:00<00:00, 6090.55it/s]\n", - "Number of sentences in dev ml: 1000\n", - "Applying normalization and script conversion for test ml\n", - "100% 2390/2390 [00:00<00:00, 2961.81it/s]\n", - "100% 2390/2390 [00:00<00:00, 6878.08it/s]\n", - "Number of sentences in test ml: 2390\n", - "Applying normalization and script conversion for train mr\n", - "100% 114220/114220 [00:30<00:00, 3773.79it/s]\n", - "100% 114220/114220 [00:17<00:00, 6513.13it/s]\n", - "Number of sentences in train mr: 114220\n", - "Applying normalization and script conversion for dev mr\n", - "100% 1000/1000 [00:00<00:00, 1671.69it/s]\n", - "100% 1000/1000 [00:00<00:00, 5737.54it/s]\n", - "Number of sentences in dev mr: 1000\n", - "Applying normalization and script conversion for test mr\n", - "100% 2390/2390 [00:00<00:00, 2959.82it/s]\n", - "100% 2390/2390 [00:00<00:00, 6393.52it/s]\n", - "Number of sentences in test mr: 2390\n", - "Applying normalization and script conversion for train or\n", - "100% 94494/94494 [00:24<00:00, 3912.66it/s]\n", - "100% 94494/94494 [00:13<00:00, 6919.45it/s]\n", - "Number of sentences in train or: 94494\n", - "Applying normalization and script conversion for dev or\n", - "100% 1000/1000 [00:00<00:00, 1680.80it/s]\n", - "100% 1000/1000 [00:00<00:00, 5797.35it/s]\n", - "Number of sentences in dev or: 1000\n", - "Applying normalization and script conversion for test or\n", - "100% 2390/2390 [00:00<00:00, 2978.67it/s]\n", - "100% 2390/2390 [00:00<00:00, 6787.01it/s]\n", - "Number of sentences in test or: 2390\n", - "Applying normalization and script conversion for train pa\n", - "100% 101092/101092 [00:26<00:00, 3826.32it/s]\n", - "100% 101092/101092 [00:15<00:00, 6425.22it/s]\n", - "Number of sentences in train pa: 101092\n", - "Applying normalization and script conversion for dev pa\n", - "100% 1000/1000 [00:00<00:00, 1667.88it/s]\n", - "100% 1000/1000 [00:00<00:00, 6182.50it/s]\n", - "Number of sentences in dev pa: 1000\n", - "Applying normalization and script conversion for test pa\n", - "100% 2390/2390 [00:00<00:00, 2993.56it/s]\n", - "100% 2390/2390 [00:00<00:00, 8002.74it/s]\n", - "Number of sentences in test pa: 2390\n", - "Applying normalization and script conversion for train ta\n", - "100% 115968/115968 [00:30<00:00, 3838.68it/s]\n", - "100% 115968/115968 [00:19<00:00, 5805.14it/s]\n", - "Number of sentences in train ta: 115968\n", - "Applying normalization and script conversion for dev ta\n", - "100% 1000/1000 [00:00<00:00, 1659.50it/s]\n", - "100% 1000/1000 [00:00<00:00, 6223.34it/s]\n", - "Number of sentences in dev ta: 1000\n", - "Applying normalization and script conversion for test ta\n", - "100% 2390/2390 [00:00<00:00, 3046.92it/s]\n", - "100% 2390/2390 [00:00<00:00, 6047.32it/s]\n", - "Number of sentences in test ta: 2390\n", - "Applying normalization and script conversion for train te\n", - "100% 44720/44720 [00:12<00:00, 3524.75it/s]\n", - "100% 44720/44720 [00:07<00:00, 6016.25it/s]\n", - "Number of sentences in train te: 44720\n", - "Applying normalization and script conversion for dev te\n", - "100% 1000/1000 [00:00<00:00, 1673.03it/s]\n", - "100% 1000/1000 [00:00<00:00, 6102.16it/s]\n", - "Number of sentences in dev te: 1000\n", - "Applying normalization and script conversion for test te\n", - "100% 2390/2390 [00:00<00:00, 2960.42it/s]\n", - "100% 2390/2390 [00:00<00:00, 7440.37it/s]\n", - "Number of sentences in test te: 2390\n", - "\n", - "../dataset/data/train.SRC\n", - "../dataset/data/train.TGT\n", - " 0% 0/11 [00:00\n", - "2021-05-09 14:03:48 | INFO | fairseq_cli.preprocess | [SRC] Dictionary: 32104 types\n", - "2021-05-09 14:03:49 | INFO | fairseq_cli.preprocess | [SRC] ../dataset/final/dev.SRC: 9000 sents, 200619 tokens, 0.117% replaced by \n", - "2021-05-09 14:03:49 | INFO | fairseq_cli.preprocess | [SRC] Dictionary: 32104 types\n", - "2021-05-09 14:03:51 | INFO | fairseq_cli.preprocess | [SRC] ../dataset/final/test.SRC: 21510 sents, 471564 tokens, 0.155% replaced by \n", - "2021-05-09 14:03:51 | INFO | fairseq_cli.preprocess | [TGT] Dictionary: 35848 types\n", - "2021-05-09 14:07:06 | INFO | fairseq_cli.preprocess | [TGT] ../dataset/final/train.TGT: 930375 sents, 35902065 tokens, 0.318% replaced by \n", - "2021-05-09 14:07:06 | INFO | fairseq_cli.preprocess | [TGT] Dictionary: 35848 types\n", - "2021-05-09 14:07:07 | INFO | fairseq_cli.preprocess | [TGT] ../dataset/final/dev.TGT: 9000 sents, 224623 tokens, 0.631% replaced by \n", - "2021-05-09 14:07:07 | INFO | fairseq_cli.preprocess | [TGT] Dictionary: 35848 types\n", - "2021-05-09 14:07:11 | INFO | fairseq_cli.preprocess | [TGT] ../dataset/final/test.TGT: 21510 sents, 526380 tokens, 0.57% replaced by \n", - "2021-05-09 14:07:11 | INFO | fairseq_cli.preprocess | Wrote preprocessed data to ../dataset/final_bin\n" - ] - }, - { - "data": { - "text/plain": [] - }, - "execution_count": 9, - "metadata": { - "tags": [] - }, - "output_type": "execute_result" - } - ], - "source": [ - "# all the data preparation happens in this cell\n", - "%%shell\n", - "\n", - "exp_dir=../dataset\n", - "src_lang=en\n", - "tgt_lang=indic\n", - "\n", - "# change this to indic-en, if you have downloaded the indic-en dir or m2m if you have downloaded the indic2indic model\n", - "download_dir=../en-indic\n", - "\n", - "train_data_dir=$exp_dir/train\n", - "dev_data_dir=$exp_dir/dev\n", - "test_data_dir=$exp_dir/test\n", - "\n", - "\n", - "echo \"Running experiment ${exp_dir} on ${src_lang} to ${tgt_lang}\"\n", - "\n", - "\n", - "train_processed_dir=$exp_dir/data\n", - "devtest_processed_dir=$exp_dir/data\n", - "\n", - "out_data_dir=$exp_dir/final_bin\n", - "\n", - "mkdir -p $train_processed_dir\n", - "mkdir -p $devtest_processed_dir\n", - "mkdir -p $out_data_dir\n", - "\n", - "# indic languages.\n", - "# cvit-pib corpus does not have as (assamese) and kn (kannada), hence its not part of this list\n", - "langs=(bn hi gu ml mr or pa ta te)\n", - "\n", - "for lang in ${langs[@]};do\n", - "\tif [ $src_lang == en ]; then\n", - "\t\ttgt_lang=$lang\n", - "\telse\n", - "\t\tsrc_lang=$lang\n", - "\tfi\n", - "\n", - "\ttrain_norm_dir=$exp_dir/norm/$src_lang-$tgt_lang\n", - "\tdevtest_norm_dir=$exp_dir/norm/$src_lang-$tgt_lang\n", - "\tmkdir -p $train_norm_dir\n", - "\tmkdir -p $devtest_norm_dir\n", - "\n", - "\n", - " # preprocessing pretokenizes the input (we use moses tokenizer for en and indicnlp lib for indic languages)\n", - " # after pretokenization, we use indicnlp to transliterate all the indic data to devnagiri script\n", - "\n", - "\t# train preprocessing\n", - "\ttrain_infname_src=$train_data_dir/en-${lang}/train.$src_lang\n", - "\ttrain_infname_tgt=$train_data_dir/en-${lang}/train.$tgt_lang\n", - "\ttrain_outfname_src=$train_norm_dir/train.$src_lang\n", - "\ttrain_outfname_tgt=$train_norm_dir/train.$tgt_lang\n", - "\techo \"Applying normalization and script conversion for train $lang\"\n", - "\tinput_size=`python scripts/preprocess_translate.py $train_infname_src $train_outfname_src $src_lang true`\n", - "\tinput_size=`python scripts/preprocess_translate.py $train_infname_tgt $train_outfname_tgt $tgt_lang true`\n", - "\techo \"Number of sentences in train $lang: $input_size\"\n", - "\n", - "\t# dev preprocessing\n", - "\tdev_infname_src=$dev_data_dir/dev.$src_lang\n", - "\tdev_infname_tgt=$dev_data_dir/dev.$tgt_lang\n", - "\tdev_outfname_src=$devtest_norm_dir/dev.$src_lang\n", - "\tdev_outfname_tgt=$devtest_norm_dir/dev.$tgt_lang\n", - "\techo \"Applying normalization and script conversion for dev $lang\"\n", - "\tinput_size=`python scripts/preprocess_translate.py $dev_infname_src $dev_outfname_src $src_lang true`\n", - "\tinput_size=`python scripts/preprocess_translate.py $dev_infname_tgt $dev_outfname_tgt $tgt_lang true`\n", - "\techo \"Number of sentences in dev $lang: $input_size\"\n", - "\n", - "\t# test preprocessing\n", - "\ttest_infname_src=$test_data_dir/test.$src_lang\n", - "\ttest_infname_tgt=$test_data_dir/test.$tgt_lang\n", - "\ttest_outfname_src=$devtest_norm_dir/test.$src_lang\n", - "\ttest_outfname_tgt=$devtest_norm_dir/test.$tgt_lang\n", - "\techo \"Applying normalization and script conversion for test $lang\"\n", - "\tinput_size=`python scripts/preprocess_translate.py $test_infname_src $test_outfname_src $src_lang true`\n", - "\tinput_size=`python scripts/preprocess_translate.py $test_infname_tgt $test_outfname_tgt $tgt_lang true`\n", - "\techo \"Number of sentences in test $lang: $input_size\"\n", - "done\n", - "\n", - "\n", - "\n", - "\n", - "# Now that we have preprocessed all the data, we can now merge these different text files into one\n", - "# ie. for en-as, we have train.en and corresponding train.as, similarly for en-bn, we have train.en and corresponding train.bn\n", - "# now we will concatenate all this into en-X where train.SRC will have all the en (src) training data and train.TGT will have all the concatenated indic lang data\n", - "\n", - "python scripts/concat_joint_data.py $exp_dir/norm $exp_dir/data $src_lang $tgt_lang 'train'\n", - "python scripts/concat_joint_data.py $exp_dir/norm $exp_dir/data $src_lang $tgt_lang 'dev'\n", - "python scripts/concat_joint_data.py $exp_dir/norm $exp_dir/data $src_lang $tgt_lang 'test'\n", - "\n", - "# use the vocab from downloaded dir\n", - "cp -r $download_dir/vocab $exp_dir\n", - "\n", - "\n", - "echo \"Applying bpe to the new finetuning data\"\n", - "bash apply_single_bpe_traindevtest_notag.sh $exp_dir\n", - "\n", - "mkdir -p $exp_dir/final\n", - "\n", - "# We also add special tags to indicate the source and target language in the inputs\n", - "# Eg: to translate a sentence from english to hindi , the input would be __src__en__ __tgt__hi__ \n", - "\n", - "echo \"Adding language tags\"\n", - "python scripts/add_joint_tags_translate.py $exp_dir 'train'\n", - "python scripts/add_joint_tags_translate.py $exp_dir 'dev'\n", - "python scripts/add_joint_tags_translate.py $exp_dir 'test'\n", - "\n", - "\n", - "\n", - "data_dir=$exp_dir/final\n", - "out_data_dir=$exp_dir/final_bin\n", - "\n", - "rm -rf $out_data_dir\n", - "\n", - "# binarizing the new data (train, dev and test) using dictionary from the download dir\n", - "\n", - " num_workers=`python -c \"import multiprocessing; print(multiprocessing.cpu_count())\"`\n", - "\n", - "data_dir=$exp_dir/final\n", - "out_data_dir=$exp_dir/final_bin\n", - "\n", - "# rm -rf $out_data_dir\n", - "\n", - "echo \"Binarizing data. This will take some time depending on the size of finetuning data\"\n", - "fairseq-preprocess --source-lang SRC --target-lang TGT \\\n", - " --trainpref $data_dir/train --validpref $data_dir/dev --testpref $data_dir/test \\\n", - " --destdir $out_data_dir --workers $num_workers \\\n", - " --srcdict $download_dir/final_bin/dict.SRC.txt --tgtdict $download_dir/final_bin/dict.TGT.txt --thresholdtgt 5 --thresholdsrc 5 " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "iz6tzbe2tcs7", - "outputId": "6705e2d6-b5cb-4810-c833-6a1370d3fce4" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2021-05-09 14:29:11 | INFO | fairseq_cli.train | {'_name': None, 'common': {'_name': None, 'no_progress_bar': False, 'log_interval': 100, 'log_format': None, 'log_file': None, 'tensorboard_logdir': '../dataset/tensorboard-wandb', 'wandb_project': None, 'azureml_logging': False, 'seed': 1, 'cpu': False, 'tpu': False, 'bf16': False, 'memory_efficient_bf16': False, 'fp16': True, 'memory_efficient_fp16': False, 'fp16_no_flatten_grads': False, 'fp16_init_scale': 128, 'fp16_scale_window': None, 'fp16_scale_tolerance': 0.0, 'min_loss_scale': 0.0001, 'threshold_loss_scale': None, 'user_dir': 'model_configs', 'empty_cache_freq': 0, 'all_gather_list_size': 16384, 'model_parallel_size': 1, 'quantization_config_path': None, 'profile': False, 'reset_logging': False, 'suppress_crashes': False, 'use_plasma_view': False, 'plasma_path': '/tmp/plasma'}, 'common_eval': {'_name': None, 'path': None, 'post_process': None, 'quiet': False, 'model_overrides': '{}', 'results_path': None}, 'distributed_training': {'_name': None, 'distributed_world_size': 1, 'distributed_rank': 0, 'distributed_backend': 'nccl', 'distributed_init_method': None, 'distributed_port': -1, 'device_id': 0, 'distributed_no_spawn': False, 'ddp_backend': 'pytorch_ddp', 'ddp_comm_hook': 'none', 'bucket_cap_mb': 25, 'fix_batches_to_gpus': False, 'find_unused_parameters': False, 'fast_stat_sync': False, 'heartbeat_timeout': -1, 'broadcast_buffers': False, 'slowmo_momentum': None, 'slowmo_algorithm': 'LocalSGD', 'localsgd_frequency': 3, 'nprocs_per_node': 1, 'pipeline_model_parallel': False, 'pipeline_balance': None, 'pipeline_devices': None, 'pipeline_chunks': 0, 'pipeline_encoder_balance': None, 'pipeline_encoder_devices': None, 'pipeline_decoder_balance': None, 'pipeline_decoder_devices': None, 'pipeline_checkpoint': 'never', 'zero_sharding': 'none', 'fp16': True, 'memory_efficient_fp16': False, 'tpu': False, 'no_reshard_after_forward': False, 'fp32_reduce_scatter': False, 'cpu_offload': False, 'distributed_num_procs': 1}, 'dataset': {'_name': None, 'num_workers': 1, 'skip_invalid_size_inputs_valid_test': True, 'max_tokens': 256, 'batch_size': None, 'required_batch_size_multiple': 8, 'required_seq_len_multiple': 1, 'dataset_impl': None, 'data_buffer_size': 10, 'train_subset': 'train', 'valid_subset': 'valid', 'validate_interval': 1, 'validate_interval_updates': 0, 'validate_after_updates': 0, 'fixed_validation_seed': None, 'disable_validation': False, 'max_tokens_valid': 256, 'batch_size_valid': None, 'max_valid_steps': None, 'curriculum': 0, 'gen_subset': 'test', 'num_shards': 1, 'shard_id': 0}, 'optimization': {'_name': None, 'max_epoch': 0, 'max_update': 1000, 'stop_time_hours': 0.0, 'clip_norm': 1.0, 'sentence_avg': False, 'update_freq': [2], 'lr': [3e-05], 'stop_min_lr': -1.0, 'use_bmuf': False}, 'checkpoint': {'_name': None, 'save_dir': '../dataset/model', 'restore_file': '../en-indic/model/checkpoint_best.pt', 'finetune_from_model': None, 'reset_dataloader': True, 'reset_lr_scheduler': True, 'reset_meters': True, 'reset_optimizer': True, 'optimizer_overrides': '{}', 'save_interval': 1, 'save_interval_updates': 0, 'keep_interval_updates': -1, 'keep_interval_updates_pattern': -1, 'keep_last_epochs': 5, 'keep_best_checkpoints': -1, 'no_save': False, 'no_epoch_checkpoints': False, 'no_last_checkpoints': False, 'no_save_optimizer_state': False, 'best_checkpoint_metric': 'loss', 'maximize_best_checkpoint_metric': False, 'patience': 5, 'checkpoint_suffix': '', 'checkpoint_shard_count': 1, 'load_checkpoint_on_all_dp_ranks': False, 'write_checkpoints_asynchronously': False, 'model_parallel_size': 1}, 'bmuf': {'_name': None, 'block_lr': 1.0, 'block_momentum': 0.875, 'global_sync_iter': 50, 'warmup_iterations': 500, 'use_nbm': False, 'average_sync': False, 'distributed_world_size': 1}, 'generation': {'_name': None, 'beam': 5, 'nbest': 1, 'max_len_a': 0.0, 'max_len_b': 200, 'min_len': 1, 'match_source_len': False, 'unnormalized': False, 'no_early_stop': False, 'no_beamable_mm': False, 'lenpen': 1.0, 'unkpen': 0.0, 'replace_unk': None, 'sacrebleu': False, 'score_reference': False, 'prefix_size': 0, 'no_repeat_ngram_size': 0, 'sampling': False, 'sampling_topk': -1, 'sampling_topp': -1.0, 'constraints': None, 'temperature': 1.0, 'diverse_beam_groups': -1, 'diverse_beam_strength': 0.5, 'diversity_rate': -1.0, 'print_alignment': None, 'print_step': False, 'lm_path': None, 'lm_weight': 0.0, 'iter_decode_eos_penalty': 0.0, 'iter_decode_max_iter': 10, 'iter_decode_force_max_iter': False, 'iter_decode_with_beam': 1, 'iter_decode_with_external_reranker': False, 'retain_iter_history': False, 'retain_dropout': False, 'retain_dropout_modules': None, 'decoding_format': None, 'no_seed_provided': False}, 'eval_lm': {'_name': None, 'output_word_probs': False, 'output_word_stats': False, 'context_window': 0, 'softmax_batch': 9223372036854775807}, 'interactive': {'_name': None, 'buffer_size': 0, 'input': '-'}, 'model': Namespace(_name='transformer_4x', activation_dropout=0.0, activation_fn='relu', adam_betas='(0.9, 0.98)', adam_eps=1e-08, adaptive_input=False, adaptive_softmax_cutoff=None, adaptive_softmax_dropout=0, all_gather_list_size=16384, arch='transformer_4x', attention_dropout=0.0, azureml_logging=False, batch_size=None, batch_size_valid=None, best_checkpoint_metric='loss', bf16=False, bpe=None, broadcast_buffers=False, bucket_cap_mb=25, checkpoint_activations=False, checkpoint_shard_count=1, checkpoint_suffix='', clip_norm=1.0, cpu=False, cpu_offload=False, criterion='label_smoothed_cross_entropy', cross_self_attention=False, curriculum=0, data='../dataset/final_bin', data_buffer_size=10, dataset_impl=None, ddp_backend='pytorch_ddp', ddp_comm_hook='none', decoder_attention_heads=16, decoder_embed_dim=1536, decoder_embed_path=None, decoder_ffn_embed_dim=4096, decoder_input_dim=1536, decoder_layerdrop=0, decoder_layers=6, decoder_layers_to_keep=None, decoder_learned_pos=False, decoder_normalize_before=False, decoder_output_dim=1536, device_id=0, disable_validation=False, distributed_backend='nccl', distributed_init_method=None, distributed_no_spawn=False, distributed_port=-1, distributed_rank=0, distributed_world_size=1, dropout=0.2, empty_cache_freq=0, encoder_attention_heads=16, encoder_embed_dim=1536, encoder_embed_path=None, encoder_ffn_embed_dim=4096, encoder_layerdrop=0, encoder_layers=6, encoder_layers_to_keep=None, encoder_learned_pos=False, encoder_normalize_before=False, eos=2, eval_bleu=False, eval_bleu_args='{}', eval_bleu_detok='space', eval_bleu_detok_args='{}', eval_bleu_print_samples=False, eval_bleu_remove_bpe=None, eval_tokenized_bleu=False, fast_stat_sync=False, find_unused_parameters=False, finetune_from_model=None, fix_batches_to_gpus=False, fixed_validation_seed=None, fp16=True, fp16_init_scale=128, fp16_no_flatten_grads=False, fp16_scale_tolerance=0.0, fp16_scale_window=None, fp32_reduce_scatter=False, gen_subset='test', heartbeat_timeout=-1, ignore_prefix_size=0, keep_best_checkpoints=-1, keep_interval_updates=-1, keep_interval_updates_pattern=-1, keep_last_epochs=5, label_smoothing=0.1, layernorm_embedding=False, left_pad_source=True, left_pad_target=False, load_alignments=False, load_checkpoint_on_all_dp_ranks=False, localsgd_frequency=3, log_file=None, log_format=None, log_interval=100, lr=[3e-05], lr_scheduler='inverse_sqrt', max_epoch=0, max_source_positions=210, max_target_positions=210, max_tokens=256, max_tokens_valid=256, max_update=1000, max_valid_steps=None, maximize_best_checkpoint_metric=False, memory_efficient_bf16=False, memory_efficient_fp16=False, min_loss_scale=0.0001, min_params_to_wrap=100000000, model_parallel_size=1, no_cross_attention=False, no_epoch_checkpoints=False, no_last_checkpoints=False, no_progress_bar=False, no_reshard_after_forward=False, no_save=False, no_save_optimizer_state=False, no_scale_embedding=False, no_seed_provided=False, no_token_positional_embeddings=False, nprocs_per_node=1, num_batch_buckets=0, num_shards=1, num_workers=1, offload_activations=False, optimizer='adam', optimizer_overrides='{}', pad=1, patience=5, pipeline_balance=None, pipeline_checkpoint='never', pipeline_chunks=0, pipeline_decoder_balance=None, pipeline_decoder_devices=None, pipeline_devices=None, pipeline_encoder_balance=None, pipeline_encoder_devices=None, pipeline_model_parallel=False, plasma_path='/tmp/plasma', profile=False, quant_noise_pq=0, quant_noise_pq_block_size=8, quant_noise_scalar=0, quantization_config_path=None, report_accuracy=False, required_batch_size_multiple=8, required_seq_len_multiple=1, reset_dataloader=True, reset_logging=False, reset_lr_scheduler=True, reset_meters=True, reset_optimizer=True, restore_file='../en-indic/model/checkpoint_best.pt', save_dir='../dataset/model', save_interval=1, save_interval_updates=0, scoring='bleu', seed=1, sentence_avg=False, shard_id=0, share_all_embeddings=False, share_decoder_input_output_embed=False, skip_invalid_size_inputs_valid_test=True, slowmo_algorithm='LocalSGD', slowmo_momentum=None, source_lang='SRC', stop_min_lr=-1.0, stop_time_hours=0, suppress_crashes=False, target_lang='TGT', task='translation', tensorboard_logdir='../dataset/tensorboard-wandb', threshold_loss_scale=None, tie_adaptive_weights=False, tokenizer=None, tpu=False, train_subset='train', truncate_source=False, unk=3, update_freq=[2], upsample_primary=-1, use_bmuf=False, use_old_adam=False, use_plasma_view=False, user_dir='model_configs', valid_subset='valid', validate_after_updates=0, validate_interval=1, validate_interval_updates=0, wandb_project=None, warmup_init_lr=1e-07, warmup_updates=4000, weight_decay=0.0, write_checkpoints_asynchronously=False, zero_sharding='none'), 'task': {'_name': 'translation', 'data': '../dataset/final_bin', 'source_lang': 'SRC', 'target_lang': 'TGT', 'load_alignments': False, 'left_pad_source': True, 'left_pad_target': False, 'max_source_positions': 210, 'max_target_positions': 210, 'upsample_primary': -1, 'truncate_source': False, 'num_batch_buckets': 0, 'train_subset': 'train', 'dataset_impl': None, 'required_seq_len_multiple': 1, 'eval_bleu': False, 'eval_bleu_args': '{}', 'eval_bleu_detok': 'space', 'eval_bleu_detok_args': '{}', 'eval_tokenized_bleu': False, 'eval_bleu_remove_bpe': None, 'eval_bleu_print_samples': False}, 'criterion': {'_name': 'label_smoothed_cross_entropy', 'label_smoothing': 0.1, 'report_accuracy': False, 'ignore_prefix_size': 0, 'sentence_avg': False}, 'optimizer': {'_name': 'adam', 'adam_betas': '(0.9, 0.98)', 'adam_eps': 1e-08, 'weight_decay': 0.0, 'use_old_adam': False, 'tpu': False, 'lr': [3e-05]}, 'lr_scheduler': {'_name': 'inverse_sqrt', 'warmup_updates': 4000, 'warmup_init_lr': 1e-07, 'lr': [3e-05]}, 'scoring': {'_name': 'bleu', 'pad': 1, 'eos': 2, 'unk': 3}, 'bpe': None, 'tokenizer': None}\n", - "2021-05-09 14:29:11 | INFO | fairseq.tasks.translation | [SRC] dictionary: 32104 types\n", - "2021-05-09 14:29:11 | INFO | fairseq.tasks.translation | [TGT] dictionary: 35848 types\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | TransformerModel(\n", - " (encoder): TransformerEncoder(\n", - " (dropout_module): FairseqDropout()\n", - " (embed_tokens): Embedding(32104, 1536, padding_idx=1)\n", - " (embed_positions): SinusoidalPositionalEmbedding()\n", - " (layers): ModuleList(\n", - " (0): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (1): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (2): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (3): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (4): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (5): TransformerEncoderLayer(\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (dropout_module): FairseqDropout()\n", - " (activation_dropout_module): FairseqDropout()\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " )\n", - " )\n", - " (decoder): TransformerDecoder(\n", - " (dropout_module): FairseqDropout()\n", - " (embed_tokens): Embedding(35848, 1536, padding_idx=1)\n", - " (embed_positions): SinusoidalPositionalEmbedding()\n", - " (layers): ModuleList(\n", - " (0): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (1): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (2): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (3): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (4): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " (5): TransformerDecoderLayer(\n", - " (dropout_module): FairseqDropout()\n", - " (self_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (activation_dropout_module): FairseqDropout()\n", - " (self_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (encoder_attn): MultiheadAttention(\n", - " (dropout_module): FairseqDropout()\n", - " (k_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (v_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (q_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " (out_proj): Linear(in_features=1536, out_features=1536, bias=True)\n", - " )\n", - " (encoder_attn_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " (fc1): Linear(in_features=1536, out_features=4096, bias=True)\n", - " (fc2): Linear(in_features=4096, out_features=1536, bias=True)\n", - " (final_layer_norm): LayerNorm((1536,), eps=1e-05, elementwise_affine=True)\n", - " )\n", - " )\n", - " (output_projection): Linear(in_features=1536, out_features=35848, bias=False)\n", - " )\n", - ")\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | task: TranslationTask\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | model: TransformerModel\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | criterion: LabelSmoothedCrossEntropyCriterion\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | num. shared model params: 480,571,392 (num. trained: 480,571,392)\n", - "2021-05-09 14:29:19 | INFO | fairseq_cli.train | num. expert model params: 0 (num. trained: 0)\n", - "2021-05-09 14:29:19 | INFO | fairseq.data.data_utils | loaded 9,000 examples from: ../dataset/final_bin/valid.SRC-TGT.SRC\n", - "2021-05-09 14:29:19 | INFO | fairseq.data.data_utils | loaded 9,000 examples from: ../dataset/final_bin/valid.SRC-TGT.TGT\n", - "2021-05-09 14:29:19 | INFO | fairseq.tasks.translation | ../dataset/final_bin valid SRC-TGT 9000 examples\n", - "2021-05-09 14:29:21 | INFO | fairseq.utils | ***********************CUDA enviroments for all 1 workers***********************\n", - "2021-05-09 14:29:21 | INFO | fairseq.utils | rank 0: capabilities = 3.7 ; total memory = 11.173 GB ; name = Tesla K80 \n", - "2021-05-09 14:29:21 | INFO | fairseq.utils | ***********************CUDA enviroments for all 1 workers***********************\n", - "2021-05-09 14:29:21 | INFO | fairseq_cli.train | training on 1 devices (GPUs/TPUs)\n", - "2021-05-09 14:29:21 | INFO | fairseq_cli.train | max tokens per device = 256 and max sentences per device = None\n", - "2021-05-09 14:29:21 | INFO | fairseq.trainer | Preparing to load checkpoint ../en-indic/model/checkpoint_best.pt\n", - "tcmalloc: large alloc 1922285568 bytes == 0x55e01c93a000 @ 0x7f8579074b6b 0x7f8579094379 0x7f851797e25e 0x7f851797f9d2 0x7f85559a8e7d 0x7f85665a3120 0x7f85661e1bd9 0x55df57c868a8 0x55df57cf9fd5 0x55df57cf47ad 0x55df57c873ea 0x55df57cf53b5 0x55df57cf47ad 0x55df57c87003 0x55df57c86b09 0x55df57dce28d 0x55df57d3d1db 0x55df57c85bb1 0x55df57d76fed 0x55df57cf9988 0x55df57cf47ad 0x55df57bc6e2c 0x55df57cf6bb5 0x55df57cf44ae 0x55df57c873ea 0x55df57cf632a 0x55df57cf44ae 0x55df57c873ea 0x55df57cf632a 0x55df57cf44ae 0x55df57c873ea\n", - "tcmalloc: large alloc 1922285568 bytes == 0x55e08f276000 @ 0x7f8579074b6b 0x7f8579094379 0x7f851797e25e 0x7f851797f9d2 0x7f85559a8e7d 0x7f85665a3120 0x7f85661e1bd9 0x55df57c868a8 0x55df57cf9fd5 0x55df57cf47ad 0x55df57c873ea 0x55df57cf53b5 0x55df57cf47ad 0x55df57c87003 0x55df57c86b09 0x55df57dce28d 0x55df57d3d1db 0x55df57c85bb1 0x55df57d76fed 0x55df57cf9988 0x55df57cf47ad 0x55df57bc6e2c 0x55df57cf6bb5 0x55df57cf44ae 0x55df57c873ea 0x55df57cf632a 0x55df57cf44ae 0x55df57c873ea 0x55df57cf632a 0x55df57cf44ae 0x55df57c873ea\n", - "2021-05-09 14:32:01 | INFO | fairseq.trainer | NOTE: your device does NOT support faster training with --fp16, please switch to FP32 which is likely to be faster\n", - "2021-05-09 14:32:01 | INFO | fairseq.trainer | Loaded checkpoint ../en-indic/model/checkpoint_best.pt (epoch 20 @ 0 updates)\n", - "2021-05-09 14:32:01 | INFO | fairseq.trainer | loading train data for epoch 1\n", - "2021-05-09 14:32:01 | INFO | fairseq.data.data_utils | loaded 930,375 examples from: ../dataset/final_bin/train.SRC-TGT.SRC\n", - "2021-05-09 14:32:01 | INFO | fairseq.data.data_utils | loaded 930,375 examples from: ../dataset/final_bin/train.SRC-TGT.TGT\n", - "2021-05-09 14:32:01 | INFO | fairseq.tasks.translation | ../dataset/final_bin train SRC-TGT 930375 examples\n", - "2021-05-09 14:32:01 | WARNING | fairseq.tasks.fairseq_task | 1,647 samples have invalid sizes and will be skipped, max_positions=(210, 210), first few sample ids=[865604, 927195, 465934, 204968, 865293, 859052, 1713, 672173, 858328, 286278]\n", - "epoch 001: 0% 0/86283 [00:00\n", - " sys.exit(load_entry_point('fairseq', 'console_scripts', 'fairseq-train')())\n", - " File \"/content/finetuning/fairseq/fairseq_cli/train.py\", line 496, in cli_main\n", - " distributed_utils.call_main(cfg, main)\n", - " File \"/content/finetuning/fairseq/fairseq/distributed/utils.py\", line 369, in call_main\n", - " main(cfg, **kwargs)\n", - " File \"/content/finetuning/fairseq/fairseq_cli/train.py\", line 173, in main\n", - " valid_losses, should_stop = train(cfg, trainer, task, epoch_itr)\n", - " File \"/usr/lib/python3.7/contextlib.py\", line 74, in inner\n", - " return func(*args, **kwds)\n", - " File \"/content/finetuning/fairseq/fairseq_cli/train.py\", line 284, in train\n", - " log_output = trainer.train_step(samples)\n", - " File \"/usr/lib/python3.7/contextlib.py\", line 74, in inner\n", - " return func(*args, **kwds)\n", - " File \"/content/finetuning/fairseq/fairseq/trainer.py\", line 810, in train_step\n", - " raise e\n", - " File \"/content/finetuning/fairseq/fairseq/trainer.py\", line 782, in train_step\n", - " self.optimizer, model=self.model, update_num=self.get_num_updates()\n", - " File \"/content/finetuning/fairseq/fairseq/tasks/fairseq_task.py\", line 489, in optimizer_step\n", - " optimizer.step()\n", - " File \"/content/finetuning/fairseq/fairseq/optim/fp16_optimizer.py\", line 213, in step\n", - " self.fp32_optimizer.step(closure, groups=groups)\n", - " File \"/content/finetuning/fairseq/fairseq/optim/fairseq_optimizer.py\", line 127, in step\n", - " self.optimizer.step(closure)\n", - " File \"/usr/local/lib/python3.7/dist-packages/torch/optim/optimizer.py\", line 89, in wrapper\n", - " return func(*args, **kwargs)\n", - " File \"/content/finetuning/fairseq/fairseq/optim/adam.py\", line 210, in step\n", - " denom = exp_avg_sq.sqrt().add_(group[\"eps\"])\n", - "RuntimeError: CUDA out of memory. Tried to allocate 1.79 GiB (GPU 0; 11.17 GiB total capacity; 8.96 GiB already allocated; 1.66 GiB free; 9.08 GiB reserved in total by PyTorch)\n" - ] - } - ], - "source": [ - "# Finetuning the model\n", - "\n", - "# pls refer to fairseq documentaion to know more about each of these options (https://fairseq.readthedocs.io/en/latest/command_line_tools.html)\n", - "\n", - "\n", - "# some notable args:\n", - "# --max-update=1000 -> for this example, to demonstrate how to finetune we are only training for 1000 steps. You should increase this when finetuning\n", - "# --arch=transformer_4x -> we use a custom transformer model and name it transformer_4x (4 times the parameter size of transformer base)\n", - "# --user_dir -> we define the custom transformer arch in model_configs folder and pass it as an argument to user_dir for fairseq to register this architechture\n", - "# --lr -> learning rate. From our limited experiments, we find that lower learning rates like 3e-5 works best for finetuning.\n", - "# --restore-file -> reload the pretrained checkpoint and start training from here (change this path for indic-en. Currently its is set to en-indic)\n", - "# --reset-* -> reset and not use lr scheduler, dataloader, optimizer etc of the older checkpoint\n", - "# --max_tokns -> this is max tokens per batch\n", - "\n", - "\n", - "!( fairseq-train ../dataset/final_bin \\\n", - "--max-source-positions=210 \\\n", - "--max-target-positions=210 \\\n", - "--max-update=1000 \\\n", - "--save-interval=1 \\\n", - "--arch=transformer_4x \\\n", - "--criterion=label_smoothed_cross_entropy \\\n", - "--source-lang=SRC \\\n", - "--lr-scheduler=inverse_sqrt \\\n", - "--target-lang=TGT \\\n", - "--label-smoothing=0.1 \\\n", - "--optimizer adam \\\n", - "--adam-betas \"(0.9, 0.98)\" \\\n", - "--clip-norm 1.0 \\\n", - "--warmup-init-lr 1e-07 \\\n", - "--warmup-updates 4000 \\\n", - "--dropout 0.2 \\\n", - "--tensorboard-logdir ../dataset/tensorboard-wandb \\\n", - "--save-dir ../dataset/model \\\n", - "--keep-last-epochs 5 \\\n", - "--patience 5 \\\n", - "--skip-invalid-size-inputs-valid-test \\\n", - "--fp16 \\\n", - "--user-dir model_configs \\\n", - "--update-freq=2 \\\n", - "--distributed-world-size 1 \\\n", - "--max-tokens 256 \\\n", - "--lr 3e-5 \\\n", - "--restore-file ../en-indic/model/checkpoint_best.pt \\\n", - "--reset-lr-scheduler \\\n", - "--reset-meters \\\n", - "--reset-dataloader \\\n", - "--reset-optimizer)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "tpPsT1e7vuO9" - }, - "outputs": [], - "source": [ - "# To test the models after training, you can use joint_translate.sh\n", - "\n", - "\n", - "\n", - "# joint_translate takes src_file, output_fname, src_lang, tgt_lang, model_folder as inputs\n", - "# src_file -> input text file to be translated\n", - "# output_fname -> name of the output file (will get created) containing the model predictions\n", - "# src_lang -> source lang code of the input text ( in this case we are using en-indic model and hence src_lang would be 'en')\n", - "# tgt_lang -> target lang code of the input text ( tgt lang for en-indic model would be any of the 11 indic langs we trained on:\n", - "# as, bn, hi, gu, kn, ml, mr, or, pa, ta, te)\n", - "# supported languages are:\n", - "# as - assamese, bn - bengali, gu - gujarathi, hi - hindi, kn - kannada, \n", - "# ml - malayalam, mr - marathi, or - oriya, pa - punjabi, ta - tamil, te - telugu\n", - "\n", - "# model_dir -> the directory containing the model and the vocab files\n", - "\n", - "# Note: if the translation is taking a lot of time, please tune the buffer_size and batch_size parameter for fairseq-interactive defined inside this joint_translate script\n", - "\n", - "\n", - "# here we are translating the english sentences to hindi\n", - "!bash joint_translate.sh $exp_dir/test/test.en en_hi_outputs.txt 'en' 'hi' $exp_dir" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "bPqneByPxilN" - }, - "outputs": [], - "source": [ - "# to compute bleu scores for the predicitions with a reference file, use the following command\n", - "# arguments:\n", - "# pred_fname: file that contains model predictions\n", - "# ref_fname: file that contains references\n", - "# src_lang and tgt_lang : the source and target language\n", - "\n", - "bash compute_bleu.sh en_hi_outputs.txt $exp_dir/test/test.hi 'en' 'hi'\n" - ] - } - ], - "metadata": { - "accelerator": "GPU", - "colab": { - "collapsed_sections": [], - "include_colab_link": true, - "name": "indicTrans_Finetuning.ipynb", - "provenance": [] - }, - "interpreter": { - "hash": "3c7d4130300118f0c7487d576c6841c0dbbdeec039e1e658ac9b107412a09af0" - }, - "kernelspec": { - "display_name": "Python 3.7.7 64-bit", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -}