{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "ari_en_nso_JW300.ipynb", "provenance": [], "collapsed_sections": [ "1bM3_Zn34LGu" ], "toc_visible": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "accelerator": "GPU" }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "HlK7-onojaYL", "colab_type": "text" }, "source": [ "#
Masakhane - Machine Translation for African Languages (Using JoeyNMT)
\n", "## Author : Ari Ramkilowan\n", "## Language Pair : English - Sepedi\n", "## Corpus : JW300 " ] }, { "cell_type": "markdown", "metadata": { "id": "rIzB5Yo6nugf", "colab_type": "text" }, "source": [ "
" ] }, { "cell_type": "markdown", "metadata": { "id": "jPmely-suPXt", "colab_type": "text" }, "source": [ "## Install JoeyNMT" ] }, { "cell_type": "code", "metadata": { "id": "K00EyOQ3ubNH", "colab_type": "code", "outputId": "cd78988b-26d5-480c-c09b-1abfd9e7a37f", "colab": { "base_uri": "https://localhost:8080/", "height": 1000 } }, "source": [ "! git clone https://github.com/joeynmt/joeynmt.git\n", "! cd joeynmt; pip3 install ." ], "execution_count": 1, "outputs": [ { "output_type": "stream", "text": [ "Cloning into 'joeynmt'...\n", "remote: Enumerating objects: 149, done.\u001b[K\n", "remote: Counting objects: 0% (1/149)\u001b[K\rremote: Counting objects: 1% (2/149)\u001b[K\rremote: Counting objects: 2% (3/149)\u001b[K\rremote: Counting objects: 3% (5/149)\u001b[K\rremote: Counting objects: 4% (6/149)\u001b[K\rremote: Counting objects: 5% (8/149)\u001b[K\rremote: Counting objects: 6% (9/149)\u001b[K\rremote: Counting objects: 7% (11/149)\u001b[K\rremote: Counting objects: 8% (12/149)\u001b[K\rremote: Counting objects: 9% (14/149)\u001b[K\rremote: Counting objects: 10% (15/149)\u001b[K\rremote: Counting objects: 11% (17/149)\u001b[K\rremote: Counting objects: 12% (18/149)\u001b[K\rremote: Counting objects: 13% (20/149)\u001b[K\rremote: Counting objects: 14% (21/149)\u001b[K\rremote: Counting objects: 15% (23/149)\u001b[K\rremote: Counting objects: 16% (24/149)\u001b[K\rremote: Counting objects: 17% (26/149)\u001b[K\rremote: Counting objects: 18% (27/149)\u001b[K\rremote: Counting objects: 19% (29/149)\u001b[K\rremote: Counting objects: 20% (30/149)\u001b[K\rremote: Counting objects: 21% (32/149)\u001b[K\rremote: Counting objects: 22% (33/149)\u001b[K\rremote: Counting objects: 23% (35/149)\u001b[K\rremote: Counting objects: 24% (36/149)\u001b[K\rremote: Counting objects: 25% (38/149)\u001b[K\rremote: Counting objects: 26% (39/149)\u001b[K\rremote: Counting objects: 27% (41/149)\u001b[K\rremote: Counting objects: 28% (42/149)\u001b[K\rremote: Counting objects: 29% (44/149)\u001b[K\rremote: Counting objects: 30% (45/149)\u001b[K\rremote: Counting objects: 31% (47/149)\u001b[K\rremote: Counting objects: 32% (48/149)\u001b[K\rremote: Counting objects: 33% (50/149)\u001b[K\rremote: Counting objects: 34% (51/149)\u001b[K\rremote: Counting objects: 35% (53/149)\u001b[K\rremote: Counting objects: 36% (54/149)\u001b[K\rremote: Counting objects: 37% (56/149)\u001b[K\rremote: Counting objects: 38% (57/149)\u001b[K\rremote: Counting objects: 39% (59/149)\u001b[K\rremote: Counting objects: 40% (60/149)\u001b[K\rremote: Counting objects: 41% (62/149)\u001b[K\rremote: Counting objects: 42% (63/149)\u001b[K\rremote: Counting objects: 43% (65/149)\u001b[K\rremote: Counting objects: 44% (66/149)\u001b[K\rremote: Counting objects: 45% (68/149)\u001b[K\rremote: Counting objects: 46% (69/149)\u001b[K\rremote: Counting objects: 47% (71/149)\u001b[K\rremote: Counting objects: 48% (72/149)\u001b[K\rremote: Counting objects: 49% (74/149)\u001b[K\rremote: Counting objects: 50% (75/149)\u001b[K\rremote: Counting objects: 51% (76/149)\u001b[K\rremote: Counting objects: 52% (78/149)\u001b[K\rremote: Counting objects: 53% (79/149)\u001b[K\rremote: Counting objects: 54% (81/149)\u001b[K\rremote: Counting objects: 55% (82/149)\u001b[K\rremote: Counting objects: 56% (84/149)\u001b[K\rremote: Counting objects: 57% (85/149)\u001b[K\rremote: Counting objects: 58% (87/149)\u001b[K\rremote: Counting objects: 59% (88/149)\u001b[K\rremote: Counting objects: 60% (90/149)\u001b[K\rremote: Counting objects: 61% (91/149)\u001b[K\rremote: Counting objects: 62% (93/149)\u001b[K\rremote: Counting objects: 63% (94/149)\u001b[K\rremote: Counting objects: 64% (96/149)\u001b[K\rremote: Counting objects: 65% (97/149)\u001b[K\rremote: Counting objects: 66% (99/149)\u001b[K\rremote: Counting objects: 67% (100/149)\u001b[K\rremote: Counting objects: 68% (102/149)\u001b[K\rremote: Counting objects: 69% (103/149)\u001b[K\rremote: Counting objects: 70% (105/149)\u001b[K\rremote: Counting objects: 71% (106/149)\u001b[K\rremote: Counting objects: 72% (108/149)\u001b[K\rremote: Counting objects: 73% (109/149)\u001b[K\rremote: Counting objects: 74% (111/149)\u001b[K\rremote: Counting objects: 75% (112/149)\u001b[K\rremote: Counting objects: 76% (114/149)\u001b[K\rremote: Counting objects: 77% (115/149)\u001b[K\rremote: Counting objects: 78% (117/149)\u001b[K\rremote: Counting objects: 79% (118/149)\u001b[K\rremote: Counting objects: 80% (120/149)\u001b[K\rremote: Counting objects: 81% (121/149)\u001b[K\rremote: Counting objects: 82% (123/149)\u001b[K\rremote: Counting objects: 83% (124/149)\u001b[K\rremote: Counting objects: 84% (126/149)\u001b[K\rremote: Counting objects: 85% (127/149)\u001b[K\rremote: Counting objects: 86% (129/149)\u001b[K\rremote: Counting objects: 87% (130/149)\u001b[K\rremote: Counting objects: 88% (132/149)\u001b[K\rremote: Counting objects: 89% (133/149)\u001b[K\rremote: Counting objects: 90% (135/149)\u001b[K\rremote: Counting objects: 91% (136/149)\u001b[K\rremote: Counting objects: 92% (138/149)\u001b[K\rremote: Counting objects: 93% (139/149)\u001b[K\rremote: Counting objects: 94% (141/149)\u001b[K\rremote: Counting objects: 95% (142/149)\u001b[K\rremote: Counting objects: 96% (144/149)\u001b[K\rremote: Counting objects: 97% (145/149)\u001b[K\rremote: Counting objects: 98% (147/149)\u001b[K\rremote: Counting objects: 99% (148/149)\u001b[K\rremote: Counting objects: 100% (149/149)\u001b[K\rremote: Counting objects: 100% (149/149), done.\u001b[K\n", "remote: Compressing objects: 0% (1/104)\u001b[K\rremote: Compressing objects: 1% (2/104)\u001b[K\rremote: Compressing objects: 2% (3/104)\u001b[K\rremote: Compressing objects: 3% (4/104)\u001b[K\rremote: Compressing objects: 4% (5/104)\u001b[K\rremote: Compressing objects: 5% (6/104)\u001b[K\rremote: Compressing objects: 6% (7/104)\u001b[K\rremote: Compressing objects: 7% (8/104)\u001b[K\rremote: Compressing objects: 8% (9/104)\u001b[K\rremote: Compressing objects: 9% (10/104)\u001b[K\rremote: Compressing objects: 10% (11/104)\u001b[K\rremote: Compressing objects: 11% (12/104)\u001b[K\rremote: Compressing objects: 12% (13/104)\u001b[K\rremote: Compressing objects: 13% (14/104)\u001b[K\rremote: Compressing objects: 14% (15/104)\u001b[K\rremote: Compressing objects: 15% (16/104)\u001b[K\rremote: Compressing objects: 16% (17/104)\u001b[K\rremote: Compressing objects: 17% (18/104)\u001b[K\rremote: Compressing objects: 18% (19/104)\u001b[K\rremote: Compressing objects: 19% (20/104)\u001b[K\rremote: Compressing objects: 20% (21/104)\u001b[K\rremote: Compressing objects: 21% (22/104)\u001b[K\rremote: Compressing objects: 22% (23/104)\u001b[K\rremote: Compressing objects: 23% (24/104)\u001b[K\rremote: Compressing objects: 24% (25/104)\u001b[K\rremote: Compressing objects: 25% (26/104)\u001b[K\rremote: Compressing objects: 26% (28/104)\u001b[K\rremote: Compressing objects: 27% (29/104)\u001b[K\rremote: Compressing objects: 28% (30/104)\u001b[K\rremote: Compressing objects: 29% (31/104)\u001b[K\rremote: Compressing objects: 30% (32/104)\u001b[K\rremote: Compressing objects: 31% (33/104)\u001b[K\rremote: Compressing objects: 32% (34/104)\u001b[K\rremote: Compressing objects: 33% (35/104)\u001b[K\rremote: Compressing objects: 34% (36/104)\u001b[K\rremote: Compressing objects: 35% (37/104)\u001b[K\rremote: Compressing objects: 36% (38/104)\u001b[K\rremote: Compressing objects: 37% (39/104)\u001b[K\rremote: Compressing objects: 38% (40/104)\u001b[K\rremote: Compressing objects: 39% (41/104)\u001b[K\rremote: Compressing objects: 40% (42/104)\u001b[K\rremote: Compressing objects: 41% (43/104)\u001b[K\rremote: Compressing objects: 42% (44/104)\u001b[K\rremote: Compressing objects: 43% (45/104)\u001b[K\rremote: Compressing objects: 44% (46/104)\u001b[K\rremote: Compressing objects: 45% (47/104)\u001b[K\rremote: Compressing objects: 46% (48/104)\u001b[K\rremote: Compressing objects: 47% (49/104)\u001b[K\rremote: Compressing objects: 48% (50/104)\u001b[K\rremote: Compressing objects: 49% (51/104)\u001b[K\rremote: Compressing objects: 50% (52/104)\u001b[K\rremote: Compressing objects: 51% (54/104)\u001b[K\rremote: Compressing objects: 52% (55/104)\u001b[K\rremote: Compressing objects: 53% (56/104)\u001b[K\rremote: Compressing objects: 54% (57/104)\u001b[K\rremote: Compressing objects: 55% (58/104)\u001b[K\rremote: Compressing objects: 56% (59/104)\u001b[K\rremote: Compressing objects: 57% (60/104)\u001b[K\rremote: Compressing objects: 58% (61/104)\u001b[K\rremote: Compressing objects: 59% (62/104)\u001b[K\rremote: Compressing objects: 60% (63/104)\u001b[K\rremote: Compressing objects: 61% (64/104)\u001b[K\rremote: Compressing objects: 62% (65/104)\u001b[K\rremote: Compressing objects: 63% (66/104)\u001b[K\rremote: Compressing objects: 64% (67/104)\u001b[K\rremote: Compressing objects: 65% (68/104)\u001b[K\rremote: Compressing objects: 66% (69/104)\u001b[K\rremote: Compressing objects: 67% (70/104)\u001b[K\rremote: Compressing objects: 68% (71/104)\u001b[K\rremote: Compressing objects: 69% (72/104)\u001b[K\rremote: Compressing objects: 70% (73/104)\u001b[K\rremote: Compressing objects: 71% (74/104)\u001b[K\rremote: Compressing objects: 72% (75/104)\u001b[K\rremote: Compressing objects: 73% (76/104)\u001b[K\rremote: Compressing objects: 74% (77/104)\u001b[K\rremote: Compressing objects: 75% (78/104)\u001b[K\rremote: Compressing objects: 76% (80/104)\u001b[K\rremote: Compressing objects: 77% (81/104)\u001b[K\rremote: Compressing objects: 78% (82/104)\u001b[K\rremote: Compressing objects: 79% (83/104)\u001b[K\rremote: Compressing objects: 80% (84/104)\u001b[K\rremote: Compressing objects: 81% (85/104)\u001b[K\rremote: Compressing objects: 82% (86/104)\u001b[K\rremote: Compressing objects: 83% (87/104)\u001b[K\rremote: Compressing objects: 84% (88/104)\u001b[K\rremote: Compressing objects: 85% (89/104)\u001b[K\rremote: Compressing objects: 86% (90/104)\u001b[K\rremote: Compressing objects: 87% (91/104)\u001b[K\rremote: Compressing objects: 88% (92/104)\u001b[K\rremote: Compressing objects: 89% (93/104)\u001b[K\rremote: Compressing objects: 90% (94/104)\u001b[K\rremote: Compressing objects: 91% (95/104)\u001b[K\rremote: Compressing objects: 92% (96/104)\u001b[K\rremote: Compressing objects: 93% (97/104)\u001b[K\rremote: Compressing objects: 94% (98/104)\u001b[K\rremote: Compressing objects: 95% (99/104)\u001b[K\rremote: Compressing objects: 96% (100/104)\u001b[K\rremote: Compressing objects: 97% (101/104)\u001b[K\rremote: Compressing objects: 98% (102/104)\u001b[K\rremote: Compressing objects: 99% (103/104)\u001b[K\rremote: Compressing objects: 100% (104/104)\u001b[K\rremote: Compressing objects: 100% (104/104), done.\u001b[K\n", "Receiving objects: 0% (1/2333) \rReceiving objects: 1% (24/2333) \rReceiving objects: 2% (47/2333) \rReceiving objects: 3% (70/2333) \rReceiving objects: 4% (94/2333) \rReceiving objects: 5% (117/2333) \rReceiving objects: 6% (140/2333) \rReceiving objects: 7% (164/2333) \rReceiving objects: 8% (187/2333) \rReceiving objects: 9% (210/2333) \rReceiving objects: 10% (234/2333) \rReceiving objects: 11% (257/2333) \rReceiving objects: 12% (280/2333) \rReceiving objects: 13% (304/2333) \rReceiving objects: 14% (327/2333) \rReceiving objects: 15% (350/2333) \rReceiving objects: 16% (374/2333) \rReceiving objects: 17% (397/2333) \rReceiving objects: 18% (420/2333) \rReceiving objects: 19% (444/2333) \rReceiving objects: 20% (467/2333) \rReceiving objects: 21% (490/2333) \rReceiving objects: 22% (514/2333) \rReceiving objects: 23% (537/2333) \rReceiving objects: 24% (560/2333) \rReceiving objects: 25% (584/2333) \rReceiving objects: 26% (607/2333) \rReceiving objects: 27% (630/2333) \rReceiving objects: 28% (654/2333) \rReceiving objects: 29% (677/2333) \rReceiving objects: 30% (700/2333) \rReceiving objects: 31% (724/2333) \rReceiving objects: 32% (747/2333) \rReceiving objects: 33% (770/2333) \rReceiving objects: 34% (794/2333) \rReceiving objects: 35% (817/2333) \rReceiving objects: 36% (840/2333) \rReceiving objects: 37% (864/2333) \rReceiving objects: 38% (887/2333) \rReceiving objects: 39% (910/2333) \rReceiving objects: 40% (934/2333) \rReceiving objects: 41% (957/2333) \rReceiving objects: 42% (980/2333) \rReceiving objects: 43% (1004/2333) \rReceiving objects: 44% (1027/2333) \rReceiving objects: 45% (1050/2333) \rReceiving objects: 46% (1074/2333) \rReceiving objects: 47% (1097/2333) \rReceiving objects: 48% (1120/2333) \rReceiving objects: 49% (1144/2333) \rReceiving objects: 50% (1167/2333) \rReceiving objects: 51% (1190/2333) \rReceiving objects: 52% (1214/2333) \rReceiving objects: 53% (1237/2333) \rReceiving objects: 54% (1260/2333) \rReceiving objects: 55% (1284/2333) \rReceiving objects: 56% (1307/2333) \rReceiving objects: 57% (1330/2333) \rReceiving objects: 58% (1354/2333) \rReceiving objects: 59% (1377/2333) \rReceiving objects: 60% (1400/2333) \rReceiving objects: 61% (1424/2333) \rReceiving objects: 62% (1447/2333) \rReceiving objects: 63% (1470/2333) \rReceiving objects: 64% (1494/2333) \rReceiving objects: 65% (1517/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 66% (1540/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 67% (1564/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 68% (1587/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 69% (1610/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 70% (1634/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 71% (1657/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 72% (1680/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 73% (1704/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 74% (1727/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 75% (1750/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 76% (1774/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 77% (1797/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 78% (1820/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 79% (1844/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 80% (1867/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 81% (1890/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 82% (1914/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 83% (1937/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 84% (1960/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 85% (1984/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 86% (2007/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 87% (2030/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 88% (2054/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 89% (2077/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 90% (2100/2333), 2.36 MiB | 4.58 MiB/s \rremote: Total 2333 (delta 98), reused 72 (delta 45), pack-reused 2184\u001b[K\n", "Receiving objects: 91% (2124/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 92% (2147/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 93% (2170/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 94% (2194/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 95% (2217/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 96% (2240/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 97% (2264/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 98% (2287/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 99% (2310/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 100% (2333/2333), 2.36 MiB | 4.58 MiB/s \rReceiving objects: 100% (2333/2333), 2.64 MiB | 5.03 MiB/s, done.\n", "Resolving deltas: 100% (1619/1619), done.\n", "Processing /content/joeynmt\n", "Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.16.0)\n", "Requirement already satisfied: pillow in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (6.2.2)\n", "Requirement already satisfied: numpy<2.0,>=1.14.5 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.17.5)\n", "Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (45.1.0)\n", "Requirement already satisfied: torch>=1.1 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.4.0)\n", "Requirement already satisfied: tensorflow>=1.14 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.15.0)\n", "Requirement already satisfied: torchtext in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.3.1)\n", "Collecting sacrebleu>=1.3.6\n", " Downloading https://files.pythonhosted.org/packages/45/31/1a135b964c169984b27fb2f7a50280fa7f8e6d9d404d8a9e596180487fd1/sacrebleu-1.4.3-py3-none-any.whl\n", "Collecting subword-nmt\n", " Downloading https://files.pythonhosted.org/packages/74/60/6600a7bc09e7ab38bc53a48a20d8cae49b837f93f5842a41fe513a694912/subword_nmt-0.3.7-py2.py3-none-any.whl\n", "Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (3.1.3)\n", "Requirement already satisfied: seaborn in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.10.0)\n", "Collecting pyyaml>=5.1\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/3d/d9/ea9816aea31beeadccd03f1f8b625ecf8f645bd66744484d162d84803ce5/PyYAML-5.3.tar.gz (268kB)\n", "\u001b[K |████████████████████████████████| 276kB 24.8MB/s \n", "\u001b[?25hCollecting pylint\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/e9/59/43fc36c5ee316bb9aeb7cf5329cdbdca89e5749c34d5602753827c0aa2dc/pylint-2.4.4-py3-none-any.whl (302kB)\n", "\u001b[K |████████████████████████████████| 307kB 67.8MB/s \n", "\u001b[?25hRequirement already satisfied: six==1.12 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.12.0)\n", "Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.34.2)\n", "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (3.1.0)\n", "Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.9.0)\n", "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.27.1)\n", "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.1.0)\n", "Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (3.10.0)\n", "Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.11.2)\n", "Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.8.1)\n", "Requirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.1.8)\n", "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.1.0)\n", "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.15.0)\n", "Requirement already satisfied: tensorflow-estimator==1.15.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.15.1)\n", "Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.0.8)\n", "Requirement already satisfied: gast==0.2.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.2.2)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from torchtext->joeynmt==0.0.1) (2.21.0)\n", "Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from torchtext->joeynmt==0.0.1) (4.28.1)\n", "Collecting portalocker\n", " Downloading https://files.pythonhosted.org/packages/91/db/7bc703c0760df726839e0699b7f78a4d8217fdc9c7fcb1b51b39c5a22a4e/portalocker-1.5.2-py2.py3-none-any.whl\n", "Requirement already satisfied: typing in /usr/local/lib/python3.6/dist-packages (from sacrebleu>=1.3.6->joeynmt==0.0.1) (3.6.6)\n", "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (2.4.6)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (1.1.0)\n", "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (2.6.1)\n", "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (0.10.0)\n", "Requirement already satisfied: scipy>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from seaborn->joeynmt==0.0.1) (1.4.1)\n", "Requirement already satisfied: pandas>=0.22.0 in /usr/local/lib/python3.6/dist-packages (from seaborn->joeynmt==0.0.1) (0.25.3)\n", "Collecting astroid<2.4,>=2.3.0\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/ad/ae/86734823047962e7b8c8529186a1ac4a7ca19aaf1aa0c7713c022ef593fd/astroid-2.3.3-py3-none-any.whl (205kB)\n", "\u001b[K |████████████████████████████████| 215kB 36.6MB/s \n", "\u001b[?25hCollecting isort<5,>=4.2.5\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/e5/b0/c121fd1fa3419ea9bfd55c7f9c4fedfec5143208d8c7ad3ce3db6c623c21/isort-4.3.21-py2.py3-none-any.whl (42kB)\n", "\u001b[K |████████████████████████████████| 51kB 7.6MB/s \n", "\u001b[?25hCollecting mccabe<0.7,>=0.6\n", " Downloading https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl\n", "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow>=1.14->joeynmt==0.0.1) (3.2)\n", "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow>=1.14->joeynmt==0.0.1) (1.0.0)\n", "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.8->tensorflow>=1.14->joeynmt==0.0.1) (2.8.0)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (2019.11.28)\n", "Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (1.24.3)\n", "Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (2.8)\n", "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (3.0.4)\n", "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.22.0->seaborn->joeynmt==0.0.1) (2018.9)\n", "Collecting typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\"\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/90/ed/5459080d95eb87a02fe860d447197be63b6e2b5e9ff73c2b0a85622994f4/typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (737kB)\n", "\u001b[K |████████████████████████████████| 747kB 69.7MB/s \n", "\u001b[?25hCollecting lazy-object-proxy==1.4.*\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/0b/dd/b1e3407e9e6913cf178e506cd0dee818e58694d9a5cd1984e3f6a8b9a10f/lazy_object_proxy-1.4.3-cp36-cp36m-manylinux1_x86_64.whl (55kB)\n", "\u001b[K |████████████████████████████████| 61kB 9.8MB/s \n", "\u001b[?25hBuilding wheels for collected packages: joeynmt, pyyaml\n", " Building wheel for joeynmt (setup.py) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for joeynmt: filename=joeynmt-0.0.1-cp36-none-any.whl size=73467 sha256=5e896def4c67279e034c19c21caeb2ec5567599582c93bb52abe938e59ec6f3d\n", " Stored in directory: /tmp/pip-ephem-wheel-cache-sgho47kl/wheels/db/01/db/751cc9f3e7f6faec127c43644ba250a3ea7ad200594aeda70a\n", " Building wheel for pyyaml (setup.py) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for pyyaml: filename=PyYAML-5.3-cp36-cp36m-linux_x86_64.whl size=44229 sha256=ed83f142725ff5dba14f0f4dc7f30ea5cdba2a766ba1ebedc49fc88365c2bdec\n", " Stored in directory: /root/.cache/pip/wheels/e4/76/4d/a95b8dd7b452b69e8ed4f68b69e1b55e12c9c9624dd962b191\n", "Successfully built joeynmt pyyaml\n", "Installing collected packages: portalocker, sacrebleu, subword-nmt, pyyaml, typed-ast, lazy-object-proxy, astroid, isort, mccabe, pylint, joeynmt\n", " Found existing installation: PyYAML 3.13\n", " Uninstalling PyYAML-3.13:\n", " Successfully uninstalled PyYAML-3.13\n", "Successfully installed astroid-2.3.3 isort-4.3.21 joeynmt-0.0.1 lazy-object-proxy-1.4.3 mccabe-0.6.1 portalocker-1.5.2 pylint-2.4.4 pyyaml-5.3 sacrebleu-1.4.3 subword-nmt-0.3.7 typed-ast-1.4.1\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "ZX77ylHfjtY0", "colab_type": "text" }, "source": [ "## Mount Google Drive\n", "\n" ] }, { "cell_type": "code", "metadata": { "id": "Gg_9x3FloWuU", "colab_type": "code", "outputId": "98fd36dc-645d-4e64-ad41-b7a1acd29365", "colab": { "base_uri": "https://localhost:8080/", "height": 124 } }, "source": [ "# If running on Google Colab - mount google drive\n", "\n", "from google.colab import drive\n", "drive.mount('/content/drive')" ], "execution_count": 2, "outputs": [ { "output_type": "stream", "text": [ "Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly\n", "\n", "Enter your authorization code:\n", "··········\n", "Mounted at /content/drive\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "yhkiqqjt0fV9", "colab_type": "code", "colab": {} }, "source": [ "" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "441Z4I3rn7DB", "colab_type": "code", "colab": {} }, "source": [ "# TODO : access data on kaggle kernels" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "ufEVGDe_okx3", "colab_type": "code", "colab": {} }, "source": [ "# TODO : Access data on paperspace" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "5Roa6jIMov3V", "colab_type": "code", "colab": {} }, "source": [ "# TODo : Access data on GCP" ], "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "mPElaQv_oy5q", "colab_type": "text" }, "source": [ "## Set your source and target languages\n" ] }, { "cell_type": "code", "metadata": { "id": "3Dj54KjZ2wal", "colab_type": "code", "colab": {} }, "source": [ "\n", "import os\n", "import numpy as np\n", "import pandas as pd\n", "\n", "source_language = \"en\"\n", "target_language = \"nso\" \n", "lc = True # If True, lowercase the data.\n", "seed = 42 # Random seed for shuffling.\n", "tag = \"baseline\" # Give a unique name to your folder - this is to ensure you don't rewrite any models you've already submitted\n", "# aggressive : more attention and more dropout\n", "vocab_size=4000\n", "corpus = \"JW300\"\n", "\n", "os.environ[\"src\"] = source_language # Sets them in bash as well, since we often use bash scripts\n", "os.environ[\"trg\"] = target_language\n", "os.environ[\"tag\"] = tag\n", "os.environ[\"vocab_size\"] = str(vocab_size)\n", "os.environ[\"corpus\"] = corpus" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "5YcHw7PW3Tvb", "colab_type": "code", "outputId": "2cdfaf6d-cb35-40c5-a906-3c81b2a03d92", "colab": { "base_uri": "https://localhost:8080/", "height": 34 } }, "source": [ "# This will save it to a folder in our gdrive instead!\n", "# !mkdir -p \"/content/drive/My Drive/masakhane/$src-$trg-$tag\"\n", "gdrive_path = f\"/content/drive/My Drive/masakhane/{source_language}-{target_language}-{tag}/\"\n", "os.environ[\"gdrive_path\"] = gdrive_path\n", "! echo $gdrive_path" ], "execution_count": 4, "outputs": [ { "output_type": "stream", "text": [ "/content/drive/My Drive/masakhane/en-nso-baseline/\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "Y99OKT00fnrO", "colab_type": "code", "outputId": "48b57d43-7c91-433f-b81d-b7c628a93a86", "colab": { "base_uri": "https://localhost:8080/", "height": 156 } }, "source": [ "# create path to joeynmt executables scripts, configs etc\n", "\n", "joey_path = f\"/content/joeynmt\"\n", "os.environ[\"joey_path\"] = joey_path\n", "! ls $joey_path/configs" ], "execution_count": 5, "outputs": [ { "output_type": "stream", "text": [ "iwslt14_deen_bpe.yaml\t\t transformer_reverse.yaml\n", "iwslt_deen_bahdanau.yaml\t transformer_small.yaml\n", "iwslt_envi_luong.yaml\t\t transformer_wmt17_ende.yaml\n", "iwslt_envi_xnmt.yaml\t\t transformer_wmt17_lven.yaml\n", "reverse.yaml\t\t\t wmt_ende_best.yaml\n", "small.yaml\t\t\t wmt_ende_default.yaml\n", "transformer_copy.yaml\t\t wmt_lven_best.yaml\n", "transformer_iwslt14_deen_bpe.yaml wmt_lven_default.yaml\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "1bM3_Zn34LGu", "colab_type": "text" }, "source": [ "## Download the global test set.\n", " **(This changes from time to time, do this just to make sure you have the most recent version)**\n" ] }, { "cell_type": "code", "metadata": { "id": "36X7RKhb4a7P", "colab_type": "code", "outputId": "ddd9a636-1563-40b1-dbdc-38b740bf0ad7", "colab": { "base_uri": "https://localhost:8080/", "height": 610 } }, "source": [ "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-any.en\n", " \n", "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-$trg.en\n", "! mv test.en-$trg.en test.en\n", "\n", "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-$trg.$trg \n", "! mv test.en-$trg.$trg test.$trg" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "--2019-11-03 20:36:39-- https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-any.en\n", "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n", "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 277791 (271K) [text/plain]\n", "Saving to: ‘test.en-any.en.1’\n", "\n", "\rtest.en-any.en.1 0%[ ] 0 --.-KB/s \rtest.en-any.en.1 100%[===================>] 271.28K --.-KB/s in 0.05s \n", "\n", "2019-11-03 20:36:40 (5.35 MB/s) - ‘test.en-any.en.1’ saved [277791/277791]\n", "\n", "--2019-11-03 20:36:42-- https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-nso.en\n", "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n", "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 205401 (201K) [text/plain]\n", "Saving to: ‘test.en-nso.en’\n", "\n", "test.en-nso.en 100%[===================>] 200.59K --.-KB/s in 0.04s \n", "\n", "2019-11-03 20:36:42 (5.22 MB/s) - ‘test.en-nso.en’ saved [205401/205401]\n", "\n", "--2019-11-03 20:36:47-- https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-nso.nso\n", "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n", "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 244175 (238K) [text/plain]\n", "Saving to: ‘test.en-nso.nso’\n", "\n", "test.en-nso.nso 100%[===================>] 238.45K --.-KB/s in 0.05s \n", "\n", "2019-11-03 20:36:48 (4.69 MB/s) - ‘test.en-nso.nso’ saved [244175/244175]\n", "\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "DQjxBMQu4AbK", "colab_type": "code", "outputId": "10236c38-b28e-4e67-c3ff-ed11f2a502a0", "colab": { "base_uri": "https://localhost:8080/", "height": 237 } }, "source": [ "# Read the test data to filter from train and dev splits.\n", "# Store english portion in set for quick filtering checks.\n", "en_test_sents = set()\n", "filter_test_sents = \"test.en-any.en\"\n", "j = 0\n", "blanks=[]\n", "with open(filter_test_sents) as f:\n", " for line in f:\n", " en_test_sents.add(line.strip())\n", " if len(line)<=1:\n", " blanks.append(j)\n", " j += 1\n", "print('Loaded {} global test sentences to filter from the training/dev data.'.format(j))" ], "execution_count": 0, "outputs": [ { "output_type": "error", "ename": "FileNotFoundError", "evalue": "ignored", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mblanks\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[0;32m----> 5\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilter_test_sents\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0men_test_sents\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstrip\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[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'test.en-any.en'" ] } ] }, { "cell_type": "code", "metadata": { "id": "kKr8Kma8oB1u", "colab_type": "code", "colab": {} }, "source": [ "# filter test set\n", "\n", "source_file = f\"test.{source_language}\"\n", "target_file = f\"test.{target_language}\"\n", "\n", "source = []\n", "target = []\n", "\n", "with open(source_file) as f:\n", " source = f.readlines()\n", " \n", "with open(target_file) as f:\n", " target = f.readlines()\n", "\n", "df = pd.DataFrame(zip(source, target), columns=['source_sentence', 'target_sentence'])\n", "\n", "# remove trailing newline chars\n", "df['source_sentence'] = df['source_sentence'].str.rstrip('\" \\n')\n", "df['target_sentence'] = df['target_sentence'].str.rstrip('\" \\n')\n", "\n", "# remove leading newline chars\n", "df['source_sentence'] = df['source_sentence'].str.lstrip('\"')\n", "df['target_sentence'] = df['target_sentence'].str.lstrip('\"')\n", "\n", "# remove rows with really short sentences\n", "df = df[~(df['source_sentence'].str.len() <8)] # remove rows wher esource text len <8 characters\n", "df = df[~(df['target_sentence'].str.len() <8)] # remove rows wher esource text len <8 characters\n", "\n", "# save the filtered test set\n", "df['source_sentence'].to_csv(f'{source_file}', index=False, header=False, doublequote=False)\n", "df['target_sentence'].to_csv(f'{target_file}', index=False, header=False, doublequote=False)" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "_BQ_g1o3gUHD", "colab_type": "code", "colab": {} }, "source": [ "# copy test sets to gdrive\n", "! cp test.$src \"$gdrive_path\"\n", "! cp test.$trg \"$gdrive_path\"\n", "! cp test.$src-any.$src \"$gdrive_path\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "LY9LrzQp5BOC", "colab_type": "text" }, "source": [ "## Import prepared dataset" ] }, { "cell_type": "code", "metadata": { "id": "1faMfeV45M9A", "colab_type": "code", "colab": {} }, "source": [ "import pandas as pd\n", "from IPython.core.interactiveshell import InteractiveShell\n", "InteractiveShell.ast_node_interactivity = \"all\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "OgtN5iU95BKe", "colab_type": "code", "colab": {} }, "source": [ "# This csv has extra columns added but no preprocessing done. all preprocessing should be captured in the NMT modelling notebook\n", "\n", "input_file = f\"{gdrive_path}/{source_language}-{target_language}-{corpus}-new.csv\"\n", "df = pd.read_csv(input_file)" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "7mVDMOgsA2L1", "colab_type": "code", "outputId": "0715d9cb-e0fb-4ef8-dbb9-4ea068053951", "colab": { "base_uri": "https://localhost:8080/", "height": 206 } }, "source": [ "df.head()" ], "execution_count": 8, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\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", "
source_sentencetarget_sentence
0They Rejoiced in Eastern EuropeBa Ile Ba Thaba Ka Bohlabela Bja Yuropa
1THIS past summer tens of thousands of people f...SELEMONG se se se fetilego batho ba masome a d...
2The streets of beautiful Budapest , Prague , Z...Ditarata tša Budapest e botse , Prague , Zagre...
3These identified them as lovers of godly freed...Tše di be di ba hlaola e le barati ba tokologo...
4For the first time ever , conventions were fre...Ka lekga la mathomo - thomo , dikopano di ile ...
\n", "
" ], "text/plain": [ " source_sentence target_sentence\n", "0 They Rejoiced in Eastern Europe Ba Ile Ba Thaba Ka Bohlabela Bja Yuropa\n", "1 THIS past summer tens of thousands of people f... SELEMONG se se se fetilego batho ba masome a d...\n", "2 The streets of beautiful Budapest , Prague , Z... Ditarata tša Budapest e botse , Prague , Zagre...\n", "3 These identified them as lovers of godly freed... Tše di be di ba hlaola e le barati ba tokologo...\n", "4 For the first time ever , conventions were fre... Ka lekga la mathomo - thomo , dikopano di ile ..." ] }, "metadata": { "tags": [] }, "execution_count": 8 } ] }, { "cell_type": "code", "metadata": { "id": "94Oq1C-YAkKz", "colab_type": "code", "outputId": "62356727-32a0-4016-a0b6-e93eb1bfab6e", "colab": { "base_uri": "https://localhost:8080/", "height": 52 } }, "source": [ "# How many samples\n", "size = len(df)\n", "print(f\"\\n {size} samples in original text\")\n", " " ], "execution_count": 9, "outputs": [ { "output_type": "stream", "text": [ "\n", " 622966 samples in original text\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "XC0KJNbsZz-z", "colab_type": "text" }, "source": [ "## Preprocess input data" ] }, { "cell_type": "code", "metadata": { "id": "RNWGwHE-6tHQ", "colab_type": "code", "outputId": "e86ca1fe-0bd5-4d47-c293-8a4cc143a19c", "colab": { "base_uri": "https://localhost:8080/", "height": 173 } }, "source": [ "## Preprocessing - Step 1 : Drop NaNs\n", "\n", "df_pp = df.dropna()\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping all NaNs\")\n", "size = new_size" ], "execution_count": 10, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 613348 entries, 0 to 622965\n", "Data columns (total 2 columns):\n", "source_sentence 613348 non-null object\n", "target_sentence 613348 non-null object\n", "dtypes: object(2)\n", "memory usage: 285.1 MB\n", "\n", " 9618(1.54 %) samples removed by dropping all NaNs\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "R-CAf05t67va", "colab_type": "code", "outputId": "590bca3b-0060-4e6b-8b30-2b8dd3c1827a", "colab": { "base_uri": "https://localhost:8080/", "height": 173 } }, "source": [ "## Preprocessing - Step 2a : Drop all duplicates in Source (en) text\n", "\n", "df_pp = df_pp.drop_duplicates(subset='source_sentence')\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping Source sentence duplicates\")\n", "size = new_size" ], "execution_count": 11, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 570881 entries, 0 to 622965\n", "Data columns (total 2 columns):\n", "source_sentence 570881 non-null object\n", "target_sentence 570881 non-null object\n", "dtypes: object(2)\n", "memory usage: 302.1 MB\n", "\n", " 42467(6.92 %) samples removed by dropping Source sentence duplicates\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "IoPGdLI_n6_L", "colab_type": "code", "outputId": "e6872b32-cfd0-465f-b18c-4092bd4b01f9", "colab": { "base_uri": "https://localhost:8080/", "height": 173 } }, "source": [ "## Preprocessing - Step 2b : Drop all duplicates in Target (zu) text\n", "\n", "df_pp = df_pp.drop_duplicates(subset='target_sentence')\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping Target sentence duplicates\")\n", "size = new_size" ], "execution_count": 12, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567792 entries, 0 to 622965\n", "Data columns (total 2 columns):\n", "source_sentence 567792 non-null object\n", "target_sentence 567792 non-null object\n", "dtypes: object(2)\n", "memory usage: 359.6 MB\n", "\n", " 3089(0.54 %) samples removed by dropping Target sentence duplicates\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "q0vDJborInA_", "colab_type": "code", "colab": {} }, "source": [ "## Preprocessing - Step 3 : Remove all numeric entries\n", "\n", "pattern = r\"([0-9]*\\.?[0-9]*)\" # catch integers and decimals\n", "import re\n", "r = re.compile(pattern)" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "n0OvHiNFL-8z", "colab_type": "code", "outputId": "c1b29cb2-c081-43f5-e69b-226a8a3b2854", "colab": { "base_uri": "https://localhost:8080/", "height": 208 } }, "source": [ "%%time\n", "## Preprocessing - Step 3a : Remove all numeric entries - Source text\n", "\n", "df_pp['source_sentence'] = df_pp['source_sentence'].str.replace(pattern,\"\")\n", "df_pp['source_sentence'] = df_pp['source_sentence'].replace(\"\",np.nan)\n", "\n", "df_pp = df_pp.dropna()\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping nummeric entries from source text\")\n", "size = new_size" ], "execution_count": 14, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567720 entries, 0 to 622965\n", "Data columns (total 2 columns):\n", "source_sentence 567720 non-null object\n", "target_sentence 567720 non-null object\n", "dtypes: object(2)\n", "memory usage: 331.8 MB\n", "\n", " 72(0.01 %) samples removed by dropping nummeric entries from source text\n", "CPU times: user 9.93 s, sys: 62 ms, total: 9.99 s\n", "Wall time: 10 s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "DlVWfIVJQ_Tn", "colab_type": "code", "outputId": "db6c9bd0-23f1-4d85-aae4-58d3d8572e63", "colab": { "base_uri": "https://localhost:8080/", "height": 208 } }, "source": [ "%%time\n", "## Preprocessing - Step 3b : Remove all numeric entries - Target text\n", "\n", "df_pp['target_sentence'] = df_pp['target_sentence'].str.replace(r,\"\")\n", "df_pp['target_sentence'] = df_pp['target_sentence'].replace(\"\",np.nan)\n", "\n", "df_pp = df_pp.dropna()\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping nummeric entries from target text\")\n", "size = new_size" ], "execution_count": 15, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567699 entries, 0 to 622965\n", "Data columns (total 2 columns):\n", "source_sentence 567699 non-null object\n", "target_sentence 567699 non-null object\n", "dtypes: object(2)\n", "memory usage: 271.9 MB\n", "\n", " 21(0.00 %) samples removed by dropping nummeric entries from target text\n", "CPU times: user 11.9 s, sys: 99.8 ms, total: 12 s\n", "Wall time: 12 s\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "4dZI2WM78oCO", "colab_type": "text" }, "source": [ "#### Preprocessing - Step 4 :Get length of sentences and then drop really short sentences\n" ] }, { "cell_type": "code", "metadata": { "colab_type": "code", "outputId": "28086ea5-6fe9-44de-bc81-78e3aeeb0ef4", "id": "zb6yGGDJAZ5H", "colab": { "base_uri": "https://localhost:8080/", "height": 243 } }, "source": [ "%%time\n", "# add length columns\n", "\n", "\n", "df_pp['source_ch_len'] = df_pp['source_sentence'].str.len()\n", "df_pp['source_w_len'] = [len(text.split()) for text in df_pp['source_sentence']] \n", "df_pp['target_ch_len'] = df_pp['target_sentence'].str.len()\n", "df_pp['target_w_len'] = [len(text.split()) for text in df_pp['target_sentence']] \n", "df_pp.info(memory_usage='deep')" ], "execution_count": 16, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567699 entries, 0 to 622965\n", "Data columns (total 6 columns):\n", "source_sentence 567699 non-null object\n", "target_sentence 567699 non-null object\n", "source_ch_len 567699 non-null int64\n", "source_w_len 567699 non-null int64\n", "target_ch_len 567699 non-null int64\n", "target_w_len 567699 non-null int64\n", "dtypes: int64(4), object(2)\n", "memory usage: 289.2 MB\n", "CPU times: user 3.07 s, sys: 22.3 ms, total: 3.09 s\n", "Wall time: 3.09 s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "M6SecEMNBkC7", "colab_type": "code", "colab": {} }, "source": [ "# # character len distrn - source text - \n", "# df_pp['source_ch_len'].value_counts().sort_index()" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "A9TFizHyVWKO", "colab_type": "code", "colab": {} }, "source": [ "# # character len distrn - target text\n", "# df_pp['target_ch_len'].value_counts().sort_index()" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "9ArLyuzIwtLq", "colab_type": "code", "colab": {} }, "source": [ "## how many rows with source text <=2chars and what do they look like ?" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "t-e7zGtV-eyq", "colab_type": "code", "colab": {} }, "source": [ "# # how many single character sentences from source ?\n", "# f\"{df_pp['source_ch_len'].value_counts()[1]} single character source sentences\"\n", "\n", "# df_pp[df_pp['source_ch_len']<=1]" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "qDe_eeocuBDw", "colab_type": "code", "colab": {} }, "source": [ "# # how many 2-character sentences from source ?\n", "# f\"{df_pp['source_ch_len'].value_counts()[2]} 2-character source sentences\"\n", "\n", "# df_pp[df_pp['source_ch_len']==2]" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "agiL0pRVyOEz", "colab_type": "code", "colab": {} }, "source": [ "" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "sPTL3nKqyWjv", "colab_type": "code", "outputId": "73e4484e-2117-4e60-a017-769a5b26d41d", "colab": { "base_uri": "https://localhost:8080/", "height": 243 } }, "source": [ "## Preprocessing - Step 4a : drop everything where the ch_len <=2 in source text\n", "\n", "df_pp = df_pp[~(df_pp['source_ch_len'] <=2) ]\n", "\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with source sentences <= 2 characters\")\n", "size = new_size" ], "execution_count": 17, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567486 entries, 0 to 622965\n", "Data columns (total 6 columns):\n", "source_sentence 567486 non-null object\n", "target_sentence 567486 non-null object\n", "source_ch_len 567486 non-null int64\n", "source_w_len 567486 non-null int64\n", "target_ch_len 567486 non-null int64\n", "target_w_len 567486 non-null int64\n", "dtypes: int64(4), object(2)\n", "memory usage: 289.2 MB\n", "\n", " 213(0.04 %) samples removed by dropping rows with source sentences <= 2 characters\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "_gnkwkS11rHW", "colab_type": "code", "outputId": "d274e25a-68df-4b85-e405-8a8e37f8349e", "colab": { "base_uri": "https://localhost:8080/", "height": 243 } }, "source": [ "## Preprocessing - Step 4b : drop everything where the ch_len <=2 in target text\n", "\n", "df_pp = df_pp[~(df_pp['target_ch_len'] <=2) ]\n", "\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with target sentences <= 2 characters\")\n", "size = new_size" ], "execution_count": 18, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 567470 entries, 0 to 622965\n", "Data columns (total 6 columns):\n", "source_sentence 567470 non-null object\n", "target_sentence 567470 non-null object\n", "source_ch_len 567470 non-null int64\n", "source_w_len 567470 non-null int64\n", "target_ch_len 567470 non-null int64\n", "target_w_len 567470 non-null int64\n", "dtypes: int64(4), object(2)\n", "memory usage: 289.2 MB\n", "\n", " 16(0.00 %) samples removed by dropping rows with target sentences <= 2 characters\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "tYgL_BspMu8t", "colab_type": "code", "outputId": "69c61591-2950-4c1b-c80e-531ebb7092ea", "colab": { "base_uri": "https://localhost:8080/", "height": 278 } }, "source": [ "%%time\n", "## Preprocessing - Step 5 : remove text from test set\n", "\n", "with open(f\"{gdrive_path}/test.en-any.en\") as f:\n", " rows = f.readlines()\n", "test_set_en = [row.strip() for row in rows]\n", "\n", "\n", "df_pp = df_pp[~df_pp['source_sentence'].str.strip().isin(test_set_en)]\n", "\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows from test set\")\n", "size = new_size" ], "execution_count": 19, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 566404 entries, 0 to 622965\n", "Data columns (total 6 columns):\n", "source_sentence 566404 non-null object\n", "target_sentence 566404 non-null object\n", "source_ch_len 566404 non-null int64\n", "source_w_len 566404 non-null int64\n", "target_ch_len 566404 non-null int64\n", "target_w_len 566404 non-null int64\n", "dtypes: int64(4), object(2)\n", "memory usage: 288.7 MB\n", "\n", " 1066(0.19 %) samples removed by dropping rows from test set\n", "CPU times: user 1.36 s, sys: 34 ms, total: 1.39 s\n", "Wall time: 2.05 s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "6IvLGPZg--pK", "colab_type": "code", "outputId": "a7c8053f-0561-46e4-8f5d-b4fe11152f79", "colab": { "base_uri": "https://localhost:8080/", "height": 278 } }, "source": [ "%%time\n", "## Preprocessing - Step 6 : remove the extra \"\n", "df_pp['source_sentence'] = df_pp['source_sentence'].map(lambda x: x.lstrip('\"').rstrip('\"'))\n", "df_pp['target_sentence'] = df_pp['target_sentence'].map(lambda x: x.lstrip('\"').rstrip('\"'))\n", "\n", "\n", "df_pp.info(memory_usage='deep')\n", "new_size = len(df_pp)\n", "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with extra quotes\")\n", "size = new_size" ], "execution_count": 20, "outputs": [ { "output_type": "stream", "text": [ "\n", "Int64Index: 566404 entries, 0 to 622965\n", "Data columns (total 6 columns):\n", "source_sentence 566404 non-null object\n", "target_sentence 566404 non-null object\n", "source_ch_len 566404 non-null int64\n", "source_w_len 566404 non-null int64\n", "target_ch_len 566404 non-null int64\n", "target_w_len 566404 non-null int64\n", "dtypes: int64(4), object(2)\n", "memory usage: 288.7 MB\n", "\n", " 0(0.00 %) samples removed by dropping rows with extra quotes\n", "CPU times: user 1.34 s, sys: 3.74 ms, total: 1.35 s\n", "Wall time: 1.35 s\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "RWj_Eh9W5IbD", "colab_type": "text" }, "source": [ "## create dev df " ] }, { "cell_type": "code", "metadata": { "id": "V30zP0cCNn5Y", "colab_type": "code", "outputId": "095543ed-6f90-4e13-9ef7-62c18f301b51", "colab": { "base_uri": "https://localhost:8080/", "height": 139 } }, "source": [ "df_dev = df_pp[['source_sentence', 'target_sentence']]\n", "# Shuffle the data to remove bias in dev set selection.\n", "seed=42\n", "df_dev = df_dev.sample(frac=1, random_state=seed).reset_index(drop=True)\n", "df_dev.info()" ], "execution_count": 21, "outputs": [ { "output_type": "stream", "text": [ "\n", "RangeIndex: 566404 entries, 0 to 566403\n", "Data columns (total 2 columns):\n", "source_sentence 566404 non-null object\n", "target_sentence 566404 non-null object\n", "dtypes: object(2)\n", "memory usage: 8.6+ MB\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "rMdFKCgBq-Hp", "colab_type": "text" }, "source": [ "## Create train and dev sets" ] }, { "cell_type": "code", "metadata": { "id": "k5ddIOazEJlF", "colab_type": "code", "outputId": "677c5087-07fc-4ea3-9c36-25e3217b4cbd", "colab": { "base_uri": "https://localhost:8080/", "height": 52 } }, "source": [ "%%time\n", "# This section does the split between train/dev for the parallel corpora then saves them as separate files\n", "# We use 1000 dev test and the given test set.\n", "\n", "# Do the split between dev/train and create parallel corpora\n", "num_dev_patterns = 1000\n", "\n", "# Optional: lower case the corpora - this will make it easier to generalize, but without proper casing.\n", "if lc: # Julia: making lowercasing optional\n", " df_dev[\"source_sentence\"] = df_dev[\"source_sentence\"].str.lower()\n", " df_dev[\"target_sentence\"] = df_dev[\"target_sentence\"].str.lower()\n", "\n", "# Julia: test sets are already generated\n", "dev = df_dev.tail(num_dev_patterns) # Herman: Error in original\n", "stripped = df_dev.drop(df_dev.tail(num_dev_patterns).index)\n", "\n", "with open(f\"{gdrive_path}/train.\"+source_language, \"w\") as src_file, open(f\"{gdrive_path}/train.\"+target_language, \"w\") as trg_file:\n", " for index, row in stripped.iterrows():\n", " src_file.write(row[\"source_sentence\"]+\"\\n\")\n", " trg_file.write(row[\"target_sentence\"]+\"\\n\")\n", " \n", "with open(f\"{gdrive_path}/dev.\"+source_language, \"w\") as src_file, open(f\"{gdrive_path}/dev.\"+target_language, \"w\") as trg_file:\n", " for index, row in dev.iterrows():\n", " src_file.write(row[\"source_sentence\"]+\"\\n\")\n", " trg_file.write(row[\"target_sentence\"]+\"\\n\")" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "CPU times: user 1min 26s, sys: 284 ms, total: 1min 26s\n", "Wall time: 1min 27s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "3YuVeEAY-Pzk", "colab_type": "code", "outputId": "53c9f643-4863-4cb7-fea3-b6f24a737e65", "colab": { "base_uri": "https://localhost:8080/", "height": 593 } }, "source": [ "# Doublecheck the format below. There should be no extra quotation marks or weird characters.\n", "! head \"$gdrive_path/train.$src\"\n", "! echo \"=================================\"\n", "! head \"$gdrive_path/dev.$src\"\n", "! echo \"=================================\"\n", "! head \"$gdrive_path/test.$src\" " ], "execution_count": 22, "outputs": [ { "output_type": "stream", "text": [ "name some of god’s gifts that we can enjoy while awaiting future blessings \n", "mark states that soldiers “ would hit him on the head with a reed and spit upon him and , bending their knees [ in mockery ] , they would do obeisance to him ”\n", "instead , our faith will be strengthened if we rely on god , show love for him , and keep his commandments \n", "another person decides that all days are the same \n", "there were mice and cockroaches to keep us company at night \n", "my feelings of failure were such that it was often too depressing for me to read the life - story articles , which often recount extraordinary accomplishments of jehovah’s people \n", "nevertheless , jesus said those surprising words for good reason \n", "especially where children are involved , many parents prefer to use the services of a professional who is not adversarial \n", "why has the number of children adopted in britain dropped drastically during the last years ?\n", "how important it is to recognize that satan and his demons want us to feel that what we do is not good enough for god !\n", "=================================\n", "a $ - ​ million contract is signed by a leading hockey player for six years \n", "meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher \n", " : ​ — what vow did paul make ?\n", "christian wives too can make their feelings known \n", "jehovah had already foretold that pharaoh’s heart would be obstinate \n", "he squints into the setting sun and then smiles broadly as he recognizes us , the light glinting off the fashionable gold facings on his front teeth \n", "unlike those faithless israelites , jesus christ lived up to his dedication to the finish \n", "the watchtower , december , , pages - \n", "the churches add to the confusion by promoting the use of bible translations that omit god’s personal name , jehovah , from the text \n", "these divinely inspired words made sense to the lady , who said that everyone was in mourning \n", "=================================\n", "Jesus said : “ You must love your neighbor as yourself . ”\n", "For day and night your hand was heavy upon me . ”\n", "Some of the names in this article have been changed .\n", "Some names in this article have been changed .\n", "This is the greatest and first commandment . ”\n", "Published by Jehovah’s Witnesses but now out of print .\n", "( Look under BIBLE TEACHINGS > BIBLE QUESTIONS ANSWERED )\n", "Jehovah is the name of God as revealed in the Bible .\n", "\"Let your will take place , as in heaven , also on earth . ”\"\n", "The Bible says that “ foolishness is bound up in the heart of a child . ”\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "Ypai27iMCoJS", "colab_type": "code", "outputId": "15421dd0-5dea-4d66-fe82-44bb8ce72e14", "colab": { "base_uri": "https://localhost:8080/", "height": 593 } }, "source": [ "! head \"$gdrive_path/train.$trg\"\n", "! echo \"=================================\"\n", "! head \"$gdrive_path/dev.$trg\"\n", "! echo \"=================================\"\n", "! head \"$gdrive_path/test.$trg\"" ], "execution_count": 23, "outputs": [ { "output_type": "stream", "text": [ "hlalosa dimpho tše dingwe tša modimo tšeo re ka di thabelago ge re dutše re letetše ditšhegofatšo tša nakong e tlago \n", "mareka o bolela gore bahlabani “ ba be ba mo itia hlogo ka lehlaka , ba mo tshwela ka mare gomme ba [ mo kwera ka go ] thinya matolo pele ga gagwe ba mo khunamela ”\n", "go e na le moo , tumelo ya rena e tla matlafala ge e ba re ithekga ka modimo , re bontšha gore re a mo rata e bile re boloka melao ya gagwe \n", "motho yo mongwe o phetha ka gore matšatši ka moka a a swana \n", "go be go e - na le magotlo le maphene a go re tloša bodutu bošego \n", "go ikwa ga - ka ke paletšwe gantši go be go ntira gore ke nyame kudu ge ke bala diphihlelo , tšeo gantši di bego di hlalosa dilo tše di makatšago tšeo di fihleletšwego ke batho ba jehofa \n", "lega go le bjalo , go na le lebaka le le kwagalago leo le dirilego gore jesu a bolele mantšu ao a makatšago \n", "batswadi ba bantši ba kgetha go diriša ditirelo tša setsebi seo se sa tšeego lehlakore , kudu - kudu moo bana ba akaretšwago \n", "ke ka baka la’ng palo ya bana bao ba thwalwago kua brithania e ile ya fokotšega ka lebelo nywageng e e fetilego ?\n", "ruri e tloga e le gabohlokwa go lemoga gore sathane le batemona ba gagwe ba nyaka gore re nagane gore ga go na selo seo re ka se dirago seo se ka kgahlago modimo !\n", "=================================\n", "sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago \n", "go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago \n", " : — ke keno efe yeo e dirilwego ke paulo ?\n", "basadi ba bakriste le bona ba ka bolela maikwelo a bona \n", "jehofa o be a šetše a boletše e sa le pele gore pelo ya farao e be e tla thatafala \n", "o a bodulala ge a lebane le letšatši leo le dikelago ke moka o myemyela ge a bona gore ke rena , seetša se dira gore gauta e botse yeo e lego menong a gagwe a ka pele e phadime \n", "ka go se swane le ba - isiraele bao ba bego ba hloka tumelo , jesu kriste o ile a phelela boineelo bja gagwe go fihla mafelelong \n", "morokami wa january , , matlakala - \n", "dikereke di hlakahlakanya batho le go feta ka go kgothaletša go diriša diphetolelo tša beibele tšeo di ntšhitšego leina la modimo e lego jehofa ka mangwalong \n", "mantšu a a buduletšwego ke modimo a ile a kwagala a e - na le tlhaologanyo go mosadi yoo a ilego a bolela gore yo mongwe le yo mongwe o be a nyamile \n", "=================================\n", "Jesu o itše : “ Wa xeno O mo ratê ka mokxwa wo O ithataxo ka wôna . ”\n", "Ka xo imêlwa ke ’ atla sa xaxo mosexare le bošexo . ”\n", "A mangwe a maina sehlogong se a fetotšwe .\n", "Maina a mangwe a dirišitšwego sehlogong se a fetotšwe .\n", "\"Ké yôna taêlô ya pele , yôna e kxolo . ”\"\n", "E gatišitšwe ke Dihlatse tša Jehofa eupša ga bjale ga e sa gatišwa .\n", "( Lebelela ka tlase ga DITHUTO TŠA BEIBELE > DIPOTŠIŠO TŠA BEIBELE DI A ARABJA )\n", "Jehofa ke leina la Modimo bjalo ka ge le utolotšwe ka Beibeleng .\n", "Thato ya gago a e direge le mo lefaseng bjalo ka ge e direga legodimong . ”\n", "\"Beibele e re , “ bošilo bo kgokeletšwe pelong ya mošemane [ goba ngwana ] . ”\"\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "bWV-5a34rdsK", "colab_type": "text" }, "source": [ "## Preprocessing the Data into Subword BPE Tokens\n", "\n", "- One of the most powerful improvements for agglutinative languages (a feature of most Bantu languages) is using BPE tokenization [ (Sennrich, 2015) ](https://arxiv.org/abs/1508.07909).\n", "\n", "- It was also shown that by optimizing the umber of BPE codes we significantly improve results for low-resourced languages [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021) [(Martinus, 2019)](https://arxiv.org/abs/1906.05685)\n", "\n", "- Below we have the scripts for doing BPE tokenization of our data. We use 4000 tokens as recommended by [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021). You do not need to change anything. Simply running the below will be suitable. " ] }, { "cell_type": "code", "metadata": { "id": "Bi5fyp1LsLv7", "colab_type": "code", "outputId": "e730151b-4552-40dc-ef1b-7f0df5fd6c87", "colab": { "base_uri": "https://localhost:8080/", "height": 52 } }, "source": [ "%%time\n", "! subword-nmt learn-joint-bpe-and-vocab --input \"$gdrive_path\"train.$src \"$gdrive_path\"train.$trg -s $vocab_size -o \"$gdrive_path\"bpe.codes.$vocab_size --write-vocabulary \"$gdrive_path\"vocab.$src \"$gdrive_path\"vocab.$trg\n", "\n", "# Apply BPE splits to the train, development and test data.\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"train.$src > \"$gdrive_path\"train.bpe.$src\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"train.$trg > \"$gdrive_path\"train.bpe.$trg\n", "\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"dev.$src > \"$gdrive_path\"dev.bpe.$src\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"dev.$trg > \"$gdrive_path\"dev.bpe.$trg\n", "\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"test.$src > \"$gdrive_path\"test.bpe.$src\n", "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"test.$trg > \"$gdrive_path\"test.bpe.$trg\n" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "CPU times: user 1.27 s, sys: 231 ms, total: 1.5 s\n", "Wall time: 3min 27s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "jCmdlJLPMiv7", "colab_type": "code", "colab": {} }, "source": [ "# Create that vocab using build_vocab\n", "! sudo chmod 777 joeynmt/scripts/build_vocab.py\n", "! joeynmt/scripts/build_vocab.py \"$gdrive_path\"train.bpe.\"$src\" \"$gdrive_path\"train.bpe.\"$trg\" --output_path \"$gdrive_path\"vocab.txt" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "lm1CNAQvGZGy", "colab_type": "code", "outputId": "a9ec9d03-1c9c-4d6e-ce32-d94cec8acee2", "colab": { "base_uri": "https://localhost:8080/", "height": 350 } }, "source": [ "\n", "# Some output\n", "! echo \"BPE Sotho Sentences\"\n", "! tail -n 5 \"$gdrive_path\"test.bpe.$trg\n", "! echo \"===========================================================================\"\n", "! echo \"Combined BPE Vocab\"\n", "! tail -n 10 \"$gdrive_path\"vocab.txt # Herman\n", "\n", "# !cp joeynmt/data/$src$tgt$vocab_size/vocab.txt \"$gdrive_path\"" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "BPE Sotho Sentences\n", "M@@ a@@ fe@@ lelong ke ile ka tu@@ ma ka go se bote@@ ge .\n", "\"@@ K@@ a morago ga gore ke ithu@@ te therešo , ke ile ka gana go tšwela pele ke dira seo , gaešita le ge mošomo woo o be o le@@ fa gabotse .@@ \"\n", "\"@@ K@@ e mohlala o mobotse go barwa ba ka ba babedi , e bile ke ne@@ ilwe di@@ tokelo ka phuthegong .@@ \"\n", "G@@ ona bjale ke tu@@ mile ka go botega gare ga ba@@ hlahlo@@ bi ba ma@@ kgetho le bao ke dirago kgwebo le bona . ”\n", "\"@@ R@@ u@@ the o ile a hudu@@ gela I@@ si@@ rae@@ le , moo a bego a ka rapela M@@ o@@ dimo wa therešo .@@ \"\n", "===========================================================================\n", "Combined BPE Vocab\n", "swantšho\n", "̀@@\n", "ė\n", "▲\n", "ể@@\n", "kots@@\n", "̱@@\n", "heber@@\n", "̆\n", "]@@\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "0P_JpDK7v2e8", "colab_type": "text" }, "source": [ "## Creating the JoeyNMT Config\n", "\n", "JoeyNMT requires a yaml config. We provide a template below. We've also set a number of defaults with it, that you may play with!\n", "\n", "- We used Transformer architecture \n", "- We set our dropout to reasonably high: 0.3 (recommended in [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021))\n", "\n", "Things worth playing with:\n", "- The batch size (also recommended to change for low-resourced languages)\n", "- The number of epochs (we've set it at 30 just so it runs in about an hour, for testing purposes)\n", "- The decoder options (beam_size, alpha)\n", "- Evaluation metrics (BLEU versus Crhf4)" ] }, { "cell_type": "code", "metadata": { "id": "4G_GWs_E0N1v", "colab_type": "code", "outputId": "b9e610f3-185d-4d85-f168-dc2a8a6ea502", "colab": { "base_uri": "https://localhost:8080/", "height": 34 } }, "source": [ "name = '%s%s%s%s' % (source_language, target_language, str(vocab_size),tag)\n", "name" ], "execution_count": 24, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "'ennso4000baseline'" ] }, "metadata": { "tags": [] }, "execution_count": 24 } ] }, { "cell_type": "code", "metadata": { "id": "o-7TTovtKnF7", "colab_type": "code", "colab": {} }, "source": [ "# Create this dir before we run for the first time so we store check points\n", "# !mkdir -p \"$gdrive_path/pretrained/$src$trg$vocab_size$tag/\" # Herman" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "nVq7B1IYv2hd", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "outputId": "b7bb2076-42d5-42ab-e778-d34813104288" }, "source": [ "# This creates the config file for our JoeyNMT system. It might seem overwhelming so we've provided a couple of useful parameters you'll need to update\n", "# (You can of course play with all the parameters if you'd like!)\n", "\n", "name = '%s%s%s%s' % (source_language, target_language, str(vocab_size),tag)\n", "gdrive_path = os.environ[\"gdrive_path\"]\n", "\n", "# Create the config\n", "config = \"\"\"\n", "name: \"{name}\"\n", "\n", "data:\n", " src: \"{source_language}\"\n", " trg: \"{target_language}\"\n", " train: \"{gdrive_path}train.bpe\"\n", " dev: \"{gdrive_path}dev.bpe\"\n", " test: \"{gdrive_path}test.bpe\"\n", " level: \"bpe\"\n", " lowercase: False\n", " max_sent_length: 100\n", " src_vocab: \"{gdrive_path}vocab.txt\"\n", " trg_vocab: \"{gdrive_path}vocab.txt\"\n", "\n", "testing:\n", " beam_size: 5\n", " alpha: 1.0\n", "\n", "training:\n", " load_model: \"{gdrive_path}pretrained/{name}/best.ckpt\" # if uncommented, load a pre-trained model from this checkpoint\n", " random_seed: 42\n", " optimizer: \"adam\"\n", " normalization: \"tokens\"\n", " adam_betas: [0.9, 0.999] \n", " scheduling: \"plateau\" # TODO: try switching from plateau to Noam scheduling\n", " patience: 5 # For plateau: decrease learning rate by decrease_factor if validation score has not improved for this many validation rounds.\n", " learning_rate_factor: 0.5 # factor for Noam scheduler (used with Transformer)\n", " learning_rate_warmup: 1000 # warmup steps for Noam scheduler (used with Transformer)\n", " decrease_factor: 0.7\n", " loss: \"crossentropy\"\n", " learning_rate: 0.0003\n", " learning_rate_min: 0.00000001\n", " weight_decay: 0.0\n", " label_smoothing: 0.1\n", " batch_size: 4096\n", " batch_type: \"token\"\n", " eval_batch_size: 3600\n", " eval_batch_type: \"token\"\n", " batch_multiplier: 1\n", " early_stopping_metric: \"ppl\"\n", " epochs: 10 # TODO: Decrease for when playing around and checking of working. Around 30 is sufficient to check if its working at all\n", " validation_freq: 1000 # TODO: Set to at least once per epoch.\n", " logging_freq: 100\n", " eval_metric: \"bleu\"\n", " model_dir: \"models/{name}_transformer\"\n", " overwrite: True # TODO: Set to True if you want to overwrite possibly existing models. \n", " shuffle: True\n", " use_cuda: True\n", " max_output_length: 100\n", " print_valid_sents: [0, 1, 2, 3]\n", " keep_last_ckpts: 3\n", "\n", "model:\n", " initializer: \"xavier\"\n", " bias_initializer: \"zeros\"\n", " init_gain: 1.0\n", " embed_initializer: \"xavier\"\n", " embed_init_gain: 1.0\n", " tied_embeddings: True\n", " tied_softmax: True\n", " encoder:\n", " type: \"transformer\"\n", " num_layers: 6\n", " num_heads: 4 # TODO: Increase to 8 for larger data.\n", " embeddings:\n", " embedding_dim: 256 # TODO: Increase to 512 for larger data.\n", " scale: True\n", " dropout: 0.3\n", " # typically ff_size = 4 x hidden_size\n", " hidden_size: 256 # TODO: Increase to 512 for larger data.\n", " ff_size: 1024 # TODO: Increase to 2048 for larger data.\n", " dropout: 0.4\n", " decoder:\n", " type: \"transformer\"\n", " num_layers: 6\n", " num_heads: 8 # TODO: Increase to 8 for larger data.\n", " embeddings:\n", " embedding_dim: 256 # TODO: Increase to 512 for larger data.\n", " scale: True\n", " dropout: 0.3\n", " # typically ff_size = 4 x hidden_size\n", " hidden_size: 256 # TODO: Increase to 512 for larger data.\n", " ff_size: 1024 # TODO: Increase to 2048 for larger data.\n", " dropout: 0.4\n", "\"\"\".format(name=name,\n", " gdrive_path=os.environ[\"gdrive_path\"],\n", " source_language=source_language,\n", " target_language=target_language\n", " )\n", "\n", "with open(\"joeynmt/configs/transformer_{name}.yaml\".format(name=name),'w') as f:\n", " f.write(config)" ], "execution_count": 25, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "3308" ] }, "metadata": { "tags": [] }, "execution_count": 25 } ] }, { "cell_type": "markdown", "metadata": { "id": "nr9b-FiGv2j9", "colab_type": "text" }, "source": [ "# Train the Model\n", "\n", "This single line of joeynmt runs the training using the config we made above" ] }, { "cell_type": "code", "metadata": { "id": "NfW_lJhwe6gD", "colab_type": "code", "outputId": "4da52cae-a1c5-47a0-b1b5-349815796db4", "colab": { "base_uri": "https://localhost:8080/", "height": 173 } }, "source": [ "! cd joeynmt/configs; ls\n", "! cp joeynmt/configs/transformer_$src$trg$vocab_size$tag.yaml \"$gdrive_path/\"" ], "execution_count": 26, "outputs": [ { "output_type": "stream", "text": [ "iwslt14_deen_bpe.yaml\t\t transformer_reverse.yaml\n", "iwslt_deen_bahdanau.yaml\t transformer_small.yaml\n", "iwslt_envi_luong.yaml\t\t transformer_wmt17_ende.yaml\n", "iwslt_envi_xnmt.yaml\t\t transformer_wmt17_lven.yaml\n", "reverse.yaml\t\t\t wmt_ende_best.yaml\n", "small.yaml\t\t\t wmt_ende_default.yaml\n", "transformer_copy.yaml\t\t wmt_lven_best.yaml\n", "transformer_ennso4000baseline.yaml wmt_lven_default.yaml\n", "transformer_iwslt14_deen_bpe.yaml\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "WiwUQaqPv2mz", "colab_type": "code", "outputId": "ac8310a5-84ad-4d8d-b6b5-12951a2f51d2", "colab": { "base_uri": "https://localhost:8080/", "height": 1000 } }, "source": [ "%%time\n", "# Train the model\n", "# You can press Ctrl-C to stop. And then run the next cell to save your checkpoints! \n", "! cd joeynmt; python3 -m joeynmt train configs/transformer_$src$trg$vocab_size$tag.yaml" ], "execution_count": 27, "outputs": [ { "output_type": "stream", "text": [ "2020-02-14 09:06:08,970 Hello! This is Joey-NMT.\n", "2020-02-14 09:06:10,079 Total params: 12158720\n", "2020-02-14 09:06:10,081 Trainable parameters: ['decoder.layer_norm.bias', 'decoder.layer_norm.weight', 'decoder.layers.0.dec_layer_norm.bias', 'decoder.layers.0.dec_layer_norm.weight', 'decoder.layers.0.feed_forward.layer_norm.bias', 'decoder.layers.0.feed_forward.layer_norm.weight', 'decoder.layers.0.feed_forward.pwff_layer.0.bias', 'decoder.layers.0.feed_forward.pwff_layer.0.weight', 'decoder.layers.0.feed_forward.pwff_layer.3.bias', 'decoder.layers.0.feed_forward.pwff_layer.3.weight', 'decoder.layers.0.src_trg_att.k_layer.bias', 'decoder.layers.0.src_trg_att.k_layer.weight', 'decoder.layers.0.src_trg_att.output_layer.bias', 'decoder.layers.0.src_trg_att.output_layer.weight', 'decoder.layers.0.src_trg_att.q_layer.bias', 'decoder.layers.0.src_trg_att.q_layer.weight', 'decoder.layers.0.src_trg_att.v_layer.bias', 'decoder.layers.0.src_trg_att.v_layer.weight', 'decoder.layers.0.trg_trg_att.k_layer.bias', 'decoder.layers.0.trg_trg_att.k_layer.weight', 'decoder.layers.0.trg_trg_att.output_layer.bias', 'decoder.layers.0.trg_trg_att.output_layer.weight', 'decoder.layers.0.trg_trg_att.q_layer.bias', 'decoder.layers.0.trg_trg_att.q_layer.weight', 'decoder.layers.0.trg_trg_att.v_layer.bias', 'decoder.layers.0.trg_trg_att.v_layer.weight', 'decoder.layers.0.x_layer_norm.bias', 'decoder.layers.0.x_layer_norm.weight', 'decoder.layers.1.dec_layer_norm.bias', 'decoder.layers.1.dec_layer_norm.weight', 'decoder.layers.1.feed_forward.layer_norm.bias', 'decoder.layers.1.feed_forward.layer_norm.weight', 'decoder.layers.1.feed_forward.pwff_layer.0.bias', 'decoder.layers.1.feed_forward.pwff_layer.0.weight', 'decoder.layers.1.feed_forward.pwff_layer.3.bias', 'decoder.layers.1.feed_forward.pwff_layer.3.weight', 'decoder.layers.1.src_trg_att.k_layer.bias', 'decoder.layers.1.src_trg_att.k_layer.weight', 'decoder.layers.1.src_trg_att.output_layer.bias', 'decoder.layers.1.src_trg_att.output_layer.weight', 'decoder.layers.1.src_trg_att.q_layer.bias', 'decoder.layers.1.src_trg_att.q_layer.weight', 'decoder.layers.1.src_trg_att.v_layer.bias', 'decoder.layers.1.src_trg_att.v_layer.weight', 'decoder.layers.1.trg_trg_att.k_layer.bias', 'decoder.layers.1.trg_trg_att.k_layer.weight', 'decoder.layers.1.trg_trg_att.output_layer.bias', 'decoder.layers.1.trg_trg_att.output_layer.weight', 'decoder.layers.1.trg_trg_att.q_layer.bias', 'decoder.layers.1.trg_trg_att.q_layer.weight', 'decoder.layers.1.trg_trg_att.v_layer.bias', 'decoder.layers.1.trg_trg_att.v_layer.weight', 'decoder.layers.1.x_layer_norm.bias', 'decoder.layers.1.x_layer_norm.weight', 'decoder.layers.2.dec_layer_norm.bias', 'decoder.layers.2.dec_layer_norm.weight', 'decoder.layers.2.feed_forward.layer_norm.bias', 'decoder.layers.2.feed_forward.layer_norm.weight', 'decoder.layers.2.feed_forward.pwff_layer.0.bias', 'decoder.layers.2.feed_forward.pwff_layer.0.weight', 'decoder.layers.2.feed_forward.pwff_layer.3.bias', 'decoder.layers.2.feed_forward.pwff_layer.3.weight', 'decoder.layers.2.src_trg_att.k_layer.bias', 'decoder.layers.2.src_trg_att.k_layer.weight', 'decoder.layers.2.src_trg_att.output_layer.bias', 'decoder.layers.2.src_trg_att.output_layer.weight', 'decoder.layers.2.src_trg_att.q_layer.bias', 'decoder.layers.2.src_trg_att.q_layer.weight', 'decoder.layers.2.src_trg_att.v_layer.bias', 'decoder.layers.2.src_trg_att.v_layer.weight', 'decoder.layers.2.trg_trg_att.k_layer.bias', 'decoder.layers.2.trg_trg_att.k_layer.weight', 'decoder.layers.2.trg_trg_att.output_layer.bias', 'decoder.layers.2.trg_trg_att.output_layer.weight', 'decoder.layers.2.trg_trg_att.q_layer.bias', 'decoder.layers.2.trg_trg_att.q_layer.weight', 'decoder.layers.2.trg_trg_att.v_layer.bias', 'decoder.layers.2.trg_trg_att.v_layer.weight', 'decoder.layers.2.x_layer_norm.bias', 'decoder.layers.2.x_layer_norm.weight', 'decoder.layers.3.dec_layer_norm.bias', 'decoder.layers.3.dec_layer_norm.weight', 'decoder.layers.3.feed_forward.layer_norm.bias', 'decoder.layers.3.feed_forward.layer_norm.weight', 'decoder.layers.3.feed_forward.pwff_layer.0.bias', 'decoder.layers.3.feed_forward.pwff_layer.0.weight', 'decoder.layers.3.feed_forward.pwff_layer.3.bias', 'decoder.layers.3.feed_forward.pwff_layer.3.weight', 'decoder.layers.3.src_trg_att.k_layer.bias', 'decoder.layers.3.src_trg_att.k_layer.weight', 'decoder.layers.3.src_trg_att.output_layer.bias', 'decoder.layers.3.src_trg_att.output_layer.weight', 'decoder.layers.3.src_trg_att.q_layer.bias', 'decoder.layers.3.src_trg_att.q_layer.weight', 'decoder.layers.3.src_trg_att.v_layer.bias', 'decoder.layers.3.src_trg_att.v_layer.weight', 'decoder.layers.3.trg_trg_att.k_layer.bias', 'decoder.layers.3.trg_trg_att.k_layer.weight', 'decoder.layers.3.trg_trg_att.output_layer.bias', 'decoder.layers.3.trg_trg_att.output_layer.weight', 'decoder.layers.3.trg_trg_att.q_layer.bias', 'decoder.layers.3.trg_trg_att.q_layer.weight', 'decoder.layers.3.trg_trg_att.v_layer.bias', 'decoder.layers.3.trg_trg_att.v_layer.weight', 'decoder.layers.3.x_layer_norm.bias', 'decoder.layers.3.x_layer_norm.weight', 'decoder.layers.4.dec_layer_norm.bias', 'decoder.layers.4.dec_layer_norm.weight', 'decoder.layers.4.feed_forward.layer_norm.bias', 'decoder.layers.4.feed_forward.layer_norm.weight', 'decoder.layers.4.feed_forward.pwff_layer.0.bias', 'decoder.layers.4.feed_forward.pwff_layer.0.weight', 'decoder.layers.4.feed_forward.pwff_layer.3.bias', 'decoder.layers.4.feed_forward.pwff_layer.3.weight', 'decoder.layers.4.src_trg_att.k_layer.bias', 'decoder.layers.4.src_trg_att.k_layer.weight', 'decoder.layers.4.src_trg_att.output_layer.bias', 'decoder.layers.4.src_trg_att.output_layer.weight', 'decoder.layers.4.src_trg_att.q_layer.bias', 'decoder.layers.4.src_trg_att.q_layer.weight', 'decoder.layers.4.src_trg_att.v_layer.bias', 'decoder.layers.4.src_trg_att.v_layer.weight', 'decoder.layers.4.trg_trg_att.k_layer.bias', 'decoder.layers.4.trg_trg_att.k_layer.weight', 'decoder.layers.4.trg_trg_att.output_layer.bias', 'decoder.layers.4.trg_trg_att.output_layer.weight', 'decoder.layers.4.trg_trg_att.q_layer.bias', 'decoder.layers.4.trg_trg_att.q_layer.weight', 'decoder.layers.4.trg_trg_att.v_layer.bias', 'decoder.layers.4.trg_trg_att.v_layer.weight', 'decoder.layers.4.x_layer_norm.bias', 'decoder.layers.4.x_layer_norm.weight', 'decoder.layers.5.dec_layer_norm.bias', 'decoder.layers.5.dec_layer_norm.weight', 'decoder.layers.5.feed_forward.layer_norm.bias', 'decoder.layers.5.feed_forward.layer_norm.weight', 'decoder.layers.5.feed_forward.pwff_layer.0.bias', 'decoder.layers.5.feed_forward.pwff_layer.0.weight', 'decoder.layers.5.feed_forward.pwff_layer.3.bias', 'decoder.layers.5.feed_forward.pwff_layer.3.weight', 'decoder.layers.5.src_trg_att.k_layer.bias', 'decoder.layers.5.src_trg_att.k_layer.weight', 'decoder.layers.5.src_trg_att.output_layer.bias', 'decoder.layers.5.src_trg_att.output_layer.weight', 'decoder.layers.5.src_trg_att.q_layer.bias', 'decoder.layers.5.src_trg_att.q_layer.weight', 'decoder.layers.5.src_trg_att.v_layer.bias', 'decoder.layers.5.src_trg_att.v_layer.weight', 'decoder.layers.5.trg_trg_att.k_layer.bias', 'decoder.layers.5.trg_trg_att.k_layer.weight', 'decoder.layers.5.trg_trg_att.output_layer.bias', 'decoder.layers.5.trg_trg_att.output_layer.weight', 'decoder.layers.5.trg_trg_att.q_layer.bias', 'decoder.layers.5.trg_trg_att.q_layer.weight', 'decoder.layers.5.trg_trg_att.v_layer.bias', 'decoder.layers.5.trg_trg_att.v_layer.weight', 'decoder.layers.5.x_layer_norm.bias', 'decoder.layers.5.x_layer_norm.weight', 'encoder.layer_norm.bias', 'encoder.layer_norm.weight', 'encoder.layers.0.feed_forward.layer_norm.bias', 'encoder.layers.0.feed_forward.layer_norm.weight', 'encoder.layers.0.feed_forward.pwff_layer.0.bias', 'encoder.layers.0.feed_forward.pwff_layer.0.weight', 'encoder.layers.0.feed_forward.pwff_layer.3.bias', 'encoder.layers.0.feed_forward.pwff_layer.3.weight', 'encoder.layers.0.layer_norm.bias', 'encoder.layers.0.layer_norm.weight', 'encoder.layers.0.src_src_att.k_layer.bias', 'encoder.layers.0.src_src_att.k_layer.weight', 'encoder.layers.0.src_src_att.output_layer.bias', 'encoder.layers.0.src_src_att.output_layer.weight', 'encoder.layers.0.src_src_att.q_layer.bias', 'encoder.layers.0.src_src_att.q_layer.weight', 'encoder.layers.0.src_src_att.v_layer.bias', 'encoder.layers.0.src_src_att.v_layer.weight', 'encoder.layers.1.feed_forward.layer_norm.bias', 'encoder.layers.1.feed_forward.layer_norm.weight', 'encoder.layers.1.feed_forward.pwff_layer.0.bias', 'encoder.layers.1.feed_forward.pwff_layer.0.weight', 'encoder.layers.1.feed_forward.pwff_layer.3.bias', 'encoder.layers.1.feed_forward.pwff_layer.3.weight', 'encoder.layers.1.layer_norm.bias', 'encoder.layers.1.layer_norm.weight', 'encoder.layers.1.src_src_att.k_layer.bias', 'encoder.layers.1.src_src_att.k_layer.weight', 'encoder.layers.1.src_src_att.output_layer.bias', 'encoder.layers.1.src_src_att.output_layer.weight', 'encoder.layers.1.src_src_att.q_layer.bias', 'encoder.layers.1.src_src_att.q_layer.weight', 'encoder.layers.1.src_src_att.v_layer.bias', 'encoder.layers.1.src_src_att.v_layer.weight', 'encoder.layers.2.feed_forward.layer_norm.bias', 'encoder.layers.2.feed_forward.layer_norm.weight', 'encoder.layers.2.feed_forward.pwff_layer.0.bias', 'encoder.layers.2.feed_forward.pwff_layer.0.weight', 'encoder.layers.2.feed_forward.pwff_layer.3.bias', 'encoder.layers.2.feed_forward.pwff_layer.3.weight', 'encoder.layers.2.layer_norm.bias', 'encoder.layers.2.layer_norm.weight', 'encoder.layers.2.src_src_att.k_layer.bias', 'encoder.layers.2.src_src_att.k_layer.weight', 'encoder.layers.2.src_src_att.output_layer.bias', 'encoder.layers.2.src_src_att.output_layer.weight', 'encoder.layers.2.src_src_att.q_layer.bias', 'encoder.layers.2.src_src_att.q_layer.weight', 'encoder.layers.2.src_src_att.v_layer.bias', 'encoder.layers.2.src_src_att.v_layer.weight', 'encoder.layers.3.feed_forward.layer_norm.bias', 'encoder.layers.3.feed_forward.layer_norm.weight', 'encoder.layers.3.feed_forward.pwff_layer.0.bias', 'encoder.layers.3.feed_forward.pwff_layer.0.weight', 'encoder.layers.3.feed_forward.pwff_layer.3.bias', 'encoder.layers.3.feed_forward.pwff_layer.3.weight', 'encoder.layers.3.layer_norm.bias', 'encoder.layers.3.layer_norm.weight', 'encoder.layers.3.src_src_att.k_layer.bias', 'encoder.layers.3.src_src_att.k_layer.weight', 'encoder.layers.3.src_src_att.output_layer.bias', 'encoder.layers.3.src_src_att.output_layer.weight', 'encoder.layers.3.src_src_att.q_layer.bias', 'encoder.layers.3.src_src_att.q_layer.weight', 'encoder.layers.3.src_src_att.v_layer.bias', 'encoder.layers.3.src_src_att.v_layer.weight', 'encoder.layers.4.feed_forward.layer_norm.bias', 'encoder.layers.4.feed_forward.layer_norm.weight', 'encoder.layers.4.feed_forward.pwff_layer.0.bias', 'encoder.layers.4.feed_forward.pwff_layer.0.weight', 'encoder.layers.4.feed_forward.pwff_layer.3.bias', 'encoder.layers.4.feed_forward.pwff_layer.3.weight', 'encoder.layers.4.layer_norm.bias', 'encoder.layers.4.layer_norm.weight', 'encoder.layers.4.src_src_att.k_layer.bias', 'encoder.layers.4.src_src_att.k_layer.weight', 'encoder.layers.4.src_src_att.output_layer.bias', 'encoder.layers.4.src_src_att.output_layer.weight', 'encoder.layers.4.src_src_att.q_layer.bias', 'encoder.layers.4.src_src_att.q_layer.weight', 'encoder.layers.4.src_src_att.v_layer.bias', 'encoder.layers.4.src_src_att.v_layer.weight', 'encoder.layers.5.feed_forward.layer_norm.bias', 'encoder.layers.5.feed_forward.layer_norm.weight', 'encoder.layers.5.feed_forward.pwff_layer.0.bias', 'encoder.layers.5.feed_forward.pwff_layer.0.weight', 'encoder.layers.5.feed_forward.pwff_layer.3.bias', 'encoder.layers.5.feed_forward.pwff_layer.3.weight', 'encoder.layers.5.layer_norm.bias', 'encoder.layers.5.layer_norm.weight', 'encoder.layers.5.src_src_att.k_layer.bias', 'encoder.layers.5.src_src_att.k_layer.weight', 'encoder.layers.5.src_src_att.output_layer.bias', 'encoder.layers.5.src_src_att.output_layer.weight', 'encoder.layers.5.src_src_att.q_layer.bias', 'encoder.layers.5.src_src_att.q_layer.weight', 'encoder.layers.5.src_src_att.v_layer.bias', 'encoder.layers.5.src_src_att.v_layer.weight', 'src_embed.lut.weight']\n", "2020-02-14 09:06:19,008 Loading model from /content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/best.ckpt\n", "2020-02-14 09:06:31,181 cfg.name : ennso4000baseline\n", "2020-02-14 09:06:31,181 cfg.data.src : en\n", "2020-02-14 09:06:31,181 cfg.data.trg : nso\n", "2020-02-14 09:06:31,181 cfg.data.train : /content/drive/My Drive/masakhane/en-nso-baseline/train.bpe\n", "2020-02-14 09:06:31,181 cfg.data.dev : /content/drive/My Drive/masakhane/en-nso-baseline/dev.bpe\n", "2020-02-14 09:06:31,181 cfg.data.test : /content/drive/My Drive/masakhane/en-nso-baseline/test.bpe\n", "2020-02-14 09:06:31,181 cfg.data.level : bpe\n", "2020-02-14 09:06:31,181 cfg.data.lowercase : False\n", "2020-02-14 09:06:31,181 cfg.data.max_sent_length : 100\n", "2020-02-14 09:06:31,182 cfg.data.src_vocab : /content/drive/My Drive/masakhane/en-nso-baseline/vocab.txt\n", "2020-02-14 09:06:31,182 cfg.data.trg_vocab : /content/drive/My Drive/masakhane/en-nso-baseline/vocab.txt\n", "2020-02-14 09:06:31,182 cfg.testing.beam_size : 5\n", "2020-02-14 09:06:31,182 cfg.testing.alpha : 1.0\n", "2020-02-14 09:06:31,182 cfg.training.load_model : /content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/best.ckpt\n", "2020-02-14 09:06:31,182 cfg.training.random_seed : 42\n", "2020-02-14 09:06:31,182 cfg.training.optimizer : adam\n", "2020-02-14 09:06:31,182 cfg.training.normalization : tokens\n", "2020-02-14 09:06:31,182 cfg.training.adam_betas : [0.9, 0.999]\n", "2020-02-14 09:06:31,182 cfg.training.scheduling : plateau\n", "2020-02-14 09:06:31,182 cfg.training.patience : 5\n", "2020-02-14 09:06:31,182 cfg.training.learning_rate_factor : 0.5\n", "2020-02-14 09:06:31,182 cfg.training.learning_rate_warmup : 1000\n", "2020-02-14 09:06:31,182 cfg.training.decrease_factor : 0.7\n", "2020-02-14 09:06:31,182 cfg.training.loss : crossentropy\n", "2020-02-14 09:06:31,182 cfg.training.learning_rate : 0.0003\n", "2020-02-14 09:06:31,182 cfg.training.learning_rate_min : 1e-08\n", "2020-02-14 09:06:31,182 cfg.training.weight_decay : 0.0\n", "2020-02-14 09:06:31,182 cfg.training.label_smoothing : 0.1\n", "2020-02-14 09:06:31,182 cfg.training.batch_size : 4096\n", "2020-02-14 09:06:31,182 cfg.training.batch_type : token\n", "2020-02-14 09:06:31,182 cfg.training.eval_batch_size : 3600\n", "2020-02-14 09:06:31,182 cfg.training.eval_batch_type : token\n", "2020-02-14 09:06:31,182 cfg.training.batch_multiplier : 1\n", "2020-02-14 09:06:31,182 cfg.training.early_stopping_metric : ppl\n", "2020-02-14 09:06:31,182 cfg.training.epochs : 10\n", "2020-02-14 09:06:31,182 cfg.training.validation_freq : 1000\n", "2020-02-14 09:06:31,182 cfg.training.logging_freq : 100\n", "2020-02-14 09:06:31,182 cfg.training.eval_metric : bleu\n", "2020-02-14 09:06:31,183 cfg.training.model_dir : models/ennso4000baseline_transformer\n", "2020-02-14 09:06:31,183 cfg.training.overwrite : True\n", "2020-02-14 09:06:31,183 cfg.training.shuffle : True\n", "2020-02-14 09:06:31,183 cfg.training.use_cuda : True\n", "2020-02-14 09:06:31,183 cfg.training.max_output_length : 100\n", "2020-02-14 09:06:31,183 cfg.training.print_valid_sents : [0, 1, 2, 3]\n", "2020-02-14 09:06:31,183 cfg.training.keep_last_ckpts : 3\n", "2020-02-14 09:06:31,183 cfg.model.initializer : xavier\n", "2020-02-14 09:06:31,183 cfg.model.bias_initializer : zeros\n", "2020-02-14 09:06:31,183 cfg.model.init_gain : 1.0\n", "2020-02-14 09:06:31,183 cfg.model.embed_initializer : xavier\n", "2020-02-14 09:06:31,183 cfg.model.embed_init_gain : 1.0\n", "2020-02-14 09:06:31,183 cfg.model.tied_embeddings : True\n", "2020-02-14 09:06:31,183 cfg.model.tied_softmax : True\n", "2020-02-14 09:06:31,183 cfg.model.encoder.type : transformer\n", "2020-02-14 09:06:31,183 cfg.model.encoder.num_layers : 6\n", "2020-02-14 09:06:31,183 cfg.model.encoder.num_heads : 4\n", "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.embedding_dim : 256\n", "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.scale : True\n", "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.dropout : 0.3\n", "2020-02-14 09:06:31,183 cfg.model.encoder.hidden_size : 256\n", "2020-02-14 09:06:31,183 cfg.model.encoder.ff_size : 1024\n", "2020-02-14 09:06:31,183 cfg.model.encoder.dropout : 0.4\n", "2020-02-14 09:06:31,183 cfg.model.decoder.type : transformer\n", "2020-02-14 09:06:31,183 cfg.model.decoder.num_layers : 6\n", "2020-02-14 09:06:31,184 cfg.model.decoder.num_heads : 8\n", "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.embedding_dim : 256\n", "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.scale : True\n", "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.dropout : 0.3\n", "2020-02-14 09:06:31,184 cfg.model.decoder.hidden_size : 256\n", "2020-02-14 09:06:31,184 cfg.model.decoder.ff_size : 1024\n", "2020-02-14 09:06:31,184 cfg.model.decoder.dropout : 0.4\n", "2020-02-14 09:06:31,184 Data set sizes: \n", "\ttrain 563849,\n", "\tvalid 1000,\n", "\ttest 2705\n", "2020-02-14 09:06:31,184 First training example:\n", "\t[SRC] name some of god’s gi@@ f@@ ts that we can enjoy while awa@@ iting future blessings\n", "\t[TRG] hlalosa di@@ mpho tše dingwe tša modimo tšeo re ka di thabe@@ lago ge re dutše re lete@@ tše ditšhegofatšo tša nakong e tlago\n", "2020-02-14 09:06:31,184 First 10 words (src): (0) (1) (2) (3) (4) , (5) a (6) go (7) le (8) ka (9) ba\n", "2020-02-14 09:06:31,184 First 10 words (trg): (0) (1) (2) (3) (4) , (5) a (6) go (7) le (8) ka (9) ba\n", "2020-02-14 09:06:31,184 Number of Src words (types): 4291\n", "2020-02-14 09:06:31,184 Number of Trg words (types): 4291\n", "2020-02-14 09:06:31,184 Model(\n", "\tencoder=TransformerEncoder(num_layers=6, num_heads=4),\n", "\tdecoder=TransformerDecoder(num_layers=6, num_heads=8),\n", "\tsrc_embed=Embeddings(embedding_dim=256, vocab_size=4291),\n", "\ttrg_embed=Embeddings(embedding_dim=256, vocab_size=4291))\n", "2020-02-14 09:06:31,188 EPOCH 1\n", "2020-02-14 09:06:43,691 Epoch 1 Step: 177100 Batch Loss: 1.554556 Tokens per Sec: 19776, Lr: 0.000300\n", "2020-02-14 09:06:55,166 Epoch 1 Step: 177200 Batch Loss: 1.402975 Tokens per Sec: 21350, Lr: 0.000300\n", "2020-02-14 09:07:06,709 Epoch 1 Step: 177300 Batch Loss: 1.653110 Tokens per Sec: 21384, Lr: 0.000300\n", "2020-02-14 09:07:18,071 Epoch 1 Step: 177400 Batch Loss: 1.119401 Tokens per Sec: 22436, Lr: 0.000300\n", "2020-02-14 09:07:29,449 Epoch 1 Step: 177500 Batch Loss: 1.342238 Tokens per Sec: 21814, Lr: 0.000300\n", "2020-02-14 09:07:40,775 Epoch 1 Step: 177600 Batch Loss: 1.005374 Tokens per Sec: 22137, Lr: 0.000300\n", "2020-02-14 09:07:52,247 Epoch 1 Step: 177700 Batch Loss: 1.039695 Tokens per Sec: 21775, Lr: 0.000300\n", "2020-02-14 09:08:03,578 Epoch 1 Step: 177800 Batch Loss: 1.083479 Tokens per Sec: 21844, Lr: 0.000300\n", "2020-02-14 09:08:15,032 Epoch 1 Step: 177900 Batch Loss: 0.867756 Tokens per Sec: 21840, Lr: 0.000300\n", "2020-02-14 09:08:26,289 Epoch 1 Step: 178000 Batch Loss: 0.963311 Tokens per Sec: 21865, Lr: 0.000300\n", "2020-02-14 09:08:45,948 Example #0\n", "2020-02-14 09:08:45,950 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:08:45,950 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:08:45,950 \tHypothesis: konteraka ya diranta tše dimilione tše , e saenwa ke sebapadi se se išago gae ka nywaga e tshelelago\n", "2020-02-14 09:08:45,950 Example #1\n", "2020-02-14 09:08:45,950 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:08:45,950 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:08:45,950 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:08:45,950 Example #2\n", "2020-02-14 09:08:45,951 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:08:45,951 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:08:45,951 \tHypothesis: : — paulo o ile a dira keno efe ?\n", "2020-02-14 09:08:45,951 Example #3\n", "2020-02-14 09:08:45,951 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:08:45,951 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:08:45,951 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:08:45,951 Validation result (greedy) at epoch 1, step 178000: bleu: 44.47, loss: 28279.8086, ppl: 2.6200, duration: 19.6613s\n", "2020-02-14 09:08:57,396 Epoch 1 Step: 178100 Batch Loss: 1.112401 Tokens per Sec: 21992, Lr: 0.000300\n", "2020-02-14 09:09:08,812 Epoch 1 Step: 178200 Batch Loss: 1.278881 Tokens per Sec: 21910, Lr: 0.000300\n", "2020-02-14 09:09:20,012 Epoch 1 Step: 178300 Batch Loss: 1.090895 Tokens per Sec: 21676, Lr: 0.000300\n", "2020-02-14 09:09:31,492 Epoch 1 Step: 178400 Batch Loss: 1.226156 Tokens per Sec: 21744, Lr: 0.000300\n", "2020-02-14 09:09:43,081 Epoch 1 Step: 178500 Batch Loss: 1.531641 Tokens per Sec: 22043, Lr: 0.000300\n", "2020-02-14 09:09:54,564 Epoch 1 Step: 178600 Batch Loss: 1.068074 Tokens per Sec: 21602, Lr: 0.000300\n", "2020-02-14 09:10:05,926 Epoch 1 Step: 178700 Batch Loss: 1.207614 Tokens per Sec: 21339, Lr: 0.000300\n", "2020-02-14 09:10:17,262 Epoch 1 Step: 178800 Batch Loss: 1.301371 Tokens per Sec: 22283, Lr: 0.000300\n", "2020-02-14 09:10:28,581 Epoch 1 Step: 178900 Batch Loss: 1.306410 Tokens per Sec: 21812, Lr: 0.000300\n", "2020-02-14 09:10:39,891 Epoch 1 Step: 179000 Batch Loss: 1.399729 Tokens per Sec: 22232, Lr: 0.000300\n", "2020-02-14 09:10:58,367 Example #0\n", "2020-02-14 09:10:58,367 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:10:58,367 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:10:58,367 \tHypothesis: konteraka ya diranta tše dimilione tše , e saenwa ke molaodi wa hockey ka nywaga e tshelelago\n", "2020-02-14 09:10:58,367 Example #1\n", "2020-02-14 09:10:58,367 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:10:58,367 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:10:58,367 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme a ba mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:10:58,367 Example #2\n", "2020-02-14 09:10:58,367 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:10:58,368 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:10:58,368 \tHypothesis: : — paulo o dirile keno efe ?\n", "2020-02-14 09:10:58,368 Example #3\n", "2020-02-14 09:10:58,368 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:10:58,368 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:10:58,368 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:10:58,368 Validation result (greedy) at epoch 1, step 179000: bleu: 44.50, loss: 28167.1602, ppl: 2.6100, duration: 18.4767s\n", "2020-02-14 09:11:09,852 Epoch 1 Step: 179100 Batch Loss: 1.129381 Tokens per Sec: 21899, Lr: 0.000300\n", "2020-02-14 09:11:21,217 Epoch 1 Step: 179200 Batch Loss: 1.389105 Tokens per Sec: 22531, Lr: 0.000300\n", "2020-02-14 09:11:32,553 Epoch 1 Step: 179300 Batch Loss: 1.237211 Tokens per Sec: 21578, Lr: 0.000300\n", "2020-02-14 09:11:44,079 Epoch 1 Step: 179400 Batch Loss: 1.298432 Tokens per Sec: 21921, Lr: 0.000300\n", "2020-02-14 09:11:55,498 Epoch 1 Step: 179500 Batch Loss: 1.340777 Tokens per Sec: 21460, Lr: 0.000300\n", "2020-02-14 09:12:06,984 Epoch 1 Step: 179600 Batch Loss: 1.040521 Tokens per Sec: 21952, Lr: 0.000300\n", "2020-02-14 09:12:18,255 Epoch 1 Step: 179700 Batch Loss: 1.265535 Tokens per Sec: 21871, Lr: 0.000300\n", "2020-02-14 09:12:29,780 Epoch 1 Step: 179800 Batch Loss: 1.098928 Tokens per Sec: 22026, Lr: 0.000300\n", "2020-02-14 09:12:41,191 Epoch 1 Step: 179900 Batch Loss: 1.009815 Tokens per Sec: 21883, Lr: 0.000300\n", "2020-02-14 09:12:52,558 Epoch 1 Step: 180000 Batch Loss: 1.302110 Tokens per Sec: 21565, Lr: 0.000300\n", "2020-02-14 09:13:11,606 Example #0\n", "2020-02-14 09:13:11,606 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:13:11,606 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:13:11,606 \tHypothesis: konteraka ya diranta tše dimilione tše e saenwa ke molaodi wa hockey ka nywaga e tshela\n", "2020-02-14 09:13:11,606 Example #1\n", "2020-02-14 09:13:11,607 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:13:11,607 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:13:11,607 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:13:11,607 Example #2\n", "2020-02-14 09:13:11,607 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:13:11,607 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:13:11,607 \tHypothesis: : — paulo o ile a dira keno efe ?\n", "2020-02-14 09:13:11,607 Example #3\n", "2020-02-14 09:13:11,607 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:13:11,607 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:13:11,607 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:13:11,607 Validation result (greedy) at epoch 1, step 180000: bleu: 44.55, loss: 28018.4434, ppl: 2.5968, duration: 19.0487s\n", "2020-02-14 09:13:23,021 Epoch 1 Step: 180100 Batch Loss: 0.914520 Tokens per Sec: 22192, Lr: 0.000300\n", "2020-02-14 09:13:34,476 Epoch 1 Step: 180200 Batch Loss: 1.122637 Tokens per Sec: 22254, Lr: 0.000300\n", "2020-02-14 09:13:45,941 Epoch 1 Step: 180300 Batch Loss: 1.204203 Tokens per Sec: 21537, Lr: 0.000300\n", "2020-02-14 09:13:57,253 Epoch 1 Step: 180400 Batch Loss: 1.120760 Tokens per Sec: 21585, Lr: 0.000300\n", "2020-02-14 09:14:08,787 Epoch 1 Step: 180500 Batch Loss: 1.044424 Tokens per Sec: 21421, Lr: 0.000300\n", "2020-02-14 09:14:20,074 Epoch 1 Step: 180600 Batch Loss: 1.145219 Tokens per Sec: 21999, Lr: 0.000300\n", "2020-02-14 09:14:31,628 Epoch 1 Step: 180700 Batch Loss: 1.191535 Tokens per Sec: 21569, Lr: 0.000300\n", "2020-02-14 09:14:43,038 Epoch 1 Step: 180800 Batch Loss: 1.038063 Tokens per Sec: 21578, Lr: 0.000300\n", "2020-02-14 09:14:54,427 Epoch 1 Step: 180900 Batch Loss: 1.098899 Tokens per Sec: 21418, Lr: 0.000300\n", "2020-02-14 09:15:05,954 Epoch 1 Step: 181000 Batch Loss: 1.252185 Tokens per Sec: 22024, Lr: 0.000300\n", "2020-02-14 09:15:24,396 Example #0\n", "2020-02-14 09:15:24,397 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:15:24,397 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:15:24,397 \tHypothesis: konteraka ya diranta tše dimilione tše e hlamilwe ke morekiši yo a etelelago pele wa hockey ka nywaga e tshelelago\n", "2020-02-14 09:15:24,397 Example #1\n", "2020-02-14 09:15:24,397 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:15:24,397 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:15:24,397 \tHypothesis: go sa dutše go le bjalo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:15:24,397 Example #2\n", "2020-02-14 09:15:24,397 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:15:24,397 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:15:24,397 \tHypothesis: : — paulo o ile a dira keno efe ?\n", "2020-02-14 09:15:24,397 Example #3\n", "2020-02-14 09:15:24,397 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:15:24,398 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:15:24,398 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:15:24,398 Validation result (greedy) at epoch 1, step 181000: bleu: 44.40, loss: 28150.8887, ppl: 2.6085, duration: 18.4431s\n", "2020-02-14 09:15:35,872 Epoch 1 Step: 181100 Batch Loss: 1.101133 Tokens per Sec: 22088, Lr: 0.000300\n", "2020-02-14 09:15:47,473 Epoch 1 Step: 181200 Batch Loss: 0.925666 Tokens per Sec: 21603, Lr: 0.000300\n", "2020-02-14 09:15:58,986 Epoch 1 Step: 181300 Batch Loss: 1.190559 Tokens per Sec: 22333, Lr: 0.000300\n", "2020-02-14 09:16:10,460 Epoch 1 Step: 181400 Batch Loss: 1.071086 Tokens per Sec: 21886, Lr: 0.000300\n", "2020-02-14 09:16:21,860 Epoch 1 Step: 181500 Batch Loss: 1.023793 Tokens per Sec: 21589, Lr: 0.000300\n", "2020-02-14 09:16:33,330 Epoch 1 Step: 181600 Batch Loss: 1.284564 Tokens per Sec: 21820, Lr: 0.000300\n", "2020-02-14 09:16:44,830 Epoch 1 Step: 181700 Batch Loss: 1.678303 Tokens per Sec: 21612, Lr: 0.000300\n", "2020-02-14 09:16:56,234 Epoch 1 Step: 181800 Batch Loss: 1.165438 Tokens per Sec: 21669, Lr: 0.000300\n", "2020-02-14 09:17:07,638 Epoch 1 Step: 181900 Batch Loss: 1.083315 Tokens per Sec: 21741, Lr: 0.000300\n", "2020-02-14 09:17:18,956 Epoch 1 Step: 182000 Batch Loss: 1.040282 Tokens per Sec: 22058, Lr: 0.000300\n", "2020-02-14 09:17:37,373 Example #0\n", "2020-02-14 09:17:37,374 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:17:37,374 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:17:37,374 \tHypothesis: tumelelano ya diranta tše dimilione tše e hlamilwe ke molaodi yo a etelelago pele wa hockey ka nywaga e tshelelago\n", "2020-02-14 09:17:37,374 Example #1\n", "2020-02-14 09:17:37,374 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:17:37,374 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:17:37,374 \tHypothesis: ka nako yeo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:17:37,374 Example #2\n", "2020-02-14 09:17:37,375 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:17:37,375 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:17:37,375 \tHypothesis: : — paulo o ile a dira keno efe ?\n", "2020-02-14 09:17:37,375 Example #3\n", "2020-02-14 09:17:37,375 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:17:37,375 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:17:37,375 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:17:37,375 Validation result (greedy) at epoch 1, step 182000: bleu: 44.51, loss: 27877.4551, ppl: 2.5843, duration: 18.4183s\n", "2020-02-14 09:17:48,878 Epoch 1 Step: 182100 Batch Loss: 1.658979 Tokens per Sec: 21147, Lr: 0.000300\n", "2020-02-14 09:18:00,337 Epoch 1 Step: 182200 Batch Loss: 1.074214 Tokens per Sec: 22047, Lr: 0.000300\n", "2020-02-14 09:18:11,786 Epoch 1 Step: 182300 Batch Loss: 1.030178 Tokens per Sec: 21561, Lr: 0.000300\n", "2020-02-14 09:18:23,139 Epoch 1 Step: 182400 Batch Loss: 1.033017 Tokens per Sec: 21445, Lr: 0.000300\n", "2020-02-14 09:18:34,574 Epoch 1 Step: 182500 Batch Loss: 1.106261 Tokens per Sec: 21178, Lr: 0.000300\n", "2020-02-14 09:18:46,055 Epoch 1 Step: 182600 Batch Loss: 1.240107 Tokens per Sec: 21443, Lr: 0.000300\n", "2020-02-14 09:18:57,477 Epoch 1 Step: 182700 Batch Loss: 1.132737 Tokens per Sec: 22105, Lr: 0.000300\n", "2020-02-14 09:19:09,169 Epoch 1 Step: 182800 Batch Loss: 1.024013 Tokens per Sec: 21172, Lr: 0.000300\n", "2020-02-14 09:19:20,582 Epoch 1 Step: 182900 Batch Loss: 1.141237 Tokens per Sec: 21745, Lr: 0.000300\n", "2020-02-14 09:19:31,839 Epoch 1 Step: 183000 Batch Loss: 1.113522 Tokens per Sec: 21353, Lr: 0.000300\n", "2020-02-14 09:19:50,302 Example #0\n", "2020-02-14 09:19:50,302 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:19:50,302 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:19:50,302 \tHypothesis: konteraka ya diranta tše dimilione tše e hlamilwe ke morekiši yo a etelelago pele wa hockey ka nywaga e tshelelago\n", "2020-02-14 09:19:50,302 Example #1\n", "2020-02-14 09:19:50,302 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:19:50,302 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:19:50,303 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o bile mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:19:50,303 Example #2\n", "2020-02-14 09:19:50,303 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:19:50,303 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:19:50,303 \tHypothesis: : — paulo o dirile keno efe ?\n", "2020-02-14 09:19:50,303 Example #3\n", "2020-02-14 09:19:50,303 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:19:50,303 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:19:50,303 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:19:50,303 Validation result (greedy) at epoch 1, step 183000: bleu: 44.49, loss: 27877.2988, ppl: 2.5843, duration: 18.4640s\n", "2020-02-14 09:20:01,618 Epoch 1 Step: 183100 Batch Loss: 1.130584 Tokens per Sec: 21325, Lr: 0.000210\n", "2020-02-14 09:20:13,197 Epoch 1 Step: 183200 Batch Loss: 1.291446 Tokens per Sec: 21131, Lr: 0.000210\n", "2020-02-14 09:20:24,581 Epoch 1 Step: 183300 Batch Loss: 1.460803 Tokens per Sec: 22206, Lr: 0.000210\n", "2020-02-14 09:20:35,873 Epoch 1 Step: 183400 Batch Loss: 1.178174 Tokens per Sec: 21599, Lr: 0.000210\n", "2020-02-14 09:20:47,458 Epoch 1 Step: 183500 Batch Loss: 0.976318 Tokens per Sec: 21957, Lr: 0.000210\n", "2020-02-14 09:20:49,345 Epoch 1: total training loss 7535.66\n", "2020-02-14 09:20:49,345 EPOCH 2\n", "2020-02-14 09:20:59,477 Epoch 2 Step: 183600 Batch Loss: 0.988506 Tokens per Sec: 20447, Lr: 0.000210\n", "2020-02-14 09:21:10,938 Epoch 2 Step: 183700 Batch Loss: 1.338627 Tokens per Sec: 21641, Lr: 0.000210\n", "2020-02-14 09:21:22,338 Epoch 2 Step: 183800 Batch Loss: 0.985906 Tokens per Sec: 22275, Lr: 0.000210\n", "2020-02-14 09:21:33,631 Epoch 2 Step: 183900 Batch Loss: 0.931342 Tokens per Sec: 21354, Lr: 0.000210\n", "2020-02-14 09:21:45,179 Epoch 2 Step: 184000 Batch Loss: 1.144215 Tokens per Sec: 21685, Lr: 0.000210\n", "2020-02-14 09:22:03,891 Example #0\n", "2020-02-14 09:22:03,891 \tSource: a $ - ​ million contract is signed by a leading hockey player for six years\n", "2020-02-14 09:22:03,891 \tReference: sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n", "2020-02-14 09:22:03,891 \tHypothesis: konteraka ya milione e saentšwe ke sebapadi se se etelelago pele sa go hloma magae ka nywaga e tshelelago\n", "2020-02-14 09:22:03,891 Example #1\n", "2020-02-14 09:22:03,892 \tSource: meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n", "2020-02-14 09:22:03,892 \tReference: go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:22:03,892 \tHypothesis: ka nako yeo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme a ba mogoeledi yo a sa kolobetšwago\n", "2020-02-14 09:22:03,892 Example #2\n", "2020-02-14 09:22:03,892 \tSource: : ​ — what vow did paul make ?\n", "2020-02-14 09:22:03,892 \tReference: : — ke keno efe yeo e dirilwego ke paulo ?\n", "2020-02-14 09:22:03,892 \tHypothesis: : — paulo o ile a dira keno efe ?\n", "2020-02-14 09:22:03,892 Example #3\n", "2020-02-14 09:22:03,892 \tSource: christian wives too can make their feelings known\n", "2020-02-14 09:22:03,892 \tReference: basadi ba bakriste le bona ba ka bolela maikwelo a bona\n", "2020-02-14 09:22:03,892 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n", "2020-02-14 09:22:03,892 Validation result (greedy) at epoch 2, step 184000: bleu: 44.62, loss: 27950.6074, ppl: 2.5908, duration: 18.7134s\n", "2020-02-14 09:22:15,249 Epoch 2 Step: 184100 Batch Loss: 1.069055 Tokens per Sec: 21314, Lr: 0.000210\n", "2020-02-14 09:22:26,663 Epoch 2 Step: 184200 Batch Loss: 0.996049 Tokens per Sec: 22156, Lr: 0.000210\n", "2020-02-14 09:22:38,107 Epoch 2 Step: 184300 Batch Loss: 1.425717 Tokens per Sec: 21802, Lr: 0.000210\n", "Traceback (most recent call last):\n", " File \"/usr/lib/python3.6/runpy.py\", line 193, in _run_module_as_main\n", " \"__main__\", mod_spec)\n", " File \"/usr/lib/python3.6/runpy.py\", line 85, in _run_code\n", " exec(code, run_globals)\n", " File \"/content/joeynmt/joeynmt/__main__.py\", line 41, in \n", " main()\n", " File \"/content/joeynmt/joeynmt/__main__.py\", line 29, in main\n", " train(cfg_file=args.config_path)\n", " File \"/content/joeynmt/joeynmt/training.py\", line 650, in train\n", " trainer.train_and_validate(train_data=train_data, valid_data=dev_data)\n", " File \"/content/joeynmt/joeynmt/training.py\", line 326, in train_and_validate\n", " batch, update=update, count=count)\n", " File \"/content/joeynmt/joeynmt/training.py\", line 500, in _train_batch\n", " norm_batch_loss.backward()\n", " File \"/usr/local/lib/python3.6/dist-packages/torch/tensor.py\", line 195, in backward\n", " torch.autograd.backward(self, gradient, retain_graph, create_graph)\n", " File \"/usr/local/lib/python3.6/dist-packages/torch/autograd/__init__.py\", line 99, in backward\n", " allow_unreachable=True) # allow_unreachable flag\n", "KeyboardInterrupt\n", "CPU times: user 2.47 s, sys: 336 ms, total: 2.81 s\n", "Wall time: 17min 3s\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "WSnJkoDCRtTY", "colab_type": "code", "colab": {} }, "source": [ "" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "UPMK6siVv2pt", "colab_type": "code", "colab": {} }, "source": [ "# Copy the created models from the notebook storage to google drive for persistant storage \n", "# !cp -r joeynmt/models/${src}${trg}${vocab_size}${tag}_transformer/* \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/\"\n", "!cp joeynmt/models/${src}${trg}${vocab_size}${tag}_transformer/*.ckpt \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "f38OFR8rJgUb", "colab_type": "code", "colab": {} }, "source": [ "# copy across the config file\n", "!cp joeynmt/configs/transformer_${src}${trg}${vocab_size}${tag}.yaml \"$gdrive_path\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "Tqc7ELUUyrMk", "colab_type": "code", "outputId": "f9db0597-2f1e-49c0-90d8-f51df6061a10", "colab": { "base_uri": "https://localhost:8080/", "height": 34 } }, "source": [ "!ls joeynmt/models" ], "execution_count": 35, "outputs": [ { "output_type": "stream", "text": [ "ennso4000baseline_transformer\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "a7Xj4vk2yKvz", "colab_type": "code", "outputId": "0ba26359-199f-4ed7-c432-0ced593f2e95", "colab": { "base_uri": "https://localhost:8080/", "height": 69 } }, "source": [ "# Test our model\n", "# ! cd joeynmt; python3 -m joeynmt test \"$gdrive_path\"\"transformer_${src}${trg}${vocab_size}${tag}.yaml\"\n", "! cd joeynmt; python3 -m joeynmt test \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config.yaml\"" ], "execution_count": 38, "outputs": [ { "output_type": "stream", "text": [ "2020-02-14 09:31:35,938 Hello! This is Joey-NMT.\n", "2020-02-14 09:32:14,148 dev bleu: 44.43 [Beam search decoding with beam size = 5 and alpha = 1.0]\n", "2020-02-14 09:33:21,929 test bleu: 15.40 [Beam search decoding with beam size = 5 and alpha = 1.0]\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "HBQ0vkOuLmCo", "colab_type": "code", "colab": {} }, "source": [ "# plot losses\n", "# ! cd joeynmt; python3 scripts/plot_validations.py \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/\" --plot_values bleu PPL --output bleu2-ppl.png" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "nep_QVw9iwmo", "colab_type": "code", "outputId": "6339b68c-a0aa-49f2-e61a-e6773debcc4b", "colab": { "base_uri": "https://localhost:8080/", "height": 54 } }, "source": [ "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config5_tok.yaml\"" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "cat: '/content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/config5_tok.yaml': No such file or directory\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "3Ms5xKfbv2tc", "colab_type": "code", "colab": {} }, "source": [ "" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "KBXt6BKvfOAE", "colab_type": "code", "outputId": "b8ffcaf7-3750-423a-92d0-5774b18d5887", "colab": { "base_uri": "https://localhost:8080/", "height": 245 } }, "source": [ "# Translate mode is mopre interactive but almsot the same as running in test mode\n", "! cd joeynmt; python3 -m joeynmt translate \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config_5sent.yaml\"" ], "execution_count": 0, "outputs": [ { "output_type": "stream", "text": [ "\n", "Please enter a source sentence (pre-processed): \n", " J@@ e@@ sus said : \" Y@@ o@@ u must love your neighbo@@ r as yourself . \n", "JoeyNMT: ▶ esus o itše : seou se swanetše go rata moagišani wa gago bjalo ka ge o ithata\n", "\n", "Please enter a source sentence (pre-processed): \n", " J@@ e@@ sus said : \" Y@@ o@@ u must love your neighbo@@ r as yourself . \n", "JoeyNMT: ▶ esus o itše : seou se swanetše go rata moagišani wa gago bjalo ka ge o ithata\n", "\n", "Please enter a source sentence (pre-processed): \n", "\n", "Bye.\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "puYoLngf4aCZ", "colab_type": "code", "colab": {} }, "source": [ "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config_5tok.yaml\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "rB9NAs2MhnVI", "colab_type": "code", "colab": {} }, "source": [ "# ! cat test.nso \n", "# ! echo \"=================================================\"\n", "# ! cat test.en" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "Pc2xgodBv2ys", "colab_type": "code", "colab": {} }, "source": [ "!# Output our validation accuracy\n", "# /content/drive/My Drive/masakhane/en-nso-baseline/train.nso\n", "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/validations.txt\"" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "N4qv69Ec0D0v", "colab_type": "code", "colab": {} }, "source": [ "" ], "execution_count": 0, "outputs": [] } ] }