{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "cYJxJ6jb3xTJ", "outputId": "d01a4787-6aea-4026-c6c1-bcbac8ed48ec" }, "outputs": [], "source": [ "# For use with Google Colab only to install transformers library\n", "# !pip install transformers" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "RqKR2tUd8W2G" }, "outputs": [], "source": [ "# importing necessary libraries\n", "import torch \n", "from torch.utils.data import Dataset\n", "from transformers import DistilBertTokenizerFast, DistilBertForSequenceClassification\n", "from transformers import AdamW\n", "import pandas as pd\n", "from sklearn.model_selection import train_test_split\n", "from torch.utils.data import DataLoader" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "LdZaCOwM8nT4", "outputId": "0847ad3f-6088-448d-be7e-43149dee7091" }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " | id | \n", "comment_text | \n", "toxic | \n", "severe_toxic | \n", "obscene | \n", "threat | \n", "insult | \n", "identity_hate | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "0000997932d777bf | \n", "Explanation\\r\\nWhy the edits made under my use... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
1 | \n", "000103f0d9cfb60f | \n", "D'aww! He matches this background colour I'm s... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
2 | \n", "000113f07ec002fd | \n", "Hey man, I'm really not trying to edit war. It... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
3 | \n", "0001b41b1c6bb37e | \n", "\"\\r\\nMore\\r\\nI can't make any real suggestions... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
4 | \n", "0001d958c54c6e35 | \n", "You, sir, are my hero. Any chance you remember... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "