This commit is contained in:
Emmanuel Awa 2020-07-06 03:44:46 +00:00
Родитель 52e751ac71
Коммит d6051810f2
1 изменённых файлов: 153 добавлений и 7 удалений

Просмотреть файл

@ -101,10 +101,121 @@
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "source": [
"Install MT-DNN package to run the notebook."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Obtaining mtdnn from git+git@github.com:microsoft/mt-dnn.git@master#egg=mtdnn\n",
"\u001b[33m DEPRECATION: This form of VCS requirement is being deprecated: git+git@github.com:microsoft/mt-dnn.git@master#egg=mtdnn. pip 21.0 will remove support for this functionality. A possible replacement is git+https://git@example.com/..., git+ssh://git@example.com/..., or the insecure git+git://git@example.com/.... You can find discussion regarding this at https://github.com/pypa/pip/issues/7554.\u001b[0m\n",
" Updating ./src/mtdnn clone (to revision master)\n",
" Running command git fetch -q --tags\n",
" Running command git reset --hard -q e5c3e07f3a8e55067433714ce261a6d28ba73d22\n",
"Requirement already satisfied: numpy in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (1.18.1)\n",
"Requirement already satisfied: torch==1.4.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (1.4.0)\n",
"Requirement already satisfied: tqdm in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (4.32.2)\n",
"Requirement already satisfied: colorlog in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (4.1.0)\n",
"Requirement already satisfied: boto3 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (1.12.26)\n",
"Requirement already satisfied: pytorch-pretrained-bert==0.6.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.6.0)\n",
"Requirement already satisfied: regex in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (2020.2.20)\n",
"Requirement already satisfied: scikit-learn in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.20.3)\n",
"Requirement already satisfied: pyyaml in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (5.3.1)\n",
"Requirement already satisfied: pytest in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (5.4.3)\n",
"Requirement already satisfied: sentencepiece in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.1.85)\n",
"Requirement already satisfied: tensorboardX in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (1.8)\n",
"Requirement already satisfied: tensorboard in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (1.15.0)\n",
"Requirement already satisfied: future in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.18.2)\n",
"Requirement already satisfied: fairseq==0.8.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.8.0)\n",
"Requirement already satisfied: seqeval==0.0.12 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (0.0.12)\n",
"Requirement already satisfied: transformers==2.9.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from mtdnn) (2.9.0)\n",
"Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from boto3->mtdnn) (0.9.5)\n",
"Requirement already satisfied: botocore<1.16.0,>=1.15.26 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from boto3->mtdnn) (1.15.26)\n",
"Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from boto3->mtdnn) (0.3.3)\n",
"Requirement already satisfied: requests in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytorch-pretrained-bert==0.6.0->mtdnn) (2.23.0)\n",
"Requirement already satisfied: scipy>=0.13.3 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from scikit-learn->mtdnn) (1.5.0)\n",
"Requirement already satisfied: py>=1.5.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (1.8.1)\n",
"Requirement already satisfied: packaging in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (20.3)\n",
"Requirement already satisfied: attrs>=17.4.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (19.3.0)\n",
"Requirement already satisfied: more-itertools>=4.0.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (8.2.0)\n",
"Requirement already satisfied: pluggy<1.0,>=0.12 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (0.13.1)\n",
"Requirement already satisfied: wcwidth in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (0.1.8)\n",
"Requirement already satisfied: importlib-metadata>=0.12 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from pytest->mtdnn) (1.5.0)\n",
"Requirement already satisfied: six in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboardX->mtdnn) (1.14.0)\n",
"Requirement already satisfied: protobuf>=3.2.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboardX->mtdnn) (3.11.4)\n",
"Requirement already satisfied: markdown>=2.6.8 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (3.1.1)\n",
"Requirement already satisfied: absl-py>=0.4 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (0.9.0)\n",
"Requirement already satisfied: setuptools>=41.0.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (46.1.1.post20200323)\n",
"Requirement already satisfied: grpcio>=1.6.3 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (1.27.2)\n",
"Requirement already satisfied: werkzeug>=0.11.15 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (0.16.1)\n",
"Requirement already satisfied: wheel>=0.26; python_version >= \"3\" in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from tensorboard->mtdnn) (0.30.0)\n",
"Requirement already satisfied: fastBPE in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from fairseq==0.8.0->mtdnn) (0.1.0)\n",
"Requirement already satisfied: sacrebleu in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from fairseq==0.8.0->mtdnn) (1.4.9)\n",
"Requirement already satisfied: cffi in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from fairseq==0.8.0->mtdnn) (1.14.0)\n",
"Requirement already satisfied: Keras>=2.2.4 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from seqeval==0.0.12->mtdnn) (2.3.1)\n",
"Requirement already satisfied: tokenizers==0.7.0 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from transformers==2.9.0->mtdnn) (0.7.0)\n",
"Requirement already satisfied: dataclasses; python_version < \"3.7\" in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from transformers==2.9.0->mtdnn) (0.7)\n",
"Requirement already satisfied: filelock in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from transformers==2.9.0->mtdnn) (3.0.12)\n",
"Requirement already satisfied: sacremoses in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from transformers==2.9.0->mtdnn) (0.0.38)\n",
"Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from botocore<1.16.0,>=1.15.26->boto3->mtdnn) (2.8.1)\n",
"Requirement already satisfied: docutils<0.16,>=0.10 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from botocore<1.16.0,>=1.15.26->boto3->mtdnn) (0.15.2)\n",
"Requirement already satisfied: urllib3<1.26,>=1.20; python_version != \"3.4\" in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from botocore<1.16.0,>=1.15.26->boto3->mtdnn) (1.25.8)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from requests->pytorch-pretrained-bert==0.6.0->mtdnn) (2020.6.20)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from requests->pytorch-pretrained-bert==0.6.0->mtdnn) (3.0.4)\n",
"Requirement already satisfied: idna<3,>=2.5 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from requests->pytorch-pretrained-bert==0.6.0->mtdnn) (2.9)\n",
"Requirement already satisfied: pyparsing>=2.0.2 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from packaging->pytest->mtdnn) (2.4.6)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: zipp>=0.5 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from importlib-metadata>=0.12->pytest->mtdnn) (2.2.0)\n",
"Requirement already satisfied: portalocker in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from sacrebleu->fairseq==0.8.0->mtdnn) (1.7.0)\n",
"Requirement already satisfied: typing in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from sacrebleu->fairseq==0.8.0->mtdnn) (3.7.4.1)\n",
"Requirement already satisfied: pycparser in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from cffi->fairseq==0.8.0->mtdnn) (2.20)\n",
"Requirement already satisfied: keras-applications>=1.0.6 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from Keras>=2.2.4->seqeval==0.0.12->mtdnn) (1.0.8)\n",
"Requirement already satisfied: keras-preprocessing>=1.0.5 in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from Keras>=2.2.4->seqeval==0.0.12->mtdnn) (1.1.0)\n",
"Requirement already satisfied: h5py in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from Keras>=2.2.4->seqeval==0.0.12->mtdnn) (2.10.0)\n",
"Requirement already satisfied: click in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from sacremoses->transformers==2.9.0->mtdnn) (7.1.1)\n",
"Requirement already satisfied: joblib in /home/useradmin/miniconda3/envs/nlp_gpu/lib/python3.6/site-packages (from sacremoses->transformers==2.9.0->mtdnn) (0.14.1)\n",
"Installing collected packages: mtdnn\n",
" Attempting uninstall: mtdnn\n",
" Found existing installation: mtdnn 1.1.0\n",
" Uninstalling mtdnn-1.1.0:\n",
" Successfully uninstalled mtdnn-1.1.0\n",
" Running setup.py develop for mtdnn\n",
"Successfully installed mtdnn\n"
]
}
],
"source": [
"!pip install -e git+git@github.com:microsoft/mt-dnn.git@master#egg=mtdnn"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [ "source": [
"%load_ext autoreload\n", "%load_ext autoreload\n",
"%autoreload 2" "%autoreload 2"
@ -112,10 +223,45 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 45, "execution_count": 18,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'mtdnn'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-c98d0d7f644d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mimport_ipynb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmtdnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommon\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtypes\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mEncoderModelType\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'mtdnn'"
]
}
],
"source": [ "source": [
"import import_ipynb\n",
"from mtdnn.common.types import EncoderModelType"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'mtdnn'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-16-7526f74c0780>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mutils_nlp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmultinli\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdownload_tsv_files_and_extract\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmtdnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommon\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtypes\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mEncoderModelType\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmtdnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconfiguration_mtdnn\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mMTDNNConfig\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmtdnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_builder_mtdnn\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mMTDNNDataBuilder\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'mtdnn'"
]
}
],
"source": [
"import import_ipynb\n",
"import json\n", "import json\n",
"import os\n", "import os\n",
"import shutil\n", "import shutil\n",
@ -125,14 +271,14 @@
"import pandas as pd\n", "import pandas as pd\n",
"import torch\n", "import torch\n",
"\n", "\n",
"from utils_nlp.dataset.multinli import download_tsv_files_and_extract\n",
"from mtdnn.common.types import EncoderModelType\n", "from mtdnn.common.types import EncoderModelType\n",
"from mtdnn.configuration_mtdnn import MTDNNConfig\n", "from mtdnn.configuration_mtdnn import MTDNNConfig\n",
"from mtdnn.data_builder_mtdnn import MTDNNDataBuilder\n", "from mtdnn.data_builder_mtdnn import MTDNNDataBuilder\n",
"from mtdnn.modeling_mtdnn import MTDNNModel\n", "from mtdnn.modeling_mtdnn import MTDNNModel\n",
"from mtdnn.process_mtdnn import MTDNNDataProcess\n", "from mtdnn.process_mtdnn import MTDNNDataProcess\n",
"from mtdnn.tasks.config import MTDNNTaskDefs\n", "from mtdnn.tasks.config import MTDNNTaskDefs\n",
"from mtdnn.tokenizer_mtdnn import MTDNNTokenizer\n", "from mtdnn.tokenizer_mtdnn import MTDNNTokenizer"
"from utils_nlp.dataset.multinli import download_tsv_files_and_extract"
] ]
}, },
{ {