{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "-7MeFJtNalS2" }, "source": [ "## sklearn and TextAttack\n", "\n", "This following code trains two different text classification models using sklearn. Both use logistic regression models: the difference is in the features. \n", "\n", "We will load data using `datasets`, train the models, and attack them using TextAttack." ] }, { "cell_type": "markdown", "metadata": { "id": "sFR3zFvBalS3" }, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/QData/TextAttack/blob/master/docs/2notebook/Example_1_sklearn.ipynb)\n", "\n", "[![View Source on GitHub](https://img.shields.io/badge/github-view%20source-black.svg)](https://github.com/QData/TextAttack/blob/master/docs/2notebook/Example_1_sklearn.ipynb)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "tl0ecB41E75i", "outputId": "b2f29b4c-76fa-42b6-d4e2-9e0407802d7c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: datasets in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (1.6.1)\n", "Requirement already satisfied: nltk in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (3.6.2)\n", "Requirement already satisfied: sklearn in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (0.0)\n", "Requirement already satisfied: multiprocess in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (0.70.11.1)\n", "Requirement already satisfied: packaging in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (20.9)\n", "Requirement already satisfied: xxhash in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (2.0.2)\n", "Requirement already satisfied: numpy>=1.17 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (1.18.5)\n", "Requirement already satisfied: pyarrow>=1.0.0 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (4.0.0)\n", "Requirement already satisfied: dill in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (0.3.3)\n", "Requirement already satisfied: requests>=2.19.0 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (2.25.1)\n", "Requirement already satisfied: tqdm<4.50.0,>=4.27 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (4.49.0)\n", "Requirement already satisfied: huggingface-hub<0.1.0 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (0.0.8)\n", "Requirement already satisfied: pandas in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (1.2.4)\n", "Requirement already satisfied: fsspec in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from datasets) (2021.4.0)\n", "Requirement already satisfied: filelock in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from huggingface-hub<0.1.0->datasets) (3.0.12)\n", "Requirement already satisfied: certifi>=2017.4.17 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from requests>=2.19.0->datasets) (2020.12.5)\n", "Requirement already satisfied: idna<3,>=2.5 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from requests>=2.19.0->datasets) (2.10)\n", "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from requests>=2.19.0->datasets) (1.26.4)\n", "Requirement already satisfied: chardet<5,>=3.0.2 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from requests>=2.19.0->datasets) (4.0.0)\n", "Requirement already satisfied: regex in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from nltk) (2021.4.4)\n", "Requirement already satisfied: click in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from nltk) (7.1.2)\n", "Requirement already satisfied: joblib in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from nltk) (1.0.1)\n", "Requirement already satisfied: scikit-learn in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from sklearn) (0.24.2)\n", "Requirement already satisfied: pyparsing>=2.0.2 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from packaging->datasets) (2.4.7)\n", "Requirement already satisfied: python-dateutil>=2.7.3 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from pandas->datasets) (2.8.1)\n", "Requirement already satisfied: pytz>=2017.3 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from pandas->datasets) (2021.1)\n", "Requirement already satisfied: six>=1.5 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas->datasets) (1.15.0)\n", "Requirement already satisfied: scipy>=0.19.1 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from scikit-learn->sklearn) (1.4.1)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in /p/qdata/jy2ma/miniconda3/envs/textattack-dev/lib/python3.8/site-packages (from scikit-learn->sklearn) (2.1.0)\n" ] } ], "source": [ "!pip install datasets nltk sklearn" ] }, { "cell_type": "markdown", "metadata": { "id": "BWh7ZuC3alS4" }, "source": [ "Please remember to run **pip3 install textattack[tensorflow]** in your notebook enviroment before the following codes:\n", "\n", "### Training\n", "\n", "This code trains two models: one on bag-of-words statistics (`bow_unstemmed`) and one on tf–idf statistics (`tfidf_unstemmed`). The dataset is the IMDB movie review dataset." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "GJrB3uszalS4", "outputId": "a01b9222-1458-4066-eb24-54443f3499cc" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[nltk_data] Downloading package punkt to /u/lab/jy2ma/nltk_data...\n", "[nltk_data] Package punkt is already up-to-date!\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import nltk # the Natural Language Toolkit\n", "\n", "nltk.download(\"punkt\") # The NLTK tokenizer" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 771, "referenced_widgets": [ "c5757ae743174906b6ac3f457c92883a", "7b23e4bfbfc94e6681861fd2274de8da", "b0f06f7a72d745538bea5f1c13492515", "564ded437808498cba5da3a878643101", "7104ef4572fa4a48a3396c85a625a23d", "f5240170070e46d09891d54e01e68c5d", "eedf56dbdee24a6b852f6fcd380b72df", "8fc8fe3403914dbab689912446015d7e", "de657f0bdef34ed48d01acb0f34d87fd", "3f4aab5e789749bf837ca9d14bafc174", "0bdf019b433a4d56aeb22550a29d066b", "9abf2d1285f94d87a0f962243c7c4a2f", "8a4fb534ea1547da8da4f49f415cea54", "2d11de1950d942f79328e9ac6666f7d6", "55b82241ad3f418f8b53f1d45ec9e063", "e36e821ec7164d58a7d885d47b06002d", "ed5d8cef24e5427b94818f4d0ce8d52e", "aa2fb2f9c23b445db52a56d634f68ddf", "f319de77f1cb4d03b8a0287a6744f8b2", "a4b27d2752a7412a8742aa6eb8523f5d", "90cc2ff6a65c446a829ff98579036ec1", "d3b5d32a5063424c93be106077a78c16", "ad093103eb2c44e4b1ce003f1164a113", "851bd4eaf00040baba7657df5eecb469", "5ea7a4eca39b40b1b78457db00a454bd", "6e65f9ee0ccc407680d2f56dca5d1e34", "ec5828528e6c4135b1a971c81bbaf0d0", "a5319932f2a845dd81534dad6bc9277b", "7655027152994c549202c02bf9514c73", "3b352536f852428891f47bec9a85de06", "8e77f192800d4239a3e31a56989adc64", "8bdc81b8109a4f3a88ea06abf1b7edae", "14d049de0e6b4361b31649738ed1f30e", "67213a9e8d1e4eef82d5a6066b372f67", "a547aa3b535648759aa3b4e24fef4a0b", "a67d6c2ec24145ddbf77ce0230a7b601", "e58e73fd1b7c4e4ea9f43757875bd3ec", "7b51dd57afb048d583e591af1d0a206e", "dbbc6c67ed6543328c2a3108724080ba", "d874dcaaefd9494eb087e7565a4e18c7", "12e6bf4bd4f94616b986e982ef91387b", "e227337e4f7e4071b1524dc2c4a684c1", "341adbff6245494e9895e18a07518179", "8b211e3a7b4c4e04bdd5838c3b796708", "d3b82204a9344f889adc18e7ab415269", "949928e3a1f646ff8681a591f80cf214", "e4878535c150446cb21f1452004b3cdf", "90c83abc28de409ba5bdc4dbd9db07e6" ] }, "id": "0E3gGgXfalS5", "outputId": "93a8a7d9-fde3-453d-bdd5-e2d0fd044fd1" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using custom data configuration default\n", "Reusing dataset rotten_tomatoes_movie_review (/u/lab/jy2ma/.cache/huggingface/datasets/rotten_tomatoes_movie_review/default/1.0.0/9c411f7ecd9f3045389de0d9ce984061a1056507703d2e3183b1ac1a90816e4d)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "...successfully loaded training data\n", "Total length of training data: 8530\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Using custom data configuration default\n", "Reusing dataset rotten_tomatoes_movie_review (/u/lab/jy2ma/.cache/huggingface/datasets/rotten_tomatoes_movie_review/default/1.0.0/9c411f7ecd9f3045389de0d9ce984061a1056507703d2e3183b1ac1a90816e4d)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "...augmented data with len_tokens and average_words\n", "...successfully loaded testing data\n", "Total length of testing data: 1066\n", "...augmented data with len_tokens and average_words\n", "...successfully created the unstemmed BOW data\n", "...successfully created the unstemmed TFIDF data\n", "Training accuracy of BOW Unstemmed: 0.6193434935521688\n", "Testing accuracy of BOW Unstemmed: 0.6031894934333959\n", " precision recall f1-score support\n", "\n", " 0 0.59 0.69 0.63 533\n", " 1 0.62 0.52 0.57 533\n", "\n", " accuracy 0.60 1066\n", " macro avg 0.61 0.60 0.60 1066\n", "weighted avg 0.61 0.60 0.60 1066\n", "\n", "Training accuracy of TFIDF Unstemmed: 0.6220398593200469\n", "Testing accuracy of TFIDF Unstemmed: 0.6088180112570356\n", " precision recall f1-score support\n", "\n", " 0 0.60 0.67 0.63 533\n", " 1 0.62 0.54 0.58 533\n", "\n", " accuracy 0.61 1066\n", " macro avg 0.61 0.61 0.61 1066\n", "weighted avg 0.61 0.61 0.61 1066\n", "\n" ] } ], "source": [ "import datasets\n", "import os\n", "import pandas as pd\n", "import re\n", "from nltk import word_tokenize\n", "from nltk.stem import PorterStemmer\n", "from sklearn.feature_extraction.text import CountVectorizer, ENGLISH_STOP_WORDS\n", "from sklearn import preprocessing\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.linear_model import LogisticRegression\n", "\n", "# Nice to see additional metrics\n", "from sklearn.metrics import classification_report\n", "\n", "\n", "def load_data(dataset_split=\"train\"):\n", " dataset = datasets.load_dataset(\"rotten_tomatoes\")[dataset_split]\n", " # Open and import positve data\n", " df = pd.DataFrame()\n", " df[\"Review\"] = [review[\"text\"] for review in dataset]\n", " df[\"Sentiment\"] = [review[\"label\"] for review in dataset]\n", " # Remove non-alphanumeric characters\n", " df[\"Review\"] = df[\"Review\"].apply(lambda x: re.sub(\"[^a-zA-Z]\", \" \", str(x)))\n", " # Tokenize the training and testing data\n", " df_tokenized = tokenize_review(df)\n", " return df_tokenized\n", "\n", "\n", "def tokenize_review(df):\n", " # Tokenize Reviews in training\n", " tokened_reviews = [word_tokenize(rev) for rev in df[\"Review\"]]\n", " # Create word stems\n", " stemmed_tokens = []\n", " porter = PorterStemmer()\n", " for i in range(len(tokened_reviews)):\n", " stems = [porter.stem(token) for token in tokened_reviews[i]]\n", " stems = \" \".join(stems)\n", " stemmed_tokens.append(stems)\n", " df.insert(1, column=\"Stemmed\", value=stemmed_tokens)\n", " return df\n", "\n", "\n", "def transform_BOW(training, testing, column_name):\n", " vect = CountVectorizer(\n", " max_features=100, ngram_range=(1, 3), stop_words=ENGLISH_STOP_WORDS\n", " )\n", " vectFit = vect.fit(training[column_name])\n", " BOW_training = vectFit.transform(training[column_name])\n", " BOW_training_df = pd.DataFrame(\n", " BOW_training.toarray(), columns=vect.get_feature_names()\n", " )\n", " BOW_testing = vectFit.transform(testing[column_name])\n", " BOW_testing_Df = pd.DataFrame(\n", " BOW_testing.toarray(), columns=vect.get_feature_names()\n", " )\n", " return vectFit, BOW_training_df, BOW_testing_Df\n", "\n", "\n", "def transform_tfidf(training, testing, column_name):\n", " Tfidf = TfidfVectorizer(\n", " ngram_range=(1, 3), max_features=100, stop_words=ENGLISH_STOP_WORDS\n", " )\n", " Tfidf_fit = Tfidf.fit(training[column_name])\n", " Tfidf_training = Tfidf_fit.transform(training[column_name])\n", " Tfidf_training_df = pd.DataFrame(\n", " Tfidf_training.toarray(), columns=Tfidf.get_feature_names()\n", " )\n", " Tfidf_testing = Tfidf_fit.transform(testing[column_name])\n", " Tfidf_testing_df = pd.DataFrame(\n", " Tfidf_testing.toarray(), columns=Tfidf.get_feature_names()\n", " )\n", " return Tfidf_fit, Tfidf_training_df, Tfidf_testing_df\n", "\n", "\n", "def add_augmenting_features(df):\n", " tokened_reviews = [word_tokenize(rev) for rev in df[\"Review\"]]\n", " # Create feature that measures length of reviews\n", " len_tokens = []\n", " for i in range(len(tokened_reviews)):\n", " len_tokens.append(len(tokened_reviews[i]))\n", " len_tokens = preprocessing.scale(len_tokens)\n", " df.insert(0, column=\"Lengths\", value=len_tokens)\n", "\n", " # Create average word length (training)\n", " Average_Words = [len(x) / (len(x.split())) for x in df[\"Review\"].tolist()]\n", " Average_Words = preprocessing.scale(Average_Words)\n", " df[\"averageWords\"] = Average_Words\n", " return df\n", "\n", "\n", "def build_model(X_train, y_train, X_test, y_test, name_of_test):\n", " log_reg = LogisticRegression(C=30, max_iter=200).fit(X_train, y_train)\n", " y_pred = log_reg.predict(X_test)\n", " print(\n", " \"Training accuracy of \" + name_of_test + \": \", log_reg.score(X_train, y_train)\n", " )\n", " print(\"Testing accuracy of \" + name_of_test + \": \", log_reg.score(X_test, y_test))\n", " print(classification_report(y_test, y_pred)) # Evaluating prediction ability\n", " return log_reg\n", "\n", "\n", "# Load training and test sets\n", "# Loading reviews into DF\n", "df_train = load_data(\"train\")\n", "\n", "print(\"...successfully loaded training data\")\n", "print(\"Total length of training data: \", len(df_train))\n", "# Add augmenting features\n", "df_train = add_augmenting_features(df_train)\n", "print(\"...augmented data with len_tokens and average_words\")\n", "\n", "# Load test DF\n", "df_test = load_data(\"test\")\n", "\n", "print(\"...successfully loaded testing data\")\n", "print(\"Total length of testing data: \", len(df_test))\n", "df_test = add_augmenting_features(df_test)\n", "print(\"...augmented data with len_tokens and average_words\")\n", "\n", "# Create unstemmed BOW features for training set\n", "unstemmed_BOW_vect_fit, df_train_bow_unstem, df_test_bow_unstem = transform_BOW(\n", " df_train, df_test, \"Review\"\n", ")\n", "print(\"...successfully created the unstemmed BOW data\")\n", "\n", "# Create TfIdf features for training set\n", "unstemmed_tfidf_vect_fit, df_train_tfidf_unstem, df_test_tfidf_unstem = transform_tfidf(\n", " df_train, df_test, \"Review\"\n", ")\n", "print(\"...successfully created the unstemmed TFIDF data\")\n", "\n", "# Running logistic regression on dataframes\n", "bow_unstemmed = build_model(\n", " df_train_bow_unstem,\n", " df_train[\"Sentiment\"],\n", " df_test_bow_unstem,\n", " df_test[\"Sentiment\"],\n", " \"BOW Unstemmed\",\n", ")\n", "\n", "tfidf_unstemmed = build_model(\n", " df_train_tfidf_unstem,\n", " df_train[\"Sentiment\"],\n", " df_test_tfidf_unstem,\n", " df_test[\"Sentiment\"],\n", " \"TFIDF Unstemmed\",\n", ")" ] }, { "cell_type": "markdown", "metadata": { "id": "m_T3Q5vralS6" }, "source": [ "### Attacking\n", "\n", "TextAttack includes a build-in `SklearnModelWrapper` that can run attacks on most sklearn models. (If your tokenization strategy is different than above, you may need to subclass `SklearnModelWrapper` to make sure the model inputs & outputs come in the correct format.)\n", "\n", "Once we initializes the model wrapper, we load a few samples from the IMDB dataset and run the `TextFoolerJin2019` attack on our model." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "aIrD_agKalS7" }, "outputs": [], "source": [ "from textattack.models.wrappers import SklearnModelWrapper\n", "\n", "model_wrapper = SklearnModelWrapper(bow_unstemmed, unstemmed_BOW_vect_fit)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "JBn5q7WCalS7", "outputId": "0482ae48-187a-4d62-d33f-01a00e69f40d" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using custom data configuration default\n", "Reusing dataset rotten_tomatoes_movie_review (/u/lab/jy2ma/.cache/huggingface/datasets/rotten_tomatoes_movie_review/default/1.0.0/9c411f7ecd9f3045389de0d9ce984061a1056507703d2e3183b1ac1a90816e4d)\n", "textattack: Loading \u001b[94mdatasets\u001b[0m dataset \u001b[94mrotten_tomatoes\u001b[0m, split \u001b[94mtrain\u001b[0m.\n", "textattack: Unknown if model of class compatible with goal function .\n", " 0%| | 0/10 [00:00 \u001b[91mNegative (51%)\u001b[0m\n", "\n", "the rock is destined to be the 21st century's \u001b[92mnew\u001b[0m \" conan \" and that he's going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .\n", "\n", "the rock is destined to be the 21st century's \u001b[91mnewest\u001b[0m \" conan \" and that he's going to make a splash even greater than arnold schwarzenegger , jean-claud van damme or steven segal .\n", "\n", "\n", "--------------------------------------------- Result 2 ---------------------------------------------\n", "\u001b[92mPositive (52%)\u001b[0m --> \u001b[91mNegative (52%)\u001b[0m\n", "\n", "the gorgeously elaborate continuation of \" the lord of the rings \" trilogy is so huge that a column of words cannot adequately describe co-writer/\u001b[92mdirector\u001b[0m peter jackson's expanded vision of j . r . r . tolkien's middle-earth .\n", "\n", "the gorgeously elaborate continuation of \" the lord of the rings \" trilogy is so huge that a column of words cannot adequately describe co-writer/\u001b[91mdumbledore\u001b[0m peter jackson's expanded vision of j . r . r . tolkien's middle-earth .\n", "\n", "\n", "--------------------------------------------- Result 3 ---------------------------------------------\n", "\u001b[91mNegative (52%)\u001b[0m --> \u001b[37m[SKIPPED]\u001b[0m\n", "\n", "effective but too-tepid biopic\n", "\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[Succeeded / Failed / Skipped / Total] 4 / 0 / 3 / 7: 70%|███████ | 7/10 [00:05<00:02, 1.29it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ "--------------------------------------------- Result 4 ---------------------------------------------\n", "\u001b[92mPositive (72%)\u001b[0m --> \u001b[91mNegative (63%)\u001b[0m\n", "\n", "if you sometimes like to go to the \u001b[92mmovies\u001b[0m to have \u001b[92mfun\u001b[0m , wasabi is a good place to start .\n", "\n", "if you sometimes like to go to the \u001b[91mmovie\u001b[0m to have \u001b[91mamuse\u001b[0m , wasabi is a good place to start .\n", "\n", "\n", "--------------------------------------------- Result 5 ---------------------------------------------\n", "\u001b[91mNegative (78%)\u001b[0m --> \u001b[37m[SKIPPED]\u001b[0m\n", "\n", "emerges as something rare , an issue movie that's so honest and keenly observed that it doesn't feel like one .\n", "\n", "\n", "--------------------------------------------- Result 6 ---------------------------------------------\n", "\u001b[92mPositive (65%)\u001b[0m --> \u001b[91mNegative (60%)\u001b[0m\n", "\n", "the \u001b[92mfilm\u001b[0m provides some \u001b[92mgreat\u001b[0m insight into the neurotic mindset of all comics -- even those who have reached the absolute top of the game .\n", "\n", "the \u001b[91mmovie\u001b[0m provides some \u001b[91madmirable\u001b[0m insight into the neurotic mindset of all comics -- even those who have reached the absolute top of the game .\n", "\n", "\n", "--------------------------------------------- Result 7 ---------------------------------------------\n", "\u001b[91mNegative (52%)\u001b[0m --> \u001b[37m[SKIPPED]\u001b[0m\n", "\n", "offers that rare combination of entertainment and education .\n", "\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[Succeeded / Failed / Skipped / Total] 5 / 0 / 5 / 10: 100%|██████████| 10/10 [00:05<00:00, 1.81it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ "--------------------------------------------- Result 8 ---------------------------------------------\n", "\u001b[92mPositive (56%)\u001b[0m --> \u001b[91mNegative (51%)\u001b[0m\n", "\n", "perhaps no picture ever made has more literally showed that the road to hell is paved with \u001b[92mgood\u001b[0m intentions .\n", "\n", "perhaps no picture ever made has more literally showed that the road to hell is paved with \u001b[91mdecent\u001b[0m intentions .\n", "\n", "\n", "--------------------------------------------- Result 9 ---------------------------------------------\n", "\u001b[91mNegative (52%)\u001b[0m --> \u001b[37m[SKIPPED]\u001b[0m\n", "\n", "steers turns in a snappy screenplay that curls at the edges ; it's so clever you want to hate it . but he somehow pulls it off .\n", "\n", "\n", "--------------------------------------------- Result 10 ---------------------------------------------\n", "\u001b[91mNegative (52%)\u001b[0m --> \u001b[37m[SKIPPED]\u001b[0m\n", "\n", "take care of my cat offers a refreshingly different slice of asian cinema .\n", "\n", "\n", "\n", "+-------------------------------+--------+\n", "| Attack Results | |\n", "+-------------------------------+--------+\n", "| Number of successful attacks: | 5 |\n", "| Number of failed attacks: | 0 |\n", "| Number of skipped attacks: | 5 |\n", "| Original accuracy: | 50.0% |\n", "| Accuracy under attack: | 0.0% |\n", "| Attack success rate: | 100.0% |\n", "| Average perturbed word %: | 6.08% |\n", "| Average num. words per input: | 19.5 |\n", "| Avg num queries: | 67.6 |\n", "+-------------------------------+--------+\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n" ] }, { "data": { "text/plain": [ "[,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ,\n", " ]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from textattack.datasets import HuggingFaceDataset\n", "from textattack.attack_recipes import TextFoolerJin2019\n", "from textattack import Attacker\n", "\n", "dataset = HuggingFaceDataset(\"rotten_tomatoes\", None, \"train\")\n", "attack = TextFoolerJin2019.build(model_wrapper)\n", "\n", "attacker = Attacker(attack, dataset)\n", "attacker.attack_dataset()" ] }, { "cell_type": "markdown", "metadata": { "id": "3v1RGsPyalS7" }, "source": [ "### Conclusion\n", "We were able to train a model on the IMDB dataset using `sklearn` and use it in TextAttack by initializing with the `SklearnModelWrapper`. It's that simple!" ] } ], "metadata": { "accelerator": "GPU", "colab": { "name": "Example_1_sklearn.ipynb", "provenance": [], "toc_visible": true }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "0bdf019b433a4d56aeb22550a29d066b": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "Downloading: ", "description_tooltip": null, "layout": "IPY_MODEL_2d11de1950d942f79328e9ac6666f7d6", "max": 869, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_8a4fb534ea1547da8da4f49f415cea54", "value": 869 } }, "12e6bf4bd4f94616b986e982ef91387b": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_341adbff6245494e9895e18a07518179", "IPY_MODEL_8b211e3a7b4c4e04bdd5838c3b796708" ], "layout": "IPY_MODEL_e227337e4f7e4071b1524dc2c4a684c1" } }, "14d049de0e6b4361b31649738ed1f30e": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_a547aa3b535648759aa3b4e24fef4a0b", "IPY_MODEL_a67d6c2ec24145ddbf77ce0230a7b601" ], "layout": "IPY_MODEL_67213a9e8d1e4eef82d5a6066b372f67" } }, "2d11de1950d942f79328e9ac6666f7d6": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "341adbff6245494e9895e18a07518179": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "info", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_949928e3a1f646ff8681a591f80cf214", "max": 1, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_d3b82204a9344f889adc18e7ab415269", "value": 1 } }, "3b352536f852428891f47bec9a85de06": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "3f4aab5e789749bf837ca9d14bafc174": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "55b82241ad3f418f8b53f1d45ec9e063": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "564ded437808498cba5da3a878643101": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_8fc8fe3403914dbab689912446015d7e", "placeholder": "​", "style": "IPY_MODEL_eedf56dbdee24a6b852f6fcd380b72df", "value": " 4.98k/? [00:01<00:00, 3.24kB/s]" } }, "5ea7a4eca39b40b1b78457db00a454bd": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_ec5828528e6c4135b1a971c81bbaf0d0", "IPY_MODEL_a5319932f2a845dd81534dad6bc9277b" ], "layout": "IPY_MODEL_6e65f9ee0ccc407680d2f56dca5d1e34" } }, "67213a9e8d1e4eef82d5a6066b372f67": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "6e65f9ee0ccc407680d2f56dca5d1e34": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "7104ef4572fa4a48a3396c85a625a23d": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "7655027152994c549202c02bf9514c73": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "7b23e4bfbfc94e6681861fd2274de8da": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "7b51dd57afb048d583e591af1d0a206e": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "851bd4eaf00040baba7657df5eecb469": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "8a4fb534ea1547da8da4f49f415cea54": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "8b211e3a7b4c4e04bdd5838c3b796708": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_90c83abc28de409ba5bdc4dbd9db07e6", "placeholder": "​", "style": "IPY_MODEL_e4878535c150446cb21f1452004b3cdf", "value": " 1066/0 [00:00<00:00, 6028.77 examples/s]" } }, "8bdc81b8109a4f3a88ea06abf1b7edae": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "8e77f192800d4239a3e31a56989adc64": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "8fc8fe3403914dbab689912446015d7e": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "90c83abc28de409ba5bdc4dbd9db07e6": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "90cc2ff6a65c446a829ff98579036ec1": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "949928e3a1f646ff8681a591f80cf214": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "9abf2d1285f94d87a0f962243c7c4a2f": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_e36e821ec7164d58a7d885d47b06002d", "placeholder": "​", "style": "IPY_MODEL_55b82241ad3f418f8b53f1d45ec9e063", "value": " 1.88k/? [00:00<00:00, 10.7kB/s]" } }, "a4b27d2752a7412a8742aa6eb8523f5d": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_851bd4eaf00040baba7657df5eecb469", "placeholder": "​", "style": "IPY_MODEL_ad093103eb2c44e4b1ce003f1164a113", "value": " 488k/488k [00:00<00:00, 2.23MB/s]" } }, "a5319932f2a845dd81534dad6bc9277b": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_8bdc81b8109a4f3a88ea06abf1b7edae", "placeholder": "​", "style": "IPY_MODEL_8e77f192800d4239a3e31a56989adc64", "value": " 8530/0 [00:02<00:00, 1.47s/ examples]" } }, "a547aa3b535648759aa3b4e24fef4a0b": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "info", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_7b51dd57afb048d583e591af1d0a206e", "max": 1, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_e58e73fd1b7c4e4ea9f43757875bd3ec", "value": 1 } }, "a67d6c2ec24145ddbf77ce0230a7b601": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_d874dcaaefd9494eb087e7565a4e18c7", "placeholder": "​", "style": "IPY_MODEL_dbbc6c67ed6543328c2a3108724080ba", "value": " 1066/0 [00:00<00:00, 11095.74 examples/s]" } }, "aa2fb2f9c23b445db52a56d634f68ddf": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "ad093103eb2c44e4b1ce003f1164a113": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "b0f06f7a72d745538bea5f1c13492515": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "Downloading: ", "description_tooltip": null, "layout": "IPY_MODEL_f5240170070e46d09891d54e01e68c5d", "max": 1861, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_7104ef4572fa4a48a3396c85a625a23d", "value": 1861 } }, "c5757ae743174906b6ac3f457c92883a": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_b0f06f7a72d745538bea5f1c13492515", "IPY_MODEL_564ded437808498cba5da3a878643101" ], "layout": "IPY_MODEL_7b23e4bfbfc94e6681861fd2274de8da" } }, "d3b5d32a5063424c93be106077a78c16": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "d3b82204a9344f889adc18e7ab415269": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "d874dcaaefd9494eb087e7565a4e18c7": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "dbbc6c67ed6543328c2a3108724080ba": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "de657f0bdef34ed48d01acb0f34d87fd": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_0bdf019b433a4d56aeb22550a29d066b", "IPY_MODEL_9abf2d1285f94d87a0f962243c7c4a2f" ], "layout": "IPY_MODEL_3f4aab5e789749bf837ca9d14bafc174" } }, "e227337e4f7e4071b1524dc2c4a684c1": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "e36e821ec7164d58a7d885d47b06002d": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } }, "e4878535c150446cb21f1452004b3cdf": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "e58e73fd1b7c4e4ea9f43757875bd3ec": { "model_module": "@jupyter-widgets/controls", "model_name": "ProgressStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": "initial" } }, "ec5828528e6c4135b1a971c81bbaf0d0": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "info", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_3b352536f852428891f47bec9a85de06", "max": 1, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_7655027152994c549202c02bf9514c73", "value": 1 } }, "ed5d8cef24e5427b94818f4d0ce8d52e": { "model_module": "@jupyter-widgets/controls", "model_name": "HBoxModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": [ "IPY_MODEL_f319de77f1cb4d03b8a0287a6744f8b2", "IPY_MODEL_a4b27d2752a7412a8742aa6eb8523f5d" ], "layout": "IPY_MODEL_aa2fb2f9c23b445db52a56d634f68ddf" } }, "eedf56dbdee24a6b852f6fcd380b72df": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } }, "f319de77f1cb4d03b8a0287a6744f8b2": { "model_module": "@jupyter-widgets/controls", "model_name": "FloatProgressModel", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "Downloading: 100%", "description_tooltip": null, "layout": "IPY_MODEL_d3b5d32a5063424c93be106077a78c16", "max": 487770, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_90cc2ff6a65c446a829ff98579036ec1", "value": 487770 } }, "f5240170070e46d09891d54e01e68c5d": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "state": { "_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null } } } } }, "nbformat": 4, "nbformat_minor": 4 }