File size: 5,955 Bytes
9e24ae8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4",
      "mount_file_id": "1npJ_m9j344UPF9JAmHTQ-_k6aMVugCpk",
      "authorship_tag": "ABX9TyM0uPiqoelXhWIVmGBY/QDu",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/lloydakresi/toxic_comment_moderator_api/blob/main/Train_Notebook.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "R_OdgWC3J90I",
        "outputId": "798bca08-f949-4c70-e6d2-cd28f020492b"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "/content/drive/MyDrive\n"
          ]
        }
      ],
      "source": [
        "%cd .."
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!rm -rf toxic_comment_moderator_api"
      ],
      "metadata": {
        "id": "QUk1Q6CEi4HD"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!git clone https://github.com/lloydakresi/toxic_comment_moderator_api.git"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Sp0Up667g4Xy",
        "outputId": "b21c7fd0-f539-42e1-992b-0ab8392a52ec"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Cloning into 'toxic_comment_moderator_api'...\n",
            "remote: Enumerating objects: 49, done.\u001b[K\n",
            "remote: Counting objects: 100% (49/49), done.\u001b[K\n",
            "remote: Compressing objects: 100% (28/28), done.\u001b[K\n",
            "remote: Total 49 (delta 23), reused 45 (delta 19), pack-reused 0 (from 0)\u001b[K\n",
            "Receiving objects: 100% (49/49), 32.99 KiB | 3.67 MiB/s, done.\n",
            "Resolving deltas: 100% (23/23), done.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "%cd toxic_comment_moderator_api"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "XzFpM_OThNor",
        "outputId": "e646206d-06b4-4bd5-c06d-059604892416"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "/content/drive/MyDrive/toxic_comment_moderator_api\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install transformers==5.12.1 datasets==5.0.0 evaluate==0.4.6 accelerate==1.14.0 scikit-learn==1.9.0 iterative-stratification==0.1.9 -q"
      ],
      "metadata": {
        "id": "GscPa1Bihx9H"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!python train.py"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "LBmM7I26imWc",
        "outputId": "bd9c3a9f-d3f8-41f3-f09f-c0c0f9986293"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "['id', 'comment_text', 'toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']\n",
            "143613\n",
            "Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n",
            "Map: 100% 143613/143613 [00:43<00:00, 3280.74 examples/s]\n",
            "Map: 100% 15958/15958 [00:05<00:00, 2756.07 examples/s]\n",
            "Loading weights: 100% 100/100 [00:00<00:00, 5538.28it/s]\n",
            "[transformers] \u001b[1mDistilBertForSequenceClassification LOAD REPORT\u001b[0m from: distilbert-base-uncased\n",
            "Key                     | Status     | \n",
            "------------------------+------------+-\n",
            "vocab_layer_norm.bias   | \u001b[38;5;208mUNEXPECTED\u001b[0m | \n",
            "vocab_transform.bias    | \u001b[38;5;208mUNEXPECTED\u001b[0m | \n",
            "vocab_transform.weight  | \u001b[38;5;208mUNEXPECTED\u001b[0m | \n",
            "vocab_projector.bias    | \u001b[38;5;208mUNEXPECTED\u001b[0m | \n",
            "vocab_layer_norm.weight | \u001b[38;5;208mUNEXPECTED\u001b[0m | \n",
            "pre_classifier.bias     | \u001b[31mMISSING\u001b[0m    | \n",
            "pre_classifier.weight   | \u001b[31mMISSING\u001b[0m    | \n",
            "classifier.bias         | \u001b[31mMISSING\u001b[0m    | \n",
            "classifier.weight       | \u001b[31mMISSING\u001b[0m    | \n",
            "\n",
            "Notes:\n",
            "- \u001b[38;5;208mUNEXPECTED:\u001b[0m\t\u001b[3mcan be ignored when loading from different task/architecture; not ok if you expect identical arch.\u001b[0m\n",
            "- \u001b[31mMISSING:\u001b[0m\t\u001b[3mthose params were newly initialized because missing from the checkpoint. Consider training on your downstream task.\u001b[0m\n",
            "True\n",
            "Tesla T4\n",
            "Model device: cuda:0\n",
            "  3% 391/11220 [19:08<8:13:13,  2.73s/it]"
          ]
        }
      ]
    }
  ]
}