└── Finetuning_BERT_for_Chatbot_intent_recognition.ipynb
/Finetuning_BERT_for_Chatbot_intent_recognition.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "gpuType": "T4",
8 | "authorship_tag": "ABX9TyNmx4wno5bWmP+v1ILSoAiV",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | },
15 | "language_info": {
16 | "name": "python"
17 | },
18 | "accelerator": "GPU",
19 | "widgets": {
20 | "application/vnd.jupyter.widget-state+json": {
21 | "4e181378f6704b2793283d2e29b61703": {
22 | "model_module": "@jupyter-widgets/controls",
23 | "model_name": "HBoxModel",
24 | "model_module_version": "1.5.0",
25 | "state": {
26 | "_dom_classes": [],
27 | "_model_module": "@jupyter-widgets/controls",
28 | "_model_module_version": "1.5.0",
29 | "_model_name": "HBoxModel",
30 | "_view_count": null,
31 | "_view_module": "@jupyter-widgets/controls",
32 | "_view_module_version": "1.5.0",
33 | "_view_name": "HBoxView",
34 | "box_style": "",
35 | "children": [
36 | "IPY_MODEL_c019c0048c1a43a79a64da317f499543",
37 | "IPY_MODEL_b47b7cd4b1164ab4b40d6cbe8fd837ce",
38 | "IPY_MODEL_2586e6c72cc44a36916470eaa6dc39f6"
39 | ],
40 | "layout": "IPY_MODEL_e72d6d45c1244d2e9c0c3fee1f7652a2"
41 | }
42 | },
43 | "c019c0048c1a43a79a64da317f499543": {
44 | "model_module": "@jupyter-widgets/controls",
45 | "model_name": "HTMLModel",
46 | "model_module_version": "1.5.0",
47 | "state": {
48 | "_dom_classes": [],
49 | "_model_module": "@jupyter-widgets/controls",
50 | "_model_module_version": "1.5.0",
51 | "_model_name": "HTMLModel",
52 | "_view_count": null,
53 | "_view_module": "@jupyter-widgets/controls",
54 | "_view_module_version": "1.5.0",
55 | "_view_name": "HTMLView",
56 | "description": "",
57 | "description_tooltip": null,
58 | "layout": "IPY_MODEL_4d507c4276604d22b7935ec0d246ccc7",
59 | "placeholder": "",
60 | "style": "IPY_MODEL_7fa19f01db734d0b9f996f5da493bc72",
61 | "value": "Downloading (…)solve/main/vocab.txt: 100%"
62 | }
63 | },
64 | "b47b7cd4b1164ab4b40d6cbe8fd837ce": {
65 | "model_module": "@jupyter-widgets/controls",
66 | "model_name": "FloatProgressModel",
67 | "model_module_version": "1.5.0",
68 | "state": {
69 | "_dom_classes": [],
70 | "_model_module": "@jupyter-widgets/controls",
71 | "_model_module_version": "1.5.0",
72 | "_model_name": "FloatProgressModel",
73 | "_view_count": null,
74 | "_view_module": "@jupyter-widgets/controls",
75 | "_view_module_version": "1.5.0",
76 | "_view_name": "ProgressView",
77 | "bar_style": "success",
78 | "description": "",
79 | "description_tooltip": null,
80 | "layout": "IPY_MODEL_fea1aaba07234c9baf9213a4fdcb7e66",
81 | "max": 213450,
82 | "min": 0,
83 | "orientation": "horizontal",
84 | "style": "IPY_MODEL_583984aaa78e4efebe8994f4e8df1f62",
85 | "value": 213450
86 | }
87 | },
88 | "2586e6c72cc44a36916470eaa6dc39f6": {
89 | "model_module": "@jupyter-widgets/controls",
90 | "model_name": "HTMLModel",
91 | "model_module_version": "1.5.0",
92 | "state": {
93 | "_dom_classes": [],
94 | "_model_module": "@jupyter-widgets/controls",
95 | "_model_module_version": "1.5.0",
96 | "_model_name": "HTMLModel",
97 | "_view_count": null,
98 | "_view_module": "@jupyter-widgets/controls",
99 | "_view_module_version": "1.5.0",
100 | "_view_name": "HTMLView",
101 | "description": "",
102 | "description_tooltip": null,
103 | "layout": "IPY_MODEL_5a563cec73634cfdb67610cd323a3193",
104 | "placeholder": "",
105 | "style": "IPY_MODEL_983525c7c3494fe0b2235597e9f096ba",
106 | "value": " 213k/213k [00:00<00:00, 4.18MB/s]"
107 | }
108 | },
109 | "e72d6d45c1244d2e9c0c3fee1f7652a2": {
110 | "model_module": "@jupyter-widgets/base",
111 | "model_name": "LayoutModel",
112 | "model_module_version": "1.2.0",
113 | "state": {
114 | "_model_module": "@jupyter-widgets/base",
115 | "_model_module_version": "1.2.0",
116 | "_model_name": "LayoutModel",
117 | "_view_count": null,
118 | "_view_module": "@jupyter-widgets/base",
119 | "_view_module_version": "1.2.0",
120 | "_view_name": "LayoutView",
121 | "align_content": null,
122 | "align_items": null,
123 | "align_self": null,
124 | "border": null,
125 | "bottom": null,
126 | "display": null,
127 | "flex": null,
128 | "flex_flow": null,
129 | "grid_area": null,
130 | "grid_auto_columns": null,
131 | "grid_auto_flow": null,
132 | "grid_auto_rows": null,
133 | "grid_column": null,
134 | "grid_gap": null,
135 | "grid_row": null,
136 | "grid_template_areas": null,
137 | "grid_template_columns": null,
138 | "grid_template_rows": null,
139 | "height": null,
140 | "justify_content": null,
141 | "justify_items": null,
142 | "left": null,
143 | "margin": null,
144 | "max_height": null,
145 | "max_width": null,
146 | "min_height": null,
147 | "min_width": null,
148 | "object_fit": null,
149 | "object_position": null,
150 | "order": null,
151 | "overflow": null,
152 | "overflow_x": null,
153 | "overflow_y": null,
154 | "padding": null,
155 | "right": null,
156 | "top": null,
157 | "visibility": null,
158 | "width": null
159 | }
160 | },
161 | "4d507c4276604d22b7935ec0d246ccc7": {
162 | "model_module": "@jupyter-widgets/base",
163 | "model_name": "LayoutModel",
164 | "model_module_version": "1.2.0",
165 | "state": {
166 | "_model_module": "@jupyter-widgets/base",
167 | "_model_module_version": "1.2.0",
168 | "_model_name": "LayoutModel",
169 | "_view_count": null,
170 | "_view_module": "@jupyter-widgets/base",
171 | "_view_module_version": "1.2.0",
172 | "_view_name": "LayoutView",
173 | "align_content": null,
174 | "align_items": null,
175 | "align_self": null,
176 | "border": null,
177 | "bottom": null,
178 | "display": null,
179 | "flex": null,
180 | "flex_flow": null,
181 | "grid_area": null,
182 | "grid_auto_columns": null,
183 | "grid_auto_flow": null,
184 | "grid_auto_rows": null,
185 | "grid_column": null,
186 | "grid_gap": null,
187 | "grid_row": null,
188 | "grid_template_areas": null,
189 | "grid_template_columns": null,
190 | "grid_template_rows": null,
191 | "height": null,
192 | "justify_content": null,
193 | "justify_items": null,
194 | "left": null,
195 | "margin": null,
196 | "max_height": null,
197 | "max_width": null,
198 | "min_height": null,
199 | "min_width": null,
200 | "object_fit": null,
201 | "object_position": null,
202 | "order": null,
203 | "overflow": null,
204 | "overflow_x": null,
205 | "overflow_y": null,
206 | "padding": null,
207 | "right": null,
208 | "top": null,
209 | "visibility": null,
210 | "width": null
211 | }
212 | },
213 | "7fa19f01db734d0b9f996f5da493bc72": {
214 | "model_module": "@jupyter-widgets/controls",
215 | "model_name": "DescriptionStyleModel",
216 | "model_module_version": "1.5.0",
217 | "state": {
218 | "_model_module": "@jupyter-widgets/controls",
219 | "_model_module_version": "1.5.0",
220 | "_model_name": "DescriptionStyleModel",
221 | "_view_count": null,
222 | "_view_module": "@jupyter-widgets/base",
223 | "_view_module_version": "1.2.0",
224 | "_view_name": "StyleView",
225 | "description_width": ""
226 | }
227 | },
228 | "fea1aaba07234c9baf9213a4fdcb7e66": {
229 | "model_module": "@jupyter-widgets/base",
230 | "model_name": "LayoutModel",
231 | "model_module_version": "1.2.0",
232 | "state": {
233 | "_model_module": "@jupyter-widgets/base",
234 | "_model_module_version": "1.2.0",
235 | "_model_name": "LayoutModel",
236 | "_view_count": null,
237 | "_view_module": "@jupyter-widgets/base",
238 | "_view_module_version": "1.2.0",
239 | "_view_name": "LayoutView",
240 | "align_content": null,
241 | "align_items": null,
242 | "align_self": null,
243 | "border": null,
244 | "bottom": null,
245 | "display": null,
246 | "flex": null,
247 | "flex_flow": null,
248 | "grid_area": null,
249 | "grid_auto_columns": null,
250 | "grid_auto_flow": null,
251 | "grid_auto_rows": null,
252 | "grid_column": null,
253 | "grid_gap": null,
254 | "grid_row": null,
255 | "grid_template_areas": null,
256 | "grid_template_columns": null,
257 | "grid_template_rows": null,
258 | "height": null,
259 | "justify_content": null,
260 | "justify_items": null,
261 | "left": null,
262 | "margin": null,
263 | "max_height": null,
264 | "max_width": null,
265 | "min_height": null,
266 | "min_width": null,
267 | "object_fit": null,
268 | "object_position": null,
269 | "order": null,
270 | "overflow": null,
271 | "overflow_x": null,
272 | "overflow_y": null,
273 | "padding": null,
274 | "right": null,
275 | "top": null,
276 | "visibility": null,
277 | "width": null
278 | }
279 | },
280 | "583984aaa78e4efebe8994f4e8df1f62": {
281 | "model_module": "@jupyter-widgets/controls",
282 | "model_name": "ProgressStyleModel",
283 | "model_module_version": "1.5.0",
284 | "state": {
285 | "_model_module": "@jupyter-widgets/controls",
286 | "_model_module_version": "1.5.0",
287 | "_model_name": "ProgressStyleModel",
288 | "_view_count": null,
289 | "_view_module": "@jupyter-widgets/base",
290 | "_view_module_version": "1.2.0",
291 | "_view_name": "StyleView",
292 | "bar_color": null,
293 | "description_width": ""
294 | }
295 | },
296 | "5a563cec73634cfdb67610cd323a3193": {
297 | "model_module": "@jupyter-widgets/base",
298 | "model_name": "LayoutModel",
299 | "model_module_version": "1.2.0",
300 | "state": {
301 | "_model_module": "@jupyter-widgets/base",
302 | "_model_module_version": "1.2.0",
303 | "_model_name": "LayoutModel",
304 | "_view_count": null,
305 | "_view_module": "@jupyter-widgets/base",
306 | "_view_module_version": "1.2.0",
307 | "_view_name": "LayoutView",
308 | "align_content": null,
309 | "align_items": null,
310 | "align_self": null,
311 | "border": null,
312 | "bottom": null,
313 | "display": null,
314 | "flex": null,
315 | "flex_flow": null,
316 | "grid_area": null,
317 | "grid_auto_columns": null,
318 | "grid_auto_flow": null,
319 | "grid_auto_rows": null,
320 | "grid_column": null,
321 | "grid_gap": null,
322 | "grid_row": null,
323 | "grid_template_areas": null,
324 | "grid_template_columns": null,
325 | "grid_template_rows": null,
326 | "height": null,
327 | "justify_content": null,
328 | "justify_items": null,
329 | "left": null,
330 | "margin": null,
331 | "max_height": null,
332 | "max_width": null,
333 | "min_height": null,
334 | "min_width": null,
335 | "object_fit": null,
336 | "object_position": null,
337 | "order": null,
338 | "overflow": null,
339 | "overflow_x": null,
340 | "overflow_y": null,
341 | "padding": null,
342 | "right": null,
343 | "top": null,
344 | "visibility": null,
345 | "width": null
346 | }
347 | },
348 | "983525c7c3494fe0b2235597e9f096ba": {
349 | "model_module": "@jupyter-widgets/controls",
350 | "model_name": "DescriptionStyleModel",
351 | "model_module_version": "1.5.0",
352 | "state": {
353 | "_model_module": "@jupyter-widgets/controls",
354 | "_model_module_version": "1.5.0",
355 | "_model_name": "DescriptionStyleModel",
356 | "_view_count": null,
357 | "_view_module": "@jupyter-widgets/base",
358 | "_view_module_version": "1.2.0",
359 | "_view_name": "StyleView",
360 | "description_width": ""
361 | }
362 | },
363 | "e2667431e6024893b99fee705a01e418": {
364 | "model_module": "@jupyter-widgets/controls",
365 | "model_name": "HBoxModel",
366 | "model_module_version": "1.5.0",
367 | "state": {
368 | "_dom_classes": [],
369 | "_model_module": "@jupyter-widgets/controls",
370 | "_model_module_version": "1.5.0",
371 | "_model_name": "HBoxModel",
372 | "_view_count": null,
373 | "_view_module": "@jupyter-widgets/controls",
374 | "_view_module_version": "1.5.0",
375 | "_view_name": "HBoxView",
376 | "box_style": "",
377 | "children": [
378 | "IPY_MODEL_d01a9cc31bc7414c9e1c158a05a8a130",
379 | "IPY_MODEL_401c48702ff249b7ae4533a890bf5416",
380 | "IPY_MODEL_ba454a9a340d42a8a14ec44dc2058e90"
381 | ],
382 | "layout": "IPY_MODEL_42728bc9e2a74b63ba34a2c528aa7eba"
383 | }
384 | },
385 | "d01a9cc31bc7414c9e1c158a05a8a130": {
386 | "model_module": "@jupyter-widgets/controls",
387 | "model_name": "HTMLModel",
388 | "model_module_version": "1.5.0",
389 | "state": {
390 | "_dom_classes": [],
391 | "_model_module": "@jupyter-widgets/controls",
392 | "_model_module_version": "1.5.0",
393 | "_model_name": "HTMLModel",
394 | "_view_count": null,
395 | "_view_module": "@jupyter-widgets/controls",
396 | "_view_module_version": "1.5.0",
397 | "_view_name": "HTMLView",
398 | "description": "",
399 | "description_tooltip": null,
400 | "layout": "IPY_MODEL_6a7f7283d81843c9a89cae818b10de2f",
401 | "placeholder": "",
402 | "style": "IPY_MODEL_73ae19c1364c4c1f90f07cd9acff7420",
403 | "value": "Downloading (…)okenizer_config.json: 100%"
404 | }
405 | },
406 | "401c48702ff249b7ae4533a890bf5416": {
407 | "model_module": "@jupyter-widgets/controls",
408 | "model_name": "FloatProgressModel",
409 | "model_module_version": "1.5.0",
410 | "state": {
411 | "_dom_classes": [],
412 | "_model_module": "@jupyter-widgets/controls",
413 | "_model_module_version": "1.5.0",
414 | "_model_name": "FloatProgressModel",
415 | "_view_count": null,
416 | "_view_module": "@jupyter-widgets/controls",
417 | "_view_module_version": "1.5.0",
418 | "_view_name": "ProgressView",
419 | "bar_style": "success",
420 | "description": "",
421 | "description_tooltip": null,
422 | "layout": "IPY_MODEL_4f2d9665c52e472fa121c0e82a683d1f",
423 | "max": 29,
424 | "min": 0,
425 | "orientation": "horizontal",
426 | "style": "IPY_MODEL_be036286276044d8b6648054e75ed79d",
427 | "value": 29
428 | }
429 | },
430 | "ba454a9a340d42a8a14ec44dc2058e90": {
431 | "model_module": "@jupyter-widgets/controls",
432 | "model_name": "HTMLModel",
433 | "model_module_version": "1.5.0",
434 | "state": {
435 | "_dom_classes": [],
436 | "_model_module": "@jupyter-widgets/controls",
437 | "_model_module_version": "1.5.0",
438 | "_model_name": "HTMLModel",
439 | "_view_count": null,
440 | "_view_module": "@jupyter-widgets/controls",
441 | "_view_module_version": "1.5.0",
442 | "_view_name": "HTMLView",
443 | "description": "",
444 | "description_tooltip": null,
445 | "layout": "IPY_MODEL_01a51067061d423693b8a07e6ab458db",
446 | "placeholder": "",
447 | "style": "IPY_MODEL_17ab1c783afb4e1eaf283a3a49247399",
448 | "value": " 29.0/29.0 [00:00<00:00, 1.17kB/s]"
449 | }
450 | },
451 | "42728bc9e2a74b63ba34a2c528aa7eba": {
452 | "model_module": "@jupyter-widgets/base",
453 | "model_name": "LayoutModel",
454 | "model_module_version": "1.2.0",
455 | "state": {
456 | "_model_module": "@jupyter-widgets/base",
457 | "_model_module_version": "1.2.0",
458 | "_model_name": "LayoutModel",
459 | "_view_count": null,
460 | "_view_module": "@jupyter-widgets/base",
461 | "_view_module_version": "1.2.0",
462 | "_view_name": "LayoutView",
463 | "align_content": null,
464 | "align_items": null,
465 | "align_self": null,
466 | "border": null,
467 | "bottom": null,
468 | "display": null,
469 | "flex": null,
470 | "flex_flow": null,
471 | "grid_area": null,
472 | "grid_auto_columns": null,
473 | "grid_auto_flow": null,
474 | "grid_auto_rows": null,
475 | "grid_column": null,
476 | "grid_gap": null,
477 | "grid_row": null,
478 | "grid_template_areas": null,
479 | "grid_template_columns": null,
480 | "grid_template_rows": null,
481 | "height": null,
482 | "justify_content": null,
483 | "justify_items": null,
484 | "left": null,
485 | "margin": null,
486 | "max_height": null,
487 | "max_width": null,
488 | "min_height": null,
489 | "min_width": null,
490 | "object_fit": null,
491 | "object_position": null,
492 | "order": null,
493 | "overflow": null,
494 | "overflow_x": null,
495 | "overflow_y": null,
496 | "padding": null,
497 | "right": null,
498 | "top": null,
499 | "visibility": null,
500 | "width": null
501 | }
502 | },
503 | "6a7f7283d81843c9a89cae818b10de2f": {
504 | "model_module": "@jupyter-widgets/base",
505 | "model_name": "LayoutModel",
506 | "model_module_version": "1.2.0",
507 | "state": {
508 | "_model_module": "@jupyter-widgets/base",
509 | "_model_module_version": "1.2.0",
510 | "_model_name": "LayoutModel",
511 | "_view_count": null,
512 | "_view_module": "@jupyter-widgets/base",
513 | "_view_module_version": "1.2.0",
514 | "_view_name": "LayoutView",
515 | "align_content": null,
516 | "align_items": null,
517 | "align_self": null,
518 | "border": null,
519 | "bottom": null,
520 | "display": null,
521 | "flex": null,
522 | "flex_flow": null,
523 | "grid_area": null,
524 | "grid_auto_columns": null,
525 | "grid_auto_flow": null,
526 | "grid_auto_rows": null,
527 | "grid_column": null,
528 | "grid_gap": null,
529 | "grid_row": null,
530 | "grid_template_areas": null,
531 | "grid_template_columns": null,
532 | "grid_template_rows": null,
533 | "height": null,
534 | "justify_content": null,
535 | "justify_items": null,
536 | "left": null,
537 | "margin": null,
538 | "max_height": null,
539 | "max_width": null,
540 | "min_height": null,
541 | "min_width": null,
542 | "object_fit": null,
543 | "object_position": null,
544 | "order": null,
545 | "overflow": null,
546 | "overflow_x": null,
547 | "overflow_y": null,
548 | "padding": null,
549 | "right": null,
550 | "top": null,
551 | "visibility": null,
552 | "width": null
553 | }
554 | },
555 | "73ae19c1364c4c1f90f07cd9acff7420": {
556 | "model_module": "@jupyter-widgets/controls",
557 | "model_name": "DescriptionStyleModel",
558 | "model_module_version": "1.5.0",
559 | "state": {
560 | "_model_module": "@jupyter-widgets/controls",
561 | "_model_module_version": "1.5.0",
562 | "_model_name": "DescriptionStyleModel",
563 | "_view_count": null,
564 | "_view_module": "@jupyter-widgets/base",
565 | "_view_module_version": "1.2.0",
566 | "_view_name": "StyleView",
567 | "description_width": ""
568 | }
569 | },
570 | "4f2d9665c52e472fa121c0e82a683d1f": {
571 | "model_module": "@jupyter-widgets/base",
572 | "model_name": "LayoutModel",
573 | "model_module_version": "1.2.0",
574 | "state": {
575 | "_model_module": "@jupyter-widgets/base",
576 | "_model_module_version": "1.2.0",
577 | "_model_name": "LayoutModel",
578 | "_view_count": null,
579 | "_view_module": "@jupyter-widgets/base",
580 | "_view_module_version": "1.2.0",
581 | "_view_name": "LayoutView",
582 | "align_content": null,
583 | "align_items": null,
584 | "align_self": null,
585 | "border": null,
586 | "bottom": null,
587 | "display": null,
588 | "flex": null,
589 | "flex_flow": null,
590 | "grid_area": null,
591 | "grid_auto_columns": null,
592 | "grid_auto_flow": null,
593 | "grid_auto_rows": null,
594 | "grid_column": null,
595 | "grid_gap": null,
596 | "grid_row": null,
597 | "grid_template_areas": null,
598 | "grid_template_columns": null,
599 | "grid_template_rows": null,
600 | "height": null,
601 | "justify_content": null,
602 | "justify_items": null,
603 | "left": null,
604 | "margin": null,
605 | "max_height": null,
606 | "max_width": null,
607 | "min_height": null,
608 | "min_width": null,
609 | "object_fit": null,
610 | "object_position": null,
611 | "order": null,
612 | "overflow": null,
613 | "overflow_x": null,
614 | "overflow_y": null,
615 | "padding": null,
616 | "right": null,
617 | "top": null,
618 | "visibility": null,
619 | "width": null
620 | }
621 | },
622 | "be036286276044d8b6648054e75ed79d": {
623 | "model_module": "@jupyter-widgets/controls",
624 | "model_name": "ProgressStyleModel",
625 | "model_module_version": "1.5.0",
626 | "state": {
627 | "_model_module": "@jupyter-widgets/controls",
628 | "_model_module_version": "1.5.0",
629 | "_model_name": "ProgressStyleModel",
630 | "_view_count": null,
631 | "_view_module": "@jupyter-widgets/base",
632 | "_view_module_version": "1.2.0",
633 | "_view_name": "StyleView",
634 | "bar_color": null,
635 | "description_width": ""
636 | }
637 | },
638 | "01a51067061d423693b8a07e6ab458db": {
639 | "model_module": "@jupyter-widgets/base",
640 | "model_name": "LayoutModel",
641 | "model_module_version": "1.2.0",
642 | "state": {
643 | "_model_module": "@jupyter-widgets/base",
644 | "_model_module_version": "1.2.0",
645 | "_model_name": "LayoutModel",
646 | "_view_count": null,
647 | "_view_module": "@jupyter-widgets/base",
648 | "_view_module_version": "1.2.0",
649 | "_view_name": "LayoutView",
650 | "align_content": null,
651 | "align_items": null,
652 | "align_self": null,
653 | "border": null,
654 | "bottom": null,
655 | "display": null,
656 | "flex": null,
657 | "flex_flow": null,
658 | "grid_area": null,
659 | "grid_auto_columns": null,
660 | "grid_auto_flow": null,
661 | "grid_auto_rows": null,
662 | "grid_column": null,
663 | "grid_gap": null,
664 | "grid_row": null,
665 | "grid_template_areas": null,
666 | "grid_template_columns": null,
667 | "grid_template_rows": null,
668 | "height": null,
669 | "justify_content": null,
670 | "justify_items": null,
671 | "left": null,
672 | "margin": null,
673 | "max_height": null,
674 | "max_width": null,
675 | "min_height": null,
676 | "min_width": null,
677 | "object_fit": null,
678 | "object_position": null,
679 | "order": null,
680 | "overflow": null,
681 | "overflow_x": null,
682 | "overflow_y": null,
683 | "padding": null,
684 | "right": null,
685 | "top": null,
686 | "visibility": null,
687 | "width": null
688 | }
689 | },
690 | "17ab1c783afb4e1eaf283a3a49247399": {
691 | "model_module": "@jupyter-widgets/controls",
692 | "model_name": "DescriptionStyleModel",
693 | "model_module_version": "1.5.0",
694 | "state": {
695 | "_model_module": "@jupyter-widgets/controls",
696 | "_model_module_version": "1.5.0",
697 | "_model_name": "DescriptionStyleModel",
698 | "_view_count": null,
699 | "_view_module": "@jupyter-widgets/base",
700 | "_view_module_version": "1.2.0",
701 | "_view_name": "StyleView",
702 | "description_width": ""
703 | }
704 | },
705 | "6eaade12516048b1a3cbaa306665587f": {
706 | "model_module": "@jupyter-widgets/controls",
707 | "model_name": "HBoxModel",
708 | "model_module_version": "1.5.0",
709 | "state": {
710 | "_dom_classes": [],
711 | "_model_module": "@jupyter-widgets/controls",
712 | "_model_module_version": "1.5.0",
713 | "_model_name": "HBoxModel",
714 | "_view_count": null,
715 | "_view_module": "@jupyter-widgets/controls",
716 | "_view_module_version": "1.5.0",
717 | "_view_name": "HBoxView",
718 | "box_style": "",
719 | "children": [
720 | "IPY_MODEL_eab55e77c16245659b26032ec1dcacc7",
721 | "IPY_MODEL_01e6a5dfeb694c4c8e040e8f7218bf53",
722 | "IPY_MODEL_8f077d8f3ff341d4925e4ee960459471"
723 | ],
724 | "layout": "IPY_MODEL_9c3b34b27d654f419741e58ddebd14f3"
725 | }
726 | },
727 | "eab55e77c16245659b26032ec1dcacc7": {
728 | "model_module": "@jupyter-widgets/controls",
729 | "model_name": "HTMLModel",
730 | "model_module_version": "1.5.0",
731 | "state": {
732 | "_dom_classes": [],
733 | "_model_module": "@jupyter-widgets/controls",
734 | "_model_module_version": "1.5.0",
735 | "_model_name": "HTMLModel",
736 | "_view_count": null,
737 | "_view_module": "@jupyter-widgets/controls",
738 | "_view_module_version": "1.5.0",
739 | "_view_name": "HTMLView",
740 | "description": "",
741 | "description_tooltip": null,
742 | "layout": "IPY_MODEL_cf460dc6602e4a48ba8c7992987cfcd9",
743 | "placeholder": "",
744 | "style": "IPY_MODEL_9a5f4ebd8a0c429192b5a25705571c57",
745 | "value": "Downloading (…)lve/main/config.json: 100%"
746 | }
747 | },
748 | "01e6a5dfeb694c4c8e040e8f7218bf53": {
749 | "model_module": "@jupyter-widgets/controls",
750 | "model_name": "FloatProgressModel",
751 | "model_module_version": "1.5.0",
752 | "state": {
753 | "_dom_classes": [],
754 | "_model_module": "@jupyter-widgets/controls",
755 | "_model_module_version": "1.5.0",
756 | "_model_name": "FloatProgressModel",
757 | "_view_count": null,
758 | "_view_module": "@jupyter-widgets/controls",
759 | "_view_module_version": "1.5.0",
760 | "_view_name": "ProgressView",
761 | "bar_style": "success",
762 | "description": "",
763 | "description_tooltip": null,
764 | "layout": "IPY_MODEL_e082d9d9ca2942799661fd56945e19ea",
765 | "max": 570,
766 | "min": 0,
767 | "orientation": "horizontal",
768 | "style": "IPY_MODEL_1b49abcdc609482a8714da87be3a3269",
769 | "value": 570
770 | }
771 | },
772 | "8f077d8f3ff341d4925e4ee960459471": {
773 | "model_module": "@jupyter-widgets/controls",
774 | "model_name": "HTMLModel",
775 | "model_module_version": "1.5.0",
776 | "state": {
777 | "_dom_classes": [],
778 | "_model_module": "@jupyter-widgets/controls",
779 | "_model_module_version": "1.5.0",
780 | "_model_name": "HTMLModel",
781 | "_view_count": null,
782 | "_view_module": "@jupyter-widgets/controls",
783 | "_view_module_version": "1.5.0",
784 | "_view_name": "HTMLView",
785 | "description": "",
786 | "description_tooltip": null,
787 | "layout": "IPY_MODEL_be779890dfa5439f9f9e4d910d85e696",
788 | "placeholder": "",
789 | "style": "IPY_MODEL_dafd8d98a2064d9a98e23381edbe662b",
790 | "value": " 570/570 [00:00<00:00, 32.9kB/s]"
791 | }
792 | },
793 | "9c3b34b27d654f419741e58ddebd14f3": {
794 | "model_module": "@jupyter-widgets/base",
795 | "model_name": "LayoutModel",
796 | "model_module_version": "1.2.0",
797 | "state": {
798 | "_model_module": "@jupyter-widgets/base",
799 | "_model_module_version": "1.2.0",
800 | "_model_name": "LayoutModel",
801 | "_view_count": null,
802 | "_view_module": "@jupyter-widgets/base",
803 | "_view_module_version": "1.2.0",
804 | "_view_name": "LayoutView",
805 | "align_content": null,
806 | "align_items": null,
807 | "align_self": null,
808 | "border": null,
809 | "bottom": null,
810 | "display": null,
811 | "flex": null,
812 | "flex_flow": null,
813 | "grid_area": null,
814 | "grid_auto_columns": null,
815 | "grid_auto_flow": null,
816 | "grid_auto_rows": null,
817 | "grid_column": null,
818 | "grid_gap": null,
819 | "grid_row": null,
820 | "grid_template_areas": null,
821 | "grid_template_columns": null,
822 | "grid_template_rows": null,
823 | "height": null,
824 | "justify_content": null,
825 | "justify_items": null,
826 | "left": null,
827 | "margin": null,
828 | "max_height": null,
829 | "max_width": null,
830 | "min_height": null,
831 | "min_width": null,
832 | "object_fit": null,
833 | "object_position": null,
834 | "order": null,
835 | "overflow": null,
836 | "overflow_x": null,
837 | "overflow_y": null,
838 | "padding": null,
839 | "right": null,
840 | "top": null,
841 | "visibility": null,
842 | "width": null
843 | }
844 | },
845 | "cf460dc6602e4a48ba8c7992987cfcd9": {
846 | "model_module": "@jupyter-widgets/base",
847 | "model_name": "LayoutModel",
848 | "model_module_version": "1.2.0",
849 | "state": {
850 | "_model_module": "@jupyter-widgets/base",
851 | "_model_module_version": "1.2.0",
852 | "_model_name": "LayoutModel",
853 | "_view_count": null,
854 | "_view_module": "@jupyter-widgets/base",
855 | "_view_module_version": "1.2.0",
856 | "_view_name": "LayoutView",
857 | "align_content": null,
858 | "align_items": null,
859 | "align_self": null,
860 | "border": null,
861 | "bottom": null,
862 | "display": null,
863 | "flex": null,
864 | "flex_flow": null,
865 | "grid_area": null,
866 | "grid_auto_columns": null,
867 | "grid_auto_flow": null,
868 | "grid_auto_rows": null,
869 | "grid_column": null,
870 | "grid_gap": null,
871 | "grid_row": null,
872 | "grid_template_areas": null,
873 | "grid_template_columns": null,
874 | "grid_template_rows": null,
875 | "height": null,
876 | "justify_content": null,
877 | "justify_items": null,
878 | "left": null,
879 | "margin": null,
880 | "max_height": null,
881 | "max_width": null,
882 | "min_height": null,
883 | "min_width": null,
884 | "object_fit": null,
885 | "object_position": null,
886 | "order": null,
887 | "overflow": null,
888 | "overflow_x": null,
889 | "overflow_y": null,
890 | "padding": null,
891 | "right": null,
892 | "top": null,
893 | "visibility": null,
894 | "width": null
895 | }
896 | },
897 | "9a5f4ebd8a0c429192b5a25705571c57": {
898 | "model_module": "@jupyter-widgets/controls",
899 | "model_name": "DescriptionStyleModel",
900 | "model_module_version": "1.5.0",
901 | "state": {
902 | "_model_module": "@jupyter-widgets/controls",
903 | "_model_module_version": "1.5.0",
904 | "_model_name": "DescriptionStyleModel",
905 | "_view_count": null,
906 | "_view_module": "@jupyter-widgets/base",
907 | "_view_module_version": "1.2.0",
908 | "_view_name": "StyleView",
909 | "description_width": ""
910 | }
911 | },
912 | "e082d9d9ca2942799661fd56945e19ea": {
913 | "model_module": "@jupyter-widgets/base",
914 | "model_name": "LayoutModel",
915 | "model_module_version": "1.2.0",
916 | "state": {
917 | "_model_module": "@jupyter-widgets/base",
918 | "_model_module_version": "1.2.0",
919 | "_model_name": "LayoutModel",
920 | "_view_count": null,
921 | "_view_module": "@jupyter-widgets/base",
922 | "_view_module_version": "1.2.0",
923 | "_view_name": "LayoutView",
924 | "align_content": null,
925 | "align_items": null,
926 | "align_self": null,
927 | "border": null,
928 | "bottom": null,
929 | "display": null,
930 | "flex": null,
931 | "flex_flow": null,
932 | "grid_area": null,
933 | "grid_auto_columns": null,
934 | "grid_auto_flow": null,
935 | "grid_auto_rows": null,
936 | "grid_column": null,
937 | "grid_gap": null,
938 | "grid_row": null,
939 | "grid_template_areas": null,
940 | "grid_template_columns": null,
941 | "grid_template_rows": null,
942 | "height": null,
943 | "justify_content": null,
944 | "justify_items": null,
945 | "left": null,
946 | "margin": null,
947 | "max_height": null,
948 | "max_width": null,
949 | "min_height": null,
950 | "min_width": null,
951 | "object_fit": null,
952 | "object_position": null,
953 | "order": null,
954 | "overflow": null,
955 | "overflow_x": null,
956 | "overflow_y": null,
957 | "padding": null,
958 | "right": null,
959 | "top": null,
960 | "visibility": null,
961 | "width": null
962 | }
963 | },
964 | "1b49abcdc609482a8714da87be3a3269": {
965 | "model_module": "@jupyter-widgets/controls",
966 | "model_name": "ProgressStyleModel",
967 | "model_module_version": "1.5.0",
968 | "state": {
969 | "_model_module": "@jupyter-widgets/controls",
970 | "_model_module_version": "1.5.0",
971 | "_model_name": "ProgressStyleModel",
972 | "_view_count": null,
973 | "_view_module": "@jupyter-widgets/base",
974 | "_view_module_version": "1.2.0",
975 | "_view_name": "StyleView",
976 | "bar_color": null,
977 | "description_width": ""
978 | }
979 | },
980 | "be779890dfa5439f9f9e4d910d85e696": {
981 | "model_module": "@jupyter-widgets/base",
982 | "model_name": "LayoutModel",
983 | "model_module_version": "1.2.0",
984 | "state": {
985 | "_model_module": "@jupyter-widgets/base",
986 | "_model_module_version": "1.2.0",
987 | "_model_name": "LayoutModel",
988 | "_view_count": null,
989 | "_view_module": "@jupyter-widgets/base",
990 | "_view_module_version": "1.2.0",
991 | "_view_name": "LayoutView",
992 | "align_content": null,
993 | "align_items": null,
994 | "align_self": null,
995 | "border": null,
996 | "bottom": null,
997 | "display": null,
998 | "flex": null,
999 | "flex_flow": null,
1000 | "grid_area": null,
1001 | "grid_auto_columns": null,
1002 | "grid_auto_flow": null,
1003 | "grid_auto_rows": null,
1004 | "grid_column": null,
1005 | "grid_gap": null,
1006 | "grid_row": null,
1007 | "grid_template_areas": null,
1008 | "grid_template_columns": null,
1009 | "grid_template_rows": null,
1010 | "height": null,
1011 | "justify_content": null,
1012 | "justify_items": null,
1013 | "left": null,
1014 | "margin": null,
1015 | "max_height": null,
1016 | "max_width": null,
1017 | "min_height": null,
1018 | "min_width": null,
1019 | "object_fit": null,
1020 | "object_position": null,
1021 | "order": null,
1022 | "overflow": null,
1023 | "overflow_x": null,
1024 | "overflow_y": null,
1025 | "padding": null,
1026 | "right": null,
1027 | "top": null,
1028 | "visibility": null,
1029 | "width": null
1030 | }
1031 | },
1032 | "dafd8d98a2064d9a98e23381edbe662b": {
1033 | "model_module": "@jupyter-widgets/controls",
1034 | "model_name": "DescriptionStyleModel",
1035 | "model_module_version": "1.5.0",
1036 | "state": {
1037 | "_model_module": "@jupyter-widgets/controls",
1038 | "_model_module_version": "1.5.0",
1039 | "_model_name": "DescriptionStyleModel",
1040 | "_view_count": null,
1041 | "_view_module": "@jupyter-widgets/base",
1042 | "_view_module_version": "1.2.0",
1043 | "_view_name": "StyleView",
1044 | "description_width": ""
1045 | }
1046 | },
1047 | "26a184303e4744b3be5a518ee8bf318d": {
1048 | "model_module": "@jupyter-widgets/controls",
1049 | "model_name": "HBoxModel",
1050 | "model_module_version": "1.5.0",
1051 | "state": {
1052 | "_dom_classes": [],
1053 | "_model_module": "@jupyter-widgets/controls",
1054 | "_model_module_version": "1.5.0",
1055 | "_model_name": "HBoxModel",
1056 | "_view_count": null,
1057 | "_view_module": "@jupyter-widgets/controls",
1058 | "_view_module_version": "1.5.0",
1059 | "_view_name": "HBoxView",
1060 | "box_style": "",
1061 | "children": [
1062 | "IPY_MODEL_e18f30f7ef6e4bf0932292b79b014908",
1063 | "IPY_MODEL_6d2bbdaf8e014b29a2b5c9029a276ce8",
1064 | "IPY_MODEL_4acf12d91e384fa391b5ddd0fda20f9f"
1065 | ],
1066 | "layout": "IPY_MODEL_3b7d63b6088f461582138ef23174441e"
1067 | }
1068 | },
1069 | "e18f30f7ef6e4bf0932292b79b014908": {
1070 | "model_module": "@jupyter-widgets/controls",
1071 | "model_name": "HTMLModel",
1072 | "model_module_version": "1.5.0",
1073 | "state": {
1074 | "_dom_classes": [],
1075 | "_model_module": "@jupyter-widgets/controls",
1076 | "_model_module_version": "1.5.0",
1077 | "_model_name": "HTMLModel",
1078 | "_view_count": null,
1079 | "_view_module": "@jupyter-widgets/controls",
1080 | "_view_module_version": "1.5.0",
1081 | "_view_name": "HTMLView",
1082 | "description": "",
1083 | "description_tooltip": null,
1084 | "layout": "IPY_MODEL_10aa0f19f5e64effbe37ca9e9ee1bcc1",
1085 | "placeholder": "",
1086 | "style": "IPY_MODEL_76e54c6cac654c0abcb741cd0a7f29f5",
1087 | "value": "Downloading model.safetensors: 100%"
1088 | }
1089 | },
1090 | "6d2bbdaf8e014b29a2b5c9029a276ce8": {
1091 | "model_module": "@jupyter-widgets/controls",
1092 | "model_name": "FloatProgressModel",
1093 | "model_module_version": "1.5.0",
1094 | "state": {
1095 | "_dom_classes": [],
1096 | "_model_module": "@jupyter-widgets/controls",
1097 | "_model_module_version": "1.5.0",
1098 | "_model_name": "FloatProgressModel",
1099 | "_view_count": null,
1100 | "_view_module": "@jupyter-widgets/controls",
1101 | "_view_module_version": "1.5.0",
1102 | "_view_name": "ProgressView",
1103 | "bar_style": "success",
1104 | "description": "",
1105 | "description_tooltip": null,
1106 | "layout": "IPY_MODEL_632aef428e8845fa8fb68b31f7c28c2f",
1107 | "max": 435755784,
1108 | "min": 0,
1109 | "orientation": "horizontal",
1110 | "style": "IPY_MODEL_767138cce21941d383e730ab9c36a194",
1111 | "value": 435755784
1112 | }
1113 | },
1114 | "4acf12d91e384fa391b5ddd0fda20f9f": {
1115 | "model_module": "@jupyter-widgets/controls",
1116 | "model_name": "HTMLModel",
1117 | "model_module_version": "1.5.0",
1118 | "state": {
1119 | "_dom_classes": [],
1120 | "_model_module": "@jupyter-widgets/controls",
1121 | "_model_module_version": "1.5.0",
1122 | "_model_name": "HTMLModel",
1123 | "_view_count": null,
1124 | "_view_module": "@jupyter-widgets/controls",
1125 | "_view_module_version": "1.5.0",
1126 | "_view_name": "HTMLView",
1127 | "description": "",
1128 | "description_tooltip": null,
1129 | "layout": "IPY_MODEL_fefb6725130f44799a9c80c0274409b0",
1130 | "placeholder": "",
1131 | "style": "IPY_MODEL_6487543dc0d647808a42a57474c52408",
1132 | "value": " 436M/436M [00:05<00:00, 79.6MB/s]"
1133 | }
1134 | },
1135 | "3b7d63b6088f461582138ef23174441e": {
1136 | "model_module": "@jupyter-widgets/base",
1137 | "model_name": "LayoutModel",
1138 | "model_module_version": "1.2.0",
1139 | "state": {
1140 | "_model_module": "@jupyter-widgets/base",
1141 | "_model_module_version": "1.2.0",
1142 | "_model_name": "LayoutModel",
1143 | "_view_count": null,
1144 | "_view_module": "@jupyter-widgets/base",
1145 | "_view_module_version": "1.2.0",
1146 | "_view_name": "LayoutView",
1147 | "align_content": null,
1148 | "align_items": null,
1149 | "align_self": null,
1150 | "border": null,
1151 | "bottom": null,
1152 | "display": null,
1153 | "flex": null,
1154 | "flex_flow": null,
1155 | "grid_area": null,
1156 | "grid_auto_columns": null,
1157 | "grid_auto_flow": null,
1158 | "grid_auto_rows": null,
1159 | "grid_column": null,
1160 | "grid_gap": null,
1161 | "grid_row": null,
1162 | "grid_template_areas": null,
1163 | "grid_template_columns": null,
1164 | "grid_template_rows": null,
1165 | "height": null,
1166 | "justify_content": null,
1167 | "justify_items": null,
1168 | "left": null,
1169 | "margin": null,
1170 | "max_height": null,
1171 | "max_width": null,
1172 | "min_height": null,
1173 | "min_width": null,
1174 | "object_fit": null,
1175 | "object_position": null,
1176 | "order": null,
1177 | "overflow": null,
1178 | "overflow_x": null,
1179 | "overflow_y": null,
1180 | "padding": null,
1181 | "right": null,
1182 | "top": null,
1183 | "visibility": null,
1184 | "width": null
1185 | }
1186 | },
1187 | "10aa0f19f5e64effbe37ca9e9ee1bcc1": {
1188 | "model_module": "@jupyter-widgets/base",
1189 | "model_name": "LayoutModel",
1190 | "model_module_version": "1.2.0",
1191 | "state": {
1192 | "_model_module": "@jupyter-widgets/base",
1193 | "_model_module_version": "1.2.0",
1194 | "_model_name": "LayoutModel",
1195 | "_view_count": null,
1196 | "_view_module": "@jupyter-widgets/base",
1197 | "_view_module_version": "1.2.0",
1198 | "_view_name": "LayoutView",
1199 | "align_content": null,
1200 | "align_items": null,
1201 | "align_self": null,
1202 | "border": null,
1203 | "bottom": null,
1204 | "display": null,
1205 | "flex": null,
1206 | "flex_flow": null,
1207 | "grid_area": null,
1208 | "grid_auto_columns": null,
1209 | "grid_auto_flow": null,
1210 | "grid_auto_rows": null,
1211 | "grid_column": null,
1212 | "grid_gap": null,
1213 | "grid_row": null,
1214 | "grid_template_areas": null,
1215 | "grid_template_columns": null,
1216 | "grid_template_rows": null,
1217 | "height": null,
1218 | "justify_content": null,
1219 | "justify_items": null,
1220 | "left": null,
1221 | "margin": null,
1222 | "max_height": null,
1223 | "max_width": null,
1224 | "min_height": null,
1225 | "min_width": null,
1226 | "object_fit": null,
1227 | "object_position": null,
1228 | "order": null,
1229 | "overflow": null,
1230 | "overflow_x": null,
1231 | "overflow_y": null,
1232 | "padding": null,
1233 | "right": null,
1234 | "top": null,
1235 | "visibility": null,
1236 | "width": null
1237 | }
1238 | },
1239 | "76e54c6cac654c0abcb741cd0a7f29f5": {
1240 | "model_module": "@jupyter-widgets/controls",
1241 | "model_name": "DescriptionStyleModel",
1242 | "model_module_version": "1.5.0",
1243 | "state": {
1244 | "_model_module": "@jupyter-widgets/controls",
1245 | "_model_module_version": "1.5.0",
1246 | "_model_name": "DescriptionStyleModel",
1247 | "_view_count": null,
1248 | "_view_module": "@jupyter-widgets/base",
1249 | "_view_module_version": "1.2.0",
1250 | "_view_name": "StyleView",
1251 | "description_width": ""
1252 | }
1253 | },
1254 | "632aef428e8845fa8fb68b31f7c28c2f": {
1255 | "model_module": "@jupyter-widgets/base",
1256 | "model_name": "LayoutModel",
1257 | "model_module_version": "1.2.0",
1258 | "state": {
1259 | "_model_module": "@jupyter-widgets/base",
1260 | "_model_module_version": "1.2.0",
1261 | "_model_name": "LayoutModel",
1262 | "_view_count": null,
1263 | "_view_module": "@jupyter-widgets/base",
1264 | "_view_module_version": "1.2.0",
1265 | "_view_name": "LayoutView",
1266 | "align_content": null,
1267 | "align_items": null,
1268 | "align_self": null,
1269 | "border": null,
1270 | "bottom": null,
1271 | "display": null,
1272 | "flex": null,
1273 | "flex_flow": null,
1274 | "grid_area": null,
1275 | "grid_auto_columns": null,
1276 | "grid_auto_flow": null,
1277 | "grid_auto_rows": null,
1278 | "grid_column": null,
1279 | "grid_gap": null,
1280 | "grid_row": null,
1281 | "grid_template_areas": null,
1282 | "grid_template_columns": null,
1283 | "grid_template_rows": null,
1284 | "height": null,
1285 | "justify_content": null,
1286 | "justify_items": null,
1287 | "left": null,
1288 | "margin": null,
1289 | "max_height": null,
1290 | "max_width": null,
1291 | "min_height": null,
1292 | "min_width": null,
1293 | "object_fit": null,
1294 | "object_position": null,
1295 | "order": null,
1296 | "overflow": null,
1297 | "overflow_x": null,
1298 | "overflow_y": null,
1299 | "padding": null,
1300 | "right": null,
1301 | "top": null,
1302 | "visibility": null,
1303 | "width": null
1304 | }
1305 | },
1306 | "767138cce21941d383e730ab9c36a194": {
1307 | "model_module": "@jupyter-widgets/controls",
1308 | "model_name": "ProgressStyleModel",
1309 | "model_module_version": "1.5.0",
1310 | "state": {
1311 | "_model_module": "@jupyter-widgets/controls",
1312 | "_model_module_version": "1.5.0",
1313 | "_model_name": "ProgressStyleModel",
1314 | "_view_count": null,
1315 | "_view_module": "@jupyter-widgets/base",
1316 | "_view_module_version": "1.2.0",
1317 | "_view_name": "StyleView",
1318 | "bar_color": null,
1319 | "description_width": ""
1320 | }
1321 | },
1322 | "fefb6725130f44799a9c80c0274409b0": {
1323 | "model_module": "@jupyter-widgets/base",
1324 | "model_name": "LayoutModel",
1325 | "model_module_version": "1.2.0",
1326 | "state": {
1327 | "_model_module": "@jupyter-widgets/base",
1328 | "_model_module_version": "1.2.0",
1329 | "_model_name": "LayoutModel",
1330 | "_view_count": null,
1331 | "_view_module": "@jupyter-widgets/base",
1332 | "_view_module_version": "1.2.0",
1333 | "_view_name": "LayoutView",
1334 | "align_content": null,
1335 | "align_items": null,
1336 | "align_self": null,
1337 | "border": null,
1338 | "bottom": null,
1339 | "display": null,
1340 | "flex": null,
1341 | "flex_flow": null,
1342 | "grid_area": null,
1343 | "grid_auto_columns": null,
1344 | "grid_auto_flow": null,
1345 | "grid_auto_rows": null,
1346 | "grid_column": null,
1347 | "grid_gap": null,
1348 | "grid_row": null,
1349 | "grid_template_areas": null,
1350 | "grid_template_columns": null,
1351 | "grid_template_rows": null,
1352 | "height": null,
1353 | "justify_content": null,
1354 | "justify_items": null,
1355 | "left": null,
1356 | "margin": null,
1357 | "max_height": null,
1358 | "max_width": null,
1359 | "min_height": null,
1360 | "min_width": null,
1361 | "object_fit": null,
1362 | "object_position": null,
1363 | "order": null,
1364 | "overflow": null,
1365 | "overflow_x": null,
1366 | "overflow_y": null,
1367 | "padding": null,
1368 | "right": null,
1369 | "top": null,
1370 | "visibility": null,
1371 | "width": null
1372 | }
1373 | },
1374 | "6487543dc0d647808a42a57474c52408": {
1375 | "model_module": "@jupyter-widgets/controls",
1376 | "model_name": "DescriptionStyleModel",
1377 | "model_module_version": "1.5.0",
1378 | "state": {
1379 | "_model_module": "@jupyter-widgets/controls",
1380 | "_model_module_version": "1.5.0",
1381 | "_model_name": "DescriptionStyleModel",
1382 | "_view_count": null,
1383 | "_view_module": "@jupyter-widgets/base",
1384 | "_view_module_version": "1.2.0",
1385 | "_view_name": "StyleView",
1386 | "description_width": ""
1387 | }
1388 | }
1389 | }
1390 | }
1391 | },
1392 | "cells": [
1393 | {
1394 | "cell_type": "markdown",
1395 | "metadata": {
1396 | "id": "view-in-github",
1397 | "colab_type": "text"
1398 | },
1399 | "source": [
1400 | "
"
1401 | ]
1402 | },
1403 | {
1404 | "cell_type": "code",
1405 | "source": [
1406 | "!pip install transformers"
1407 | ],
1408 | "metadata": {
1409 | "colab": {
1410 | "base_uri": "https://localhost:8080/"
1411 | },
1412 | "id": "Swz2kIIIdA7V",
1413 | "outputId": "493226cb-73b6-4274-d8a5-33538410b5b2"
1414 | },
1415 | "execution_count": null,
1416 | "outputs": [
1417 | {
1418 | "output_type": "stream",
1419 | "name": "stdout",
1420 | "text": [
1421 | "Collecting transformers\n",
1422 | " Downloading transformers-4.31.0-py3-none-any.whl (7.4 MB)\n",
1423 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.4/7.4 MB\u001b[0m \u001b[31m15.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
1424 | "\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers) (3.12.2)\n",
1425 | "Collecting huggingface-hub<1.0,>=0.14.1 (from transformers)\n",
1426 | " Downloading huggingface_hub-0.16.4-py3-none-any.whl (268 kB)\n",
1427 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m26.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
1428 | "\u001b[?25hRequirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (1.23.5)\n",
1429 | "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (23.1)\n",
1430 | "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (6.0.1)\n",
1431 | "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2022.10.31)\n",
1432 | "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.31.0)\n",
1433 | "Collecting tokenizers!=0.11.3,<0.14,>=0.11.1 (from transformers)\n",
1434 | " Downloading tokenizers-0.13.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB)\n",
1435 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m36.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
1436 | "\u001b[?25hCollecting safetensors>=0.3.1 (from transformers)\n",
1437 | " Downloading safetensors-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n",
1438 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m48.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
1439 | "\u001b[?25hRequirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.65.0)\n",
1440 | "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (2023.6.0)\n",
1441 | "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (4.7.1)\n",
1442 | "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.2.0)\n",
1443 | "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.4)\n",
1444 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (1.26.16)\n",
1445 | "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2023.7.22)\n",
1446 | "Installing collected packages: tokenizers, safetensors, huggingface-hub, transformers\n",
1447 | "Successfully installed huggingface-hub-0.16.4 safetensors-0.3.2 tokenizers-0.13.3 transformers-4.31.0\n"
1448 | ]
1449 | }
1450 | ]
1451 | },
1452 | {
1453 | "cell_type": "code",
1454 | "execution_count": null,
1455 | "metadata": {
1456 | "colab": {
1457 | "base_uri": "https://localhost:8080/"
1458 | },
1459 | "id": "UpEfXvKoZfDc",
1460 | "outputId": "e78fd96d-5b76-43df-eb49-b97279a35697"
1461 | },
1462 | "outputs": [
1463 | {
1464 | "output_type": "stream",
1465 | "name": "stdout",
1466 | "text": [
1467 | "Mounted at /content/gdrive\n"
1468 | ]
1469 | }
1470 | ],
1471 | "source": [
1472 | "from google.colab import drive\n",
1473 | "drive.mount('/content/gdrive', force_remount=True)\n",
1474 | "root_dir = \"/content/gdrive/My Drive/training/\""
1475 | ]
1476 | },
1477 | {
1478 | "cell_type": "code",
1479 | "source": [
1480 | "import os\n",
1481 | "os.listdir(root_dir)"
1482 | ],
1483 | "metadata": {
1484 | "colab": {
1485 | "base_uri": "https://localhost:8080/"
1486 | },
1487 | "id": "buoZFap_aGav",
1488 | "outputId": "56b029e5-cf1e-4e18-8248-3d5b7a0fce49"
1489 | },
1490 | "execution_count": null,
1491 | "outputs": [
1492 | {
1493 | "output_type": "execute_result",
1494 | "data": {
1495 | "text/plain": [
1496 | "['train.csv', '.ipynb_checkpoints']"
1497 | ]
1498 | },
1499 | "metadata": {},
1500 | "execution_count": 4
1501 | }
1502 | ]
1503 | },
1504 | {
1505 | "cell_type": "code",
1506 | "source": [
1507 | "import pandas as pd\n",
1508 | "\n",
1509 | "root_path = f\"{root_dir}training/train.csv\"\n",
1510 | "df = pd.read_csv(f\"{root_dir}train.csv\")\n",
1511 | "df.head()"
1512 | ],
1513 | "metadata": {
1514 | "colab": {
1515 | "base_uri": "https://localhost:8080/",
1516 | "height": 206
1517 | },
1518 | "id": "DJBFucr5ahZb",
1519 | "outputId": "90cfbc8e-fc29-4f5a-fdaa-9470e697cec2"
1520 | },
1521 | "execution_count": null,
1522 | "outputs": [
1523 | {
1524 | "output_type": "execute_result",
1525 | "data": {
1526 | "text/plain": [
1527 | " category text\n",
1528 | "0 SearchDynamicNews Which city hosted a major international confer...\n",
1529 | "1 SearchDynamicNews What is the current status of the cryptocurren...\n",
1530 | "2 SearchDynamicNews What is the current status of the global clima...\n",
1531 | "3 NormalChat I'm currently reading a mystery novel.\n",
1532 | "4 NormalChat Have you seen the latest episode of that TV show?"
1533 | ],
1534 | "text/html": [
1535 | "\n",
1536 | "\n",
1537 | "
\n",
1538 | "
\n",
1539 | "
\n",
1540 | "\n",
1553 | "
\n",
1554 | " \n",
1555 | " \n",
1556 | " | \n",
1557 | " category | \n",
1558 | " text | \n",
1559 | "
\n",
1560 | " \n",
1561 | " \n",
1562 | " \n",
1563 | " | 0 | \n",
1564 | " SearchDynamicNews | \n",
1565 | " Which city hosted a major international confer... | \n",
1566 | "
\n",
1567 | " \n",
1568 | " | 1 | \n",
1569 | " SearchDynamicNews | \n",
1570 | " What is the current status of the cryptocurren... | \n",
1571 | "
\n",
1572 | " \n",
1573 | " | 2 | \n",
1574 | " SearchDynamicNews | \n",
1575 | " What is the current status of the global clima... | \n",
1576 | "
\n",
1577 | " \n",
1578 | " | 3 | \n",
1579 | " NormalChat | \n",
1580 | " I'm currently reading a mystery novel. | \n",
1581 | "
\n",
1582 | " \n",
1583 | " | 4 | \n",
1584 | " NormalChat | \n",
1585 | " Have you seen the latest episode of that TV show? | \n",
1586 | "
\n",
1587 | " \n",
1588 | "
\n",
1589 | "
\n",
1590 | "
\n",
1600 | "\n",
1601 | "\n",
1602 | "\n",
1603 | "
\n",
1604 | "
\n",
1615 | "
\n",
1616 | "\n",
1617 | "\n",
1648 | "\n",
1649 | " \n",
1656 | "\n",
1657 | " \n",
1668 | " \n",
1705 | "\n",
1706 | " \n",
1730 | "
\n",
1731 | "
\n"
1732 | ]
1733 | },
1734 | "metadata": {},
1735 | "execution_count": 5
1736 | }
1737 | ]
1738 | },
1739 | {
1740 | "cell_type": "code",
1741 | "source": [
1742 | "df['encoded_text'] = df['category'].astype('category').cat.codes\n",
1743 | "\n",
1744 | "df.head(10)"
1745 | ],
1746 | "metadata": {
1747 | "colab": {
1748 | "base_uri": "https://localhost:8080/",
1749 | "height": 363
1750 | },
1751 | "id": "yHvvKlRRahV6",
1752 | "outputId": "a23dde96-a6b9-4430-8517-081ef7c6ea16"
1753 | },
1754 | "execution_count": null,
1755 | "outputs": [
1756 | {
1757 | "output_type": "execute_result",
1758 | "data": {
1759 | "text/plain": [
1760 | " category text \\\n",
1761 | "0 SearchDynamicNews Which city hosted a major international confer... \n",
1762 | "1 SearchDynamicNews What is the current status of the cryptocurren... \n",
1763 | "2 SearchDynamicNews What is the current status of the global clima... \n",
1764 | "3 NormalChat I'm currently reading a mystery novel. \n",
1765 | "4 NormalChat Have you seen the latest episode of that TV show? \n",
1766 | "5 SearchDynamicNews What are the updates on international trade ag... \n",
1767 | "6 SearchDynamicNews Who is the CEO of Twitter? \n",
1768 | "7 SearchDynamicNews What is the current situation of the pandemic ... \n",
1769 | "8 NormalChat Board game nights are so much fun! \n",
1770 | "9 SearchDynamicNews What is the breakthrough in cancer research? \n",
1771 | "\n",
1772 | " encoded_text \n",
1773 | "0 1 \n",
1774 | "1 1 \n",
1775 | "2 1 \n",
1776 | "3 0 \n",
1777 | "4 0 \n",
1778 | "5 1 \n",
1779 | "6 1 \n",
1780 | "7 1 \n",
1781 | "8 0 \n",
1782 | "9 1 "
1783 | ],
1784 | "text/html": [
1785 | "\n",
1786 | "\n",
1787 | " \n",
1788 | "
\n",
1789 | "
\n",
1790 | "\n",
1803 | "
\n",
1804 | " \n",
1805 | " \n",
1806 | " | \n",
1807 | " category | \n",
1808 | " text | \n",
1809 | " encoded_text | \n",
1810 | "
\n",
1811 | " \n",
1812 | " \n",
1813 | " \n",
1814 | " | 0 | \n",
1815 | " SearchDynamicNews | \n",
1816 | " Which city hosted a major international confer... | \n",
1817 | " 1 | \n",
1818 | "
\n",
1819 | " \n",
1820 | " | 1 | \n",
1821 | " SearchDynamicNews | \n",
1822 | " What is the current status of the cryptocurren... | \n",
1823 | " 1 | \n",
1824 | "
\n",
1825 | " \n",
1826 | " | 2 | \n",
1827 | " SearchDynamicNews | \n",
1828 | " What is the current status of the global clima... | \n",
1829 | " 1 | \n",
1830 | "
\n",
1831 | " \n",
1832 | " | 3 | \n",
1833 | " NormalChat | \n",
1834 | " I'm currently reading a mystery novel. | \n",
1835 | " 0 | \n",
1836 | "
\n",
1837 | " \n",
1838 | " | 4 | \n",
1839 | " NormalChat | \n",
1840 | " Have you seen the latest episode of that TV show? | \n",
1841 | " 0 | \n",
1842 | "
\n",
1843 | " \n",
1844 | " | 5 | \n",
1845 | " SearchDynamicNews | \n",
1846 | " What are the updates on international trade ag... | \n",
1847 | " 1 | \n",
1848 | "
\n",
1849 | " \n",
1850 | " | 6 | \n",
1851 | " SearchDynamicNews | \n",
1852 | " Who is the CEO of Twitter? | \n",
1853 | " 1 | \n",
1854 | "
\n",
1855 | " \n",
1856 | " | 7 | \n",
1857 | " SearchDynamicNews | \n",
1858 | " What is the current situation of the pandemic ... | \n",
1859 | " 1 | \n",
1860 | "
\n",
1861 | " \n",
1862 | " | 8 | \n",
1863 | " NormalChat | \n",
1864 | " Board game nights are so much fun! | \n",
1865 | " 0 | \n",
1866 | "
\n",
1867 | " \n",
1868 | " | 9 | \n",
1869 | " SearchDynamicNews | \n",
1870 | " What is the breakthrough in cancer research? | \n",
1871 | " 1 | \n",
1872 | "
\n",
1873 | " \n",
1874 | "
\n",
1875 | "
\n",
1876 | "
\n",
1886 | "\n",
1887 | "\n",
1888 | "\n",
1889 | "
\n",
1890 | "
\n",
1901 | "
\n",
1902 | "\n",
1903 | "\n",
1934 | "\n",
1935 | " \n",
1942 | "\n",
1943 | " \n",
1954 | " \n",
1991 | "\n",
1992 | " \n",
2016 | "
\n",
2017 | "
\n"
2018 | ]
2019 | },
2020 | "metadata": {},
2021 | "execution_count": 6
2022 | }
2023 | ]
2024 | },
2025 | {
2026 | "cell_type": "code",
2027 | "source": [
2028 | "# df = df.drop(['category'], axis=1)\n",
2029 | "df.rename(columns={'encoded_text': 'Sentiment', 'text':'Phrase'}, inplace=True)\n",
2030 | "df.head(10)"
2031 | ],
2032 | "metadata": {
2033 | "colab": {
2034 | "base_uri": "https://localhost:8080/",
2035 | "height": 363
2036 | },
2037 | "id": "zxVAOu32ahT2",
2038 | "outputId": "7e709532-fb10-48b7-d535-38968e732353"
2039 | },
2040 | "execution_count": null,
2041 | "outputs": [
2042 | {
2043 | "output_type": "execute_result",
2044 | "data": {
2045 | "text/plain": [
2046 | " category Phrase \\\n",
2047 | "0 SearchDynamicNews Which city hosted a major international confer... \n",
2048 | "1 SearchDynamicNews What is the current status of the cryptocurren... \n",
2049 | "2 SearchDynamicNews What is the current status of the global clima... \n",
2050 | "3 NormalChat I'm currently reading a mystery novel. \n",
2051 | "4 NormalChat Have you seen the latest episode of that TV show? \n",
2052 | "5 SearchDynamicNews What are the updates on international trade ag... \n",
2053 | "6 SearchDynamicNews Who is the CEO of Twitter? \n",
2054 | "7 SearchDynamicNews What is the current situation of the pandemic ... \n",
2055 | "8 NormalChat Board game nights are so much fun! \n",
2056 | "9 SearchDynamicNews What is the breakthrough in cancer research? \n",
2057 | "\n",
2058 | " Sentiment \n",
2059 | "0 1 \n",
2060 | "1 1 \n",
2061 | "2 1 \n",
2062 | "3 0 \n",
2063 | "4 0 \n",
2064 | "5 1 \n",
2065 | "6 1 \n",
2066 | "7 1 \n",
2067 | "8 0 \n",
2068 | "9 1 "
2069 | ],
2070 | "text/html": [
2071 | "\n",
2072 | "\n",
2073 | " \n",
2074 | "
\n",
2075 | "
\n",
2076 | "\n",
2089 | "
\n",
2090 | " \n",
2091 | " \n",
2092 | " | \n",
2093 | " category | \n",
2094 | " Phrase | \n",
2095 | " Sentiment | \n",
2096 | "
\n",
2097 | " \n",
2098 | " \n",
2099 | " \n",
2100 | " | 0 | \n",
2101 | " SearchDynamicNews | \n",
2102 | " Which city hosted a major international confer... | \n",
2103 | " 1 | \n",
2104 | "
\n",
2105 | " \n",
2106 | " | 1 | \n",
2107 | " SearchDynamicNews | \n",
2108 | " What is the current status of the cryptocurren... | \n",
2109 | " 1 | \n",
2110 | "
\n",
2111 | " \n",
2112 | " | 2 | \n",
2113 | " SearchDynamicNews | \n",
2114 | " What is the current status of the global clima... | \n",
2115 | " 1 | \n",
2116 | "
\n",
2117 | " \n",
2118 | " | 3 | \n",
2119 | " NormalChat | \n",
2120 | " I'm currently reading a mystery novel. | \n",
2121 | " 0 | \n",
2122 | "
\n",
2123 | " \n",
2124 | " | 4 | \n",
2125 | " NormalChat | \n",
2126 | " Have you seen the latest episode of that TV show? | \n",
2127 | " 0 | \n",
2128 | "
\n",
2129 | " \n",
2130 | " | 5 | \n",
2131 | " SearchDynamicNews | \n",
2132 | " What are the updates on international trade ag... | \n",
2133 | " 1 | \n",
2134 | "
\n",
2135 | " \n",
2136 | " | 6 | \n",
2137 | " SearchDynamicNews | \n",
2138 | " Who is the CEO of Twitter? | \n",
2139 | " 1 | \n",
2140 | "
\n",
2141 | " \n",
2142 | " | 7 | \n",
2143 | " SearchDynamicNews | \n",
2144 | " What is the current situation of the pandemic ... | \n",
2145 | " 1 | \n",
2146 | "
\n",
2147 | " \n",
2148 | " | 8 | \n",
2149 | " NormalChat | \n",
2150 | " Board game nights are so much fun! | \n",
2151 | " 0 | \n",
2152 | "
\n",
2153 | " \n",
2154 | " | 9 | \n",
2155 | " SearchDynamicNews | \n",
2156 | " What is the breakthrough in cancer research? | \n",
2157 | " 1 | \n",
2158 | "
\n",
2159 | " \n",
2160 | "
\n",
2161 | "
\n",
2162 | "
\n",
2172 | "\n",
2173 | "\n",
2174 | "\n",
2175 | "
\n",
2176 | "
\n",
2187 | "
\n",
2188 | "\n",
2189 | "\n",
2220 | "\n",
2221 | " \n",
2228 | "\n",
2229 | " \n",
2240 | " \n",
2277 | "\n",
2278 | " \n",
2302 | "
\n",
2303 | "
\n"
2304 | ]
2305 | },
2306 | "metadata": {},
2307 | "execution_count": 7
2308 | }
2309 | ]
2310 | },
2311 | {
2312 | "cell_type": "code",
2313 | "source": [
2314 | "import numpy as np\n",
2315 | "\n",
2316 | "seq_len = 512\n",
2317 | "num_samples = len(df)\n",
2318 | "\n",
2319 | "Xids = np.zeros((num_samples, seq_len))\n",
2320 | "Xmask = np.zeros((num_samples, seq_len))\n",
2321 | "\n",
2322 | "Xids.shape"
2323 | ],
2324 | "metadata": {
2325 | "colab": {
2326 | "base_uri": "https://localhost:8080/"
2327 | },
2328 | "id": "8kfKCJ-TahNz",
2329 | "outputId": "3fc51cd7-3e3d-41e6-fd28-76dfc859454c"
2330 | },
2331 | "execution_count": null,
2332 | "outputs": [
2333 | {
2334 | "output_type": "execute_result",
2335 | "data": {
2336 | "text/plain": [
2337 | "(116, 512)"
2338 | ]
2339 | },
2340 | "metadata": {},
2341 | "execution_count": 8
2342 | }
2343 | ]
2344 | },
2345 | {
2346 | "cell_type": "code",
2347 | "source": [
2348 | "from transformers import BertTokenizer\n",
2349 | "\n",
2350 | "tokenizer = BertTokenizer.from_pretrained('bert-base-cased')"
2351 | ],
2352 | "metadata": {
2353 | "colab": {
2354 | "base_uri": "https://localhost:8080/",
2355 | "height": 113,
2356 | "referenced_widgets": [
2357 | "4e181378f6704b2793283d2e29b61703",
2358 | "c019c0048c1a43a79a64da317f499543",
2359 | "b47b7cd4b1164ab4b40d6cbe8fd837ce",
2360 | "2586e6c72cc44a36916470eaa6dc39f6",
2361 | "e72d6d45c1244d2e9c0c3fee1f7652a2",
2362 | "4d507c4276604d22b7935ec0d246ccc7",
2363 | "7fa19f01db734d0b9f996f5da493bc72",
2364 | "fea1aaba07234c9baf9213a4fdcb7e66",
2365 | "583984aaa78e4efebe8994f4e8df1f62",
2366 | "5a563cec73634cfdb67610cd323a3193",
2367 | "983525c7c3494fe0b2235597e9f096ba",
2368 | "e2667431e6024893b99fee705a01e418",
2369 | "d01a9cc31bc7414c9e1c158a05a8a130",
2370 | "401c48702ff249b7ae4533a890bf5416",
2371 | "ba454a9a340d42a8a14ec44dc2058e90",
2372 | "42728bc9e2a74b63ba34a2c528aa7eba",
2373 | "6a7f7283d81843c9a89cae818b10de2f",
2374 | "73ae19c1364c4c1f90f07cd9acff7420",
2375 | "4f2d9665c52e472fa121c0e82a683d1f",
2376 | "be036286276044d8b6648054e75ed79d",
2377 | "01a51067061d423693b8a07e6ab458db",
2378 | "17ab1c783afb4e1eaf283a3a49247399",
2379 | "6eaade12516048b1a3cbaa306665587f",
2380 | "eab55e77c16245659b26032ec1dcacc7",
2381 | "01e6a5dfeb694c4c8e040e8f7218bf53",
2382 | "8f077d8f3ff341d4925e4ee960459471",
2383 | "9c3b34b27d654f419741e58ddebd14f3",
2384 | "cf460dc6602e4a48ba8c7992987cfcd9",
2385 | "9a5f4ebd8a0c429192b5a25705571c57",
2386 | "e082d9d9ca2942799661fd56945e19ea",
2387 | "1b49abcdc609482a8714da87be3a3269",
2388 | "be779890dfa5439f9f9e4d910d85e696",
2389 | "dafd8d98a2064d9a98e23381edbe662b"
2390 | ]
2391 | },
2392 | "id": "sQSs6ai8ahHD",
2393 | "outputId": "bf42e53a-e227-40f8-caae-c76bcd91fb57"
2394 | },
2395 | "execution_count": null,
2396 | "outputs": [
2397 | {
2398 | "output_type": "display_data",
2399 | "data": {
2400 | "text/plain": [
2401 | "Downloading (…)solve/main/vocab.txt: 0%| | 0.00/213k [00:00, ?B/s]"
2402 | ],
2403 | "application/vnd.jupyter.widget-view+json": {
2404 | "version_major": 2,
2405 | "version_minor": 0,
2406 | "model_id": "4e181378f6704b2793283d2e29b61703"
2407 | }
2408 | },
2409 | "metadata": {}
2410 | },
2411 | {
2412 | "output_type": "display_data",
2413 | "data": {
2414 | "text/plain": [
2415 | "Downloading (…)okenizer_config.json: 0%| | 0.00/29.0 [00:00, ?B/s]"
2416 | ],
2417 | "application/vnd.jupyter.widget-view+json": {
2418 | "version_major": 2,
2419 | "version_minor": 0,
2420 | "model_id": "e2667431e6024893b99fee705a01e418"
2421 | }
2422 | },
2423 | "metadata": {}
2424 | },
2425 | {
2426 | "output_type": "display_data",
2427 | "data": {
2428 | "text/plain": [
2429 | "Downloading (…)lve/main/config.json: 0%| | 0.00/570 [00:00, ?B/s]"
2430 | ],
2431 | "application/vnd.jupyter.widget-view+json": {
2432 | "version_major": 2,
2433 | "version_minor": 0,
2434 | "model_id": "6eaade12516048b1a3cbaa306665587f"
2435 | }
2436 | },
2437 | "metadata": {}
2438 | }
2439 | ]
2440 | },
2441 | {
2442 | "cell_type": "code",
2443 | "source": [
2444 | "for i, phrase in enumerate(df['Phrase']):\n",
2445 | " tokens = tokenizer.encode_plus(phrase, max_length=seq_len, truncation=True,\n",
2446 | " padding='max_length', add_special_tokens=True,\n",
2447 | " return_tensors='tf')\n",
2448 | " # assign tokenized outputs to respective rows in numpy arrays\n",
2449 | " Xids[i, :] = tokens['input_ids']\n",
2450 | " Xmask[i, :] = tokens['attention_mask']"
2451 | ],
2452 | "metadata": {
2453 | "id": "AR-0gx-4dRh_"
2454 | },
2455 | "execution_count": null,
2456 | "outputs": []
2457 | },
2458 | {
2459 | "cell_type": "code",
2460 | "source": [
2461 | "# Xids\n",
2462 | "Xmask"
2463 | ],
2464 | "metadata": {
2465 | "colab": {
2466 | "base_uri": "https://localhost:8080/"
2467 | },
2468 | "id": "lpZ3XbC3eIn4",
2469 | "outputId": "a3c40806-dae1-45b3-f355-066ee7f86f6c"
2470 | },
2471 | "execution_count": null,
2472 | "outputs": [
2473 | {
2474 | "output_type": "execute_result",
2475 | "data": {
2476 | "text/plain": [
2477 | "array([[1., 1., 1., ..., 0., 0., 0.],\n",
2478 | " [1., 1., 1., ..., 0., 0., 0.],\n",
2479 | " [1., 1., 1., ..., 0., 0., 0.],\n",
2480 | " ...,\n",
2481 | " [1., 1., 1., ..., 0., 0., 0.],\n",
2482 | " [1., 1., 1., ..., 0., 0., 0.],\n",
2483 | " [1., 1., 1., ..., 0., 0., 0.]])"
2484 | ]
2485 | },
2486 | "metadata": {},
2487 | "execution_count": 11
2488 | }
2489 | ]
2490 | },
2491 | {
2492 | "cell_type": "code",
2493 | "source": [
2494 | "# first extract sentiment column\n",
2495 | "arr = df['Sentiment'].values\n",
2496 | "\n",
2497 | "# we then initialize the zero array\n",
2498 | "labels = np.zeros((num_samples, arr.max()+1))\n",
2499 | "\n",
2500 | "# set relevant index for each row to 1 (one-hot encode)\n",
2501 | "labels[np.arange(num_samples), arr] = 1"
2502 | ],
2503 | "metadata": {
2504 | "id": "GU2mthnefChX"
2505 | },
2506 | "execution_count": null,
2507 | "outputs": []
2508 | },
2509 | {
2510 | "cell_type": "code",
2511 | "source": [
2512 | "import tensorflow as tf"
2513 | ],
2514 | "metadata": {
2515 | "id": "MhduPsLrgl8m"
2516 | },
2517 | "execution_count": null,
2518 | "outputs": []
2519 | },
2520 | {
2521 | "cell_type": "code",
2522 | "source": [
2523 | "# create the dataset object\n",
2524 | "dataset = tf.data.Dataset.from_tensor_slices((Xids, Xmask, labels))\n",
2525 | "\n",
2526 | "def map_func(input_ids, masks, labels):\n",
2527 | " # we convert our three-item tuple into a two-item tuple where the input item is a dictionary\n",
2528 | " return {'input_ids': input_ids, 'attention_mask': masks}, labels\n",
2529 | "\n",
2530 | "# then we use the dataset map method to apply this transformation\n",
2531 | "dataset = dataset.map(map_func)"
2532 | ],
2533 | "metadata": {
2534 | "id": "BtsR8p_Igi7E"
2535 | },
2536 | "execution_count": null,
2537 | "outputs": []
2538 | },
2539 | {
2540 | "cell_type": "code",
2541 | "source": [
2542 | "dataset.take(1)"
2543 | ],
2544 | "metadata": {
2545 | "colab": {
2546 | "base_uri": "https://localhost:8080/"
2547 | },
2548 | "id": "JTvkNkkRhJf_",
2549 | "outputId": "7d446da7-ea08-44b8-a1fa-8a590e85fb05"
2550 | },
2551 | "execution_count": null,
2552 | "outputs": [
2553 | {
2554 | "output_type": "execute_result",
2555 | "data": {
2556 | "text/plain": [
2557 | "<_TakeDataset element_spec=({'input_ids': TensorSpec(shape=(512,), dtype=tf.float64, name=None), 'attention_mask': TensorSpec(shape=(512,), dtype=tf.float64, name=None)}, TensorSpec(shape=(2,), dtype=tf.float64, name=None))>"
2558 | ]
2559 | },
2560 | "metadata": {},
2561 | "execution_count": 15
2562 | }
2563 | ]
2564 | },
2565 | {
2566 | "cell_type": "code",
2567 | "source": [
2568 | "# we will split into batches of 16\n",
2569 | "batch_size = 6\n",
2570 | "\n",
2571 | "# shuffle and batch - dropping any remaining samples that don't cleanly\n",
2572 | "# fit into a batch of 16\n",
2573 | "dataset = dataset.shuffle(10000).batch(batch_size, drop_remainder=True)"
2574 | ],
2575 | "metadata": {
2576 | "id": "0aIFGcZ2hShP"
2577 | },
2578 | "execution_count": null,
2579 | "outputs": []
2580 | },
2581 | {
2582 | "cell_type": "code",
2583 | "source": [
2584 | "# set split size (90% training data) and calculate training set size\n",
2585 | "split = 0.9\n",
2586 | "size = int((Xids.shape[0]/batch_size)*split)\n",
2587 | "\n",
2588 | "# get training and validation sets\n",
2589 | "train_ds = dataset.take(size)\n",
2590 | "val_ds = dataset.skip(size)"
2591 | ],
2592 | "metadata": {
2593 | "id": "6E8FjN1EiTZy"
2594 | },
2595 | "execution_count": null,
2596 | "outputs": []
2597 | },
2598 | {
2599 | "cell_type": "code",
2600 | "source": [
2601 | "del dataset"
2602 | ],
2603 | "metadata": {
2604 | "id": "kZnh58MaiZch"
2605 | },
2606 | "execution_count": null,
2607 | "outputs": []
2608 | },
2609 | {
2610 | "cell_type": "code",
2611 | "source": [
2612 | "# AutoModel for PyTorch, TFAutoModel for TensorFlow\n",
2613 | "from transformers import TFAutoModel\n",
2614 | "\n",
2615 | "bert = TFAutoModel.from_pretrained('bert-base-cased')"
2616 | ],
2617 | "metadata": {
2618 | "colab": {
2619 | "base_uri": "https://localhost:8080/",
2620 | "height": 156,
2621 | "referenced_widgets": [
2622 | "26a184303e4744b3be5a518ee8bf318d",
2623 | "e18f30f7ef6e4bf0932292b79b014908",
2624 | "6d2bbdaf8e014b29a2b5c9029a276ce8",
2625 | "4acf12d91e384fa391b5ddd0fda20f9f",
2626 | "3b7d63b6088f461582138ef23174441e",
2627 | "10aa0f19f5e64effbe37ca9e9ee1bcc1",
2628 | "76e54c6cac654c0abcb741cd0a7f29f5",
2629 | "632aef428e8845fa8fb68b31f7c28c2f",
2630 | "767138cce21941d383e730ab9c36a194",
2631 | "fefb6725130f44799a9c80c0274409b0",
2632 | "6487543dc0d647808a42a57474c52408"
2633 | ]
2634 | },
2635 | "id": "pz03ZCtsp_5p",
2636 | "outputId": "cd112ec8-1370-487b-f6e3-d34ceafa2861"
2637 | },
2638 | "execution_count": null,
2639 | "outputs": [
2640 | {
2641 | "output_type": "display_data",
2642 | "data": {
2643 | "text/plain": [
2644 | "Downloading model.safetensors: 0%| | 0.00/436M [00:00, ?B/s]"
2645 | ],
2646 | "application/vnd.jupyter.widget-view+json": {
2647 | "version_major": 2,
2648 | "version_minor": 0,
2649 | "model_id": "26a184303e4744b3be5a518ee8bf318d"
2650 | }
2651 | },
2652 | "metadata": {}
2653 | },
2654 | {
2655 | "output_type": "stream",
2656 | "name": "stderr",
2657 | "text": [
2658 | "Some weights of the PyTorch model were not used when initializing the TF 2.0 model TFBertModel: ['cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.bias', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias']\n",
2659 | "- This IS expected if you are initializing TFBertModel from a PyTorch model trained on another task or with another architecture (e.g. initializing a TFBertForSequenceClassification model from a BertForPreTraining model).\n",
2660 | "- This IS NOT expected if you are initializing TFBertModel from a PyTorch model that you expect to be exactly identical (e.g. initializing a TFBertForSequenceClassification model from a BertForSequenceClassification model).\n",
2661 | "All the weights of TFBertModel were initialized from the PyTorch model.\n",
2662 | "If your task is similar to the task the model of the checkpoint was trained on, you can already use TFBertModel for predictions without further training.\n"
2663 | ]
2664 | }
2665 | ]
2666 | },
2667 | {
2668 | "cell_type": "code",
2669 | "source": [
2670 | "bert.summary()"
2671 | ],
2672 | "metadata": {
2673 | "colab": {
2674 | "base_uri": "https://localhost:8080/"
2675 | },
2676 | "id": "m-OrcL6OqfbH",
2677 | "outputId": "58fb735a-aac9-481b-ac85-1ac1cb3db80e"
2678 | },
2679 | "execution_count": null,
2680 | "outputs": [
2681 | {
2682 | "output_type": "stream",
2683 | "name": "stdout",
2684 | "text": [
2685 | "Model: \"tf_bert_model\"\n",
2686 | "_________________________________________________________________\n",
2687 | " Layer (type) Output Shape Param # \n",
2688 | "=================================================================\n",
2689 | " bert (TFBertMainLayer) multiple 108310272 \n",
2690 | " \n",
2691 | "=================================================================\n",
2692 | "Total params: 108,310,272\n",
2693 | "Trainable params: 108,310,272\n",
2694 | "Non-trainable params: 0\n",
2695 | "_________________________________________________________________\n"
2696 | ]
2697 | }
2698 | ]
2699 | },
2700 | {
2701 | "cell_type": "code",
2702 | "source": [
2703 | "# two input layers, we ensure layer name variables match to dictionary keys in TF dataset\n",
2704 | "input_ids = tf.keras.layers.Input(shape=(512,), name='input_ids', dtype='int32')\n",
2705 | "mask = tf.keras.layers.Input(shape=(512,), name='attention_mask', dtype='int32')\n",
2706 | "\n",
2707 | "# we access the transformer model within our bert object using the bert attribute (eg bert.bert instead of bert)\n",
2708 | "embeddings = bert.bert(input_ids, attention_mask=mask)[1] # access pooled activations with [1]\n",
2709 | "\n",
2710 | "# convert bert embeddings into 5 output classes\n",
2711 | "x = tf.keras.layers.Dense(1024, activation='relu')(embeddings)\n",
2712 | "y = tf.keras.layers.Dense(arr.max()+1, activation='softmax', name='outputs')(x)"
2713 | ],
2714 | "metadata": {
2715 | "id": "z3akHzBnqhW3"
2716 | },
2717 | "execution_count": null,
2718 | "outputs": []
2719 | },
2720 | {
2721 | "cell_type": "code",
2722 | "source": [
2723 | "# initialize model\n",
2724 | "model = tf.keras.Model(inputs=[input_ids, mask], outputs=y)\n",
2725 | "\n",
2726 | "# (optional) freeze bert layer\n",
2727 | "#model.layers[2].trainable = False\n",
2728 | "model.summary()"
2729 | ],
2730 | "metadata": {
2731 | "colab": {
2732 | "base_uri": "https://localhost:8080/"
2733 | },
2734 | "id": "zXn-HYmJr4AK",
2735 | "outputId": "a2b54f2a-2d72-4299-ec5c-70a1bea38848"
2736 | },
2737 | "execution_count": null,
2738 | "outputs": [
2739 | {
2740 | "output_type": "stream",
2741 | "name": "stdout",
2742 | "text": [
2743 | "Model: \"model\"\n",
2744 | "__________________________________________________________________________________________________\n",
2745 | " Layer (type) Output Shape Param # Connected to \n",
2746 | "==================================================================================================\n",
2747 | " input_ids (InputLayer) [(None, 512)] 0 [] \n",
2748 | " \n",
2749 | " attention_mask (InputLayer) [(None, 512)] 0 [] \n",
2750 | " \n",
2751 | " bert (TFBertMainLayer) TFBaseModelOutputWi 108310272 ['input_ids[0][0]', \n",
2752 | " thPoolingAndCrossAt 'attention_mask[0][0]'] \n",
2753 | " tentions(last_hidde \n",
2754 | " n_state=(None, 512, \n",
2755 | " 768), \n",
2756 | " pooler_output=(Non \n",
2757 | " e, 768), \n",
2758 | " past_key_values=No \n",
2759 | " ne, hidden_states=N \n",
2760 | " one, attentions=Non \n",
2761 | " e, cross_attentions \n",
2762 | " =None) \n",
2763 | " \n",
2764 | " dense (Dense) (None, 1024) 787456 ['bert[0][1]'] \n",
2765 | " \n",
2766 | " outputs (Dense) (None, 2) 2050 ['dense[0][0]'] \n",
2767 | " \n",
2768 | "==================================================================================================\n",
2769 | "Total params: 109,099,778\n",
2770 | "Trainable params: 109,099,778\n",
2771 | "Non-trainable params: 0\n",
2772 | "__________________________________________________________________________________________________\n"
2773 | ]
2774 | }
2775 | ]
2776 | },
2777 | {
2778 | "cell_type": "code",
2779 | "source": [
2780 | "optimizer = tf.keras.optimizers.legacy.Adam(lr=1e-5, decay=1e-6)\n",
2781 | "loss = tf.keras.losses.CategoricalCrossentropy()\n",
2782 | "acc = tf.keras.metrics.CategoricalAccuracy('accuracy')\n",
2783 | "\n",
2784 | "model.compile(optimizer=optimizer, loss=loss, metrics=[acc])"
2785 | ],
2786 | "metadata": {
2787 | "colab": {
2788 | "base_uri": "https://localhost:8080/"
2789 | },
2790 | "id": "fpXqHghKsCYT",
2791 | "outputId": "dcf1a047-01c2-4448-e5e2-db6d21f0d9da"
2792 | },
2793 | "execution_count": null,
2794 | "outputs": [
2795 | {
2796 | "output_type": "stream",
2797 | "name": "stderr",
2798 | "text": [
2799 | "/usr/local/lib/python3.10/dist-packages/keras/optimizers/legacy/adam.py:117: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.\n",
2800 | " super().__init__(name, **kwargs)\n"
2801 | ]
2802 | }
2803 | ]
2804 | },
2805 | {
2806 | "cell_type": "code",
2807 | "source": [
2808 | "history = model.fit(\n",
2809 | " train_ds,\n",
2810 | " validation_data=val_ds,\n",
2811 | " epochs=3\n",
2812 | ")"
2813 | ],
2814 | "metadata": {
2815 | "colab": {
2816 | "base_uri": "https://localhost:8080/"
2817 | },
2818 | "id": "vVUQArv1tkT2",
2819 | "outputId": "0dae860f-de82-45a8-f1a3-944fe51965ea"
2820 | },
2821 | "execution_count": null,
2822 | "outputs": [
2823 | {
2824 | "output_type": "stream",
2825 | "name": "stdout",
2826 | "text": [
2827 | "Epoch 1/3\n",
2828 | "17/17 [==============================] - 27s 862ms/step - loss: 0.5844 - accuracy: 0.6961 - val_loss: 0.3777 - val_accuracy: 0.9167\n",
2829 | "Epoch 2/3\n",
2830 | "17/17 [==============================] - 12s 700ms/step - loss: 0.2246 - accuracy: 0.9510 - val_loss: 0.0622 - val_accuracy: 1.0000\n",
2831 | "Epoch 3/3\n",
2832 | "17/17 [==============================] - 12s 710ms/step - loss: 0.0470 - accuracy: 1.0000 - val_loss: 0.0113 - val_accuracy: 1.0000\n"
2833 | ]
2834 | }
2835 | ]
2836 | },
2837 | {
2838 | "cell_type": "code",
2839 | "source": [
2840 | "model.save('sentiment_model')"
2841 | ],
2842 | "metadata": {
2843 | "colab": {
2844 | "base_uri": "https://localhost:8080/"
2845 | },
2846 | "id": "hyV3W7SIt9-E",
2847 | "outputId": "8e22d776-bff8-4746-e181-eb2f0754ad71"
2848 | },
2849 | "execution_count": null,
2850 | "outputs": [
2851 | {
2852 | "output_type": "stream",
2853 | "name": "stderr",
2854 | "text": [
2855 | "WARNING:absl:Found untraced functions such as embeddings_layer_call_fn, embeddings_layer_call_and_return_conditional_losses, encoder_layer_call_fn, encoder_layer_call_and_return_conditional_losses, pooler_layer_call_fn while saving (showing 5 of 420). These functions will not be directly callable after loading.\n"
2856 | ]
2857 | }
2858 | ]
2859 | },
2860 | {
2861 | "cell_type": "code",
2862 | "source": [
2863 | "# we just load the model from which directory it was saved to (eg '/sentiment_model')\n",
2864 | "model = tf.keras.models.load_model('sentiment_model')"
2865 | ],
2866 | "metadata": {
2867 | "id": "AtTnRwzqvBbw"
2868 | },
2869 | "execution_count": null,
2870 | "outputs": []
2871 | },
2872 | {
2873 | "cell_type": "code",
2874 | "source": [
2875 | "model.summary()"
2876 | ],
2877 | "metadata": {
2878 | "colab": {
2879 | "base_uri": "https://localhost:8080/"
2880 | },
2881 | "id": "C1n2kaAzYG-G",
2882 | "outputId": "d085d7a6-77ef-4aca-e446-843fbdd5de52"
2883 | },
2884 | "execution_count": null,
2885 | "outputs": [
2886 | {
2887 | "output_type": "stream",
2888 | "name": "stdout",
2889 | "text": [
2890 | "Model: \"model\"\n",
2891 | "__________________________________________________________________________________________________\n",
2892 | " Layer (type) Output Shape Param # Connected to \n",
2893 | "==================================================================================================\n",
2894 | " input_ids (InputLayer) [(None, 512)] 0 [] \n",
2895 | " \n",
2896 | " attention_mask (InputLayer) [(None, 512)] 0 [] \n",
2897 | " \n",
2898 | " bert (TFBertMainLayer) TFBaseModelOutputWi 108310272 ['input_ids[0][0]', \n",
2899 | " thPoolingAndCrossAt 'attention_mask[0][0]'] \n",
2900 | " tentions(last_hidde \n",
2901 | " n_state=(None, 512, \n",
2902 | " 768), \n",
2903 | " pooler_output=(Non \n",
2904 | " e, 768), \n",
2905 | " past_key_values=No \n",
2906 | " ne, hidden_states=N \n",
2907 | " one, attentions=Non \n",
2908 | " e, cross_attentions \n",
2909 | " =None) \n",
2910 | " \n",
2911 | " dense (Dense) (None, 1024) 787456 ['bert[0][1]'] \n",
2912 | " \n",
2913 | " outputs (Dense) (None, 2) 2050 ['dense[0][0]'] \n",
2914 | " \n",
2915 | "==================================================================================================\n",
2916 | "Total params: 109,099,778\n",
2917 | "Trainable params: 109,099,778\n",
2918 | "Non-trainable params: 0\n",
2919 | "__________________________________________________________________________________________________\n"
2920 | ]
2921 | }
2922 | ]
2923 | },
2924 | {
2925 | "cell_type": "markdown",
2926 | "source": [
2927 | "Now, we're creating a function to tokenize input texts for prediction"
2928 | ],
2929 | "metadata": {
2930 | "id": "w8oSMdFNYTCI"
2931 | }
2932 | },
2933 | {
2934 | "cell_type": "code",
2935 | "source": [
2936 | "# initialize tokenizer from transformers\n",
2937 | "tokenizer = BertTokenizer.from_pretrained('bert-base-cased')\n",
2938 | "\n",
2939 | "def prep_data(text):\n",
2940 | " # tokenize to get input IDs and attention mask tensors\n",
2941 | " tokens = tokenizer.encode_plus(text, max_length=512,\n",
2942 | " truncation=True, padding='max_length',\n",
2943 | " add_special_tokens=True, return_token_type_ids=False,\n",
2944 | " return_tensors='tf')\n",
2945 | " # tokenizer returns int32 tensors, we need to return float64, so we use tf.cast\n",
2946 | " return {'input_ids': tf.cast(tokens['input_ids'], tf.float64),\n",
2947 | " 'attention_mask': tf.cast(tokens['attention_mask'], tf.float64)}"
2948 | ],
2949 | "metadata": {
2950 | "id": "-HkZPJu7vbB4"
2951 | },
2952 | "execution_count": null,
2953 | "outputs": []
2954 | },
2955 | {
2956 | "cell_type": "code",
2957 | "source": [
2958 | "test = prep_data('Who is the most richest person in the world?')"
2959 | ],
2960 | "metadata": {
2961 | "id": "70YRtd-WY20w"
2962 | },
2963 | "execution_count": null,
2964 | "outputs": []
2965 | },
2966 | {
2967 | "cell_type": "code",
2968 | "source": [
2969 | "probs = model.predict(test)\n",
2970 | "probs[0] #We find probabilities but they are unreadable"
2971 | ],
2972 | "metadata": {
2973 | "colab": {
2974 | "base_uri": "https://localhost:8080/"
2975 | },
2976 | "id": "b0SvnzhfY8bR",
2977 | "outputId": "d5186bbd-f395-4fee-c0cc-35f465c04684"
2978 | },
2979 | "execution_count": null,
2980 | "outputs": [
2981 | {
2982 | "output_type": "stream",
2983 | "name": "stdout",
2984 | "text": [
2985 | "1/1 [==============================] - 0s 131ms/step\n"
2986 | ]
2987 | },
2988 | {
2989 | "output_type": "execute_result",
2990 | "data": {
2991 | "text/plain": [
2992 | "array([0.0085841, 0.9914159], dtype=float32)"
2993 | ]
2994 | },
2995 | "metadata": {},
2996 | "execution_count": 44
2997 | }
2998 | ]
2999 | },
3000 | {
3001 | "cell_type": "code",
3002 | "source": [
3003 | "import numpy as np"
3004 | ],
3005 | "metadata": {
3006 | "id": "k-9eKZg5ZDYH"
3007 | },
3008 | "execution_count": null,
3009 | "outputs": []
3010 | },
3011 | {
3012 | "cell_type": "code",
3013 | "source": [
3014 | "import time\n",
3015 | "\n",
3016 | "def output_to_intent(softmax_output):\n",
3017 | " switcher = {\n",
3018 | " 0: \"NormalChat\",\n",
3019 | " 1: \"SearchDynamicNews\",\n",
3020 | " }\n",
3021 | " return switcher.get(softmax_output, \"nothing\")\n",
3022 | "\n",
3023 | "def main():\n",
3024 | " for i in range(10):\n",
3025 | " user_input = \"Did julie make a cameo in that marvel movie?\"\n",
3026 | " test = prep_data(user_input)\n",
3027 | " probs = model.predict(test)\n",
3028 | " softmax_output = np.argmax(probs)\n",
3029 | " if i == 1:\n",
3030 | " print(\"Hello, I'm a chatbot\")\n",
3031 | " print(user_input)\n",
3032 | " print(output_to_intent(softmax_output))\n",
3033 | "\n",
3034 | "start_time = time.time()\n",
3035 | "main()\n",
3036 | "end_time = time.time()\n",
3037 | "elapsed_time = end_time - start_time\n",
3038 | "\n",
3039 | "print(\"Elapsed time:\", elapsed_time, \"seconds\")"
3040 | ],
3041 | "metadata": {
3042 | "colab": {
3043 | "base_uri": "https://localhost:8080/"
3044 | },
3045 | "id": "ysp2EOvadHF-",
3046 | "outputId": "b35312f9-48e3-48ec-9d87-9cbea7e0506d"
3047 | },
3048 | "execution_count": null,
3049 | "outputs": [
3050 | {
3051 | "output_type": "stream",
3052 | "name": "stdout",
3053 | "text": [
3054 | "1/1 [==============================] - 0s 98ms/step\n",
3055 | "1/1 [==============================] - 0s 105ms/step\n",
3056 | "Hello, I'm a chatbot\n",
3057 | "Did julie make a cameo in that marvel movie?\n",
3058 | "SearchDynamicNews\n",
3059 | "1/1 [==============================] - 0s 101ms/step\n",
3060 | "1/1 [==============================] - 0s 101ms/step\n",
3061 | "1/1 [==============================] - 0s 106ms/step\n",
3062 | "1/1 [==============================] - 0s 103ms/step\n",
3063 | "1/1 [==============================] - 0s 103ms/step\n",
3064 | "1/1 [==============================] - 0s 112ms/step\n",
3065 | "1/1 [==============================] - 0s 104ms/step\n",
3066 | "1/1 [==============================] - 0s 108ms/step\n",
3067 | "Elapsed time: 1.8725767135620117 seconds\n"
3068 | ]
3069 | }
3070 | ]
3071 | }
3072 | ]
3073 | }
--------------------------------------------------------------------------------