a b/Roberta+LLM/evaluate_roberta_chia.ipynb
1
{
2
  "cells": [
3
    {
4
      "cell_type": "markdown",
5
      "metadata": {
6
        "id": "view-in-github",
7
        "colab_type": "text"
8
      },
9
      "source": [
10
        "<a href=\"https://colab.research.google.com/github/jlopetegui98/NER-ClinicalTrials-Elegibility-Criteria/blob/main/Roberta%2BLLM/evaluate_roberta_chia.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
11
      ]
12
    },
13
    {
14
      "cell_type": "code",
15
      "execution_count": 1,
16
      "metadata": {
17
        "id": "OmG4urkedeiv",
18
        "outputId": "87a33dc4-f118-45a7-c8aa-aab80e9c76ca",
19
        "colab": {
20
          "base_uri": "https://localhost:8080/"
21
        }
22
      },
23
      "outputs": [
24
        {
25
          "output_type": "stream",
26
          "name": "stdout",
27
          "text": [
28
            "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
29
          ]
30
        }
31
      ],
32
      "source": [
33
        "# uncomment if working in colab\n",
34
        "from google.colab import drive\n",
35
        "drive.mount('/content/drive')"
36
      ]
37
    },
38
    {
39
      "cell_type": "code",
40
      "execution_count": 2,
41
      "metadata": {
42
        "id": "pG8-9pLtdeiv",
43
        "outputId": "d3c710c2-a443-4b3b-db20-2fafe6746f0d",
44
        "colab": {
45
          "base_uri": "https://localhost:8080/"
46
        }
47
      },
48
      "outputs": [
49
        {
50
          "output_type": "stream",
51
          "name": "stdout",
52
          "text": [
53
            "  Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
54
            "  Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
55
            "  Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
56
            "  Building wheel for transformers (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
57
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m510.5/510.5 kB\u001b[0m \u001b[31m10.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
58
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m116.3/116.3 kB\u001b[0m \u001b[31m15.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
59
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m194.1/194.1 kB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
60
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m17.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
61
            "\u001b[?25h  Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
62
            "  Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
63
            "  Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
64
            "  Building wheel for accelerate (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
65
            "Collecting seqeval\n",
66
            "  Downloading seqeval-1.2.2.tar.gz (43 kB)\n",
67
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.6/43.6 kB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
68
            "\u001b[?25h  Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
69
            "Requirement already satisfied: numpy>=1.14.0 in /usr/local/lib/python3.10/dist-packages (from seqeval) (1.25.2)\n",
70
            "Requirement already satisfied: scikit-learn>=0.21.3 in /usr/local/lib/python3.10/dist-packages (from seqeval) (1.2.2)\n",
71
            "Requirement already satisfied: scipy>=1.3.2 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21.3->seqeval) (1.11.4)\n",
72
            "Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21.3->seqeval) (1.4.0)\n",
73
            "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21.3->seqeval) (3.4.0)\n",
74
            "Building wheels for collected packages: seqeval\n",
75
            "  Building wheel for seqeval (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
76
            "  Created wheel for seqeval: filename=seqeval-1.2.2-py3-none-any.whl size=16161 sha256=b571c9c4836027705ada02b905790e6d0b00dff2c033b522f11aeb9c3d0d66ed\n",
77
            "  Stored in directory: /root/.cache/pip/wheels/1a/67/4a/ad4082dd7dfc30f2abfe4d80a2ed5926a506eb8a972b4767fa\n",
78
            "Successfully built seqeval\n",
79
            "Installing collected packages: seqeval\n",
80
            "Successfully installed seqeval-1.2.2\n",
81
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.1/84.1 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
82
            "\u001b[?25h"
83
          ]
84
        }
85
      ],
86
      "source": [
87
        "# uncomment if using colab\n",
88
        "!pip install -q -U git+https://github.com/huggingface/transformers.git\n",
89
        "!pip install -q -U datasets\n",
90
        "!pip install -q -U git+https://github.com/huggingface/accelerate.git\n",
91
        "!pip install seqeval\n",
92
        "!pip install -q -U evaluate"
93
      ]
94
    },
95
    {
96
      "cell_type": "code",
97
      "execution_count": 2,
98
      "metadata": {
99
        "id": "cD_ebmTNdeiv"
100
      },
101
      "outputs": [],
102
      "source": [
103
        "import numpy as np\n",
104
        "from transformers import AutoTokenizer, AutoModelForTokenClassification, DataCollatorForTokenClassification,  Trainer, TrainingArguments\n",
105
        "from datasets import load_dataset, load_metric\n",
106
        "from seqeval.metrics import classification_report\n",
107
        "from seqeval.scheme import IOB2\n",
108
        "import evaluate\n",
109
        "import torch"
110
      ]
111
    },
112
    {
113
      "cell_type": "code",
114
      "execution_count": 3,
115
      "metadata": {
116
        "id": "RTiSFJvzdeiw",
117
        "outputId": "ed96941b-ab02-41bb-da96-c668cb8aac43",
118
        "colab": {
119
          "base_uri": "https://localhost:8080/",
120
          "height": 145,
121
          "referenced_widgets": [
122
            "aae03eda481e488eaf1ef5b0610cdc0b",
123
            "034ac69beaf14927bb2800c7e848ecbb",
124
            "0c7e1ad3261b4ff4876a9a8654fc9464",
125
            "306bc801a94541999e50632fbc3f4c0f",
126
            "36dbf510f6fc446383291658d394066a",
127
            "77affba1207543b483febb7acb086298",
128
            "d2605acf97fa45ad8b157868a831e4f7",
129
            "c116ed771b584a1398d9200fd3a8eba0",
130
            "f3a413d8c726471295e252f3ea122f31",
131
            "2e4c44c84e464804b1c757f88e46d506",
132
            "719dfc3140194a839f84e6efe01e01b0",
133
            "7e0e3e6216db4347a7de8f4553dd6282",
134
            "7c10261a70ee4e7184524cc2590a28c1",
135
            "5b93a9aedb2f49d88e5e1d9cdb13c751",
136
            "5ad14d3ac4614dcc903d60dcb4edbb88",
137
            "c218b57c46fc4f5eb9260fd08c5a94c8",
138
            "e377b67ff2a948e3be138334ed3de886",
139
            "d9a4367195b94edc9d1ba97d7b0a2eb8",
140
            "aa9ffe65a42643c69f553f283cdf6772",
141
            "8a95f6bbd81148519ec4639d8b0f4db6",
142
            "13acbfe9fc7a4ff4a6ec0a8be56c4f62",
143
            "e7bcd126a8384f94a027e130d09f2346",
144
            "ee0ac8c2fac44c02b28844bb5bc6822a",
145
            "d1444855a9cc4726a37cf9f184be8409",
146
            "baa7f4149cb446078d05574550f33cda",
147
            "002b9e99a05c46749a052c5770f280a5",
148
            "33a233aa855f4356960aa336d361bfdb",
149
            "b111ac45f0d648a8b89e1bf3d26dc354",
150
            "7c0010ffc2b84b7cb1c2e943e849a67b",
151
            "4a0ecc50b9e94408b714c578a0786f03",
152
            "f67c37bb203c4775b5997e50af97fae7",
153
            "8fe86ac5511c400d81c52bd335c96859"
154
          ]
155
        }
156
      },
157
      "outputs": [
158
        {
159
          "output_type": "display_data",
160
          "data": {
161
            "text/plain": [
162
              "VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
163
            ],
164
            "application/vnd.jupyter.widget-view+json": {
165
              "version_major": 2,
166
              "version_minor": 0,
167
              "model_id": "aae03eda481e488eaf1ef5b0610cdc0b"
168
            }
169
          },
170
          "metadata": {}
171
        }
172
      ],
173
      "source": [
174
        "from huggingface_hub import notebook_login\n",
175
        "\n",
176
        "notebook_login()"
177
      ]
178
    },
179
    {
180
      "cell_type": "code",
181
      "execution_count": 4,
182
      "metadata": {
183
        "id": "46CEQFSvdeiw"
184
      },
185
      "outputs": [],
186
      "source": [
187
        "# dict for the entities (entity to int value)\n",
188
        "simple_ent = {\"Condition\", \"Value\", \"Drug\", \"Procedure\", \"Measurement\", \"Temporal\", \"Observation\", \"Person\", \"Device\"}\n",
189
        "sel_ent = {\n",
190
        "    \"O\": 0,\n",
191
        "    \"B-Condition\": 1,\n",
192
        "    \"I-Condition\": 2,\n",
193
        "    \"B-Value\": 3,\n",
194
        "    \"I-Value\": 4,\n",
195
        "    \"B-Drug\": 5,\n",
196
        "    \"I-Drug\": 6,\n",
197
        "    \"B-Procedure\": 7,\n",
198
        "    \"I-Procedure\": 8,\n",
199
        "    \"B-Measurement\": 9,\n",
200
        "    \"I-Measurement\": 10,\n",
201
        "    \"B-Temporal\": 11,\n",
202
        "    \"I-Temporal\": 12,\n",
203
        "    \"B-Observation\": 13,\n",
204
        "    \"I-Observation\": 14,\n",
205
        "    \"B-Person\": 15,\n",
206
        "    \"I-Person\": 16,\n",
207
        "    \"B-Device\": 17,\n",
208
        "    \"I-Device\": 18\n",
209
        "}\n",
210
        "\n",
211
        "entities_list = list(sel_ent.keys())\n",
212
        "sel_ent_inv = {v: k for k, v in sel_ent.items()}"
213
      ]
214
    },
215
    {
216
      "cell_type": "code",
217
      "execution_count": 5,
218
      "metadata": {
219
        "id": "8DChGuXtdeiw"
220
      },
221
      "outputs": [],
222
      "source": [
223
        "root = '..'\n",
224
        "root = './drive/MyDrive/TER-LISN-2024'\n",
225
        "data_path = f'{root}/data'\n",
226
        "models_path = f'{root}/models'"
227
      ]
228
    },
229
    {
230
      "cell_type": "code",
231
      "execution_count": 6,
232
      "metadata": {
233
        "id": "azvAU6endeiw"
234
      },
235
      "outputs": [],
236
      "source": [
237
        "model_name = \"roberta-base\""
238
      ]
239
    },
240
    {
241
      "cell_type": "code",
242
      "execution_count": 7,
243
      "metadata": {
244
        "id": "9Lj6yRsIdeiw",
245
        "outputId": "c140456c-c362-4eed-c946-67e626da7f52",
246
        "colab": {
247
          "base_uri": "https://localhost:8080/"
248
        }
249
      },
250
      "outputs": [
251
        {
252
          "output_type": "stream",
253
          "name": "stderr",
254
          "text": [
255
            "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: \n",
256
            "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
257
            "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
258
            "You will be able to reuse this secret in all of your notebooks.\n",
259
            "Please note that authentication is recommended but still optional to access public models or datasets.\n",
260
            "  warnings.warn(\n"
261
          ]
262
        }
263
      ],
264
      "source": [
265
        "tokenizer = AutoTokenizer.from_pretrained(model_name, add_prefix_space=True)"
266
      ]
267
    },
268
    {
269
      "cell_type": "code",
270
      "execution_count": 8,
271
      "metadata": {
272
        "id": "jGIUj0Wwdeiw"
273
      },
274
      "outputs": [],
275
      "source": [
276
        "# tokenize and align the labels in the dataset\n",
277
        "def tokenize_and_align_labels(sentence, tokenizer, flag = 'I'):\n",
278
        "    \"\"\"\n",
279
        "    Tokenize the sentence and align the labels\n",
280
        "    inputs:\n",
281
        "        sentence: dict, the sentence from the dataset\n",
282
        "        flag: str, the flag to indicate how to deal with the labels for subwords\n",
283
        "            - 'I': use the label of the first subword for all subwords but as intermediate (I-ENT)\n",
284
        "            - 'B': use the label of the first subword for all subwords as beginning (B-ENT)\n",
285
        "            - None: use -100 for subwords\n",
286
        "    outputs:\n",
287
        "        tokenized_sentence: dict, the tokenized sentence now with a field for the labels\n",
288
        "    \"\"\"\n",
289
        "    tokenized_sentence = tokenizer(sentence['tokens'], is_split_into_words=True, truncation=True, padding='max_length', max_length=512)\n",
290
        "\n",
291
        "    labels = []\n",
292
        "    all_word_ids = []\n",
293
        "    for i, labels_s in enumerate(sentence['ner_tags']):\n",
294
        "        word_ids = tokenized_sentence.word_ids(batch_index=i)\n",
295
        "        previous_word_idx = None\n",
296
        "        label_ids = []\n",
297
        "        for word_idx in word_ids:\n",
298
        "            # if the word_idx is None, assign -100\n",
299
        "            if word_idx is None:\n",
300
        "                label_ids.append(-100)\n",
301
        "            # if it is a new word, assign the corresponding label\n",
302
        "            elif word_idx != previous_word_idx:\n",
303
        "                label_ids.append(labels_s[word_idx])\n",
304
        "            # if it is the same word, check the flag to assign\n",
305
        "            else:\n",
306
        "                if flag == 'I':\n",
307
        "                    if entities_list[labels_s[word_idx]].startswith('I'):\n",
308
        "                      label_ids.append(labels_s[word_idx])\n",
309
        "                    else:\n",
310
        "                      label_ids.append(labels_s[word_idx] + 1)\n",
311
        "                elif flag == 'B':\n",
312
        "                    label_ids.append(labels_s[word_idx])\n",
313
        "                elif flag == None:\n",
314
        "                    label_ids.append(-100)\n",
315
        "            previous_word_idx = word_idx\n",
316
        "        labels.append(label_ids)\n",
317
        "        all_word_ids.append(word_ids)\n",
318
        "    tokenized_sentence['labels'] = labels\n",
319
        "    tokenized_sentence['word_ids'] = all_word_ids\n",
320
        "    return tokenized_sentence"
321
      ]
322
    },
323
    {
324
      "cell_type": "code",
325
      "execution_count": 9,
326
      "metadata": {
327
        "id": "Vn6kc7ZJdeiw"
328
      },
329
      "outputs": [],
330
      "source": [
331
        "dataset = load_dataset('JavierLopetegui/chia_v1')"
332
      ]
333
    },
334
    {
335
      "cell_type": "code",
336
      "execution_count": 10,
337
      "metadata": {
338
        "id": "ia9F2gixdeiw",
339
        "outputId": "295daaec-e013-4539-c939-6996765bd8a8",
340
        "colab": {
341
          "base_uri": "https://localhost:8080/",
342
          "height": 49,
343
          "referenced_widgets": [
344
            "c134904ded5f47aabca0dfa5b67049db",
345
            "3c1d79df90544bdd93873579d38116a4",
346
            "3806b75490704196afde5977db7dca89",
347
            "7665c9c809964b6eb6b4a9720c5d2dac",
348
            "1785e46465ec42ccbb933604963d5dd6",
349
            "7b7dd023dbc7472998c6aac7eee1490f",
350
            "62a0e81ff19a4162a67e5884ce678f2c",
351
            "24a85f5bd83441b4943299be2d145aff",
352
            "18eaa2134e8e4edeb41340cebbeb8572",
353
            "68e1a741d3ec4fc3a26d759ecc357ac6",
354
            "de3e98c73f9547bebdad9b4bcb21d9a1"
355
          ]
356
        }
357
      },
358
      "outputs": [
359
        {
360
          "output_type": "display_data",
361
          "data": {
362
            "text/plain": [
363
              "Map:   0%|          | 0/1307 [00:00<?, ? examples/s]"
364
            ],
365
            "application/vnd.jupyter.widget-view+json": {
366
              "version_major": 2,
367
              "version_minor": 0,
368
              "model_id": "c134904ded5f47aabca0dfa5b67049db"
369
            }
370
          },
371
          "metadata": {}
372
        }
373
      ],
374
      "source": [
375
        "# tokenize and align the labels in the dataset\n",
376
        "dataset = dataset.map(lambda x: tokenize_and_align_labels(x, tokenizer, 'I'), batched = True)"
377
      ]
378
    },
379
    {
380
      "cell_type": "code",
381
      "source": [
382
        "dataset"
383
      ],
384
      "metadata": {
385
        "id": "fGpxVHNyfRJw",
386
        "outputId": "d1268582-6fc8-4531-b5af-9ea4406f4ba9",
387
        "colab": {
388
          "base_uri": "https://localhost:8080/"
389
        }
390
      },
391
      "execution_count": 11,
392
      "outputs": [
393
        {
394
          "output_type": "execute_result",
395
          "data": {
396
            "text/plain": [
397
              "DatasetDict({\n",
398
              "    train: Dataset({\n",
399
              "        features: ['tokens', 'ner_tags', 'file', 'index', 'input_ids', 'attention_mask', 'labels', 'word_ids'],\n",
400
              "        num_rows: 8881\n",
401
              "    })\n",
402
              "    test: Dataset({\n",
403
              "        features: ['tokens', 'ner_tags', 'file', 'index', 'input_ids', 'attention_mask', 'labels', 'word_ids'],\n",
404
              "        num_rows: 1307\n",
405
              "    })\n",
406
              "    val: Dataset({\n",
407
              "        features: ['tokens', 'ner_tags', 'file', 'index', 'input_ids', 'attention_mask', 'labels', 'word_ids'],\n",
408
              "        num_rows: 2221\n",
409
              "    })\n",
410
              "})"
411
            ]
412
          },
413
          "metadata": {},
414
          "execution_count": 11
415
        }
416
      ]
417
    },
418
    {
419
      "cell_type": "code",
420
      "execution_count": 12,
421
      "metadata": {
422
        "id": "smLH3_Andeiw"
423
      },
424
      "outputs": [],
425
      "source": [
426
        "# load model\n",
427
        "model = torch.load(f'{models_path}/roberta-ner-chia.pt')"
428
      ]
429
    },
430
    {
431
      "cell_type": "code",
432
      "execution_count": 13,
433
      "metadata": {
434
        "id": "GiKIdJXedeiw"
435
      },
436
      "outputs": [],
437
      "source": [
438
        "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')"
439
      ]
440
    },
441
    {
442
      "cell_type": "code",
443
      "source": [
444
        "data_for_model = dataset['test'].remove_columns(['file', 'tokens', 'labels', 'index', 'ner_tags', 'word_ids'])"
445
      ],
446
      "metadata": {
447
        "id": "k-wSN1KUfNix"
448
      },
449
      "execution_count": 14,
450
      "outputs": []
451
    },
452
    {
453
      "cell_type": "code",
454
      "source": [
455
        "data_for_model"
456
      ],
457
      "metadata": {
458
        "id": "OAeZ75r-hPCH",
459
        "outputId": "0d8c7676-3471-4f74-d3ad-942b26595c62",
460
        "colab": {
461
          "base_uri": "https://localhost:8080/"
462
        }
463
      },
464
      "execution_count": 15,
465
      "outputs": [
466
        {
467
          "output_type": "execute_result",
468
          "data": {
469
            "text/plain": [
470
              "Dataset({\n",
471
              "    features: ['input_ids', 'attention_mask'],\n",
472
              "    num_rows: 1307\n",
473
              "})"
474
            ]
475
          },
476
          "metadata": {},
477
          "execution_count": 15
478
        }
479
      ]
480
    },
481
    {
482
      "cell_type": "code",
483
      "execution_count": 16,
484
      "metadata": {
485
        "id": "b99O2uACdeiw"
486
      },
487
      "outputs": [],
488
      "source": [
489
        "data_loader = torch.utils.data.DataLoader(data_for_model, batch_size=8)"
490
      ]
491
    },
492
    {
493
      "cell_type": "code",
494
      "source": [],
495
      "metadata": {
496
        "id": "MtnU6v5Je8X9"
497
      },
498
      "execution_count": null,
499
      "outputs": []
500
    },
501
    {
502
      "cell_type": "code",
503
      "execution_count": 17,
504
      "metadata": {
505
        "id": "enBj0Mn5deiw",
506
        "outputId": "2c99fd25-35ad-4cde-d2cd-05b558f6eaf4",
507
        "colab": {
508
          "base_uri": "https://localhost:8080/"
509
        }
510
      },
511
      "outputs": [
512
        {
513
          "output_type": "execute_result",
514
          "data": {
515
            "text/plain": [
516
              "RobertaForTokenClassification(\n",
517
              "  (roberta): RobertaModel(\n",
518
              "    (embeddings): RobertaEmbeddings(\n",
519
              "      (word_embeddings): Embedding(50265, 768, padding_idx=1)\n",
520
              "      (position_embeddings): Embedding(514, 768, padding_idx=1)\n",
521
              "      (token_type_embeddings): Embedding(1, 768)\n",
522
              "      (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)\n",
523
              "      (dropout): Dropout(p=0.1, inplace=False)\n",
524
              "    )\n",
525
              "    (encoder): RobertaEncoder(\n",
526
              "      (layer): ModuleList(\n",
527
              "        (0-11): 12 x RobertaLayer(\n",
528
              "          (attention): RobertaAttention(\n",
529
              "            (self): RobertaSelfAttention(\n",
530
              "              (query): Linear(in_features=768, out_features=768, bias=True)\n",
531
              "              (key): Linear(in_features=768, out_features=768, bias=True)\n",
532
              "              (value): Linear(in_features=768, out_features=768, bias=True)\n",
533
              "              (dropout): Dropout(p=0.1, inplace=False)\n",
534
              "            )\n",
535
              "            (output): RobertaSelfOutput(\n",
536
              "              (dense): Linear(in_features=768, out_features=768, bias=True)\n",
537
              "              (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)\n",
538
              "              (dropout): Dropout(p=0.1, inplace=False)\n",
539
              "            )\n",
540
              "          )\n",
541
              "          (intermediate): RobertaIntermediate(\n",
542
              "            (dense): Linear(in_features=768, out_features=3072, bias=True)\n",
543
              "            (intermediate_act_fn): GELUActivation()\n",
544
              "          )\n",
545
              "          (output): RobertaOutput(\n",
546
              "            (dense): Linear(in_features=3072, out_features=768, bias=True)\n",
547
              "            (LayerNorm): LayerNorm((768,), eps=1e-05, elementwise_affine=True)\n",
548
              "            (dropout): Dropout(p=0.1, inplace=False)\n",
549
              "          )\n",
550
              "        )\n",
551
              "      )\n",
552
              "    )\n",
553
              "  )\n",
554
              "  (dropout): Dropout(p=0.1, inplace=False)\n",
555
              "  (classifier): Linear(in_features=768, out_features=19, bias=True)\n",
556
              ")"
557
            ]
558
          },
559
          "metadata": {},
560
          "execution_count": 17
561
        }
562
      ],
563
      "source": [
564
        "model.to(device)"
565
      ]
566
    },
567
    {
568
      "cell_type": "code",
569
      "source": [
570
        "from tqdm import tqdm"
571
      ],
572
      "metadata": {
573
        "id": "F6dReMqdeva6"
574
      },
575
      "execution_count": 18,
576
      "outputs": []
577
    },
578
    {
579
      "cell_type": "code",
580
      "source": [
581
        "len(data_loader.dataset[2]['attention_mask'])"
582
      ],
583
      "metadata": {
584
        "id": "vPBZwZGnfzG1",
585
        "outputId": "60979f60-e8f8-4fe9-8959-9a8ca30027cc",
586
        "colab": {
587
          "base_uri": "https://localhost:8080/"
588
        }
589
      },
590
      "execution_count": 19,
591
      "outputs": [
592
        {
593
          "output_type": "execute_result",
594
          "data": {
595
            "text/plain": [
596
              "512"
597
            ]
598
          },
599
          "metadata": {},
600
          "execution_count": 19
601
        }
602
      ]
603
    },
604
    {
605
      "cell_type": "code",
606
      "source": [],
607
      "metadata": {
608
        "id": "UtZKgTQcgORE"
609
      },
610
      "execution_count": null,
611
      "outputs": []
612
    },
613
    {
614
      "cell_type": "code",
615
      "execution_count": 20,
616
      "metadata": {
617
        "id": "QzmBnKxjdeiw",
618
        "outputId": "7d40eef4-7f54-4faf-c2e0-29f48313a3f9",
619
        "colab": {
620
          "base_uri": "https://localhost:8080/"
621
        }
622
      },
623
      "outputs": [
624
        {
625
          "output_type": "stream",
626
          "name": "stderr",
627
          "text": [
628
            "100%|██████████| 164/164 [00:50<00:00,  3.22it/s]\n"
629
          ]
630
        }
631
      ],
632
      "source": [
633
        "labels = []\n",
634
        "for batch in tqdm(data_loader):\n",
635
        "\n",
636
        "    batch['input_ids'] = torch.LongTensor(np.column_stack(np.array(batch['input_ids']))).to(device)\n",
637
        "    batch['attention_mask'] = torch.LongTensor(np.column_stack(np.array(batch['attention_mask']))).to(device)\n",
638
        "    batch_tokenizer = {'input_ids': batch['input_ids'], 'attention_mask': batch['attention_mask']}\n",
639
        "    # break\n",
640
        "    with torch.no_grad():\n",
641
        "        outputs = model(**batch_tokenizer)\n",
642
        "\n",
643
        "    labels_batch = torch.argmax(outputs.logits, dim=2).to('cpu').numpy()\n",
644
        "    labels.extend([list(labels_batch[i]) for i in range(labels_batch.shape[0])])\n",
645
        "\n",
646
        "    del batch\n",
647
        "    del outputs\n",
648
        "    torch.cuda.empty_cache()"
649
      ]
650
    },
651
    {
652
      "cell_type": "code",
653
      "source": [
654
        "def annotate_sentences(dataset, labels, entities_list,criteria = 'first_label'):\n",
655
        "    \"\"\"\n",
656
        "    Annotate the sentences with the predicted labels\n",
657
        "    inputs:\n",
658
        "        dataset: dataset, dataset with the sentences\n",
659
        "        labels: list, list of labels\n",
660
        "        entities_list: list, list of entities\n",
661
        "        criteria: str, criteria to use to select the label when the words pices have different labels\n",
662
        "            - first_label: select the first label\n",
663
        "            - majority: select the label with the majority\n",
664
        "    outputs:\n",
665
        "        annotated_sentences: list, list of annotated sentences\n",
666
        "    \"\"\"\n",
667
        "    annotated_sentences = []\n",
668
        "    for i in range(len(dataset)):\n",
669
        "        # get just the tokens different from None\n",
670
        "        sentence = dataset[i]\n",
671
        "        word_ids = sentence['word_ids']\n",
672
        "        sentence_labels = labels[i]\n",
673
        "        annotated_sentence = [[] for _ in range(len(dataset[i]['tokens']))]\n",
674
        "        for word_id, label in zip(word_ids, sentence_labels):\n",
675
        "            if word_id is not None:\n",
676
        "                annotated_sentence[word_id].append(label)\n",
677
        "        annotated_sentence_filtered = []\n",
678
        "        if criteria == 'first_label':\n",
679
        "            annotated_sentence_filtered = [annotated_sentence[i][0] for i in range(len(annotated_sentence))]\n",
680
        "        elif criteria == 'majority':\n",
681
        "            annotated_sentence_filtered = []\n",
682
        "            for j in range(len(annotated_sentence)):\n",
683
        "                starts_flag = entities_list[annotated_sentence[j][0]].startswith('B')\n",
684
        "\n",
685
        "                ent = max(set(annotated_sentence[j]), key=annotated_sentence[j].count)\n",
686
        "                if starts_flag and ent != 0:\n",
687
        "                    label = entities_list[ent][2:]\n",
688
        "                    label = 'B-' + label\n",
689
        "                    annotated_sentence_filtered.append(sel_ent[label])\n",
690
        "                else:\n",
691
        "                    annotated_sentence_filtered.append(ent)\n",
692
        "        annotated_sentences.append(annotated_sentence_filtered)\n",
693
        "    return annotated_sentences"
694
      ],
695
      "metadata": {
696
        "id": "w6MABN-NsXVR"
697
      },
698
      "execution_count": 21,
699
      "outputs": []
700
    },
701
    {
702
      "cell_type": "code",
703
      "source": [
704
        "annotated_sentences_first = annotate_sentences(dataset['test'], labels, entities_list, criteria='first_label')\n",
705
        "annotated_sentences_max = annotate_sentences(dataset['test'], labels, entities_list, criteria='majority')"
706
      ],
707
      "metadata": {
708
        "id": "UZVjibUbsasA"
709
      },
710
      "execution_count": 22,
711
      "outputs": []
712
    },
713
    {
714
      "cell_type": "code",
715
      "execution_count": null,
716
      "metadata": {
717
        "id": "h06Yl1uTdeix",
718
        "outputId": "f23119cd-e70b-44e3-b069-b6d2781a06f7",
719
        "colab": {
720
          "base_uri": "https://localhost:8080/",
721
          "height": 176,
722
          "referenced_widgets": [
723
            "99188e0dd50f4d5a874eaec3101ceab6",
724
            "b289d32f0876481b97a080552549f7d1",
725
            "499e568745f743aea5c0b2ac64ef160f",
726
            "12eafe87e2b84edfa7d72b93361d3e6a",
727
            "61a45966b4654a7db975880b0a193139",
728
            "95909a3c6f6245d1acd056f28bfe5ba8",
729
            "feebbbdfbc3740bba039e95ddf31e4c1",
730
            "1eed478ce7694c4cb7e2c998963cafcc",
731
            "677a609737064c3c86de6503530b6268",
732
            "3736022fd7b5476dbfe03fee20d19f09",
733
            "0846105c8d484656848ff41c571eb71f"
734
          ]
735
        }
736
      },
737
      "outputs": [
738
        {
739
          "output_type": "stream",
740
          "name": "stderr",
741
          "text": [
742
            "<ipython-input-38-653dc96d1cff>:2: FutureWarning: load_metric is deprecated and will be removed in the next major version of datasets. Use 'evaluate.load' instead, from the new library 🤗 Evaluate: https://huggingface.co/docs/evaluate\n",
743
            "  metric = load_metric(\"seqeval\")\n",
744
            "/usr/local/lib/python3.10/dist-packages/datasets/load.py:756: FutureWarning: The repository for seqeval contains custom code which must be executed to correctly load the metric. You can inspect the repository content at https://raw.githubusercontent.com/huggingface/datasets/2.18.0/metrics/seqeval/seqeval.py\n",
745
            "You can avoid this message in future by passing the argument `trust_remote_code=True`.\n",
746
            "Passing `trust_remote_code=True` will be mandatory to load this metric from the next major release of `datasets`.\n",
747
            "  warnings.warn(\n"
748
          ]
749
        },
750
        {
751
          "output_type": "display_data",
752
          "data": {
753
            "text/plain": [
754
              "Downloading builder script:   0%|          | 0.00/2.47k [00:00<?, ?B/s]"
755
            ],
756
            "application/vnd.jupyter.widget-view+json": {
757
              "version_major": 2,
758
              "version_minor": 0,
759
              "model_id": "99188e0dd50f4d5a874eaec3101ceab6"
760
            }
761
          },
762
          "metadata": {}
763
        }
764
      ],
765
      "source": [
766
        "#load seqeval metric for evaluation\n",
767
        "metric = load_metric(\"seqeval\")"
768
      ]
769
    },
770
    {
771
      "cell_type": "code",
772
      "execution_count": null,
773
      "metadata": {
774
        "id": "0jHgq7Dldeix"
775
      },
776
      "outputs": [],
777
      "source": [
778
        "def compute_metrics_tr(p):\n",
779
        "    \"\"\"\n",
780
        "    Compute the metrics for the model\n",
781
        "    inputs:\n",
782
        "        p: tuple, the predictions and the labels\n",
783
        "    outputs:\n",
784
        "        dict: the metrics\n",
785
        "    \"\"\"\n",
786
        "    predictions, labels = p\n",
787
        "\n",
788
        "    # Remove ignored index (special tokens)\n",
789
        "    true_predictions = [\n",
790
        "        [entities_list[p] for (p, l) in zip(prediction, label) if l != -100]\n",
791
        "        for prediction, label in zip(predictions, labels)\n",
792
        "    ]\n",
793
        "    true_labels = [\n",
794
        "        [entities_list[l] for (p, l) in zip(prediction, label) if l != -100]\n",
795
        "        for prediction, label in zip(predictions, labels)\n",
796
        "    ]\n",
797
        "\n",
798
        "    results = metric.compute(predictions=true_predictions, references=true_labels)\n",
799
        "    resutls_strict = metric.compute(predictions=true_predictions, references=true_labels, mode='strict', scheme='IOB2')\n",
800
        "\n",
801
        "    cr1 = classification_report(true_labels, true_predictions)\n",
802
        "    cr2 = classification_report(true_labels, true_predictions, mode='strict', scheme=IOB2)\n",
803
        "\n",
804
        "    return results, resutls_strict,cr1,cr2"
805
      ]
806
    },
807
    {
808
      "cell_type": "code",
809
      "source": [],
810
      "metadata": {
811
        "id": "wYo2jYRfp-qK"
812
      },
813
      "execution_count": null,
814
      "outputs": []
815
    },
816
    {
817
      "cell_type": "code",
818
      "source": [
819
        "def get_labels(p):\n",
820
        "    predictions, labels = p\n",
821
        "    # Remove ignored index (special tokens)\n",
822
        "    predictions = [\n",
823
        "        [entities_list[p] for (p, l) in zip(prediction, label) if l != -100]\n",
824
        "        for prediction, label in zip(predictions, labels)\n",
825
        "    ]\n",
826
        "    labels = [\n",
827
        "        [entities_list[l] for (p, l) in zip(prediction, label) if l != -100]\n",
828
        "        for prediction, label in zip(predictions, labels)\n",
829
        "    ]\n",
830
        "\n",
831
        "    return predictions, labels\n",
832
        "\n",
833
        "\n",
834
        "\n",
835
        "\n"
836
      ],
837
      "metadata": {
838
        "id": "kW2qWh4XppbT"
839
      },
840
      "execution_count": 23,
841
      "outputs": []
842
    },
843
    {
844
      "cell_type": "code",
845
      "source": [
846
        "pred_labels, true_labels = get_labels((annotated_sentences_first, dataset['test']['ner_tags']))"
847
      ],
848
      "metadata": {
849
        "id": "T8EIf4d83TXK"
850
      },
851
      "execution_count": 24,
852
      "outputs": []
853
    },
854
    {
855
      "cell_type": "code",
856
      "source": [
857
        "pred_labels[0]"
858
      ],
859
      "metadata": {
860
        "id": "MvgnYYJh608X",
861
        "outputId": "8e666e13-0733-4af0-cf6e-516da4407bb2",
862
        "colab": {
863
          "base_uri": "https://localhost:8080/"
864
        }
865
      },
866
      "execution_count": 40,
867
      "outputs": [
868
        {
869
          "output_type": "execute_result",
870
          "data": {
871
            "text/plain": [
872
              "['O',\n",
873
              " 'O',\n",
874
              " 'O',\n",
875
              " 'B-Condition',\n",
876
              " 'B-Person',\n",
877
              " 'B-Value',\n",
878
              " 'O',\n",
879
              " 'I-Value',\n",
880
              " 'I-Value',\n",
881
              " 'I-Value',\n",
882
              " 'I-Value',\n",
883
              " 'I-Value',\n",
884
              " 'O',\n",
885
              " 'O',\n",
886
              " 'O',\n",
887
              " 'I-Observation',\n",
888
              " 'O',\n",
889
              " 'O']"
890
            ]
891
          },
892
          "metadata": {},
893
          "execution_count": 40
894
        }
895
      ]
896
    },
897
    {
898
      "cell_type": "code",
899
      "source": [
900
        "# from eval_file import *\n",
901
        "\n",
902
        "import argparse\n",
903
        "from collections import defaultdict\n",
904
        "from itertools import chain\n",
905
        "from math import pow\n",
906
        "from pathlib import Path\n",
907
        "\n",
908
        "# from common_utils.common_io import load_bio_file_into_sents\n",
909
        "# from common_utils.common_log import create_logger\n",
910
        "# -*- coding: utf-8 -*-\n",
911
        "\n",
912
        "# -*- coding: utf-8 -*-\n",
913
        "\n",
914
        "import json\n",
915
        "import pickle as pkl\n",
916
        "\n",
917
        "\n",
918
        "def read_from_file(ifn):\n",
919
        "    with open(ifn, \"r\") as f:\n",
920
        "        text = f.read()\n",
921
        "    return text\n",
922
        "\n",
923
        "\n",
924
        "def write_to_file(text, ofn):\n",
925
        "    with open(ofn, \"w\") as f:\n",
926
        "        f.write(text)\n",
927
        "    return True\n",
928
        "\n",
929
        "\n",
930
        "def pkl_load(ifn):\n",
931
        "    with open(ifn, \"rb\") as f:\n",
932
        "        pdata = pkl.load(f)\n",
933
        "    return pdata\n",
934
        "\n",
935
        "\n",
936
        "def pkl_dump(pdata, ofn):\n",
937
        "    with open(ofn, \"wb\") as f:\n",
938
        "        pkl.dump(pdata, f)\n",
939
        "    return True\n",
940
        "\n",
941
        "\n",
942
        "def json_load(ifn):\n",
943
        "    with open(ifn, \"r\") as f:\n",
944
        "        jdata = json.load(f)\n",
945
        "    return jdata\n",
946
        "\n",
947
        "\n",
948
        "def json_dump(jdata, ofn):\n",
949
        "    with open(ofn, \"w\") as f:\n",
950
        "        json.dump(jdata, f)\n",
951
        "    return True\n",
952
        "\n",
953
        "\n",
954
        "def load_bio_file_into_sents(bio_file, word_sep=\" \", do_lower=False):\n",
955
        "    bio_text = read_from_file(bio_file)\n",
956
        "    bio_text = bio_text.strip()\n",
957
        "    if do_lower:\n",
958
        "        bio_text = bio_text.lower()\n",
959
        "\n",
960
        "    new_sents = []\n",
961
        "    sents = bio_text.split(\"\\n\\n\")\n",
962
        "\n",
963
        "    for sent in sents:\n",
964
        "        new_sent = []\n",
965
        "        words = sent.split(\"\\n\")\n",
966
        "        for word in words:\n",
967
        "            new_word = word.split(word_sep)\n",
968
        "            new_sent.append(new_word)\n",
969
        "        new_sents.append(new_sent)\n",
970
        "\n",
971
        "    return new_sents\n",
972
        "\n",
973
        "\n",
974
        "def output_bio(bio_data, output_file, sep=\" \"):\n",
975
        "    with open(output_file, \"w\") as f:\n",
976
        "        for sent in bio_data:\n",
977
        "            for word in sent:\n",
978
        "                line = sep.join(word)\n",
979
        "                f.write(line)\n",
980
        "                f.write(\"\\n\")\n",
981
        "            f.write(\"\\n\")\n",
982
        "\n",
983
        "\n",
984
        "class PRF:\n",
985
        "    def __init__(self):\n",
986
        "        self.true = 0\n",
987
        "        self.false = 0\n",
988
        "\n",
989
        "    def add_true_case(self):\n",
990
        "        self.true += 1\n",
991
        "\n",
992
        "    def add_false_case(self):\n",
993
        "        self.false += 1\n",
994
        "\n",
995
        "    def get_true_false_counts(self):\n",
996
        "        return self.true, self.false\n",
997
        "\n",
998
        "    def __str__(self):\n",
999
        "        return str(self.__dict__)\n",
1000
        "\n",
1001
        "\n",
1002
        "class BioEval:\n",
1003
        "    def __init__(self):\n",
1004
        "        self.acc = PRF()\n",
1005
        "        # prediction\n",
1006
        "        self.all_strict = PRF()\n",
1007
        "        self.all_relax = PRF()\n",
1008
        "        self.cat_strict = defaultdict(PRF)\n",
1009
        "        self.cat_relax = defaultdict(PRF)\n",
1010
        "        # gold standard\n",
1011
        "        self.gs_all = 0\n",
1012
        "        self.gs_cat = defaultdict(int)\n",
1013
        "        self.performance = dict()\n",
1014
        "        self.counts = dict()\n",
1015
        "        self.beta = 1\n",
1016
        "        self.label_not_for_eval = {'o'}\n",
1017
        "\n",
1018
        "    def reset(self):\n",
1019
        "        self.acc = PRF()\n",
1020
        "        self.all_strict = PRF()\n",
1021
        "        self.all_relax = PRF()\n",
1022
        "        self.cat_strict = defaultdict(PRF)\n",
1023
        "        self.cat_relax = defaultdict(PRF)\n",
1024
        "        self.gs_all = 0\n",
1025
        "        self.gs_cat = defaultdict(int)\n",
1026
        "        self.performance = dict()\n",
1027
        "        self.counts = dict()\n",
1028
        "\n",
1029
        "    def set_beta_for_f_score(self, beta):\n",
1030
        "        print(\"Using beta={} for calculating F-score\".format(beta))\n",
1031
        "        self.beta = beta\n",
1032
        "\n",
1033
        "    # def set_logger(self, logger):\n",
1034
        "    #     self.logger = logger\n",
1035
        "\n",
1036
        "    def add_labels_not_for_eval(self, *labels):\n",
1037
        "        for each in labels:\n",
1038
        "            self.label_not_for_eval.add(each.lower())\n",
1039
        "\n",
1040
        "    def __calc_prf(self, tp, fp, tp_tn):\n",
1041
        "        \"\"\"\n",
1042
        "        Using this function to calculate F-beta score, beta=1 is f_score-score, set beta=2 favor recall, and set beta=0.5 favor precision.\n",
1043
        "        Using set_beta_for_f_score function to change beta value.\n",
1044
        "        \"\"\"\n",
1045
        "        tp_fp = tp + fp\n",
1046
        "        pre = 1.0 * tp / tp_fp if tp_fp > 0 else 0.0\n",
1047
        "        rec = 1.0 * tp / tp_tn if tp_tn > 0 else 0.0\n",
1048
        "        beta2 = pow(self.beta, 2)\n",
1049
        "        f_beta = (1 + beta2) * pre * rec / (beta2 * pre + rec) if (pre + rec) > 0 else 0.0\n",
1050
        "        return pre, rec, f_beta\n",
1051
        "\n",
1052
        "    def __measure_performance(self):\n",
1053
        "        self.performance['overall'] = dict()\n",
1054
        "\n",
1055
        "        acc_true_num, acc_false_num = self.acc.get_true_false_counts()\n",
1056
        "        total_acc_num = acc_true_num + acc_false_num\n",
1057
        "        # calc acc\n",
1058
        "        overall_acc = round(1.0 * acc_true_num / total_acc_num, 4) if total_acc_num > 0 else 0.0\n",
1059
        "        self.performance['overall']['acc'] = overall_acc\n",
1060
        "\n",
1061
        "        strict_true_counts, strict_false_counts = self.all_strict.get_true_false_counts()\n",
1062
        "        strict_pre, strict_rec, strict_f_score = self.__calc_prf(strict_true_counts, strict_false_counts, self.gs_all)\n",
1063
        "        self.performance['overall']['strict'] = dict()\n",
1064
        "        self.performance['overall']['strict']['precision'] = strict_pre\n",
1065
        "        self.performance['overall']['strict']['recall'] = strict_rec\n",
1066
        "        self.performance['overall']['strict']['f_score'] = strict_f_score\n",
1067
        "\n",
1068
        "        relax_true_counts, relax_false_counts = self.all_relax.get_true_false_counts()\n",
1069
        "        relax_pre, relax_rec, relax_f_score = self.__calc_prf(relax_true_counts, relax_false_counts, self.gs_all)\n",
1070
        "        self.performance['overall']['relax'] = dict()\n",
1071
        "        self.performance['overall']['relax']['precision'] = relax_pre\n",
1072
        "        self.performance['overall']['relax']['recall'] = relax_rec\n",
1073
        "        self.performance['overall']['relax']['f_score'] = relax_f_score\n",
1074
        "\n",
1075
        "        self.performance['category'] = dict()\n",
1076
        "        self.performance['category']['strict'] = dict()\n",
1077
        "        for k, v in self.cat_strict.items():\n",
1078
        "            self.performance['category']['strict'][k] = dict()\n",
1079
        "            stc, sfc = v.get_true_false_counts()\n",
1080
        "            p, r, f = self.__calc_prf(stc, sfc, self.gs_cat[k])\n",
1081
        "            self.performance['category']['strict'][k]['precision'] = p\n",
1082
        "            self.performance['category']['strict'][k]['recall'] = r\n",
1083
        "            self.performance['category']['strict'][k]['f_score'] = f\n",
1084
        "\n",
1085
        "        self.performance['category']['relax'] = dict()\n",
1086
        "        for k, v in self.cat_relax.items():\n",
1087
        "            self.performance['category']['relax'][k] = dict()\n",
1088
        "            rtc, rfc = v.get_true_false_counts()\n",
1089
        "            p, r, f = self.__calc_prf(rtc, rfc, self.gs_cat[k])\n",
1090
        "            self.performance['category']['relax'][k]['precision'] = p\n",
1091
        "            self.performance['category']['relax'][k]['recall'] = r\n",
1092
        "            self.performance['category']['relax'][k]['f_score'] = f\n",
1093
        "\n",
1094
        "    def __measure_counts(self):\n",
1095
        "        # gold standard\n",
1096
        "        self.counts['expect'] = dict()\n",
1097
        "        self.counts['expect']['overall'] = self.gs_all\n",
1098
        "        for k, v in self.gs_cat.items():\n",
1099
        "            self.counts['expect'][k] = v\n",
1100
        "        # prediction\n",
1101
        "        self.counts['prediction'] = {'strict': dict(), 'relax': dict()}\n",
1102
        "        # strict\n",
1103
        "        strict_true_counts, strict_false_counts = self.all_strict.get_true_false_counts()\n",
1104
        "        self.counts['prediction']['strict']['overall'] = dict()\n",
1105
        "        self.counts['prediction']['strict']['overall']['total'] = strict_true_counts + strict_false_counts\n",
1106
        "        self.counts['prediction']['strict']['overall']['true'] = strict_true_counts\n",
1107
        "        self.counts['prediction']['strict']['overall']['false'] = strict_false_counts\n",
1108
        "        for k, v in self.cat_strict.items():\n",
1109
        "            t, f = v.get_true_false_counts()\n",
1110
        "            self.counts['prediction']['strict'][k] = dict()\n",
1111
        "            self.counts['prediction']['strict'][k]['total'] = t + f\n",
1112
        "            self.counts['prediction']['strict'][k]['true'] = t\n",
1113
        "            self.counts['prediction']['strict'][k]['false'] = f\n",
1114
        "        # relax\n",
1115
        "        relax_true_counts, relax_false_counts = self.all_relax.get_true_false_counts()\n",
1116
        "        self.counts['prediction']['relax']['overall'] = dict()\n",
1117
        "        self.counts['prediction']['relax']['overall']['total'] = relax_true_counts + relax_false_counts\n",
1118
        "        self.counts['prediction']['relax']['overall']['true'] = relax_true_counts\n",
1119
        "        self.counts['prediction']['relax']['overall']['false'] = relax_false_counts\n",
1120
        "        for k, v in self.cat_relax.items():\n",
1121
        "            t, f = v.get_true_false_counts()\n",
1122
        "            self.counts['prediction']['relax'][k] = dict()\n",
1123
        "            self.counts['prediction']['relax'][k]['total'] = t + f\n",
1124
        "            self.counts['prediction']['relax'][k]['true'] = t\n",
1125
        "            self.counts['prediction']['relax'][k]['false'] = f\n",
1126
        "\n",
1127
        "    @staticmethod\n",
1128
        "    def __strict_match(gs, pred, s_idx, e_idx, en_type):\n",
1129
        "        if e_idx < len(gs) and gs[e_idx] == f\"i-{en_type}\":\n",
1130
        "            # check token after end in GS is not continued entity token\n",
1131
        "            return False\n",
1132
        "        elif gs[s_idx] != f\"b-{en_type}\" or pred[s_idx] != f\"b-{en_type}\":\n",
1133
        "            # force first token to be B-\n",
1134
        "            return False\n",
1135
        "        # check every token in span is the same\n",
1136
        "        for idx in range(s_idx, e_idx):\n",
1137
        "            if gs[idx] != pred[idx]:\n",
1138
        "                return False\n",
1139
        "        return True\n",
1140
        "\n",
1141
        "    @staticmethod\n",
1142
        "    def __relax_match(gs, pred, s_idx, e_idx, en_type):\n",
1143
        "        # we adopt the partial match strategy which is very loose compare to right-left or approximate match\n",
1144
        "        for idx in range(s_idx, e_idx):\n",
1145
        "            gs_cate = gs[idx].split(\"-\")[-1]\n",
1146
        "            pred_bound, pred_cate = pred[idx].split(\"-\")\n",
1147
        "            if gs_cate == pred_cate == en_type:\n",
1148
        "                return True\n",
1149
        "        return False\n",
1150
        "\n",
1151
        "    @staticmethod\n",
1152
        "    def __check_evaluated_already(gs_dict, cate, start_idx, end_idx):\n",
1153
        "        for k, v in gs_dict.items():\n",
1154
        "            c, s, e = k\n",
1155
        "            if not (e < start_idx or s > end_idx) and c == cate:\n",
1156
        "                if v == 0:\n",
1157
        "                    return True\n",
1158
        "                else:\n",
1159
        "                    gs_dict[k] -= 1\n",
1160
        "                    return False\n",
1161
        "        return False\n",
1162
        "\n",
1163
        "    def __process_bio(self, gs_bio, pred_bio):\n",
1164
        "        # measure acc\n",
1165
        "        for w_idx, (gs_word, pred_word) in enumerate(zip(gs_bio, pred_bio)):\n",
1166
        "            # measure acc\n",
1167
        "            if gs_word == pred_word:\n",
1168
        "                self.acc.add_true_case()\n",
1169
        "            else:\n",
1170
        "                self.acc.add_false_case()\n",
1171
        "\n",
1172
        "        # process gold standard\n",
1173
        "        llen = len(gs_bio)\n",
1174
        "        gs_dict = defaultdict(int)\n",
1175
        "        cur_idx = 0\n",
1176
        "        while cur_idx < llen:\n",
1177
        "            if gs_bio[cur_idx].strip() in self.label_not_for_eval:\n",
1178
        "                cur_idx += 1\n",
1179
        "            else:\n",
1180
        "                start_idx = cur_idx\n",
1181
        "                end_idx = start_idx + 1\n",
1182
        "                _, cate = gs_bio[start_idx].strip().split('-')\n",
1183
        "                while end_idx < llen and gs_bio[end_idx].strip() == f\"i-{cate}\":\n",
1184
        "                    end_idx += 1\n",
1185
        "                self.gs_all += 1\n",
1186
        "                self.gs_cat[cate] += 1\n",
1187
        "                gs_dict[(cate, start_idx, end_idx)] += 1\n",
1188
        "                cur_idx = end_idx\n",
1189
        "        # process predictions\n",
1190
        "        cur_idx = 0\n",
1191
        "        while cur_idx < llen:\n",
1192
        "            if pred_bio[cur_idx].strip() in self.label_not_for_eval:\n",
1193
        "                cur_idx += 1\n",
1194
        "            else:\n",
1195
        "                start_idx = cur_idx\n",
1196
        "                end_idx = start_idx + 1\n",
1197
        "                _, cate = pred_bio[start_idx].strip().split(\"-\")\n",
1198
        "                while end_idx < llen and pred_bio[end_idx].strip() == f\"i-{cate}\":\n",
1199
        "                    end_idx += 1\n",
1200
        "                if self.__strict_match(gs_bio, pred_bio, start_idx, end_idx, cate):\n",
1201
        "                    self.all_strict.add_true_case()\n",
1202
        "                    self.cat_strict[cate].add_true_case()\n",
1203
        "                    self.all_relax.add_true_case()\n",
1204
        "                    self.cat_relax[cate].add_true_case()\n",
1205
        "                elif self.__relax_match(gs_bio, pred_bio, start_idx, end_idx, cate):\n",
1206
        "                    if self.__check_evaluated_already(gs_dict, cate, start_idx, end_idx):\n",
1207
        "                        cur_idx = end_idx\n",
1208
        "                        continue\n",
1209
        "                    self.all_strict.add_false_case()\n",
1210
        "                    self.cat_strict[cate].add_false_case()\n",
1211
        "                    self.all_relax.add_true_case()\n",
1212
        "                    self.cat_relax[cate].add_true_case()\n",
1213
        "                else:\n",
1214
        "                    self.all_strict.add_false_case()\n",
1215
        "                    self.cat_strict[cate].add_false_case()\n",
1216
        "                    self.all_relax.add_false_case()\n",
1217
        "                    self.cat_relax[cate].add_false_case()\n",
1218
        "                cur_idx = end_idx\n",
1219
        "\n",
1220
        "    def eval_file(self, gs_file, pred_file):\n",
1221
        "        print(\"processing gold standard file: {} and prediciton file: {}\".format(gs_file, pred_file))\n",
1222
        "        pred_bio_sents = load_bio_file_into_sents(pred_file, do_lower=True)\n",
1223
        "        gs_bio_sents = load_bio_file_into_sents(gs_file, do_lower=True)\n",
1224
        "        # process bio data\n",
1225
        "        # check two data have same amount of sents\n",
1226
        "        assert len(gs_bio_sents) == len(pred_bio_sents), \\\n",
1227
        "            \"gold standard and prediction have different dimension: gs: {}; pred: {}\".format(len(gs_bio_sents), len(pred_bio_sents))\n",
1228
        "        # measure performance\n",
1229
        "        for s_idx, (gs_sent, pred_sent) in enumerate(zip(gs_bio_sents, pred_bio_sents)):\n",
1230
        "            # check two sents have same No. of words\n",
1231
        "            assert len(gs_sent) == len(pred_sent), \\\n",
1232
        "                \"In {}th sentence, the words counts are different; gs: {}; pred: {}\".format(s_idx, gs_sent, pred_sent)\n",
1233
        "            gs_sent = list(map(lambda x: x[-1], gs_sent))\n",
1234
        "            pred_sent = list(map(lambda x: x[-1], pred_sent))\n",
1235
        "            self.__process_bio(gs_sent, pred_sent)\n",
1236
        "        # get the evaluation matrix\n",
1237
        "        self.__measure_performance()\n",
1238
        "        self.__measure_counts()\n",
1239
        "\n",
1240
        "    def eval_mem(self, gs, pred, do_flat=False):\n",
1241
        "        # flat sents to sent; we assume input sequences only have 1 dimension (only labels)\n",
1242
        "        if do_flat:\n",
1243
        "            print('Sentences have been flatten to 1 dim.')\n",
1244
        "            gs = list(chain(*gs))\n",
1245
        "            pred = list(chain(*pred))\n",
1246
        "            gs = list(map(lambda x: x.lower(), gs))\n",
1247
        "            pred = list(map(lambda x: x.lower(), pred))\n",
1248
        "            self.__process_bio(gs, pred)\n",
1249
        "        else:\n",
1250
        "            for sidx, (gs_s, pred_s) in enumerate(zip(gs, pred)):\n",
1251
        "                gs_s = list(map(lambda x: x.lower(), gs_s))\n",
1252
        "                pred_s = list(map(lambda x: x.lower(), pred_s))\n",
1253
        "                self.__process_bio(gs_s, pred_s)\n",
1254
        "\n",
1255
        "        self.__measure_performance()\n",
1256
        "        self.__measure_counts()\n",
1257
        "\n",
1258
        "    def evaluate_annotations(self, gs, pred, do_lower=False):\n",
1259
        "        for gs_sent, pred_sent in zip(gs, pred):\n",
1260
        "            if do_lower:\n",
1261
        "              gs_sent = list(map(lambda x: x.lower(), gs_sent))\n",
1262
        "              pred_sent = list(map(lambda x: x.lower(), pred_sent))\n",
1263
        "            self.__process_bio(gs_sent, pred_sent)\n",
1264
        "\n",
1265
        "        self.__measure_performance()\n",
1266
        "        self.__measure_counts()\n",
1267
        "\n",
1268
        "    def get_performance(self):\n",
1269
        "        return self.performance\n",
1270
        "\n",
1271
        "    def get_counts(self):\n",
1272
        "        return self.counts\n",
1273
        "\n",
1274
        "    def save_evaluation(self, file):\n",
1275
        "        with open(file, \"w\") as f:\n",
1276
        "            json.dump(self.performance, f)\n",
1277
        "\n",
1278
        "    def show_evaluation(self, digits=4):\n",
1279
        "        if len(self.performance) == 0:\n",
1280
        "            raise RuntimeError('call eval_mem() first to get the performance attribute')\n",
1281
        "\n",
1282
        "        cate = self.performance['category']['strict'].keys()\n",
1283
        "\n",
1284
        "        headers = ['precision', 'recall', 'f1']\n",
1285
        "        width = max(max([len(c) for c in cate]), len('overall'), digits)\n",
1286
        "        head_fmt = '{:>{width}s} ' + ' {:>9}' * len(headers)\n",
1287
        "\n",
1288
        "        report = head_fmt.format(u'', *headers, width=width)\n",
1289
        "        report += '\\n\\nstrict\\n'\n",
1290
        "\n",
1291
        "        row_fmt = '{:>{width}s} ' + ' {:>9.{digits}f}' * 3 + '\\n'\n",
1292
        "        for c in cate:\n",
1293
        "            precision = self.performance['category']['strict'][c]['precision']\n",
1294
        "            recall = self.performance['category']['strict'][c]['recall']\n",
1295
        "            f1 = self.performance['category']['strict'][c]['f_score']\n",
1296
        "            report += row_fmt.format(c, *[precision, recall, f1], width=width, digits=digits)\n",
1297
        "\n",
1298
        "        report += '\\nrelax\\n'\n",
1299
        "\n",
1300
        "        for c in cate:\n",
1301
        "            precision = self.performance['category']['relax'][c]['precision']\n",
1302
        "            recall = self.performance['category']['relax'][c]['recall']\n",
1303
        "            f1 = self.performance['category']['relax'][c]['f_score']\n",
1304
        "            report += row_fmt.format(c, *[precision, recall, f1], width=width, digits=digits)\n",
1305
        "\n",
1306
        "        report += '\\n\\noverall\\n'\n",
1307
        "        report += 'acc: ' + str(self.performance['overall']['acc'])\n",
1308
        "        report += '\\nstrict\\n'\n",
1309
        "        report += row_fmt.format('', *[self.performance['overall']['strict']['precision'],\n",
1310
        "                                       self.performance['overall']['strict']['recall'],\n",
1311
        "                                       self.performance['overall']['strict']['f_score']], width=width, digits=digits)\n",
1312
        "\n",
1313
        "        report += '\\nrelax\\n'\n",
1314
        "        report += row_fmt.format('', *[self.performance['overall']['relax']['precision'],\n",
1315
        "                                       self.performance['overall']['relax']['recall'],\n",
1316
        "                                       self.performance['overall']['relax']['f_score']], width=width, digits=digits)\n",
1317
        "        return report\n"
1318
      ],
1319
      "metadata": {
1320
        "id": "c0uiL0XA3dnz"
1321
      },
1322
      "execution_count": 32,
1323
      "outputs": []
1324
    },
1325
    {
1326
      "cell_type": "code",
1327
      "source": [
1328
        "s = \"i-\""
1329
      ],
1330
      "metadata": {
1331
        "id": "WFBRwTMN8v2d"
1332
      },
1333
      "execution_count": null,
1334
      "outputs": []
1335
    },
1336
    {
1337
      "cell_type": "code",
1338
      "source": [
1339
        "evaluator = BioEval()"
1340
      ],
1341
      "metadata": {
1342
        "id": "6l6fW5Bd6MMK"
1343
      },
1344
      "execution_count": 33,
1345
      "outputs": []
1346
    },
1347
    {
1348
      "cell_type": "code",
1349
      "source": [
1350
        "evaluator.evaluate_annotations(true_labels, pred_labels, do_lower=True)"
1351
      ],
1352
      "metadata": {
1353
        "id": "obqUWCw-6T90"
1354
      },
1355
      "execution_count": 34,
1356
      "outputs": []
1357
    },
1358
    {
1359
      "cell_type": "code",
1360
      "source": [
1361
        "evaluator.performance"
1362
      ],
1363
      "metadata": {
1364
        "id": "XAdRmNx39MYa",
1365
        "outputId": "f2b1b26b-9ae1-4ce1-f513-8002bbc4d809",
1366
        "colab": {
1367
          "base_uri": "https://localhost:8080/"
1368
        }
1369
      },
1370
      "execution_count": 38,
1371
      "outputs": [
1372
        {
1373
          "output_type": "execute_result",
1374
          "data": {
1375
            "text/plain": [
1376
              "{'overall': {'acc': 0.8351,\n",
1377
              "  'strict': {'precision': 0.6225968648328897,\n",
1378
              "   'recall': 0.6740313800832533,\n",
1379
              "   'f_score': 0.6472939729397292},\n",
1380
              "  'relax': {'precision': 0.7580597456373854,\n",
1381
              "   'recall': 0.8206852385526737,\n",
1382
              "   'f_score': 0.7881303813038131}},\n",
1383
              " 'category': {'strict': {'condition': {'precision': 0.6648394675019577,\n",
1384
              "    'recall': 0.7683257918552037,\n",
1385
              "    'f_score': 0.7128463476070528},\n",
1386
              "   'person': {'precision': 0.7133757961783439,\n",
1387
              "    'recall': 0.8296296296296296,\n",
1388
              "    'f_score': 0.7671232876712328},\n",
1389
              "   'value': {'precision': 0.7067039106145251,\n",
1390
              "    'recall': 0.7207977207977208,\n",
1391
              "    'f_score': 0.7136812411847672},\n",
1392
              "   'drug': {'precision': 0.7180043383947939,\n",
1393
              "    'recall': 0.7471783295711061,\n",
1394
              "    'f_score': 0.7323008849557522},\n",
1395
              "   'temporal': {'precision': 0.49279538904899134,\n",
1396
              "    'recall': 0.5757575757575758,\n",
1397
              "    'f_score': 0.5310559006211181},\n",
1398
              "   'measurement': {'precision': 0.5473372781065089,\n",
1399
              "    'recall': 0.6379310344827587,\n",
1400
              "    'f_score': 0.5891719745222931},\n",
1401
              "   'procedure': {'precision': 0.5241157556270096,\n",
1402
              "    'recall': 0.5207667731629393,\n",
1403
              "    'f_score': 0.5224358974358974},\n",
1404
              "   'observation': {'precision': 0.31683168316831684,\n",
1405
              "    'recall': 0.1927710843373494,\n",
1406
              "    'f_score': 0.2397003745318352},\n",
1407
              "   'device': {'precision': 0.2903225806451613,\n",
1408
              "    'recall': 0.391304347826087,\n",
1409
              "    'f_score': 0.33333333333333337}},\n",
1410
              "  'relax': {'condition': {'precision': 0.7956147220046985,\n",
1411
              "    'recall': 0.9194570135746606,\n",
1412
              "    'f_score': 0.8530646515533165},\n",
1413
              "   'person': {'precision': 0.7261146496815286,\n",
1414
              "    'recall': 0.8444444444444444,\n",
1415
              "    'f_score': 0.7808219178082192},\n",
1416
              "   'value': {'precision': 0.8547486033519553,\n",
1417
              "    'recall': 0.8717948717948718,\n",
1418
              "    'f_score': 0.8631875881523272},\n",
1419
              "   'drug': {'precision': 0.841648590021692,\n",
1420
              "    'recall': 0.8758465011286681,\n",
1421
              "    'f_score': 0.8584070796460177},\n",
1422
              "   'temporal': {'precision': 0.6368876080691642,\n",
1423
              "    'recall': 0.7441077441077442,\n",
1424
              "    'f_score': 0.686335403726708},\n",
1425
              "   'measurement': {'precision': 0.7189349112426036,\n",
1426
              "    'recall': 0.8379310344827586,\n",
1427
              "    'f_score': 0.7738853503184714},\n",
1428
              "   'procedure': {'precision': 0.6752411575562701,\n",
1429
              "    'recall': 0.670926517571885,\n",
1430
              "    'f_score': 0.6730769230769232},\n",
1431
              "   'observation': {'precision': 0.5148514851485149,\n",
1432
              "    'recall': 0.3132530120481928,\n",
1433
              "    'f_score': 0.3895131086142322},\n",
1434
              "   'device': {'precision': 0.41935483870967744,\n",
1435
              "    'recall': 0.5652173913043478,\n",
1436
              "    'f_score': 0.4814814814814815}}}}"
1437
            ]
1438
          },
1439
          "metadata": {},
1440
          "execution_count": 38
1441
        }
1442
      ]
1443
    },
1444
    {
1445
      "cell_type": "code",
1446
      "source": [
1447
        "evaluator.save_evaluation('eval.json')"
1448
      ],
1449
      "metadata": {
1450
        "id": "kbc_sKVo901C"
1451
      },
1452
      "execution_count": 40,
1453
      "outputs": []
1454
    },
1455
    {
1456
      "cell_type": "code",
1457
      "execution_count": null,
1458
      "metadata": {
1459
        "id": "EY9TwGjjdeix"
1460
      },
1461
      "outputs": [],
1462
      "source": [
1463
        "results, results_strict,cr1,cr2 = compute_metrics_tr((annotated_sentences_first, dataset['test']['ner_tags']))"
1464
      ]
1465
    },
1466
    {
1467
      "cell_type": "code",
1468
      "source": [
1469
        "print(cr1)"
1470
      ],
1471
      "metadata": {
1472
        "id": "t8cITFjd2947",
1473
        "outputId": "363f869d-a417-49f3-85a2-d14fc4296b59",
1474
        "colab": {
1475
          "base_uri": "https://localhost:8080/"
1476
        }
1477
      },
1478
      "execution_count": null,
1479
      "outputs": [
1480
        {
1481
          "output_type": "stream",
1482
          "name": "stdout",
1483
          "text": [
1484
            "              precision    recall  f1-score   support\n",
1485
            "\n",
1486
            "   Condition       0.64      0.77      0.70      1105\n",
1487
            "      Device       0.24      0.30      0.27        23\n",
1488
            "        Drug       0.68      0.73      0.70       443\n",
1489
            " Measurement       0.53      0.62      0.57       290\n",
1490
            " Observation       0.30      0.18      0.23       166\n",
1491
            "      Person       0.76      0.84      0.80       135\n",
1492
            "   Procedure       0.46      0.49      0.48       313\n",
1493
            "    Temporal       0.48      0.58      0.52       297\n",
1494
            "       Value       0.65      0.70      0.68       351\n",
1495
            "\n",
1496
            "   micro avg       0.60      0.67      0.63      3123\n",
1497
            "   macro avg       0.53      0.58      0.55      3123\n",
1498
            "weighted avg       0.59      0.67      0.62      3123\n",
1499
            "\n"
1500
          ]
1501
        }
1502
      ]
1503
    },
1504
    {
1505
      "cell_type": "code",
1506
      "source": [
1507
        "print(cr2)"
1508
      ],
1509
      "metadata": {
1510
        "id": "FOYL6Awc3Cp5",
1511
        "outputId": "07c1fd7c-c56f-4adc-f3d5-5c4bf7f0ed7d",
1512
        "colab": {
1513
          "base_uri": "https://localhost:8080/"
1514
        }
1515
      },
1516
      "execution_count": null,
1517
      "outputs": [
1518
        {
1519
          "output_type": "stream",
1520
          "name": "stdout",
1521
          "text": [
1522
            "              precision    recall  f1-score   support\n",
1523
            "\n",
1524
            "   Condition       0.69      0.76      0.72      1104\n",
1525
            "      Device       0.29      0.30      0.30        23\n",
1526
            "        Drug       0.73      0.73      0.73       443\n",
1527
            " Measurement       0.59      0.61      0.60       288\n",
1528
            " Observation       0.40      0.17      0.24       166\n",
1529
            "      Person       0.76      0.84      0.80       135\n",
1530
            "   Procedure       0.53      0.49      0.51       311\n",
1531
            "    Temporal       0.58      0.57      0.58       295\n",
1532
            "       Value       0.70      0.72      0.71       345\n",
1533
            "\n",
1534
            "   micro avg       0.66      0.66      0.66      3110\n",
1535
            "   macro avg       0.59      0.58      0.58      3110\n",
1536
            "weighted avg       0.65      0.66      0.65      3110\n",
1537
            "\n"
1538
          ]
1539
        }
1540
      ]
1541
    }
1542
  ],
1543
  "metadata": {
1544
    "kernelspec": {
1545
      "display_name": "Python 3",
1546
      "name": "python3"
1547
    },
1548
    "language_info": {
1549
      "codemirror_mode": {
1550
        "name": "ipython",
1551
        "version": 3
1552
      },
1553
      "file_extension": ".py",
1554
      "mimetype": "text/x-python",
1555
      "name": "python",
1556
      "nbconvert_exporter": "python",
1557
      "pygments_lexer": "ipython3",
1558
      "version": "3.10.13"
1559
    },
1560
    "colab": {
1561
      "provenance": [],
1562
      "gpuType": "T4",
1563
      "include_colab_link": true
1564
    },
1565
    "accelerator": "GPU",
1566
    "widgets": {
1567
      "application/vnd.jupyter.widget-state+json": {
1568
        "99188e0dd50f4d5a874eaec3101ceab6": {
1569
          "model_module": "@jupyter-widgets/controls",
1570
          "model_name": "HBoxModel",
1571
          "model_module_version": "1.5.0",
1572
          "state": {
1573
            "_dom_classes": [],
1574
            "_model_module": "@jupyter-widgets/controls",
1575
            "_model_module_version": "1.5.0",
1576
            "_model_name": "HBoxModel",
1577
            "_view_count": null,
1578
            "_view_module": "@jupyter-widgets/controls",
1579
            "_view_module_version": "1.5.0",
1580
            "_view_name": "HBoxView",
1581
            "box_style": "",
1582
            "children": [
1583
              "IPY_MODEL_b289d32f0876481b97a080552549f7d1",
1584
              "IPY_MODEL_499e568745f743aea5c0b2ac64ef160f",
1585
              "IPY_MODEL_12eafe87e2b84edfa7d72b93361d3e6a"
1586
            ],
1587
            "layout": "IPY_MODEL_61a45966b4654a7db975880b0a193139"
1588
          }
1589
        },
1590
        "b289d32f0876481b97a080552549f7d1": {
1591
          "model_module": "@jupyter-widgets/controls",
1592
          "model_name": "HTMLModel",
1593
          "model_module_version": "1.5.0",
1594
          "state": {
1595
            "_dom_classes": [],
1596
            "_model_module": "@jupyter-widgets/controls",
1597
            "_model_module_version": "1.5.0",
1598
            "_model_name": "HTMLModel",
1599
            "_view_count": null,
1600
            "_view_module": "@jupyter-widgets/controls",
1601
            "_view_module_version": "1.5.0",
1602
            "_view_name": "HTMLView",
1603
            "description": "",
1604
            "description_tooltip": null,
1605
            "layout": "IPY_MODEL_95909a3c6f6245d1acd056f28bfe5ba8",
1606
            "placeholder": "​",
1607
            "style": "IPY_MODEL_feebbbdfbc3740bba039e95ddf31e4c1",
1608
            "value": "Downloading builder script: "
1609
          }
1610
        },
1611
        "499e568745f743aea5c0b2ac64ef160f": {
1612
          "model_module": "@jupyter-widgets/controls",
1613
          "model_name": "FloatProgressModel",
1614
          "model_module_version": "1.5.0",
1615
          "state": {
1616
            "_dom_classes": [],
1617
            "_model_module": "@jupyter-widgets/controls",
1618
            "_model_module_version": "1.5.0",
1619
            "_model_name": "FloatProgressModel",
1620
            "_view_count": null,
1621
            "_view_module": "@jupyter-widgets/controls",
1622
            "_view_module_version": "1.5.0",
1623
            "_view_name": "ProgressView",
1624
            "bar_style": "success",
1625
            "description": "",
1626
            "description_tooltip": null,
1627
            "layout": "IPY_MODEL_1eed478ce7694c4cb7e2c998963cafcc",
1628
            "max": 2471,
1629
            "min": 0,
1630
            "orientation": "horizontal",
1631
            "style": "IPY_MODEL_677a609737064c3c86de6503530b6268",
1632
            "value": 2471
1633
          }
1634
        },
1635
        "12eafe87e2b84edfa7d72b93361d3e6a": {
1636
          "model_module": "@jupyter-widgets/controls",
1637
          "model_name": "HTMLModel",
1638
          "model_module_version": "1.5.0",
1639
          "state": {
1640
            "_dom_classes": [],
1641
            "_model_module": "@jupyter-widgets/controls",
1642
            "_model_module_version": "1.5.0",
1643
            "_model_name": "HTMLModel",
1644
            "_view_count": null,
1645
            "_view_module": "@jupyter-widgets/controls",
1646
            "_view_module_version": "1.5.0",
1647
            "_view_name": "HTMLView",
1648
            "description": "",
1649
            "description_tooltip": null,
1650
            "layout": "IPY_MODEL_3736022fd7b5476dbfe03fee20d19f09",
1651
            "placeholder": "​",
1652
            "style": "IPY_MODEL_0846105c8d484656848ff41c571eb71f",
1653
            "value": " 6.33k/? [00:00&lt;00:00, 501kB/s]"
1654
          }
1655
        },
1656
        "61a45966b4654a7db975880b0a193139": {
1657
          "model_module": "@jupyter-widgets/base",
1658
          "model_name": "LayoutModel",
1659
          "model_module_version": "1.2.0",
1660
          "state": {
1661
            "_model_module": "@jupyter-widgets/base",
1662
            "_model_module_version": "1.2.0",
1663
            "_model_name": "LayoutModel",
1664
            "_view_count": null,
1665
            "_view_module": "@jupyter-widgets/base",
1666
            "_view_module_version": "1.2.0",
1667
            "_view_name": "LayoutView",
1668
            "align_content": null,
1669
            "align_items": null,
1670
            "align_self": null,
1671
            "border": null,
1672
            "bottom": null,
1673
            "display": null,
1674
            "flex": null,
1675
            "flex_flow": null,
1676
            "grid_area": null,
1677
            "grid_auto_columns": null,
1678
            "grid_auto_flow": null,
1679
            "grid_auto_rows": null,
1680
            "grid_column": null,
1681
            "grid_gap": null,
1682
            "grid_row": null,
1683
            "grid_template_areas": null,
1684
            "grid_template_columns": null,
1685
            "grid_template_rows": null,
1686
            "height": null,
1687
            "justify_content": null,
1688
            "justify_items": null,
1689
            "left": null,
1690
            "margin": null,
1691
            "max_height": null,
1692
            "max_width": null,
1693
            "min_height": null,
1694
            "min_width": null,
1695
            "object_fit": null,
1696
            "object_position": null,
1697
            "order": null,
1698
            "overflow": null,
1699
            "overflow_x": null,
1700
            "overflow_y": null,
1701
            "padding": null,
1702
            "right": null,
1703
            "top": null,
1704
            "visibility": null,
1705
            "width": null
1706
          }
1707
        },
1708
        "95909a3c6f6245d1acd056f28bfe5ba8": {
1709
          "model_module": "@jupyter-widgets/base",
1710
          "model_name": "LayoutModel",
1711
          "model_module_version": "1.2.0",
1712
          "state": {
1713
            "_model_module": "@jupyter-widgets/base",
1714
            "_model_module_version": "1.2.0",
1715
            "_model_name": "LayoutModel",
1716
            "_view_count": null,
1717
            "_view_module": "@jupyter-widgets/base",
1718
            "_view_module_version": "1.2.0",
1719
            "_view_name": "LayoutView",
1720
            "align_content": null,
1721
            "align_items": null,
1722
            "align_self": null,
1723
            "border": null,
1724
            "bottom": null,
1725
            "display": null,
1726
            "flex": null,
1727
            "flex_flow": null,
1728
            "grid_area": null,
1729
            "grid_auto_columns": null,
1730
            "grid_auto_flow": null,
1731
            "grid_auto_rows": null,
1732
            "grid_column": null,
1733
            "grid_gap": null,
1734
            "grid_row": null,
1735
            "grid_template_areas": null,
1736
            "grid_template_columns": null,
1737
            "grid_template_rows": null,
1738
            "height": null,
1739
            "justify_content": null,
1740
            "justify_items": null,
1741
            "left": null,
1742
            "margin": null,
1743
            "max_height": null,
1744
            "max_width": null,
1745
            "min_height": null,
1746
            "min_width": null,
1747
            "object_fit": null,
1748
            "object_position": null,
1749
            "order": null,
1750
            "overflow": null,
1751
            "overflow_x": null,
1752
            "overflow_y": null,
1753
            "padding": null,
1754
            "right": null,
1755
            "top": null,
1756
            "visibility": null,
1757
            "width": null
1758
          }
1759
        },
1760
        "feebbbdfbc3740bba039e95ddf31e4c1": {
1761
          "model_module": "@jupyter-widgets/controls",
1762
          "model_name": "DescriptionStyleModel",
1763
          "model_module_version": "1.5.0",
1764
          "state": {
1765
            "_model_module": "@jupyter-widgets/controls",
1766
            "_model_module_version": "1.5.0",
1767
            "_model_name": "DescriptionStyleModel",
1768
            "_view_count": null,
1769
            "_view_module": "@jupyter-widgets/base",
1770
            "_view_module_version": "1.2.0",
1771
            "_view_name": "StyleView",
1772
            "description_width": ""
1773
          }
1774
        },
1775
        "1eed478ce7694c4cb7e2c998963cafcc": {
1776
          "model_module": "@jupyter-widgets/base",
1777
          "model_name": "LayoutModel",
1778
          "model_module_version": "1.2.0",
1779
          "state": {
1780
            "_model_module": "@jupyter-widgets/base",
1781
            "_model_module_version": "1.2.0",
1782
            "_model_name": "LayoutModel",
1783
            "_view_count": null,
1784
            "_view_module": "@jupyter-widgets/base",
1785
            "_view_module_version": "1.2.0",
1786
            "_view_name": "LayoutView",
1787
            "align_content": null,
1788
            "align_items": null,
1789
            "align_self": null,
1790
            "border": null,
1791
            "bottom": null,
1792
            "display": null,
1793
            "flex": null,
1794
            "flex_flow": null,
1795
            "grid_area": null,
1796
            "grid_auto_columns": null,
1797
            "grid_auto_flow": null,
1798
            "grid_auto_rows": null,
1799
            "grid_column": null,
1800
            "grid_gap": null,
1801
            "grid_row": null,
1802
            "grid_template_areas": null,
1803
            "grid_template_columns": null,
1804
            "grid_template_rows": null,
1805
            "height": null,
1806
            "justify_content": null,
1807
            "justify_items": null,
1808
            "left": null,
1809
            "margin": null,
1810
            "max_height": null,
1811
            "max_width": null,
1812
            "min_height": null,
1813
            "min_width": null,
1814
            "object_fit": null,
1815
            "object_position": null,
1816
            "order": null,
1817
            "overflow": null,
1818
            "overflow_x": null,
1819
            "overflow_y": null,
1820
            "padding": null,
1821
            "right": null,
1822
            "top": null,
1823
            "visibility": null,
1824
            "width": null
1825
          }
1826
        },
1827
        "677a609737064c3c86de6503530b6268": {
1828
          "model_module": "@jupyter-widgets/controls",
1829
          "model_name": "ProgressStyleModel",
1830
          "model_module_version": "1.5.0",
1831
          "state": {
1832
            "_model_module": "@jupyter-widgets/controls",
1833
            "_model_module_version": "1.5.0",
1834
            "_model_name": "ProgressStyleModel",
1835
            "_view_count": null,
1836
            "_view_module": "@jupyter-widgets/base",
1837
            "_view_module_version": "1.2.0",
1838
            "_view_name": "StyleView",
1839
            "bar_color": null,
1840
            "description_width": ""
1841
          }
1842
        },
1843
        "3736022fd7b5476dbfe03fee20d19f09": {
1844
          "model_module": "@jupyter-widgets/base",
1845
          "model_name": "LayoutModel",
1846
          "model_module_version": "1.2.0",
1847
          "state": {
1848
            "_model_module": "@jupyter-widgets/base",
1849
            "_model_module_version": "1.2.0",
1850
            "_model_name": "LayoutModel",
1851
            "_view_count": null,
1852
            "_view_module": "@jupyter-widgets/base",
1853
            "_view_module_version": "1.2.0",
1854
            "_view_name": "LayoutView",
1855
            "align_content": null,
1856
            "align_items": null,
1857
            "align_self": null,
1858
            "border": null,
1859
            "bottom": null,
1860
            "display": null,
1861
            "flex": null,
1862
            "flex_flow": null,
1863
            "grid_area": null,
1864
            "grid_auto_columns": null,
1865
            "grid_auto_flow": null,
1866
            "grid_auto_rows": null,
1867
            "grid_column": null,
1868
            "grid_gap": null,
1869
            "grid_row": null,
1870
            "grid_template_areas": null,
1871
            "grid_template_columns": null,
1872
            "grid_template_rows": null,
1873
            "height": null,
1874
            "justify_content": null,
1875
            "justify_items": null,
1876
            "left": null,
1877
            "margin": null,
1878
            "max_height": null,
1879
            "max_width": null,
1880
            "min_height": null,
1881
            "min_width": null,
1882
            "object_fit": null,
1883
            "object_position": null,
1884
            "order": null,
1885
            "overflow": null,
1886
            "overflow_x": null,
1887
            "overflow_y": null,
1888
            "padding": null,
1889
            "right": null,
1890
            "top": null,
1891
            "visibility": null,
1892
            "width": null
1893
          }
1894
        },
1895
        "0846105c8d484656848ff41c571eb71f": {
1896
          "model_module": "@jupyter-widgets/controls",
1897
          "model_name": "DescriptionStyleModel",
1898
          "model_module_version": "1.5.0",
1899
          "state": {
1900
            "_model_module": "@jupyter-widgets/controls",
1901
            "_model_module_version": "1.5.0",
1902
            "_model_name": "DescriptionStyleModel",
1903
            "_view_count": null,
1904
            "_view_module": "@jupyter-widgets/base",
1905
            "_view_module_version": "1.2.0",
1906
            "_view_name": "StyleView",
1907
            "description_width": ""
1908
          }
1909
        },
1910
        "aae03eda481e488eaf1ef5b0610cdc0b": {
1911
          "model_module": "@jupyter-widgets/controls",
1912
          "model_name": "VBoxModel",
1913
          "model_module_version": "1.5.0",
1914
          "state": {
1915
            "_dom_classes": [],
1916
            "_model_module": "@jupyter-widgets/controls",
1917
            "_model_module_version": "1.5.0",
1918
            "_model_name": "VBoxModel",
1919
            "_view_count": null,
1920
            "_view_module": "@jupyter-widgets/controls",
1921
            "_view_module_version": "1.5.0",
1922
            "_view_name": "VBoxView",
1923
            "box_style": "",
1924
            "children": [
1925
              "IPY_MODEL_13acbfe9fc7a4ff4a6ec0a8be56c4f62",
1926
              "IPY_MODEL_e7bcd126a8384f94a027e130d09f2346",
1927
              "IPY_MODEL_ee0ac8c2fac44c02b28844bb5bc6822a",
1928
              "IPY_MODEL_d1444855a9cc4726a37cf9f184be8409"
1929
            ],
1930
            "layout": "IPY_MODEL_d2605acf97fa45ad8b157868a831e4f7"
1931
          }
1932
        },
1933
        "034ac69beaf14927bb2800c7e848ecbb": {
1934
          "model_module": "@jupyter-widgets/controls",
1935
          "model_name": "HTMLModel",
1936
          "model_module_version": "1.5.0",
1937
          "state": {
1938
            "_dom_classes": [],
1939
            "_model_module": "@jupyter-widgets/controls",
1940
            "_model_module_version": "1.5.0",
1941
            "_model_name": "HTMLModel",
1942
            "_view_count": null,
1943
            "_view_module": "@jupyter-widgets/controls",
1944
            "_view_module_version": "1.5.0",
1945
            "_view_name": "HTMLView",
1946
            "description": "",
1947
            "description_tooltip": null,
1948
            "layout": "IPY_MODEL_c116ed771b584a1398d9200fd3a8eba0",
1949
            "placeholder": "​",
1950
            "style": "IPY_MODEL_f3a413d8c726471295e252f3ea122f31",
1951
            "value": "<center> <img\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.svg\nalt='Hugging Face'> <br> Copy a token from <a\nhref=\"https://huggingface.co/settings/tokens\" target=\"_blank\">your Hugging Face\ntokens page</a> and paste it below. <br> Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file. </center>"
1952
          }
1953
        },
1954
        "0c7e1ad3261b4ff4876a9a8654fc9464": {
1955
          "model_module": "@jupyter-widgets/controls",
1956
          "model_name": "PasswordModel",
1957
          "model_module_version": "1.5.0",
1958
          "state": {
1959
            "_dom_classes": [],
1960
            "_model_module": "@jupyter-widgets/controls",
1961
            "_model_module_version": "1.5.0",
1962
            "_model_name": "PasswordModel",
1963
            "_view_count": null,
1964
            "_view_module": "@jupyter-widgets/controls",
1965
            "_view_module_version": "1.5.0",
1966
            "_view_name": "PasswordView",
1967
            "continuous_update": true,
1968
            "description": "Token:",
1969
            "description_tooltip": null,
1970
            "disabled": false,
1971
            "layout": "IPY_MODEL_2e4c44c84e464804b1c757f88e46d506",
1972
            "placeholder": "​",
1973
            "style": "IPY_MODEL_719dfc3140194a839f84e6efe01e01b0",
1974
            "value": ""
1975
          }
1976
        },
1977
        "306bc801a94541999e50632fbc3f4c0f": {
1978
          "model_module": "@jupyter-widgets/controls",
1979
          "model_name": "CheckboxModel",
1980
          "model_module_version": "1.5.0",
1981
          "state": {
1982
            "_dom_classes": [],
1983
            "_model_module": "@jupyter-widgets/controls",
1984
            "_model_module_version": "1.5.0",
1985
            "_model_name": "CheckboxModel",
1986
            "_view_count": null,
1987
            "_view_module": "@jupyter-widgets/controls",
1988
            "_view_module_version": "1.5.0",
1989
            "_view_name": "CheckboxView",
1990
            "description": "Add token as git credential?",
1991
            "description_tooltip": null,
1992
            "disabled": false,
1993
            "indent": true,
1994
            "layout": "IPY_MODEL_7e0e3e6216db4347a7de8f4553dd6282",
1995
            "style": "IPY_MODEL_7c10261a70ee4e7184524cc2590a28c1",
1996
            "value": true
1997
          }
1998
        },
1999
        "36dbf510f6fc446383291658d394066a": {
2000
          "model_module": "@jupyter-widgets/controls",
2001
          "model_name": "ButtonModel",
2002
          "model_module_version": "1.5.0",
2003
          "state": {
2004
            "_dom_classes": [],
2005
            "_model_module": "@jupyter-widgets/controls",
2006
            "_model_module_version": "1.5.0",
2007
            "_model_name": "ButtonModel",
2008
            "_view_count": null,
2009
            "_view_module": "@jupyter-widgets/controls",
2010
            "_view_module_version": "1.5.0",
2011
            "_view_name": "ButtonView",
2012
            "button_style": "",
2013
            "description": "Login",
2014
            "disabled": false,
2015
            "icon": "",
2016
            "layout": "IPY_MODEL_5b93a9aedb2f49d88e5e1d9cdb13c751",
2017
            "style": "IPY_MODEL_5ad14d3ac4614dcc903d60dcb4edbb88",
2018
            "tooltip": ""
2019
          }
2020
        },
2021
        "77affba1207543b483febb7acb086298": {
2022
          "model_module": "@jupyter-widgets/controls",
2023
          "model_name": "HTMLModel",
2024
          "model_module_version": "1.5.0",
2025
          "state": {
2026
            "_dom_classes": [],
2027
            "_model_module": "@jupyter-widgets/controls",
2028
            "_model_module_version": "1.5.0",
2029
            "_model_name": "HTMLModel",
2030
            "_view_count": null,
2031
            "_view_module": "@jupyter-widgets/controls",
2032
            "_view_module_version": "1.5.0",
2033
            "_view_name": "HTMLView",
2034
            "description": "",
2035
            "description_tooltip": null,
2036
            "layout": "IPY_MODEL_c218b57c46fc4f5eb9260fd08c5a94c8",
2037
            "placeholder": "​",
2038
            "style": "IPY_MODEL_e377b67ff2a948e3be138334ed3de886",
2039
            "value": "\n<b>Pro Tip:</b> If you don't already have one, you can create a dedicated\n'notebooks' token with 'write' access, that you can then easily reuse for all\nnotebooks. </center>"
2040
          }
2041
        },
2042
        "d2605acf97fa45ad8b157868a831e4f7": {
2043
          "model_module": "@jupyter-widgets/base",
2044
          "model_name": "LayoutModel",
2045
          "model_module_version": "1.2.0",
2046
          "state": {
2047
            "_model_module": "@jupyter-widgets/base",
2048
            "_model_module_version": "1.2.0",
2049
            "_model_name": "LayoutModel",
2050
            "_view_count": null,
2051
            "_view_module": "@jupyter-widgets/base",
2052
            "_view_module_version": "1.2.0",
2053
            "_view_name": "LayoutView",
2054
            "align_content": null,
2055
            "align_items": "center",
2056
            "align_self": null,
2057
            "border": null,
2058
            "bottom": null,
2059
            "display": "flex",
2060
            "flex": null,
2061
            "flex_flow": "column",
2062
            "grid_area": null,
2063
            "grid_auto_columns": null,
2064
            "grid_auto_flow": null,
2065
            "grid_auto_rows": null,
2066
            "grid_column": null,
2067
            "grid_gap": null,
2068
            "grid_row": null,
2069
            "grid_template_areas": null,
2070
            "grid_template_columns": null,
2071
            "grid_template_rows": null,
2072
            "height": null,
2073
            "justify_content": null,
2074
            "justify_items": null,
2075
            "left": null,
2076
            "margin": null,
2077
            "max_height": null,
2078
            "max_width": null,
2079
            "min_height": null,
2080
            "min_width": null,
2081
            "object_fit": null,
2082
            "object_position": null,
2083
            "order": null,
2084
            "overflow": null,
2085
            "overflow_x": null,
2086
            "overflow_y": null,
2087
            "padding": null,
2088
            "right": null,
2089
            "top": null,
2090
            "visibility": null,
2091
            "width": "50%"
2092
          }
2093
        },
2094
        "c116ed771b584a1398d9200fd3a8eba0": {
2095
          "model_module": "@jupyter-widgets/base",
2096
          "model_name": "LayoutModel",
2097
          "model_module_version": "1.2.0",
2098
          "state": {
2099
            "_model_module": "@jupyter-widgets/base",
2100
            "_model_module_version": "1.2.0",
2101
            "_model_name": "LayoutModel",
2102
            "_view_count": null,
2103
            "_view_module": "@jupyter-widgets/base",
2104
            "_view_module_version": "1.2.0",
2105
            "_view_name": "LayoutView",
2106
            "align_content": null,
2107
            "align_items": null,
2108
            "align_self": null,
2109
            "border": null,
2110
            "bottom": null,
2111
            "display": null,
2112
            "flex": null,
2113
            "flex_flow": null,
2114
            "grid_area": null,
2115
            "grid_auto_columns": null,
2116
            "grid_auto_flow": null,
2117
            "grid_auto_rows": null,
2118
            "grid_column": null,
2119
            "grid_gap": null,
2120
            "grid_row": null,
2121
            "grid_template_areas": null,
2122
            "grid_template_columns": null,
2123
            "grid_template_rows": null,
2124
            "height": null,
2125
            "justify_content": null,
2126
            "justify_items": null,
2127
            "left": null,
2128
            "margin": null,
2129
            "max_height": null,
2130
            "max_width": null,
2131
            "min_height": null,
2132
            "min_width": null,
2133
            "object_fit": null,
2134
            "object_position": null,
2135
            "order": null,
2136
            "overflow": null,
2137
            "overflow_x": null,
2138
            "overflow_y": null,
2139
            "padding": null,
2140
            "right": null,
2141
            "top": null,
2142
            "visibility": null,
2143
            "width": null
2144
          }
2145
        },
2146
        "f3a413d8c726471295e252f3ea122f31": {
2147
          "model_module": "@jupyter-widgets/controls",
2148
          "model_name": "DescriptionStyleModel",
2149
          "model_module_version": "1.5.0",
2150
          "state": {
2151
            "_model_module": "@jupyter-widgets/controls",
2152
            "_model_module_version": "1.5.0",
2153
            "_model_name": "DescriptionStyleModel",
2154
            "_view_count": null,
2155
            "_view_module": "@jupyter-widgets/base",
2156
            "_view_module_version": "1.2.0",
2157
            "_view_name": "StyleView",
2158
            "description_width": ""
2159
          }
2160
        },
2161
        "2e4c44c84e464804b1c757f88e46d506": {
2162
          "model_module": "@jupyter-widgets/base",
2163
          "model_name": "LayoutModel",
2164
          "model_module_version": "1.2.0",
2165
          "state": {
2166
            "_model_module": "@jupyter-widgets/base",
2167
            "_model_module_version": "1.2.0",
2168
            "_model_name": "LayoutModel",
2169
            "_view_count": null,
2170
            "_view_module": "@jupyter-widgets/base",
2171
            "_view_module_version": "1.2.0",
2172
            "_view_name": "LayoutView",
2173
            "align_content": null,
2174
            "align_items": null,
2175
            "align_self": null,
2176
            "border": null,
2177
            "bottom": null,
2178
            "display": null,
2179
            "flex": null,
2180
            "flex_flow": null,
2181
            "grid_area": null,
2182
            "grid_auto_columns": null,
2183
            "grid_auto_flow": null,
2184
            "grid_auto_rows": null,
2185
            "grid_column": null,
2186
            "grid_gap": null,
2187
            "grid_row": null,
2188
            "grid_template_areas": null,
2189
            "grid_template_columns": null,
2190
            "grid_template_rows": null,
2191
            "height": null,
2192
            "justify_content": null,
2193
            "justify_items": null,
2194
            "left": null,
2195
            "margin": null,
2196
            "max_height": null,
2197
            "max_width": null,
2198
            "min_height": null,
2199
            "min_width": null,
2200
            "object_fit": null,
2201
            "object_position": null,
2202
            "order": null,
2203
            "overflow": null,
2204
            "overflow_x": null,
2205
            "overflow_y": null,
2206
            "padding": null,
2207
            "right": null,
2208
            "top": null,
2209
            "visibility": null,
2210
            "width": null
2211
          }
2212
        },
2213
        "719dfc3140194a839f84e6efe01e01b0": {
2214
          "model_module": "@jupyter-widgets/controls",
2215
          "model_name": "DescriptionStyleModel",
2216
          "model_module_version": "1.5.0",
2217
          "state": {
2218
            "_model_module": "@jupyter-widgets/controls",
2219
            "_model_module_version": "1.5.0",
2220
            "_model_name": "DescriptionStyleModel",
2221
            "_view_count": null,
2222
            "_view_module": "@jupyter-widgets/base",
2223
            "_view_module_version": "1.2.0",
2224
            "_view_name": "StyleView",
2225
            "description_width": ""
2226
          }
2227
        },
2228
        "7e0e3e6216db4347a7de8f4553dd6282": {
2229
          "model_module": "@jupyter-widgets/base",
2230
          "model_name": "LayoutModel",
2231
          "model_module_version": "1.2.0",
2232
          "state": {
2233
            "_model_module": "@jupyter-widgets/base",
2234
            "_model_module_version": "1.2.0",
2235
            "_model_name": "LayoutModel",
2236
            "_view_count": null,
2237
            "_view_module": "@jupyter-widgets/base",
2238
            "_view_module_version": "1.2.0",
2239
            "_view_name": "LayoutView",
2240
            "align_content": null,
2241
            "align_items": null,
2242
            "align_self": null,
2243
            "border": null,
2244
            "bottom": null,
2245
            "display": null,
2246
            "flex": null,
2247
            "flex_flow": null,
2248
            "grid_area": null,
2249
            "grid_auto_columns": null,
2250
            "grid_auto_flow": null,
2251
            "grid_auto_rows": null,
2252
            "grid_column": null,
2253
            "grid_gap": null,
2254
            "grid_row": null,
2255
            "grid_template_areas": null,
2256
            "grid_template_columns": null,
2257
            "grid_template_rows": null,
2258
            "height": null,
2259
            "justify_content": null,
2260
            "justify_items": null,
2261
            "left": null,
2262
            "margin": null,
2263
            "max_height": null,
2264
            "max_width": null,
2265
            "min_height": null,
2266
            "min_width": null,
2267
            "object_fit": null,
2268
            "object_position": null,
2269
            "order": null,
2270
            "overflow": null,
2271
            "overflow_x": null,
2272
            "overflow_y": null,
2273
            "padding": null,
2274
            "right": null,
2275
            "top": null,
2276
            "visibility": null,
2277
            "width": null
2278
          }
2279
        },
2280
        "7c10261a70ee4e7184524cc2590a28c1": {
2281
          "model_module": "@jupyter-widgets/controls",
2282
          "model_name": "DescriptionStyleModel",
2283
          "model_module_version": "1.5.0",
2284
          "state": {
2285
            "_model_module": "@jupyter-widgets/controls",
2286
            "_model_module_version": "1.5.0",
2287
            "_model_name": "DescriptionStyleModel",
2288
            "_view_count": null,
2289
            "_view_module": "@jupyter-widgets/base",
2290
            "_view_module_version": "1.2.0",
2291
            "_view_name": "StyleView",
2292
            "description_width": ""
2293
          }
2294
        },
2295
        "5b93a9aedb2f49d88e5e1d9cdb13c751": {
2296
          "model_module": "@jupyter-widgets/base",
2297
          "model_name": "LayoutModel",
2298
          "model_module_version": "1.2.0",
2299
          "state": {
2300
            "_model_module": "@jupyter-widgets/base",
2301
            "_model_module_version": "1.2.0",
2302
            "_model_name": "LayoutModel",
2303
            "_view_count": null,
2304
            "_view_module": "@jupyter-widgets/base",
2305
            "_view_module_version": "1.2.0",
2306
            "_view_name": "LayoutView",
2307
            "align_content": null,
2308
            "align_items": null,
2309
            "align_self": null,
2310
            "border": null,
2311
            "bottom": null,
2312
            "display": null,
2313
            "flex": null,
2314
            "flex_flow": null,
2315
            "grid_area": null,
2316
            "grid_auto_columns": null,
2317
            "grid_auto_flow": null,
2318
            "grid_auto_rows": null,
2319
            "grid_column": null,
2320
            "grid_gap": null,
2321
            "grid_row": null,
2322
            "grid_template_areas": null,
2323
            "grid_template_columns": null,
2324
            "grid_template_rows": null,
2325
            "height": null,
2326
            "justify_content": null,
2327
            "justify_items": null,
2328
            "left": null,
2329
            "margin": null,
2330
            "max_height": null,
2331
            "max_width": null,
2332
            "min_height": null,
2333
            "min_width": null,
2334
            "object_fit": null,
2335
            "object_position": null,
2336
            "order": null,
2337
            "overflow": null,
2338
            "overflow_x": null,
2339
            "overflow_y": null,
2340
            "padding": null,
2341
            "right": null,
2342
            "top": null,
2343
            "visibility": null,
2344
            "width": null
2345
          }
2346
        },
2347
        "5ad14d3ac4614dcc903d60dcb4edbb88": {
2348
          "model_module": "@jupyter-widgets/controls",
2349
          "model_name": "ButtonStyleModel",
2350
          "model_module_version": "1.5.0",
2351
          "state": {
2352
            "_model_module": "@jupyter-widgets/controls",
2353
            "_model_module_version": "1.5.0",
2354
            "_model_name": "ButtonStyleModel",
2355
            "_view_count": null,
2356
            "_view_module": "@jupyter-widgets/base",
2357
            "_view_module_version": "1.2.0",
2358
            "_view_name": "StyleView",
2359
            "button_color": null,
2360
            "font_weight": ""
2361
          }
2362
        },
2363
        "c218b57c46fc4f5eb9260fd08c5a94c8": {
2364
          "model_module": "@jupyter-widgets/base",
2365
          "model_name": "LayoutModel",
2366
          "model_module_version": "1.2.0",
2367
          "state": {
2368
            "_model_module": "@jupyter-widgets/base",
2369
            "_model_module_version": "1.2.0",
2370
            "_model_name": "LayoutModel",
2371
            "_view_count": null,
2372
            "_view_module": "@jupyter-widgets/base",
2373
            "_view_module_version": "1.2.0",
2374
            "_view_name": "LayoutView",
2375
            "align_content": null,
2376
            "align_items": null,
2377
            "align_self": null,
2378
            "border": null,
2379
            "bottom": null,
2380
            "display": null,
2381
            "flex": null,
2382
            "flex_flow": null,
2383
            "grid_area": null,
2384
            "grid_auto_columns": null,
2385
            "grid_auto_flow": null,
2386
            "grid_auto_rows": null,
2387
            "grid_column": null,
2388
            "grid_gap": null,
2389
            "grid_row": null,
2390
            "grid_template_areas": null,
2391
            "grid_template_columns": null,
2392
            "grid_template_rows": null,
2393
            "height": null,
2394
            "justify_content": null,
2395
            "justify_items": null,
2396
            "left": null,
2397
            "margin": null,
2398
            "max_height": null,
2399
            "max_width": null,
2400
            "min_height": null,
2401
            "min_width": null,
2402
            "object_fit": null,
2403
            "object_position": null,
2404
            "order": null,
2405
            "overflow": null,
2406
            "overflow_x": null,
2407
            "overflow_y": null,
2408
            "padding": null,
2409
            "right": null,
2410
            "top": null,
2411
            "visibility": null,
2412
            "width": null
2413
          }
2414
        },
2415
        "e377b67ff2a948e3be138334ed3de886": {
2416
          "model_module": "@jupyter-widgets/controls",
2417
          "model_name": "DescriptionStyleModel",
2418
          "model_module_version": "1.5.0",
2419
          "state": {
2420
            "_model_module": "@jupyter-widgets/controls",
2421
            "_model_module_version": "1.5.0",
2422
            "_model_name": "DescriptionStyleModel",
2423
            "_view_count": null,
2424
            "_view_module": "@jupyter-widgets/base",
2425
            "_view_module_version": "1.2.0",
2426
            "_view_name": "StyleView",
2427
            "description_width": ""
2428
          }
2429
        },
2430
        "d9a4367195b94edc9d1ba97d7b0a2eb8": {
2431
          "model_module": "@jupyter-widgets/controls",
2432
          "model_name": "LabelModel",
2433
          "model_module_version": "1.5.0",
2434
          "state": {
2435
            "_dom_classes": [],
2436
            "_model_module": "@jupyter-widgets/controls",
2437
            "_model_module_version": "1.5.0",
2438
            "_model_name": "LabelModel",
2439
            "_view_count": null,
2440
            "_view_module": "@jupyter-widgets/controls",
2441
            "_view_module_version": "1.5.0",
2442
            "_view_name": "LabelView",
2443
            "description": "",
2444
            "description_tooltip": null,
2445
            "layout": "IPY_MODEL_aa9ffe65a42643c69f553f283cdf6772",
2446
            "placeholder": "​",
2447
            "style": "IPY_MODEL_8a95f6bbd81148519ec4639d8b0f4db6",
2448
            "value": "Connecting..."
2449
          }
2450
        },
2451
        "aa9ffe65a42643c69f553f283cdf6772": {
2452
          "model_module": "@jupyter-widgets/base",
2453
          "model_name": "LayoutModel",
2454
          "model_module_version": "1.2.0",
2455
          "state": {
2456
            "_model_module": "@jupyter-widgets/base",
2457
            "_model_module_version": "1.2.0",
2458
            "_model_name": "LayoutModel",
2459
            "_view_count": null,
2460
            "_view_module": "@jupyter-widgets/base",
2461
            "_view_module_version": "1.2.0",
2462
            "_view_name": "LayoutView",
2463
            "align_content": null,
2464
            "align_items": null,
2465
            "align_self": null,
2466
            "border": null,
2467
            "bottom": null,
2468
            "display": null,
2469
            "flex": null,
2470
            "flex_flow": null,
2471
            "grid_area": null,
2472
            "grid_auto_columns": null,
2473
            "grid_auto_flow": null,
2474
            "grid_auto_rows": null,
2475
            "grid_column": null,
2476
            "grid_gap": null,
2477
            "grid_row": null,
2478
            "grid_template_areas": null,
2479
            "grid_template_columns": null,
2480
            "grid_template_rows": null,
2481
            "height": null,
2482
            "justify_content": null,
2483
            "justify_items": null,
2484
            "left": null,
2485
            "margin": null,
2486
            "max_height": null,
2487
            "max_width": null,
2488
            "min_height": null,
2489
            "min_width": null,
2490
            "object_fit": null,
2491
            "object_position": null,
2492
            "order": null,
2493
            "overflow": null,
2494
            "overflow_x": null,
2495
            "overflow_y": null,
2496
            "padding": null,
2497
            "right": null,
2498
            "top": null,
2499
            "visibility": null,
2500
            "width": null
2501
          }
2502
        },
2503
        "8a95f6bbd81148519ec4639d8b0f4db6": {
2504
          "model_module": "@jupyter-widgets/controls",
2505
          "model_name": "DescriptionStyleModel",
2506
          "model_module_version": "1.5.0",
2507
          "state": {
2508
            "_model_module": "@jupyter-widgets/controls",
2509
            "_model_module_version": "1.5.0",
2510
            "_model_name": "DescriptionStyleModel",
2511
            "_view_count": null,
2512
            "_view_module": "@jupyter-widgets/base",
2513
            "_view_module_version": "1.2.0",
2514
            "_view_name": "StyleView",
2515
            "description_width": ""
2516
          }
2517
        },
2518
        "13acbfe9fc7a4ff4a6ec0a8be56c4f62": {
2519
          "model_module": "@jupyter-widgets/controls",
2520
          "model_name": "LabelModel",
2521
          "model_module_version": "1.5.0",
2522
          "state": {
2523
            "_dom_classes": [],
2524
            "_model_module": "@jupyter-widgets/controls",
2525
            "_model_module_version": "1.5.0",
2526
            "_model_name": "LabelModel",
2527
            "_view_count": null,
2528
            "_view_module": "@jupyter-widgets/controls",
2529
            "_view_module_version": "1.5.0",
2530
            "_view_name": "LabelView",
2531
            "description": "",
2532
            "description_tooltip": null,
2533
            "layout": "IPY_MODEL_baa7f4149cb446078d05574550f33cda",
2534
            "placeholder": "​",
2535
            "style": "IPY_MODEL_002b9e99a05c46749a052c5770f280a5",
2536
            "value": "Token is valid (permission: write)."
2537
          }
2538
        },
2539
        "e7bcd126a8384f94a027e130d09f2346": {
2540
          "model_module": "@jupyter-widgets/controls",
2541
          "model_name": "LabelModel",
2542
          "model_module_version": "1.5.0",
2543
          "state": {
2544
            "_dom_classes": [],
2545
            "_model_module": "@jupyter-widgets/controls",
2546
            "_model_module_version": "1.5.0",
2547
            "_model_name": "LabelModel",
2548
            "_view_count": null,
2549
            "_view_module": "@jupyter-widgets/controls",
2550
            "_view_module_version": "1.5.0",
2551
            "_view_name": "LabelView",
2552
            "description": "",
2553
            "description_tooltip": null,
2554
            "layout": "IPY_MODEL_33a233aa855f4356960aa336d361bfdb",
2555
            "placeholder": "​",
2556
            "style": "IPY_MODEL_b111ac45f0d648a8b89e1bf3d26dc354",
2557
            "value": "Your token has been saved in your configured git credential helpers (store)."
2558
          }
2559
        },
2560
        "ee0ac8c2fac44c02b28844bb5bc6822a": {
2561
          "model_module": "@jupyter-widgets/controls",
2562
          "model_name": "LabelModel",
2563
          "model_module_version": "1.5.0",
2564
          "state": {
2565
            "_dom_classes": [],
2566
            "_model_module": "@jupyter-widgets/controls",
2567
            "_model_module_version": "1.5.0",
2568
            "_model_name": "LabelModel",
2569
            "_view_count": null,
2570
            "_view_module": "@jupyter-widgets/controls",
2571
            "_view_module_version": "1.5.0",
2572
            "_view_name": "LabelView",
2573
            "description": "",
2574
            "description_tooltip": null,
2575
            "layout": "IPY_MODEL_7c0010ffc2b84b7cb1c2e943e849a67b",
2576
            "placeholder": "​",
2577
            "style": "IPY_MODEL_4a0ecc50b9e94408b714c578a0786f03",
2578
            "value": "Your token has been saved to /root/.cache/huggingface/token"
2579
          }
2580
        },
2581
        "d1444855a9cc4726a37cf9f184be8409": {
2582
          "model_module": "@jupyter-widgets/controls",
2583
          "model_name": "LabelModel",
2584
          "model_module_version": "1.5.0",
2585
          "state": {
2586
            "_dom_classes": [],
2587
            "_model_module": "@jupyter-widgets/controls",
2588
            "_model_module_version": "1.5.0",
2589
            "_model_name": "LabelModel",
2590
            "_view_count": null,
2591
            "_view_module": "@jupyter-widgets/controls",
2592
            "_view_module_version": "1.5.0",
2593
            "_view_name": "LabelView",
2594
            "description": "",
2595
            "description_tooltip": null,
2596
            "layout": "IPY_MODEL_f67c37bb203c4775b5997e50af97fae7",
2597
            "placeholder": "​",
2598
            "style": "IPY_MODEL_8fe86ac5511c400d81c52bd335c96859",
2599
            "value": "Login successful"
2600
          }
2601
        },
2602
        "baa7f4149cb446078d05574550f33cda": {
2603
          "model_module": "@jupyter-widgets/base",
2604
          "model_name": "LayoutModel",
2605
          "model_module_version": "1.2.0",
2606
          "state": {
2607
            "_model_module": "@jupyter-widgets/base",
2608
            "_model_module_version": "1.2.0",
2609
            "_model_name": "LayoutModel",
2610
            "_view_count": null,
2611
            "_view_module": "@jupyter-widgets/base",
2612
            "_view_module_version": "1.2.0",
2613
            "_view_name": "LayoutView",
2614
            "align_content": null,
2615
            "align_items": null,
2616
            "align_self": null,
2617
            "border": null,
2618
            "bottom": null,
2619
            "display": null,
2620
            "flex": null,
2621
            "flex_flow": null,
2622
            "grid_area": null,
2623
            "grid_auto_columns": null,
2624
            "grid_auto_flow": null,
2625
            "grid_auto_rows": null,
2626
            "grid_column": null,
2627
            "grid_gap": null,
2628
            "grid_row": null,
2629
            "grid_template_areas": null,
2630
            "grid_template_columns": null,
2631
            "grid_template_rows": null,
2632
            "height": null,
2633
            "justify_content": null,
2634
            "justify_items": null,
2635
            "left": null,
2636
            "margin": null,
2637
            "max_height": null,
2638
            "max_width": null,
2639
            "min_height": null,
2640
            "min_width": null,
2641
            "object_fit": null,
2642
            "object_position": null,
2643
            "order": null,
2644
            "overflow": null,
2645
            "overflow_x": null,
2646
            "overflow_y": null,
2647
            "padding": null,
2648
            "right": null,
2649
            "top": null,
2650
            "visibility": null,
2651
            "width": null
2652
          }
2653
        },
2654
        "002b9e99a05c46749a052c5770f280a5": {
2655
          "model_module": "@jupyter-widgets/controls",
2656
          "model_name": "DescriptionStyleModel",
2657
          "model_module_version": "1.5.0",
2658
          "state": {
2659
            "_model_module": "@jupyter-widgets/controls",
2660
            "_model_module_version": "1.5.0",
2661
            "_model_name": "DescriptionStyleModel",
2662
            "_view_count": null,
2663
            "_view_module": "@jupyter-widgets/base",
2664
            "_view_module_version": "1.2.0",
2665
            "_view_name": "StyleView",
2666
            "description_width": ""
2667
          }
2668
        },
2669
        "33a233aa855f4356960aa336d361bfdb": {
2670
          "model_module": "@jupyter-widgets/base",
2671
          "model_name": "LayoutModel",
2672
          "model_module_version": "1.2.0",
2673
          "state": {
2674
            "_model_module": "@jupyter-widgets/base",
2675
            "_model_module_version": "1.2.0",
2676
            "_model_name": "LayoutModel",
2677
            "_view_count": null,
2678
            "_view_module": "@jupyter-widgets/base",
2679
            "_view_module_version": "1.2.0",
2680
            "_view_name": "LayoutView",
2681
            "align_content": null,
2682
            "align_items": null,
2683
            "align_self": null,
2684
            "border": null,
2685
            "bottom": null,
2686
            "display": null,
2687
            "flex": null,
2688
            "flex_flow": null,
2689
            "grid_area": null,
2690
            "grid_auto_columns": null,
2691
            "grid_auto_flow": null,
2692
            "grid_auto_rows": null,
2693
            "grid_column": null,
2694
            "grid_gap": null,
2695
            "grid_row": null,
2696
            "grid_template_areas": null,
2697
            "grid_template_columns": null,
2698
            "grid_template_rows": null,
2699
            "height": null,
2700
            "justify_content": null,
2701
            "justify_items": null,
2702
            "left": null,
2703
            "margin": null,
2704
            "max_height": null,
2705
            "max_width": null,
2706
            "min_height": null,
2707
            "min_width": null,
2708
            "object_fit": null,
2709
            "object_position": null,
2710
            "order": null,
2711
            "overflow": null,
2712
            "overflow_x": null,
2713
            "overflow_y": null,
2714
            "padding": null,
2715
            "right": null,
2716
            "top": null,
2717
            "visibility": null,
2718
            "width": null
2719
          }
2720
        },
2721
        "b111ac45f0d648a8b89e1bf3d26dc354": {
2722
          "model_module": "@jupyter-widgets/controls",
2723
          "model_name": "DescriptionStyleModel",
2724
          "model_module_version": "1.5.0",
2725
          "state": {
2726
            "_model_module": "@jupyter-widgets/controls",
2727
            "_model_module_version": "1.5.0",
2728
            "_model_name": "DescriptionStyleModel",
2729
            "_view_count": null,
2730
            "_view_module": "@jupyter-widgets/base",
2731
            "_view_module_version": "1.2.0",
2732
            "_view_name": "StyleView",
2733
            "description_width": ""
2734
          }
2735
        },
2736
        "7c0010ffc2b84b7cb1c2e943e849a67b": {
2737
          "model_module": "@jupyter-widgets/base",
2738
          "model_name": "LayoutModel",
2739
          "model_module_version": "1.2.0",
2740
          "state": {
2741
            "_model_module": "@jupyter-widgets/base",
2742
            "_model_module_version": "1.2.0",
2743
            "_model_name": "LayoutModel",
2744
            "_view_count": null,
2745
            "_view_module": "@jupyter-widgets/base",
2746
            "_view_module_version": "1.2.0",
2747
            "_view_name": "LayoutView",
2748
            "align_content": null,
2749
            "align_items": null,
2750
            "align_self": null,
2751
            "border": null,
2752
            "bottom": null,
2753
            "display": null,
2754
            "flex": null,
2755
            "flex_flow": null,
2756
            "grid_area": null,
2757
            "grid_auto_columns": null,
2758
            "grid_auto_flow": null,
2759
            "grid_auto_rows": null,
2760
            "grid_column": null,
2761
            "grid_gap": null,
2762
            "grid_row": null,
2763
            "grid_template_areas": null,
2764
            "grid_template_columns": null,
2765
            "grid_template_rows": null,
2766
            "height": null,
2767
            "justify_content": null,
2768
            "justify_items": null,
2769
            "left": null,
2770
            "margin": null,
2771
            "max_height": null,
2772
            "max_width": null,
2773
            "min_height": null,
2774
            "min_width": null,
2775
            "object_fit": null,
2776
            "object_position": null,
2777
            "order": null,
2778
            "overflow": null,
2779
            "overflow_x": null,
2780
            "overflow_y": null,
2781
            "padding": null,
2782
            "right": null,
2783
            "top": null,
2784
            "visibility": null,
2785
            "width": null
2786
          }
2787
        },
2788
        "4a0ecc50b9e94408b714c578a0786f03": {
2789
          "model_module": "@jupyter-widgets/controls",
2790
          "model_name": "DescriptionStyleModel",
2791
          "model_module_version": "1.5.0",
2792
          "state": {
2793
            "_model_module": "@jupyter-widgets/controls",
2794
            "_model_module_version": "1.5.0",
2795
            "_model_name": "DescriptionStyleModel",
2796
            "_view_count": null,
2797
            "_view_module": "@jupyter-widgets/base",
2798
            "_view_module_version": "1.2.0",
2799
            "_view_name": "StyleView",
2800
            "description_width": ""
2801
          }
2802
        },
2803
        "f67c37bb203c4775b5997e50af97fae7": {
2804
          "model_module": "@jupyter-widgets/base",
2805
          "model_name": "LayoutModel",
2806
          "model_module_version": "1.2.0",
2807
          "state": {
2808
            "_model_module": "@jupyter-widgets/base",
2809
            "_model_module_version": "1.2.0",
2810
            "_model_name": "LayoutModel",
2811
            "_view_count": null,
2812
            "_view_module": "@jupyter-widgets/base",
2813
            "_view_module_version": "1.2.0",
2814
            "_view_name": "LayoutView",
2815
            "align_content": null,
2816
            "align_items": null,
2817
            "align_self": null,
2818
            "border": null,
2819
            "bottom": null,
2820
            "display": null,
2821
            "flex": null,
2822
            "flex_flow": null,
2823
            "grid_area": null,
2824
            "grid_auto_columns": null,
2825
            "grid_auto_flow": null,
2826
            "grid_auto_rows": null,
2827
            "grid_column": null,
2828
            "grid_gap": null,
2829
            "grid_row": null,
2830
            "grid_template_areas": null,
2831
            "grid_template_columns": null,
2832
            "grid_template_rows": null,
2833
            "height": null,
2834
            "justify_content": null,
2835
            "justify_items": null,
2836
            "left": null,
2837
            "margin": null,
2838
            "max_height": null,
2839
            "max_width": null,
2840
            "min_height": null,
2841
            "min_width": null,
2842
            "object_fit": null,
2843
            "object_position": null,
2844
            "order": null,
2845
            "overflow": null,
2846
            "overflow_x": null,
2847
            "overflow_y": null,
2848
            "padding": null,
2849
            "right": null,
2850
            "top": null,
2851
            "visibility": null,
2852
            "width": null
2853
          }
2854
        },
2855
        "8fe86ac5511c400d81c52bd335c96859": {
2856
          "model_module": "@jupyter-widgets/controls",
2857
          "model_name": "DescriptionStyleModel",
2858
          "model_module_version": "1.5.0",
2859
          "state": {
2860
            "_model_module": "@jupyter-widgets/controls",
2861
            "_model_module_version": "1.5.0",
2862
            "_model_name": "DescriptionStyleModel",
2863
            "_view_count": null,
2864
            "_view_module": "@jupyter-widgets/base",
2865
            "_view_module_version": "1.2.0",
2866
            "_view_name": "StyleView",
2867
            "description_width": ""
2868
          }
2869
        },
2870
        "c134904ded5f47aabca0dfa5b67049db": {
2871
          "model_module": "@jupyter-widgets/controls",
2872
          "model_name": "HBoxModel",
2873
          "model_module_version": "1.5.0",
2874
          "state": {
2875
            "_dom_classes": [],
2876
            "_model_module": "@jupyter-widgets/controls",
2877
            "_model_module_version": "1.5.0",
2878
            "_model_name": "HBoxModel",
2879
            "_view_count": null,
2880
            "_view_module": "@jupyter-widgets/controls",
2881
            "_view_module_version": "1.5.0",
2882
            "_view_name": "HBoxView",
2883
            "box_style": "",
2884
            "children": [
2885
              "IPY_MODEL_3c1d79df90544bdd93873579d38116a4",
2886
              "IPY_MODEL_3806b75490704196afde5977db7dca89",
2887
              "IPY_MODEL_7665c9c809964b6eb6b4a9720c5d2dac"
2888
            ],
2889
            "layout": "IPY_MODEL_1785e46465ec42ccbb933604963d5dd6"
2890
          }
2891
        },
2892
        "3c1d79df90544bdd93873579d38116a4": {
2893
          "model_module": "@jupyter-widgets/controls",
2894
          "model_name": "HTMLModel",
2895
          "model_module_version": "1.5.0",
2896
          "state": {
2897
            "_dom_classes": [],
2898
            "_model_module": "@jupyter-widgets/controls",
2899
            "_model_module_version": "1.5.0",
2900
            "_model_name": "HTMLModel",
2901
            "_view_count": null,
2902
            "_view_module": "@jupyter-widgets/controls",
2903
            "_view_module_version": "1.5.0",
2904
            "_view_name": "HTMLView",
2905
            "description": "",
2906
            "description_tooltip": null,
2907
            "layout": "IPY_MODEL_7b7dd023dbc7472998c6aac7eee1490f",
2908
            "placeholder": "​",
2909
            "style": "IPY_MODEL_62a0e81ff19a4162a67e5884ce678f2c",
2910
            "value": "Map: 100%"
2911
          }
2912
        },
2913
        "3806b75490704196afde5977db7dca89": {
2914
          "model_module": "@jupyter-widgets/controls",
2915
          "model_name": "FloatProgressModel",
2916
          "model_module_version": "1.5.0",
2917
          "state": {
2918
            "_dom_classes": [],
2919
            "_model_module": "@jupyter-widgets/controls",
2920
            "_model_module_version": "1.5.0",
2921
            "_model_name": "FloatProgressModel",
2922
            "_view_count": null,
2923
            "_view_module": "@jupyter-widgets/controls",
2924
            "_view_module_version": "1.5.0",
2925
            "_view_name": "ProgressView",
2926
            "bar_style": "success",
2927
            "description": "",
2928
            "description_tooltip": null,
2929
            "layout": "IPY_MODEL_24a85f5bd83441b4943299be2d145aff",
2930
            "max": 1307,
2931
            "min": 0,
2932
            "orientation": "horizontal",
2933
            "style": "IPY_MODEL_18eaa2134e8e4edeb41340cebbeb8572",
2934
            "value": 1307
2935
          }
2936
        },
2937
        "7665c9c809964b6eb6b4a9720c5d2dac": {
2938
          "model_module": "@jupyter-widgets/controls",
2939
          "model_name": "HTMLModel",
2940
          "model_module_version": "1.5.0",
2941
          "state": {
2942
            "_dom_classes": [],
2943
            "_model_module": "@jupyter-widgets/controls",
2944
            "_model_module_version": "1.5.0",
2945
            "_model_name": "HTMLModel",
2946
            "_view_count": null,
2947
            "_view_module": "@jupyter-widgets/controls",
2948
            "_view_module_version": "1.5.0",
2949
            "_view_name": "HTMLView",
2950
            "description": "",
2951
            "description_tooltip": null,
2952
            "layout": "IPY_MODEL_68e1a741d3ec4fc3a26d759ecc357ac6",
2953
            "placeholder": "​",
2954
            "style": "IPY_MODEL_de3e98c73f9547bebdad9b4bcb21d9a1",
2955
            "value": " 1307/1307 [00:01&lt;00:00, 860.18 examples/s]"
2956
          }
2957
        },
2958
        "1785e46465ec42ccbb933604963d5dd6": {
2959
          "model_module": "@jupyter-widgets/base",
2960
          "model_name": "LayoutModel",
2961
          "model_module_version": "1.2.0",
2962
          "state": {
2963
            "_model_module": "@jupyter-widgets/base",
2964
            "_model_module_version": "1.2.0",
2965
            "_model_name": "LayoutModel",
2966
            "_view_count": null,
2967
            "_view_module": "@jupyter-widgets/base",
2968
            "_view_module_version": "1.2.0",
2969
            "_view_name": "LayoutView",
2970
            "align_content": null,
2971
            "align_items": null,
2972
            "align_self": null,
2973
            "border": null,
2974
            "bottom": null,
2975
            "display": null,
2976
            "flex": null,
2977
            "flex_flow": null,
2978
            "grid_area": null,
2979
            "grid_auto_columns": null,
2980
            "grid_auto_flow": null,
2981
            "grid_auto_rows": null,
2982
            "grid_column": null,
2983
            "grid_gap": null,
2984
            "grid_row": null,
2985
            "grid_template_areas": null,
2986
            "grid_template_columns": null,
2987
            "grid_template_rows": null,
2988
            "height": null,
2989
            "justify_content": null,
2990
            "justify_items": null,
2991
            "left": null,
2992
            "margin": null,
2993
            "max_height": null,
2994
            "max_width": null,
2995
            "min_height": null,
2996
            "min_width": null,
2997
            "object_fit": null,
2998
            "object_position": null,
2999
            "order": null,
3000
            "overflow": null,
3001
            "overflow_x": null,
3002
            "overflow_y": null,
3003
            "padding": null,
3004
            "right": null,
3005
            "top": null,
3006
            "visibility": null,
3007
            "width": null
3008
          }
3009
        },
3010
        "7b7dd023dbc7472998c6aac7eee1490f": {
3011
          "model_module": "@jupyter-widgets/base",
3012
          "model_name": "LayoutModel",
3013
          "model_module_version": "1.2.0",
3014
          "state": {
3015
            "_model_module": "@jupyter-widgets/base",
3016
            "_model_module_version": "1.2.0",
3017
            "_model_name": "LayoutModel",
3018
            "_view_count": null,
3019
            "_view_module": "@jupyter-widgets/base",
3020
            "_view_module_version": "1.2.0",
3021
            "_view_name": "LayoutView",
3022
            "align_content": null,
3023
            "align_items": null,
3024
            "align_self": null,
3025
            "border": null,
3026
            "bottom": null,
3027
            "display": null,
3028
            "flex": null,
3029
            "flex_flow": null,
3030
            "grid_area": null,
3031
            "grid_auto_columns": null,
3032
            "grid_auto_flow": null,
3033
            "grid_auto_rows": null,
3034
            "grid_column": null,
3035
            "grid_gap": null,
3036
            "grid_row": null,
3037
            "grid_template_areas": null,
3038
            "grid_template_columns": null,
3039
            "grid_template_rows": null,
3040
            "height": null,
3041
            "justify_content": null,
3042
            "justify_items": null,
3043
            "left": null,
3044
            "margin": null,
3045
            "max_height": null,
3046
            "max_width": null,
3047
            "min_height": null,
3048
            "min_width": null,
3049
            "object_fit": null,
3050
            "object_position": null,
3051
            "order": null,
3052
            "overflow": null,
3053
            "overflow_x": null,
3054
            "overflow_y": null,
3055
            "padding": null,
3056
            "right": null,
3057
            "top": null,
3058
            "visibility": null,
3059
            "width": null
3060
          }
3061
        },
3062
        "62a0e81ff19a4162a67e5884ce678f2c": {
3063
          "model_module": "@jupyter-widgets/controls",
3064
          "model_name": "DescriptionStyleModel",
3065
          "model_module_version": "1.5.0",
3066
          "state": {
3067
            "_model_module": "@jupyter-widgets/controls",
3068
            "_model_module_version": "1.5.0",
3069
            "_model_name": "DescriptionStyleModel",
3070
            "_view_count": null,
3071
            "_view_module": "@jupyter-widgets/base",
3072
            "_view_module_version": "1.2.0",
3073
            "_view_name": "StyleView",
3074
            "description_width": ""
3075
          }
3076
        },
3077
        "24a85f5bd83441b4943299be2d145aff": {
3078
          "model_module": "@jupyter-widgets/base",
3079
          "model_name": "LayoutModel",
3080
          "model_module_version": "1.2.0",
3081
          "state": {
3082
            "_model_module": "@jupyter-widgets/base",
3083
            "_model_module_version": "1.2.0",
3084
            "_model_name": "LayoutModel",
3085
            "_view_count": null,
3086
            "_view_module": "@jupyter-widgets/base",
3087
            "_view_module_version": "1.2.0",
3088
            "_view_name": "LayoutView",
3089
            "align_content": null,
3090
            "align_items": null,
3091
            "align_self": null,
3092
            "border": null,
3093
            "bottom": null,
3094
            "display": null,
3095
            "flex": null,
3096
            "flex_flow": null,
3097
            "grid_area": null,
3098
            "grid_auto_columns": null,
3099
            "grid_auto_flow": null,
3100
            "grid_auto_rows": null,
3101
            "grid_column": null,
3102
            "grid_gap": null,
3103
            "grid_row": null,
3104
            "grid_template_areas": null,
3105
            "grid_template_columns": null,
3106
            "grid_template_rows": null,
3107
            "height": null,
3108
            "justify_content": null,
3109
            "justify_items": null,
3110
            "left": null,
3111
            "margin": null,
3112
            "max_height": null,
3113
            "max_width": null,
3114
            "min_height": null,
3115
            "min_width": null,
3116
            "object_fit": null,
3117
            "object_position": null,
3118
            "order": null,
3119
            "overflow": null,
3120
            "overflow_x": null,
3121
            "overflow_y": null,
3122
            "padding": null,
3123
            "right": null,
3124
            "top": null,
3125
            "visibility": null,
3126
            "width": null
3127
          }
3128
        },
3129
        "18eaa2134e8e4edeb41340cebbeb8572": {
3130
          "model_module": "@jupyter-widgets/controls",
3131
          "model_name": "ProgressStyleModel",
3132
          "model_module_version": "1.5.0",
3133
          "state": {
3134
            "_model_module": "@jupyter-widgets/controls",
3135
            "_model_module_version": "1.5.0",
3136
            "_model_name": "ProgressStyleModel",
3137
            "_view_count": null,
3138
            "_view_module": "@jupyter-widgets/base",
3139
            "_view_module_version": "1.2.0",
3140
            "_view_name": "StyleView",
3141
            "bar_color": null,
3142
            "description_width": ""
3143
          }
3144
        },
3145
        "68e1a741d3ec4fc3a26d759ecc357ac6": {
3146
          "model_module": "@jupyter-widgets/base",
3147
          "model_name": "LayoutModel",
3148
          "model_module_version": "1.2.0",
3149
          "state": {
3150
            "_model_module": "@jupyter-widgets/base",
3151
            "_model_module_version": "1.2.0",
3152
            "_model_name": "LayoutModel",
3153
            "_view_count": null,
3154
            "_view_module": "@jupyter-widgets/base",
3155
            "_view_module_version": "1.2.0",
3156
            "_view_name": "LayoutView",
3157
            "align_content": null,
3158
            "align_items": null,
3159
            "align_self": null,
3160
            "border": null,
3161
            "bottom": null,
3162
            "display": null,
3163
            "flex": null,
3164
            "flex_flow": null,
3165
            "grid_area": null,
3166
            "grid_auto_columns": null,
3167
            "grid_auto_flow": null,
3168
            "grid_auto_rows": null,
3169
            "grid_column": null,
3170
            "grid_gap": null,
3171
            "grid_row": null,
3172
            "grid_template_areas": null,
3173
            "grid_template_columns": null,
3174
            "grid_template_rows": null,
3175
            "height": null,
3176
            "justify_content": null,
3177
            "justify_items": null,
3178
            "left": null,
3179
            "margin": null,
3180
            "max_height": null,
3181
            "max_width": null,
3182
            "min_height": null,
3183
            "min_width": null,
3184
            "object_fit": null,
3185
            "object_position": null,
3186
            "order": null,
3187
            "overflow": null,
3188
            "overflow_x": null,
3189
            "overflow_y": null,
3190
            "padding": null,
3191
            "right": null,
3192
            "top": null,
3193
            "visibility": null,
3194
            "width": null
3195
          }
3196
        },
3197
        "de3e98c73f9547bebdad9b4bcb21d9a1": {
3198
          "model_module": "@jupyter-widgets/controls",
3199
          "model_name": "DescriptionStyleModel",
3200
          "model_module_version": "1.5.0",
3201
          "state": {
3202
            "_model_module": "@jupyter-widgets/controls",
3203
            "_model_module_version": "1.5.0",
3204
            "_model_name": "DescriptionStyleModel",
3205
            "_view_count": null,
3206
            "_view_module": "@jupyter-widgets/base",
3207
            "_view_module_version": "1.2.0",
3208
            "_view_name": "StyleView",
3209
            "description_width": ""
3210
          }
3211
        }
3212
      }
3213
    }
3214
  },
3215
  "nbformat": 4,
3216
  "nbformat_minor": 0
3217
}