diff --git "a/3-5/SPA_INFERENCE_5.ipynb" "b/3-5/SPA_INFERENCE_5.ipynb"
new file mode 100644--- /dev/null
+++ "b/3-5/SPA_INFERENCE_5.ipynb"
@@ -0,0 +1,5911 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "machine_shape": "hm",
+ "gpuType": "A100"
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ },
+ "accelerator": "GPU",
+ "widgets": {
+ "application/vnd.jupyter.widget-state+json": {
+ "fedaa2e96e6c4f6e8f44f587c229311e": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "VBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "VBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "VBoxView",
+ "box_style": "",
+ "children": [],
+ "layout": "IPY_MODEL_3c6db3fa010c4caa8558a0630e2e7d25"
+ }
+ },
+ "b3cf0c9c7f544fec9789931a208ee08a": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_c08999bdfc3c430591f0fb26413a458c",
+ "placeholder": "",
+ "style": "IPY_MODEL_8a3729ff65294c7ba4ffa456cbad3688",
+ "value": "
Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file. "
+ }
+ },
+ "6eacb525b9b7441580edfca0fec99015": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "PasswordModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "PasswordModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "PasswordView",
+ "continuous_update": true,
+ "description": "Token:",
+ "description_tooltip": null,
+ "disabled": false,
+ "layout": "IPY_MODEL_1cb7c6d8456b4619974ab6e2dd8e8e4c",
+ "placeholder": "",
+ "style": "IPY_MODEL_f31e7b4354fc4924a0de1123ee89c4c8",
+ "value": ""
+ }
+ },
+ "55bc85db48484fa7ba6e14bd4cb6a5ed": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "CheckboxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "CheckboxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "CheckboxView",
+ "description": "Add token as git credential?",
+ "description_tooltip": null,
+ "disabled": false,
+ "indent": true,
+ "layout": "IPY_MODEL_033e73c5a22f46498b7f79b4e26132aa",
+ "style": "IPY_MODEL_db3c4ec20408417e85d8e41299d89036",
+ "value": true
+ }
+ },
+ "70a23afc28f84de4a2748d70f08b6b87": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ButtonModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ButtonModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ButtonView",
+ "button_style": "",
+ "description": "Login",
+ "disabled": false,
+ "icon": "",
+ "layout": "IPY_MODEL_ec2ee07e07b84583bb4d1d542319f731",
+ "style": "IPY_MODEL_f0d2bee4ca1e4f19801525dfec5ace13",
+ "tooltip": ""
+ }
+ },
+ "a488d905db1d402eb69ed9ce1c74086c": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_27e8c88baa33464b96e44d277105aa39",
+ "placeholder": "",
+ "style": "IPY_MODEL_12d8c51a1fcf47699cd62a0191461281",
+ "value": "\nPro Tip: 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. "
+ }
+ },
+ "3c6db3fa010c4caa8558a0630e2e7d25": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": "center",
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": "flex",
+ "flex": null,
+ "flex_flow": "column",
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": "50%"
+ }
+ },
+ "c08999bdfc3c430591f0fb26413a458c": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "8a3729ff65294c7ba4ffa456cbad3688": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "1cb7c6d8456b4619974ab6e2dd8e8e4c": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "f31e7b4354fc4924a0de1123ee89c4c8": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "033e73c5a22f46498b7f79b4e26132aa": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "db3c4ec20408417e85d8e41299d89036": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "ec2ee07e07b84583bb4d1d542319f731": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "f0d2bee4ca1e4f19801525dfec5ace13": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ButtonStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ButtonStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "button_color": null,
+ "font_weight": ""
+ }
+ },
+ "27e8c88baa33464b96e44d277105aa39": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "12d8c51a1fcf47699cd62a0191461281": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "837787de17b34d8ca7a48e516f7908e9": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "LabelModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "LabelModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "LabelView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_3badef1b95e945c087cffbbb58f01bcf",
+ "placeholder": "",
+ "style": "IPY_MODEL_06b18115a5e842f1b673fdf280cf5240",
+ "value": "Connecting..."
+ }
+ },
+ "3badef1b95e945c087cffbbb58f01bcf": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "06b18115a5e842f1b673fdf280cf5240": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "994ab606af24474a8c1a1bb2b552e3a7": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HBoxView",
+ "box_style": "",
+ "children": [
+ "IPY_MODEL_b5d7e3d762974277888ba30da30696b2",
+ "IPY_MODEL_e5558ac25e1f47faa7ff3d20e3af81d8",
+ "IPY_MODEL_2c43b2a7f2884ab2a5469b48b46a7894"
+ ],
+ "layout": "IPY_MODEL_8dbd64092a53457cbb9c7d66674918b7"
+ }
+ },
+ "b5d7e3d762974277888ba30da30696b2": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_69d340da9b43489aaecd29f0279ed4f2",
+ "placeholder": "",
+ "style": "IPY_MODEL_a66bc45f53514e30bcb5a29dd9a41d2e",
+ "value": "config.json: 100%"
+ }
+ },
+ "e5558ac25e1f47faa7ff3d20e3af81d8": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "FloatProgressModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "FloatProgressModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ProgressView",
+ "bar_style": "success",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_406e8fe2f45b4c2e9cd6e04c2792b497",
+ "max": 772,
+ "min": 0,
+ "orientation": "horizontal",
+ "style": "IPY_MODEL_b11641bd010f4ac99a242b6e234bb622",
+ "value": 772
+ }
+ },
+ "2c43b2a7f2884ab2a5469b48b46a7894": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_49efe56091054a65badfb33a3becfda7",
+ "placeholder": "",
+ "style": "IPY_MODEL_e1bc90b628454d24a6d8921d041b60d9",
+ "value": " 772/772 [00:00<00:00, 67.6kB/s]"
+ }
+ },
+ "8dbd64092a53457cbb9c7d66674918b7": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "69d340da9b43489aaecd29f0279ed4f2": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "a66bc45f53514e30bcb5a29dd9a41d2e": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "406e8fe2f45b4c2e9cd6e04c2792b497": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "b11641bd010f4ac99a242b6e234bb622": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ProgressStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ProgressStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "bar_color": null,
+ "description_width": ""
+ }
+ },
+ "49efe56091054a65badfb33a3becfda7": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "e1bc90b628454d24a6d8921d041b60d9": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "16e8e25011c44df0a91ac28ac88a35d5": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HBoxView",
+ "box_style": "",
+ "children": [
+ "IPY_MODEL_0cb0aec0f8cf431dae59f98c31d392a5",
+ "IPY_MODEL_2165093635724c4ea93988468e2ee4ec",
+ "IPY_MODEL_d61b5f53d270429290271394240f21a1"
+ ],
+ "layout": "IPY_MODEL_7345c152f1124cc487b584baaaa20108"
+ }
+ },
+ "0cb0aec0f8cf431dae59f98c31d392a5": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_8262102752314a3ea88dce66de4787eb",
+ "placeholder": "",
+ "style": "IPY_MODEL_d39400631ef64cb7a70a5e031c571007",
+ "value": "tf_model.h5: 100%"
+ }
+ },
+ "2165093635724c4ea93988468e2ee4ec": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "FloatProgressModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "FloatProgressModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ProgressView",
+ "bar_style": "success",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_8badb95ac58e482ca3dc6b07c51e740e",
+ "max": 1246320936,
+ "min": 0,
+ "orientation": "horizontal",
+ "style": "IPY_MODEL_954fedc807994f95973e3b2f5c9e2fef",
+ "value": 1246320936
+ }
+ },
+ "d61b5f53d270429290271394240f21a1": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_8bcb7ac3ad4b47359ee279de8f9604eb",
+ "placeholder": "",
+ "style": "IPY_MODEL_bf2213ffcb8e4e6b8e0342ea52bec417",
+ "value": " 1.25G/1.25G [00:05<00:00, 236MB/s]"
+ }
+ },
+ "7345c152f1124cc487b584baaaa20108": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "8262102752314a3ea88dce66de4787eb": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "d39400631ef64cb7a70a5e031c571007": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "8badb95ac58e482ca3dc6b07c51e740e": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "954fedc807994f95973e3b2f5c9e2fef": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ProgressStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ProgressStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "bar_color": null,
+ "description_width": ""
+ }
+ },
+ "8bcb7ac3ad4b47359ee279de8f9604eb": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "bf2213ffcb8e4e6b8e0342ea52bec417": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "5e3719138b294d1fbdd8dd25f481d0cb": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HBoxView",
+ "box_style": "",
+ "children": [
+ "IPY_MODEL_abd8c2e7b77f43bdb8894f4c96cb37b4",
+ "IPY_MODEL_9b1e596585ac4c1bbe3287be1a57d8f3",
+ "IPY_MODEL_f68fa48477ee4cefa168505c6c4b841a"
+ ],
+ "layout": "IPY_MODEL_01065fe2096e484db23ceb73de1922b7"
+ }
+ },
+ "abd8c2e7b77f43bdb8894f4c96cb37b4": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_c5734191284c4fe6bc1a384492b8e642",
+ "placeholder": "",
+ "style": "IPY_MODEL_1391e6eb7b954704ad3fdccdde5f674c",
+ "value": "tokenizer_config.json: 100%"
+ }
+ },
+ "9b1e596585ac4c1bbe3287be1a57d8f3": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "FloatProgressModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "FloatProgressModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ProgressView",
+ "bar_style": "success",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_7efce577348c4043bb6f3ab0513fb86f",
+ "max": 453,
+ "min": 0,
+ "orientation": "horizontal",
+ "style": "IPY_MODEL_e0445165df8a468fbb81d8410c924940",
+ "value": 453
+ }
+ },
+ "f68fa48477ee4cefa168505c6c4b841a": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_ddb640ddf5044f4982e1a3af868ed5d0",
+ "placeholder": "",
+ "style": "IPY_MODEL_90868d5f4fe04416ab34226491d77a1d",
+ "value": " 453/453 [00:00<00:00, 46.7kB/s]"
+ }
+ },
+ "01065fe2096e484db23ceb73de1922b7": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "c5734191284c4fe6bc1a384492b8e642": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "1391e6eb7b954704ad3fdccdde5f674c": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "7efce577348c4043bb6f3ab0513fb86f": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "e0445165df8a468fbb81d8410c924940": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ProgressStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ProgressStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "bar_color": null,
+ "description_width": ""
+ }
+ },
+ "ddb640ddf5044f4982e1a3af868ed5d0": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "90868d5f4fe04416ab34226491d77a1d": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "ce468297529e4909b8042a4e919cee6b": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HBoxView",
+ "box_style": "",
+ "children": [
+ "IPY_MODEL_4002d49584744a51b93e3d3c686b5e0c",
+ "IPY_MODEL_5cd8059ea13246e490bc31667c04daea",
+ "IPY_MODEL_5cd7b91316d9493db2fd3142cf0eaa9c"
+ ],
+ "layout": "IPY_MODEL_898df2b813d949a8b67995fe6009dcab"
+ }
+ },
+ "4002d49584744a51b93e3d3c686b5e0c": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_d32bef3a3e5a4a55a5620e95cb4d945c",
+ "placeholder": "",
+ "style": "IPY_MODEL_2822b99069a74551a3582ed1635c9690",
+ "value": "tokenizer.json: 100%"
+ }
+ },
+ "5cd8059ea13246e490bc31667c04daea": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "FloatProgressModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "FloatProgressModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ProgressView",
+ "bar_style": "success",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_3c58b5eefcb2476c945c79cffa548835",
+ "max": 17082660,
+ "min": 0,
+ "orientation": "horizontal",
+ "style": "IPY_MODEL_d3969decfcc5498199fa460be8a67da7",
+ "value": 17082660
+ }
+ },
+ "5cd7b91316d9493db2fd3142cf0eaa9c": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_758f241e682f4a7189f699f8bc4cc327",
+ "placeholder": "",
+ "style": "IPY_MODEL_b28d84fb4ae749d183ad0a5ba631c1c9",
+ "value": " 17.1M/17.1M [00:00<00:00, 175MB/s]"
+ }
+ },
+ "898df2b813d949a8b67995fe6009dcab": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "d32bef3a3e5a4a55a5620e95cb4d945c": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "2822b99069a74551a3582ed1635c9690": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "3c58b5eefcb2476c945c79cffa548835": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "d3969decfcc5498199fa460be8a67da7": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ProgressStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ProgressStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "bar_color": null,
+ "description_width": ""
+ }
+ },
+ "758f241e682f4a7189f699f8bc4cc327": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "b28d84fb4ae749d183ad0a5ba631c1c9": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "13e334bc19244961b0e748b89490e2ed": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HBoxModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HBoxModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HBoxView",
+ "box_style": "",
+ "children": [
+ "IPY_MODEL_7fc67bdabea0409f830c6bc8cd50d094",
+ "IPY_MODEL_f700ce630ffd4ca88e31ab3e92e7655d",
+ "IPY_MODEL_68c5981c26db411d992b358dd53bb6ce"
+ ],
+ "layout": "IPY_MODEL_df5c6ed40d4f4e4890dc2595e22e7bf2"
+ }
+ },
+ "7fc67bdabea0409f830c6bc8cd50d094": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_edb16999c39d40d5ba0a7a23c104d7ca",
+ "placeholder": "",
+ "style": "IPY_MODEL_e117b257301c43d1b85f5a1c95b7dcf3",
+ "value": "special_tokens_map.json: 100%"
+ }
+ },
+ "f700ce630ffd4ca88e31ab3e92e7655d": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "FloatProgressModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "FloatProgressModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "ProgressView",
+ "bar_style": "success",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_82a4edff8a254da4a37bc733bc206ee9",
+ "max": 280,
+ "min": 0,
+ "orientation": "horizontal",
+ "style": "IPY_MODEL_46c670160e454a95a3d32afb354633f1",
+ "value": 280
+ }
+ },
+ "68c5981c26db411d992b358dd53bb6ce": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "HTMLModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_dom_classes": [],
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "HTMLModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/controls",
+ "_view_module_version": "1.5.0",
+ "_view_name": "HTMLView",
+ "description": "",
+ "description_tooltip": null,
+ "layout": "IPY_MODEL_0c21ad59117c4fcf9a1aad6f5ff68b8b",
+ "placeholder": "",
+ "style": "IPY_MODEL_9680ddd062954ef99855818bad479337",
+ "value": " 280/280 [00:00<00:00, 27.5kB/s]"
+ }
+ },
+ "df5c6ed40d4f4e4890dc2595e22e7bf2": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "edb16999c39d40d5ba0a7a23c104d7ca": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "e117b257301c43d1b85f5a1c95b7dcf3": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ },
+ "82a4edff8a254da4a37bc733bc206ee9": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "46c670160e454a95a3d32afb354633f1": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "ProgressStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "ProgressStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "bar_color": null,
+ "description_width": ""
+ }
+ },
+ "0c21ad59117c4fcf9a1aad6f5ff68b8b": {
+ "model_module": "@jupyter-widgets/base",
+ "model_name": "LayoutModel",
+ "model_module_version": "1.2.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/base",
+ "_model_module_version": "1.2.0",
+ "_model_name": "LayoutModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "LayoutView",
+ "align_content": null,
+ "align_items": null,
+ "align_self": null,
+ "border": null,
+ "bottom": null,
+ "display": null,
+ "flex": null,
+ "flex_flow": null,
+ "grid_area": null,
+ "grid_auto_columns": null,
+ "grid_auto_flow": null,
+ "grid_auto_rows": null,
+ "grid_column": null,
+ "grid_gap": null,
+ "grid_row": null,
+ "grid_template_areas": null,
+ "grid_template_columns": null,
+ "grid_template_rows": null,
+ "height": null,
+ "justify_content": null,
+ "justify_items": null,
+ "left": null,
+ "margin": null,
+ "max_height": null,
+ "max_width": null,
+ "min_height": null,
+ "min_width": null,
+ "object_fit": null,
+ "object_position": null,
+ "order": null,
+ "overflow": null,
+ "overflow_x": null,
+ "overflow_y": null,
+ "padding": null,
+ "right": null,
+ "top": null,
+ "visibility": null,
+ "width": null
+ }
+ },
+ "9680ddd062954ef99855818bad479337": {
+ "model_module": "@jupyter-widgets/controls",
+ "model_name": "DescriptionStyleModel",
+ "model_module_version": "1.5.0",
+ "state": {
+ "_model_module": "@jupyter-widgets/controls",
+ "_model_module_version": "1.5.0",
+ "_model_name": "DescriptionStyleModel",
+ "_view_count": null,
+ "_view_module": "@jupyter-widgets/base",
+ "_view_module_version": "1.2.0",
+ "_view_name": "StyleView",
+ "description_width": ""
+ }
+ }
+ }
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "code",
+ "source": [
+ "from huggingface_hub import notebook_login\n",
+ "notebook_login()"
+ ],
+ "metadata": {
+ "id": "yrM6ZzXldMLo",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 17,
+ "referenced_widgets": [
+ "fedaa2e96e6c4f6e8f44f587c229311e",
+ "b3cf0c9c7f544fec9789931a208ee08a",
+ "6eacb525b9b7441580edfca0fec99015",
+ "55bc85db48484fa7ba6e14bd4cb6a5ed",
+ "70a23afc28f84de4a2748d70f08b6b87",
+ "a488d905db1d402eb69ed9ce1c74086c",
+ "3c6db3fa010c4caa8558a0630e2e7d25",
+ "c08999bdfc3c430591f0fb26413a458c",
+ "8a3729ff65294c7ba4ffa456cbad3688",
+ "1cb7c6d8456b4619974ab6e2dd8e8e4c",
+ "f31e7b4354fc4924a0de1123ee89c4c8",
+ "033e73c5a22f46498b7f79b4e26132aa",
+ "db3c4ec20408417e85d8e41299d89036",
+ "ec2ee07e07b84583bb4d1d542319f731",
+ "f0d2bee4ca1e4f19801525dfec5ace13",
+ "27e8c88baa33464b96e44d277105aa39",
+ "12d8c51a1fcf47699cd62a0191461281",
+ "837787de17b34d8ca7a48e516f7908e9",
+ "3badef1b95e945c087cffbbb58f01bcf",
+ "06b18115a5e842f1b673fdf280cf5240"
+ ]
+ },
+ "outputId": "ef18dd66-b31d-4c3f-bde1-a80438f456b4"
+ },
+ "execution_count": 1,
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "VBox(children=(HTML(value='
\n",
+ " \n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " ISO | \n",
+ " LLM used | \n",
+ " Type | \n",
+ " Data Split | \n",
+ " Original text | \n",
+ " Original Word Count | \n",
+ " Original Char Count | \n",
+ " Split Location | \n",
+ " Modified text | \n",
+ " New Word Count | \n",
+ " New Char Count | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " SPA | \n",
+ " Command-R-Plus | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Kepa aseguró que se trató de una confusión y q... | \n",
+ " 981 | \n",
+ " 5783 | \n",
+ " 380 | \n",
+ " Kepa aseguró que se trató de una confusión y q... | \n",
+ " 482 | \n",
+ " 2891 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " SPA | \n",
+ " PPLX-Sonar-Large | \n",
+ " Partial | \n",
+ " Train | \n",
+ " El portal de lasprovincias.es ha crecido un 10... | \n",
+ " 84 | \n",
+ " 498 | \n",
+ " 55 | \n",
+ " El portal de lasprovincias.es ha crecido un 10... | \n",
+ " 218 | \n",
+ " 1407 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Lite-1.0 | \n",
+ " Partial | \n",
+ " Train | \n",
+ " Hefner forma parte ya de la iconografía pop de... | \n",
+ " 155 | \n",
+ " 897 | \n",
+ " 46 | \n",
+ " Hefner forma parte ya de la iconografía pop de... | \n",
+ " 222 | \n",
+ " 1343 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " SPA | \n",
+ " Mistral-Large-2411 | \n",
+ " Partial | \n",
+ " Dev | \n",
+ " El homenaje arrancó con la intervención de la ... | \n",
+ " 126 | \n",
+ " 811 | \n",
+ " 57 | \n",
+ " El homenaje arrancó con la intervención de la ... | \n",
+ " 136 | \n",
+ " 847 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " SPA | \n",
+ " Claude-Haiku-3.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " HZR: Sí, claro. Los cambios que estamos propon... | \n",
+ " 53 | \n",
+ " 335 | \n",
+ " 22 | \n",
+ " HZR: Sí, claro. Los cambios que estamos propon... | \n",
+ " 86 | \n",
+ " 552 | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 119786 | \n",
+ " SPA | \n",
+ " Gemini-Pro-1.5 | \n",
+ " Rewritten | \n",
+ " Test | \n",
+ " Además con la ayuda de los gaviristas (de Aníb... | \n",
+ " 74 | \n",
+ " 459 | \n",
+ " 0 | \n",
+ " Continúa la tensión política en Antioquia. Tra... | \n",
+ " 97 | \n",
+ " 626 | \n",
+ "
\n",
+ " \n",
+ " | 119787 | \n",
+ " SPA | \n",
+ " Gemini-Flash-1.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Para celebrar el setenta aniversario, Amics de... | \n",
+ " 100 | \n",
+ " 569 | \n",
+ " 47 | \n",
+ " Para celebrar el setenta aniversario, Amics de... | \n",
+ " 112 | \n",
+ " 640 | \n",
+ "
\n",
+ " \n",
+ " | 119788 | \n",
+ " SPA | \n",
+ " Command-R-Plus | \n",
+ " Partial | \n",
+ " Dev | \n",
+ " - El gatopardo. Cuando vi la película me gustó... | \n",
+ " 55 | \n",
+ " 294 | \n",
+ " 21 | \n",
+ " - El gatopardo. Cuando vi la película me gustó... | \n",
+ " 103 | \n",
+ " 572 | \n",
+ "
\n",
+ " \n",
+ " | 119789 | \n",
+ " SPA | \n",
+ " Mistral-Large-2411 | \n",
+ " Partial | \n",
+ " Train | \n",
+ " - Pues, ahora que lo dices, sí, la verdad es q... | \n",
+ " 64 | \n",
+ " 320 | \n",
+ " 26 | \n",
+ " - Pues, ahora que lo dices, sí, la verdad es q... | \n",
+ " 100 | \n",
+ " 566 | \n",
+ "
\n",
+ " \n",
+ " | 119790 | \n",
+ " SPA | \n",
+ " Command-R-Plus | \n",
+ " Partial | \n",
+ " Test | \n",
+ " FRANCIA: La Liga de Fútbol Profesional frances... | \n",
+ " 71 | \n",
+ " 394 | \n",
+ " 27 | \n",
+ " FRANCIA: La Liga de Fútbol Profesional frances... | \n",
+ " 106 | \n",
+ " 657 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
119791 rows × 11 columns
\n",
+ "
\n",
+ " \n",
+ " \n"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "dataframe",
+ "variable_name": "df"
+ }
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ],
+ "source": [
+ "import pandas as pd\n",
+ "splits = {'Arabic': 'Data-v3.1/ARA-v3-1.csv', 'Chinese': 'Data-v3.1/ZHO-v3-1.csv', 'Czech': 'Data-v3.1/CES-v3-1.csv', 'Dutch': 'Data-v3.1/NLD-v3-1.csv', 'English': 'Data-v3.1/ENG-v3-1.csv', 'French': 'Data-v3.1/FRA-v3-1.csv', 'German': 'Data-v3.1/DEU-v3-1.csv', 'Greek': 'Data-v3.1/ELL-v3-1.csv', 'Hebrew': 'Data-v3.1/HEB-v3-1.csv', 'Hindi': 'Data-v3.1/HIN-v3-1.csv', 'Indonesian': 'Data-v3.1/IND-v3-1.csv', 'Italian': 'Data-v3.1/ITA-v3-1.csv', 'Japanese': 'Data-v3.1/JPN-v3-1.csv', 'Korean': 'Data-v3.1/KOR-v3-1.csv', 'Persian': 'Data-v3.1/PES-v3-1.csv', 'Polish': 'Data-v3.1/POL-v3-1.csv', 'Portuguese': 'Data-v3.1/POR-v3-1.csv', 'Romanian': 'Data-v3.1/RON-v3-1.csv', 'Russian': 'Data-v3.1/RUS-v3-1.csv', 'Spanish': 'Data-v3.1/SPA-v3-1.csv', 'Turkish': 'Data-v3.1/TUR-v3-1.csv', 'Vietnamese': 'Data-v3.1/VIE-v3-1.csv', 'Ukrainian': 'Data-v3.1/UKR-v3-1.csv'}\n",
+ "df = pd.read_csv(\"hf://datasets/1024m/mMGTD-Corpus/\" + splits[\"Spanish\"])\n",
+ "df"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df = df.sample(frac=1).reset_index(drop=True)"
+ ],
+ "metadata": {
+ "id": "KIgwx1iCpC3f"
+ },
+ "execution_count": 3,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df_train = df[(df['Type'].isin(['Partial', 'Rewritten', 'Unchanged'])) & (df['Data Split'] == 'Train')]\n",
+ "df_dev = df[(df['Type'].isin(['Partial', 'Rewritten', 'Unchanged'])) & (df['Data Split'] == 'Dev')]\n",
+ "df_test = df[(df['Type'].isin(['Partial', 'Rewritten', 'Unchanged'])) & (df['Data Split'] == 'Test')]\n",
+ "print(len(df_train))\n",
+ "print(len(df_dev))\n",
+ "print(len(df_test))"
+ ],
+ "metadata": {
+ "id": "cVKBbVG9qDGF",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "e089f713-8629-4615-a3bb-09c38c1a9585"
+ },
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "47945\n",
+ "11984\n",
+ "59862\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "SPA_train = df_train.copy()\n",
+ "SPA_dev = df_dev.copy()\n",
+ "SPA_test = df_test.copy()"
+ ],
+ "metadata": {
+ "id": "1QWJPFozqFUh"
+ },
+ "execution_count": 5,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df_train['id'] = 'SPA' + df_train.index.astype(str) # Creating the 'id' column\n",
+ "df_train = df_train.rename(columns={'Modified text': 'text', 'Split Location': 'label'})\n",
+ "df_dev['id'] = 'SPA' + df_dev.index.astype(str) # Creating the 'id' column\n",
+ "df_dev = df_dev.rename(columns={'Modified text': 'text', 'Split Location': 'label'})\n",
+ "df_test['id'] = 'SPA' + df_test.index.astype(str) # Creating the 'id' column\n",
+ "df_test = df_test.rename(columns={'Modified text': 'text', 'Split Location': 'label'})"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "bSlHXAnzqHmd",
+ "outputId": "d103122a-f241-4c09-b544-552ceecc8e3e"
+ },
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stderr",
+ "text": [
+ ":1: SettingWithCopyWarning: \n",
+ "A value is trying to be set on a copy of a slice from a DataFrame.\n",
+ "Try using .loc[row_indexer,col_indexer] = value instead\n",
+ "\n",
+ "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
+ " df_train['id'] = 'SPA' + df_train.index.astype(str) # Creating the 'id' column\n",
+ ":3: SettingWithCopyWarning: \n",
+ "A value is trying to be set on a copy of a slice from a DataFrame.\n",
+ "Try using .loc[row_indexer,col_indexer] = value instead\n",
+ "\n",
+ "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
+ " df_dev['id'] = 'SPA' + df_dev.index.astype(str) # Creating the 'id' column\n",
+ ":5: SettingWithCopyWarning: \n",
+ "A value is trying to be set on a copy of a slice from a DataFrame.\n",
+ "Try using .loc[row_indexer,col_indexer] = value instead\n",
+ "\n",
+ "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
+ " df_test['id'] = 'SPA' + df_test.index.astype(str) # Creating the 'id' column\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df_train = pd.concat([df_train, df_dev], ignore_index=True)"
+ ],
+ "metadata": {
+ "id": "aGvboB0ZqJ8M"
+ },
+ "execution_count": 7,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "print(len(df_train))\n",
+ "print(len(df_dev))\n",
+ "print(len(df_test))"
+ ],
+ "metadata": {
+ "id": "qIVYeup9qM5X",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "a7b6c320-54a1-4b8c-ee32-150d036a1d85"
+ },
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "59929\n",
+ "11984\n",
+ "59862\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df_train.to_json('SPA_train.jsonl', orient='records', lines=True)\n",
+ "df_test.to_json('SPA_test.jsonl', orient='records', lines=True)"
+ ],
+ "metadata": {
+ "id": "9javNVKDqO1j"
+ },
+ "execution_count": 9,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!pip install torch\n",
+ "!pip install transformers\n",
+ "!pip install accelerate -U\n",
+ "!pip install tqdm\n",
+ "!pip install pytorch-crf\n",
+ "!pip install sentencepiece"
+ ],
+ "metadata": {
+ "id": "C6wCkGRXqQpc",
+ "collapsed": true,
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "72358606-f8ee-4d66-f762-e4527b7b7bfc"
+ },
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Requirement already satisfied: torch in /usr/local/lib/python3.11/dist-packages (2.5.1+cu124)\n",
+ "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from torch) (3.17.0)\n",
+ "Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.11/dist-packages (from torch) (4.12.2)\n",
+ "Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch) (3.4.2)\n",
+ "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch) (3.1.5)\n",
+ "Requirement already satisfied: fsspec in /usr/local/lib/python3.11/dist-packages (from torch) (2024.10.0)\n",
+ "Collecting nvidia-cuda-nvrtc-cu12==12.4.127 (from torch)\n",
+ " Downloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Collecting nvidia-cuda-runtime-cu12==12.4.127 (from torch)\n",
+ " Downloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Collecting nvidia-cuda-cupti-cu12==12.4.127 (from torch)\n",
+ " Downloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
+ "Collecting nvidia-cudnn-cu12==9.1.0.70 (from torch)\n",
+ " Downloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
+ "Collecting nvidia-cublas-cu12==12.4.5.8 (from torch)\n",
+ " Downloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Collecting nvidia-cufft-cu12==11.2.1.3 (from torch)\n",
+ " Downloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Collecting nvidia-curand-cu12==10.3.5.147 (from torch)\n",
+ " Downloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Collecting nvidia-cusolver-cu12==11.6.1.9 (from torch)\n",
+ " Downloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
+ "Collecting nvidia-cusparse-cu12==12.3.1.170 (from torch)\n",
+ " Downloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
+ "Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /usr/local/lib/python3.11/dist-packages (from torch) (2.21.5)\n",
+ "Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch) (12.4.127)\n",
+ "Collecting nvidia-nvjitlink-cu12==12.4.127 (from torch)\n",
+ " Downloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
+ "Requirement already satisfied: triton==3.1.0 in /usr/local/lib/python3.11/dist-packages (from torch) (3.1.0)\n",
+ "Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.11/dist-packages (from torch) (1.13.1)\n",
+ "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy==1.13.1->torch) (1.3.0)\n",
+ "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch) (3.0.2)\n",
+ "Downloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl (363.4 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (13.8 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m93.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (24.6 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m88.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (883 kB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m54.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m1.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl (211.5 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m10.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl (56.3 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m41.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl (127.9 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m18.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl (207.5 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hDownloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (21.1 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m58.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
+ "\u001b[?25hInstalling collected packages: nvidia-nvjitlink-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, nvidia-cusparse-cu12, nvidia-cudnn-cu12, nvidia-cusolver-cu12\n",
+ " Attempting uninstall: nvidia-nvjitlink-cu12\n",
+ " Found existing installation: nvidia-nvjitlink-cu12 12.5.82\n",
+ " Uninstalling nvidia-nvjitlink-cu12-12.5.82:\n",
+ " Successfully uninstalled nvidia-nvjitlink-cu12-12.5.82\n",
+ " Attempting uninstall: nvidia-curand-cu12\n",
+ " Found existing installation: nvidia-curand-cu12 10.3.6.82\n",
+ " Uninstalling nvidia-curand-cu12-10.3.6.82:\n",
+ " Successfully uninstalled nvidia-curand-cu12-10.3.6.82\n",
+ " Attempting uninstall: nvidia-cufft-cu12\n",
+ " Found existing installation: nvidia-cufft-cu12 11.2.3.61\n",
+ " Uninstalling nvidia-cufft-cu12-11.2.3.61:\n",
+ " Successfully uninstalled nvidia-cufft-cu12-11.2.3.61\n",
+ " Attempting uninstall: nvidia-cuda-runtime-cu12\n",
+ " Found existing installation: nvidia-cuda-runtime-cu12 12.5.82\n",
+ " Uninstalling nvidia-cuda-runtime-cu12-12.5.82:\n",
+ " Successfully uninstalled nvidia-cuda-runtime-cu12-12.5.82\n",
+ " Attempting uninstall: nvidia-cuda-nvrtc-cu12\n",
+ " Found existing installation: nvidia-cuda-nvrtc-cu12 12.5.82\n",
+ " Uninstalling nvidia-cuda-nvrtc-cu12-12.5.82:\n",
+ " Successfully uninstalled nvidia-cuda-nvrtc-cu12-12.5.82\n",
+ " Attempting uninstall: nvidia-cuda-cupti-cu12\n",
+ " Found existing installation: nvidia-cuda-cupti-cu12 12.5.82\n",
+ " Uninstalling nvidia-cuda-cupti-cu12-12.5.82:\n",
+ " Successfully uninstalled nvidia-cuda-cupti-cu12-12.5.82\n",
+ " Attempting uninstall: nvidia-cublas-cu12\n",
+ " Found existing installation: nvidia-cublas-cu12 12.5.3.2\n",
+ " Uninstalling nvidia-cublas-cu12-12.5.3.2:\n",
+ " Successfully uninstalled nvidia-cublas-cu12-12.5.3.2\n",
+ " Attempting uninstall: nvidia-cusparse-cu12\n",
+ " Found existing installation: nvidia-cusparse-cu12 12.5.1.3\n",
+ " Uninstalling nvidia-cusparse-cu12-12.5.1.3:\n",
+ " Successfully uninstalled nvidia-cusparse-cu12-12.5.1.3\n",
+ " Attempting uninstall: nvidia-cudnn-cu12\n",
+ " Found existing installation: nvidia-cudnn-cu12 9.3.0.75\n",
+ " Uninstalling nvidia-cudnn-cu12-9.3.0.75:\n",
+ " Successfully uninstalled nvidia-cudnn-cu12-9.3.0.75\n",
+ " Attempting uninstall: nvidia-cusolver-cu12\n",
+ " Found existing installation: nvidia-cusolver-cu12 11.6.3.83\n",
+ " Uninstalling nvidia-cusolver-cu12-11.6.3.83:\n",
+ " Successfully uninstalled nvidia-cusolver-cu12-11.6.3.83\n",
+ "Successfully installed nvidia-cublas-cu12-12.4.5.8 nvidia-cuda-cupti-cu12-12.4.127 nvidia-cuda-nvrtc-cu12-12.4.127 nvidia-cuda-runtime-cu12-12.4.127 nvidia-cudnn-cu12-9.1.0.70 nvidia-cufft-cu12-11.2.1.3 nvidia-curand-cu12-10.3.5.147 nvidia-cusolver-cu12-11.6.1.9 nvidia-cusparse-cu12-12.3.1.170 nvidia-nvjitlink-cu12-12.4.127\n",
+ "Requirement already satisfied: transformers in /usr/local/lib/python3.11/dist-packages (4.48.2)\n",
+ "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from transformers) (3.17.0)\n",
+ "Requirement already satisfied: huggingface-hub<1.0,>=0.24.0 in /usr/local/lib/python3.11/dist-packages (from transformers) (0.28.1)\n",
+ "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.11/dist-packages (from transformers) (1.26.4)\n",
+ "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from transformers) (24.2)\n",
+ "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.11/dist-packages (from transformers) (6.0.2)\n",
+ "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.11/dist-packages (from transformers) (2024.11.6)\n",
+ "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from transformers) (2.32.3)\n",
+ "Requirement already satisfied: tokenizers<0.22,>=0.21 in /usr/local/lib/python3.11/dist-packages (from transformers) (0.21.0)\n",
+ "Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.11/dist-packages (from transformers) (0.5.2)\n",
+ "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.11/dist-packages (from transformers) (4.67.1)\n",
+ "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub<1.0,>=0.24.0->transformers) (2024.10.0)\n",
+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub<1.0,>=0.24.0->transformers) (4.12.2)\n",
+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->transformers) (3.4.1)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->transformers) (3.10)\n",
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->transformers) (2.3.0)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests->transformers) (2025.1.31)\n",
+ "Requirement already satisfied: accelerate in /usr/local/lib/python3.11/dist-packages (1.3.0)\n",
+ "Requirement already satisfied: numpy<3.0.0,>=1.17 in /usr/local/lib/python3.11/dist-packages (from accelerate) (1.26.4)\n",
+ "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from accelerate) (24.2)\n",
+ "Requirement already satisfied: psutil in /usr/local/lib/python3.11/dist-packages (from accelerate) (5.9.5)\n",
+ "Requirement already satisfied: pyyaml in /usr/local/lib/python3.11/dist-packages (from accelerate) (6.0.2)\n",
+ "Requirement already satisfied: torch>=2.0.0 in /usr/local/lib/python3.11/dist-packages (from accelerate) (2.5.1+cu124)\n",
+ "Requirement already satisfied: huggingface-hub>=0.21.0 in /usr/local/lib/python3.11/dist-packages (from accelerate) (0.28.1)\n",
+ "Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.11/dist-packages (from accelerate) (0.5.2)\n",
+ "Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.21.0->accelerate) (3.17.0)\n",
+ "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.21.0->accelerate) (2024.10.0)\n",
+ "Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.21.0->accelerate) (2.32.3)\n",
+ "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.21.0->accelerate) (4.67.1)\n",
+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.21.0->accelerate) (4.12.2)\n",
+ "Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (3.4.2)\n",
+ "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (3.1.5)\n",
+ "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.127)\n",
+ "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.127)\n",
+ "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.127)\n",
+ "Requirement already satisfied: nvidia-cudnn-cu12==9.1.0.70 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (9.1.0.70)\n",
+ "Requirement already satisfied: nvidia-cublas-cu12==12.4.5.8 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.5.8)\n",
+ "Requirement already satisfied: nvidia-cufft-cu12==11.2.1.3 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (11.2.1.3)\n",
+ "Requirement already satisfied: nvidia-curand-cu12==10.3.5.147 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (10.3.5.147)\n",
+ "Requirement already satisfied: nvidia-cusolver-cu12==11.6.1.9 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (11.6.1.9)\n",
+ "Requirement already satisfied: nvidia-cusparse-cu12==12.3.1.170 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.3.1.170)\n",
+ "Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (2.21.5)\n",
+ "Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.127)\n",
+ "Requirement already satisfied: nvidia-nvjitlink-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (12.4.127)\n",
+ "Requirement already satisfied: triton==3.1.0 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (3.1.0)\n",
+ "Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.11/dist-packages (from torch>=2.0.0->accelerate) (1.13.1)\n",
+ "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy==1.13.1->torch>=2.0.0->accelerate) (1.3.0)\n",
+ "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch>=2.0.0->accelerate) (3.0.2)\n",
+ "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.4.1)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.21.0->accelerate) (3.10)\n",
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2.3.0)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.21.0->accelerate) (2025.1.31)\n",
+ "Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (4.67.1)\n",
+ "Collecting pytorch-crf\n",
+ " Downloading pytorch_crf-0.7.2-py3-none-any.whl.metadata (2.4 kB)\n",
+ "Downloading pytorch_crf-0.7.2-py3-none-any.whl (9.5 kB)\n",
+ "Installing collected packages: pytorch-crf\n",
+ "Successfully installed pytorch-crf-0.7.2\n",
+ "Requirement already satisfied: sentencepiece in /usr/local/lib/python3.11/dist-packages (0.2.0)\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import os\n",
+ "os.makedirs(\"./runs/exp_seed\", exist_ok=True)\n",
+ "os.makedirs(\"./runs/exp_seed/logs\", exist_ok=True)\n",
+ "os.makedirs(\"./runs/exp_seed/xlmlongformerbase\", exist_ok=True)"
+ ],
+ "metadata": {
+ "id": "if7zZ-egqSrE"
+ },
+ "execution_count": 11,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import torch\n",
+ "import json\n",
+ "from transformers import AutoTokenizer, AutoModelForTokenClassification\n",
+ "from transformers.trainer_callback import TrainerState\n",
+ "from torch.utils.data import Dataset, DataLoader\n",
+ "from torch.nn.utils.rnn import pad_sequence\n",
+ "import transformers\n",
+ "from torch import nn\n",
+ "from transformers import AutoModel, AutoConfig\n",
+ "from torchcrf import CRF\n",
+ "from torch.cuda.amp import autocast\n",
+ "from transformers import Trainer\n",
+ "from tqdm import tqdm\n",
+ "import numpy as np\n",
+ "import logging\n",
+ "import glob\n",
+ "from tqdm import tqdm\n",
+ "from dataclasses import dataclass, field\n",
+ "logging.basicConfig(level=logging.INFO)\n",
+ "logger = logging.getLogger()\n",
+ "@dataclass\n",
+ "class ModelConfig:\n",
+ " model_path = \"hyperonym/xlm-roberta-longformer-base-16384\"\n",
+ " model_checkpoint_dir = \"./runs\"\n",
+ "@dataclass\n",
+ "class DatasetConfig:\n",
+ " train_file = \"/content/SPA_train.jsonl\"\n",
+ " test_files = [\"/content/SPA_test.jsonl\"]\n",
+ "@dataclass\n",
+ "class TrainingArgsConfig:\n",
+ " do_train = False\n",
+ " do_predict = False\n",
+ " seed = 1024\n",
+ " output_dir = \"./runs/exp_seed\"\n",
+ " logging_steps = 160\n",
+ " logging_dir = \"./runs/exp_seed\"\n",
+ " num_train_epochs = 30\n",
+ " per_device_train_batch_size = 12\n",
+ " per_device_eval_batch_size = 12\n",
+ " max_length = 2048\n",
+ "model_args = ModelConfig()\n",
+ "data_args = DatasetConfig()\n",
+ "training_args = TrainingArgsConfig()\n",
+ "class CRFTrainer(Trainer):\n",
+ " def __init__(self, *args, **kwargs):\n",
+ " super().__init__(*args, **kwargs)\n",
+ " def compute_loss(self, model, inputs, return_outputs=False):\n",
+ " print(inputs.keys())\n",
+ " labels = inputs.pop(\"labels\")\n",
+ " outputs = model(**inputs)\n",
+ " emissions = outputs[0]\n",
+ " mask = inputs[\"attention_mask\"]\n",
+ " crf_loss = -model.crf(emissions, labels, mask=mask)\n",
+ " return crf_loss\n",
+ " def training_step(self, model, inputs):\n",
+ " loss = self.compute_loss(model, inputs)\n",
+ " return {\"loss\": loss, \"inputs\": inputs}\n",
+ "class AutoModelCRF(nn.Module):\n",
+ " def __init__(self, model_name_or_path, dropout=0.075):\n",
+ " super(AutoModelCRF, self).__init__()\n",
+ " self.config = AutoConfig.from_pretrained(model_name_or_path)\n",
+ " self.num_labels = 2\n",
+ " self.encoder = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True, config=self.config, from_tf=True)\n",
+ " self.dropout = nn.Dropout(dropout)\n",
+ " self.linear = nn.Linear(self.config.hidden_size, self.num_labels)\n",
+ " self.crf = CRF(self.num_labels, batch_first=True)\n",
+ " def forward(self, input_ids, attention_mask, labels=None):\n",
+ " inputs = {'input_ids': input_ids, 'attention_mask': attention_mask}\n",
+ " outputs = self.encoder(**inputs)\n",
+ " seq_output = outputs[0]\n",
+ " seq_output = self.dropout(seq_output)\n",
+ " emission = self.linear(seq_output)\n",
+ " if labels is None:\n",
+ " tags = self.crf.decode(emission, attention_mask.byte())\n",
+ " tags_padded = []\n",
+ " for idx, sequence in enumerate(tags):\n",
+ " if len(attention_mask[idx]) > len(sequence):\n",
+ " tag_padded = sequence + [sequence[-1]]*(len(attention_mask[idx])-len(sequence))\n",
+ " else:\n",
+ " tag_padded = sequence\n",
+ " tags_padded.append(tag_padded)\n",
+ " out = np.array(tags_padded)\n",
+ " return out\n",
+ " else:\n",
+ " crf_loss = -self.crf(emission, labels, mask=attention_mask.byte())\n",
+ " return crf_loss\n",
+ "def evaluate_position_difference(actual_position, predicted_position):\n",
+ " return abs(actual_position - predicted_position)\n",
+ "def get_start_position(sequence, mapping=None, token_level=True):\n",
+ " if mapping is not None:\n",
+ " mask = mapping != -100\n",
+ " sequence = sequence[mask]\n",
+ " mapping = mapping[mask]\n",
+ " change_indices = np.where(np.diff(sequence) == 1)[0]\n",
+ " if len(change_indices) > 0:\n",
+ " value = change_indices[0] + 1\n",
+ " else:\n",
+ " value = 0 if sequence[0] == 1 else len(sequence) - 1\n",
+ " if not token_level:\n",
+ " value = mapping[value] if mapping is not None else value\n",
+ " return value\n",
+ "def evaluate_machine_start_position(labels, predictions, idx2word=None, token_level=False):\n",
+ " actual_starts = []\n",
+ " predicted_starts = []\n",
+ " if not token_level and idx2word is None:\n",
+ " raise ValueError(\"idx2word must be provided if evaluation is at word level (token_level=False)\")\n",
+ " for idx in range(labels.shape[0]):\n",
+ " predict, label, mapping = (predictions[idx][1:len(labels[idx])], labels[idx][1:len(labels[idx])], idx2word[idx][1:len(labels[idx])] if not token_level else None,)\n",
+ " predicted_value = get_start_position(predict, mapping, token_level)\n",
+ " actual_value = get_start_position(label, mapping, token_level)\n",
+ " predicted_starts.append(predicted_value)\n",
+ " actual_starts.append(actual_value)\n",
+ " position_differences = [ evaluate_position_difference(actual, predict) for actual, predict in zip(actual_starts, predicted_starts) ]\n",
+ " mean_position_difference = np.mean(position_differences)\n",
+ " return mean_position_difference\n",
+ "def compute_metrics(p):\n",
+ " pred, labels = p\n",
+ " mean_absolute_diff = evaluate_machine_start_position(labels, pred, token_level=True)\n",
+ " return {\"mean_absolute_diff\": mean_absolute_diff,}\n",
+ "def training_loop(model, optimizer, train_dataloader, device):\n",
+ " model.train()\n",
+ " total_loss = 0\n",
+ " for step, batch in enumerate(tqdm(train_dataloader)):\n",
+ " input_ids = batch[\"input_ids\"].to(device)\n",
+ " attention_mask = batch[\"attention_mask\"].to(device)\n",
+ " labels = batch[\"labels\"].to(device)\n",
+ " optimizer.zero_grad()\n",
+ " loss = model(input_ids, attention_mask, labels=labels)\n",
+ " loss.backward()\n",
+ " optimizer.step()\n",
+ " logger.info(f\"Step {step}: {loss.item():.4f}\")\n",
+ " total_loss += loss.item()\n",
+ " avg_loss = total_loss/len(train_dataloader)\n",
+ " print(f\"Training loss: {avg_loss:.4f}\")\n",
+ "def predict(model, test_dataloader, device):\n",
+ " all_preds = []\n",
+ " with torch.no_grad():\n",
+ " for batch in tqdm(test_dataloader):\n",
+ " input_ids = batch[\"input_ids\"].to(device)\n",
+ " attention_mask = batch[\"attention_mask\"].to(device)\n",
+ " preds = model(input_ids, attention_mask)\n",
+ " all_preds.extend(preds)\n",
+ " out = np.array(all_preds)\n",
+ " print(out.shape)\n",
+ " return out\n",
+ "def save_model(model_name, model, optimizer, epoch, output_dir): # train_mae, val_mae,\n",
+ " if not os.path.exists(output_dir):\n",
+ " os.makedirs(output_dir)\n",
+ " checkpoint = {'model_state_dict': model.state_dict(),'optimizer_state_dict': optimizer.state_dict()} # 'train_mae': train_mae,'val_mae': val_mae,\n",
+ " model_name = model_name.replace(\"/\", \"-\")\n",
+ " file_path = os.path.join(output_dir, f\"{model_name}-epoch-{epoch}.pt\")\n",
+ " print(file_path)\n",
+ " torch.save(checkpoint, file_path)\n",
+ " logger.info(f\"Model has been saved successfully to {file_path}\")\n",
+ "class Semeval_Data(torch.utils.data.Dataset):\n",
+ " def __init__(self, data_path, model_name, max_length=512, inference=False, debug=False):\n",
+ " with open(data_path, \"r\") as f:\n",
+ " self.data = [json.loads(line) for line in f]\n",
+ " self.inference = inference\n",
+ " self.tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
+ " self.max_length = max_length\n",
+ " self.debug = debug\n",
+ " def __len__(self):\n",
+ " return len(self.data)\n",
+ " def __getitem__(self, idx):\n",
+ " text = self.data[idx][\"text\"]\n",
+ " id = self.data[idx][\"id\"]\n",
+ " label = None\n",
+ " labels_available = \"label\" in self.data[idx]\n",
+ " if labels_available:\n",
+ " label = self.data[idx][\"label\"]\n",
+ " labels = []\n",
+ " corresponding_word = []\n",
+ " tokens = []\n",
+ " input_ids = []\n",
+ " attention_mask = []\n",
+ " for jdx, word in enumerate(text.split(\" \")):\n",
+ " word_encoded = self.tokenizer.tokenize(word)\n",
+ " sub_words = len(word_encoded)\n",
+ " if labels_available:\n",
+ " is_machine_text = 1 if jdx >= label else 0\n",
+ " labels.extend([is_machine_text] * sub_words)\n",
+ " corresponding_word.extend([jdx] * sub_words)\n",
+ " tokens.extend(word_encoded)\n",
+ " input_ids.extend(self.tokenizer.convert_tokens_to_ids(word_encoded))\n",
+ " attention_mask.extend([1] * sub_words)\n",
+ " if len(input_ids) < self.max_length - 2:\n",
+ " input_ids = ( [0] + input_ids + [2] + [1] * (self.max_length - len(input_ids) - 2) )\n",
+ " if labels_available:\n",
+ " labels = [0] + labels + [labels[-1]] * (self.max_length - len(labels) - 1)\n",
+ " attention_mask = ( [1] + attention_mask + [1] + [0] * (self.max_length - len(attention_mask) - 2) )\n",
+ " corresponding_word = ( [-100] + corresponding_word + [-100] * (self.max_length - len(corresponding_word) - 1) )\n",
+ " tokens = ( [\"\"] + tokens + [\"\"] + [\"\"] * (self.max_length - len(tokens) - 2) )\n",
+ " else:\n",
+ " input_ids = [0] + input_ids[: self.max_length - 2] + [2]\n",
+ " if labels_available:\n",
+ " labels = [0] + labels[: self.max_length - 2] + [labels[self.max_length - 3]]\n",
+ " corresponding_word = ( [-100] + corresponding_word[: self.max_length - 2] + [-100] )\n",
+ " attention_mask = [1] + attention_mask[: self.max_length - 2] + [1]\n",
+ " tokens = [\"\"] + tokens[: self.max_length - 2] + [\"\"]\n",
+ " encoded = {}\n",
+ " if labels_available:\n",
+ " encoded[\"labels\"] = torch.tensor(labels)\n",
+ " encoded[\"input_ids\"] = torch.tensor(input_ids)\n",
+ " encoded[\"attention_mask\"] = torch.tensor(attention_mask)\n",
+ " if labels_available:\n",
+ " assert encoded[\"input_ids\"].shape == encoded[\"labels\"].shape\n",
+ " if self.debug and not self.inference:\n",
+ " encoded[\"partial_human_review\"] = \" \".join(text.split(\" \")[:label])\n",
+ " if self.inference:\n",
+ " encoded[\"text\"] = text\n",
+ " encoded[\"id\"] = id\n",
+ " encoded[\"corresponding_word\"] = corresponding_word\n",
+ " return encoded\n",
+ "if __name__ == \"__main__\":\n",
+ " model_args = ModelConfig()\n",
+ " data_args = DatasetConfig()\n",
+ " training_args = TrainingArgsConfig()\n",
+ " transformers.set_seed(training_args.seed)\n",
+ " model_path = model_args.model_path\n",
+ " model_checkpoint_dir = model_args.model_checkpoint_dir\n",
+ " device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
+ " model = AutoModelCRF(model_path).to(device)\n",
+ " optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)\n",
+ " train_set = Semeval_Data(data_args.train_file, model_path, max_length=training_args.max_length)\n",
+ " train_dataloader = DataLoader(train_set, batch_size=training_args.per_device_train_batch_size, shuffle=True)\n",
+ " train_eval_dataloader = DataLoader(train_set, batch_size=training_args.per_device_eval_batch_size, shuffle=False)\n",
+ " if training_args.do_train:\n",
+ " logger.info(\"Training...\")\n",
+ " logger.info(\"*** Train Dataset ***\")\n",
+ " logger.info(f\"Number of samples: {len(train_set)}\")\n",
+ " num_train_epochs = training_args.num_train_epochs\n",
+ " for epoch in tqdm(range(num_train_epochs)):\n",
+ " training_loop(model, optimizer, train_dataloader, device)\n",
+ " save_model(model_path, model, optimizer, epoch, model_checkpoint_dir) # ,train_mse ,val_mse"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 301,
+ "referenced_widgets": [
+ "994ab606af24474a8c1a1bb2b552e3a7",
+ "b5d7e3d762974277888ba30da30696b2",
+ "e5558ac25e1f47faa7ff3d20e3af81d8",
+ "2c43b2a7f2884ab2a5469b48b46a7894",
+ "8dbd64092a53457cbb9c7d66674918b7",
+ "69d340da9b43489aaecd29f0279ed4f2",
+ "a66bc45f53514e30bcb5a29dd9a41d2e",
+ "406e8fe2f45b4c2e9cd6e04c2792b497",
+ "b11641bd010f4ac99a242b6e234bb622",
+ "49efe56091054a65badfb33a3becfda7",
+ "e1bc90b628454d24a6d8921d041b60d9",
+ "16e8e25011c44df0a91ac28ac88a35d5",
+ "0cb0aec0f8cf431dae59f98c31d392a5",
+ "2165093635724c4ea93988468e2ee4ec",
+ "d61b5f53d270429290271394240f21a1",
+ "7345c152f1124cc487b584baaaa20108",
+ "8262102752314a3ea88dce66de4787eb",
+ "d39400631ef64cb7a70a5e031c571007",
+ "8badb95ac58e482ca3dc6b07c51e740e",
+ "954fedc807994f95973e3b2f5c9e2fef",
+ "8bcb7ac3ad4b47359ee279de8f9604eb",
+ "bf2213ffcb8e4e6b8e0342ea52bec417",
+ "5e3719138b294d1fbdd8dd25f481d0cb",
+ "abd8c2e7b77f43bdb8894f4c96cb37b4",
+ "9b1e596585ac4c1bbe3287be1a57d8f3",
+ "f68fa48477ee4cefa168505c6c4b841a",
+ "01065fe2096e484db23ceb73de1922b7",
+ "c5734191284c4fe6bc1a384492b8e642",
+ "1391e6eb7b954704ad3fdccdde5f674c",
+ "7efce577348c4043bb6f3ab0513fb86f",
+ "e0445165df8a468fbb81d8410c924940",
+ "ddb640ddf5044f4982e1a3af868ed5d0",
+ "90868d5f4fe04416ab34226491d77a1d",
+ "ce468297529e4909b8042a4e919cee6b",
+ "4002d49584744a51b93e3d3c686b5e0c",
+ "5cd8059ea13246e490bc31667c04daea",
+ "5cd7b91316d9493db2fd3142cf0eaa9c",
+ "898df2b813d949a8b67995fe6009dcab",
+ "d32bef3a3e5a4a55a5620e95cb4d945c",
+ "2822b99069a74551a3582ed1635c9690",
+ "3c58b5eefcb2476c945c79cffa548835",
+ "d3969decfcc5498199fa460be8a67da7",
+ "758f241e682f4a7189f699f8bc4cc327",
+ "b28d84fb4ae749d183ad0a5ba631c1c9",
+ "13e334bc19244961b0e748b89490e2ed",
+ "7fc67bdabea0409f830c6bc8cd50d094",
+ "f700ce630ffd4ca88e31ab3e92e7655d",
+ "68c5981c26db411d992b358dd53bb6ce",
+ "df5c6ed40d4f4e4890dc2595e22e7bf2",
+ "edb16999c39d40d5ba0a7a23c104d7ca",
+ "e117b257301c43d1b85f5a1c95b7dcf3",
+ "82a4edff8a254da4a37bc733bc206ee9",
+ "46c670160e454a95a3d32afb354633f1",
+ "0c21ad59117c4fcf9a1aad6f5ff68b8b",
+ "9680ddd062954ef99855818bad479337"
+ ]
+ },
+ "id": "tXBLrJp0quLE",
+ "outputId": "ee598c51-219c-4336-b920-8231ff2e3054"
+ },
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "config.json: 0%| | 0.00/772 [00:00, ?B/s]"
+ ],
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "994ab606af24474a8c1a1bb2b552e3a7"
+ }
+ },
+ "metadata": {}
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "tf_model.h5: 0%| | 0.00/1.25G [00:00, ?B/s]"
+ ],
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "16e8e25011c44df0a91ac28ac88a35d5"
+ }
+ },
+ "metadata": {}
+ },
+ {
+ "output_type": "stream",
+ "name": "stderr",
+ "text": [
+ "/usr/local/lib/python3.11/dist-packages/tf_keras/src/initializers/initializers.py:121: UserWarning: The initializer TruncatedNormal is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). Please update your code to provide a seed to the initializer, or avoid using the same initializer instance more than once.\n",
+ " warnings.warn(\n",
+ "All TF 2.0 model weights were used when initializing LongformerModel.\n",
+ "\n",
+ "All the weights of LongformerModel were initialized from the TF 2.0 model.\n",
+ "If your task is similar to the task the model of the checkpoint was trained on, you can already use LongformerModel for predictions without further training.\n"
+ ]
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "tokenizer_config.json: 0%| | 0.00/453 [00:00, ?B/s]"
+ ],
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "5e3719138b294d1fbdd8dd25f481d0cb"
+ }
+ },
+ "metadata": {}
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "tokenizer.json: 0%| | 0.00/17.1M [00:00, ?B/s]"
+ ],
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "ce468297529e4909b8042a4e919cee6b"
+ }
+ },
+ "metadata": {}
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "special_tokens_map.json: 0%| | 0.00/280 [00:00, ?B/s]"
+ ],
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "13e334bc19244961b0e748b89490e2ed"
+ }
+ },
+ "metadata": {}
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!wget -O SPA-xlm-longformer https://huggingface.co/DrishtiSharma/SPA-Checkpoints-v1/resolve/main/SPA/xlm-longformer-epoch-4.pt"
+ ],
+ "metadata": {
+ "id": "sjsb2Af-q9YV",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "8b35fd45-775e-4a17-e956-6dd3be824169"
+ },
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "--2025-02-12 03:05:25-- https://huggingface.co/DrishtiSharma/SPA-Checkpoints-v1/resolve/main/SPA/xlm-longformer-epoch-4.pt\n",
+ "Resolving huggingface.co (huggingface.co)... 13.35.202.97, 13.35.202.34, 13.35.202.121, ...\n",
+ "Connecting to huggingface.co (huggingface.co)|13.35.202.97|:443... connected.\n",
+ "HTTP request sent, awaiting response... 307 Temporary Redirect\n",
+ "Location: /1-800-SHARED-TASKS/SPA-Checkpoints/resolve/main/SPA/xlm-longformer-epoch-4.pt [following]\n",
+ "--2025-02-12 03:05:25-- https://huggingface.co/1-800-SHARED-TASKS/SPA-Checkpoints/resolve/main/SPA/xlm-longformer-epoch-4.pt\n",
+ "Reusing existing connection to huggingface.co:443.\n",
+ "HTTP request sent, awaiting response... 302 Found\n",
+ "Location: https://cdn-lfs-us-1.hf.co/repos/c6/9d/c69dfafc630300b80258d053daaeb65b60c65f3c5616cfec040b8dc874ac1d31/d530fc6afb114b611ed051c40cec5f1150debeeac686530e947b74123feb44b9?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27xlm-longformer-epoch-4.pt%3B+filename%3D%22xlm-longformer-epoch-4.pt%22%3B&Expires=1739333125&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczOTMzMzEyNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zL2M2LzlkL2M2OWRmYWZjNjMwMzAwYjgwMjU4ZDA1M2RhYWViNjViNjBjNjVmM2M1NjE2Y2ZlYzA0MGI4ZGM4NzRhYzFkMzEvZDUzMGZjNmFmYjExNGI2MTFlZDA1MWM0MGNlYzVmMTE1MGRlYmVlYWM2ODY1MzBlOTQ3Yjc0MTIzZmViNDRiOT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=OjTm%7E95CnpJf3KNcLP3uuRVyudU2G-MA5ZD5SZj7rU6AQvykhGHJWIAB9Uws6KtnwGYMA7VueGB83LvyPTGttQW0HAwYHMGcTHc1N8Oyrgv0ruLI4QRyFdQJ5tDeG1smr97%7EaOwPVeBqSMiCz-2VPERPq4vrZE2m72BblqURetV1BdlDUypAArU4iHqlrhc2hzHFyIH6Lkq6sluExeyfJhkI9z2s7y9qBDRs-LCXDgsKQcBPn4KfVI1q8Vqh066ISqwtl8gkS6A1Dd62JdM8HDabf6Jc890%7EW0mmpvPmwJmWJaZvMXs0HLAV2QBnOR6ClngKGctxlWeG5IAMQPQtsA__&Key-Pair-Id=K24J24Z295AEI9 [following]\n",
+ "--2025-02-12 03:05:25-- https://cdn-lfs-us-1.hf.co/repos/c6/9d/c69dfafc630300b80258d053daaeb65b60c65f3c5616cfec040b8dc874ac1d31/d530fc6afb114b611ed051c40cec5f1150debeeac686530e947b74123feb44b9?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27xlm-longformer-epoch-4.pt%3B+filename%3D%22xlm-longformer-epoch-4.pt%22%3B&Expires=1739333125&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczOTMzMzEyNX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zL2M2LzlkL2M2OWRmYWZjNjMwMzAwYjgwMjU4ZDA1M2RhYWViNjViNjBjNjVmM2M1NjE2Y2ZlYzA0MGI4ZGM4NzRhYzFkMzEvZDUzMGZjNmFmYjExNGI2MTFlZDA1MWM0MGNlYzVmMTE1MGRlYmVlYWM2ODY1MzBlOTQ3Yjc0MTIzZmViNDRiOT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=OjTm%7E95CnpJf3KNcLP3uuRVyudU2G-MA5ZD5SZj7rU6AQvykhGHJWIAB9Uws6KtnwGYMA7VueGB83LvyPTGttQW0HAwYHMGcTHc1N8Oyrgv0ruLI4QRyFdQJ5tDeG1smr97%7EaOwPVeBqSMiCz-2VPERPq4vrZE2m72BblqURetV1BdlDUypAArU4iHqlrhc2hzHFyIH6Lkq6sluExeyfJhkI9z2s7y9qBDRs-LCXDgsKQcBPn4KfVI1q8Vqh066ISqwtl8gkS6A1Dd62JdM8HDabf6Jc890%7EW0mmpvPmwJmWJaZvMXs0HLAV2QBnOR6ClngKGctxlWeG5IAMQPQtsA__&Key-Pair-Id=K24J24Z295AEI9\n",
+ "Resolving cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)... 3.171.198.59, 3.171.198.97, 3.171.198.22, ...\n",
+ "Connecting to cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)|3.171.198.59|:443... connected.\n",
+ "HTTP request sent, awaiting response... 200 OK\n",
+ "Length: 3563459222 (3.3G) [binary/octet-stream]\n",
+ "Saving to: ‘SPA-xlm-longformer’\n",
+ "\n",
+ "SPA-xlm-longformer 100%[===================>] 3.32G 40.1MB/s in 85s \n",
+ "\n",
+ "2025-02-12 03:06:50 (40.1 MB/s) - ‘SPA-xlm-longformer’ saved [3563459222/3563459222]\n",
+ "\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import os\n",
+ "model = AutoModelCRF(model_args.model_path).to(device)\n",
+ "tokenizer = AutoTokenizer.from_pretrained(model_args.model_path)\n",
+ "checkpoint = torch.load('SPA-xlm-longformer')\n",
+ "model.load_state_dict(checkpoint['model_state_dict'])\n",
+ "model.eval()\n",
+ "test_sets = []\n",
+ "for test_file in data_args.test_files:\n",
+ " test_set = Semeval_Data(test_file, model_args.model_path, max_length=training_args.max_length, inference=True)\n",
+ " test_dataloader = DataLoader(test_set, batch_size=training_args.per_device_eval_batch_size, shuffle=False)\n",
+ " test_sets.append(test_dataloader)\n",
+ "logger.info(\"Predicting...\")\n",
+ "logger.info(\"*** Test Datasets ***\")\n",
+ "logger.info(f\"Number of sets: {len(test_sets)}\")\n",
+ "for idx, test_set in enumerate(test_sets):\n",
+ " logger.info(f\"Test Dataset {idx + 1}\")\n",
+ " logger.info(f\"Number of samples: {len(test_set)}\")\n",
+ " predictions = predict(model, test_set, device)\n",
+ " corresponding_words = []\n",
+ " ids = []\n",
+ " for batch in test_set:\n",
+ " corr_word_tensors = [torch.tensor(cw) for cw in batch['corresponding_word']]\n",
+ " corr_word_padded = torch.nn.utils.rnn.pad_sequence(corr_word_tensors, batch_first=True, padding_value=-100)\n",
+ " corr_word = np.transpose(corr_word_padded.numpy(), (1, 0))\n",
+ " ids.extend(batch[\"id\"])\n",
+ " corresponding_words.extend(corr_word)\n",
+ " corresponding_words = np.array(corresponding_words)\n",
+ " logger.info(\"Predictions completed!\")\n",
+ " df_ids = []\n",
+ " df_labels = []\n",
+ " for id, pred, corr_word in zip(ids, predictions, corresponding_words):\n",
+ " df_ids.append(id)\n",
+ " df_labels.append(get_start_position(pred, corr_word, token_level=False))\n",
+ " df = pd.DataFrame({\"id\": df_ids, \"label\": df_labels})\n",
+ " file_name = os.path.basename(test_file)\n",
+ " file_dirs = os.path.join(training_args.output_dir, \"predictions\")\n",
+ " os.makedirs(file_dirs, exist_ok=True)\n",
+ " file_path = os.path.join(file_dirs, file_name)\n",
+ " records = df.to_dict(\"records\")\n",
+ " with open(file_path, \"w\") as f:\n",
+ " for record in records:\n",
+ " f.write(json.dumps(record) + \"\\n\")"
+ ],
+ "metadata": {
+ "id": "fIMLFzDxrVSA",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "9141c2b2-b76e-4f39-d4fd-3a1182f87e28"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "metadata": {
+ "tags": null
+ },
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "All TF 2.0 model weights were used when initializing LongformerModel.\n",
+ "\n",
+ "All the weights of LongformerModel were initialized from the TF 2.0 model.\n",
+ "If your task is similar to the task the model of the checkpoint was trained on, you can already use LongformerModel for predictions without further training.\n",
+ ":4: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
+ " checkpoint = torch.load('SPA-xlm-longformer')\n",
+ " 0%| | 0/4989 [00:00, ?it/s]/usr/local/lib/python3.11/dist-packages/torchcrf/__init__.py:305: UserWarning: where received a uint8 condition tensor. This behavior is deprecated and will be removed in a future version of PyTorch. Use a boolean condition instead. (Triggered internally at ../aten/src/ATen/native/TensorCompare.cpp:530.)\n",
+ " score = torch.where(mask[i].unsqueeze(1), next_score, score)\n",
+ "100%|██████████| 4989/4989 [1:06:01<00:00, 1.26it/s]\n"
+ ]
+ },
+ {
+ "metadata": {
+ "tags": null
+ },
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(59862, 2048)\n"
+ ]
+ },
+ {
+ "metadata": {
+ "tags": null
+ },
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ ":22: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
+ " corr_word_tensors = [torch.tensor(cw) for cw in batch['corresponding_word']]\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!pip install jsonlines\n",
+ "import pandas as pd\n",
+ "import jsonlines\n",
+ "jsonl_file_path = '/content/runs/exp_seed/predictions/SPA_test.jsonl'\n",
+ "def display_jsonl_as_dataframe(file_path):\n",
+ " data = []\n",
+ " with jsonlines.open(file_path) as reader:\n",
+ " for obj in reader:\n",
+ " data.append(obj)\n",
+ " df = pd.DataFrame(data)\n",
+ " return df\n",
+ "jsonl_df = display_jsonl_as_dataframe(jsonl_file_path)\n",
+ "jsonl_df"
+ ],
+ "metadata": {
+ "id": "yutpCG-Drcjn"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "jsonl_file_path = '/content/SPA_test.jsonl'\n",
+ "def display_jsonl_as_dataframe(file_path):\n",
+ " data = []\n",
+ " with jsonlines.open(file_path) as reader:\n",
+ " for obj in reader:\n",
+ " data.append(obj)\n",
+ " df = pd.DataFrame(data)\n",
+ " return df\n",
+ "jsonl_df_gold = display_jsonl_as_dataframe(jsonl_file_path)\n",
+ "jsonl_df_gold"
+ ],
+ "metadata": {
+ "id": "nLm2KGliriEN"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "jsonl_df = jsonl_df.rename(columns={'label': 'label_pred'})\n",
+ "jsonl_df_gold = jsonl_df_gold.rename(columns={'label': 'label_gold'})\n",
+ "merged_df = pd.merge(jsonl_df[['id', 'label_pred']], jsonl_df_gold[['id','text','label_gold']], on='id')\n",
+ "merged_df"
+ ],
+ "metadata": {
+ "id": "wFmwSZsirsFY"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "merged_df['diff'] = (merged_df['label_pred'] - merged_df['label_gold']).abs()\n",
+ "merged_df"
+ ],
+ "metadata": {
+ "id": "Lh8HQBtIrvFx"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "merged_df['id'] = merged_df['id'].str[3:].astype(int)\n",
+ "merged_df"
+ ],
+ "metadata": {
+ "id": "zZf3ctI2rwvS"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "merged_df = SPA_test.merge(merged_df, left_index=True, right_on='id', how='outer')\n",
+ "merged_df"
+ ],
+ "metadata": {
+ "id": "yzQw_jhDr1-E"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df = merged_df.copy()\n",
+ "tokenizer = AutoTokenizer.from_pretrained(\"hyperonym/xlm-roberta-longformer-base-16384\") # USE SAME TOKENIZER AS USED IN TRAINING\n",
+ "def check_split_position(row):\n",
+ " text = row['Modified text']\n",
+ " words = text.split()\n",
+ " cumulative_tokens = 0\n",
+ " for i in range(row['Split Location']): # Assuming Split Location is 1-based index\n",
+ " tokens = tokenizer.tokenize(words[i])\n",
+ " cumulative_tokens += len(tokens)\n",
+ " if cumulative_tokens > 2048: # Check if we've already passed 2048 tokens\n",
+ " return \"Outside\"\n",
+ " return \"Inside\"\n",
+ "df['Token Limit Check'] = df.apply(check_split_position, axis=1)\n",
+ "df"
+ ],
+ "metadata": {
+ "id": "n3EtjBRXr53j"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df['Token Limit Check'].value_counts()"
+ ],
+ "metadata": {
+ "id": "gWfUnO17r8zb"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df['Split Location'].max()"
+ ],
+ "metadata": {
+ "id": "HdNmbX6yr_Lv"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# prompt: 2 new columns in df_demo as series/list of zeroes and ones : WORDS_REAL : length is row's Word Count, start with row's Split Location number of zeroes and end with ones : WORDS_PRED : lenght is rows' Word Count , start with row's label_pred number of zeroes and end wit ones\n",
+ "def create_word_series(row, column_name):\n",
+ " word_count = row['New Word Count']\n",
+ " split_location = row[column_name]\n",
+ " series = [0] * split_location + [1] * (word_count - split_location)\n",
+ " return series\n",
+ "df['WORDS_REAL'] = df.apply(create_word_series, axis=1, args=('Split Location',))\n",
+ "df['WORDS_PRED'] = df.apply(create_word_series, axis=1, args=('label_pred',))\n",
+ "df"
+ ],
+ "metadata": {
+ "id": "R6waU4p-sCcV"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# prompt: 4 new columns : ROW_TP, ROW_FP, ROW_TN , ROW_FN : based on zeroes and ones in WORDS_PRED , WORDS_REAL . note : lenght of series is diff in each row\n",
+ "def calculate_metrics(row):\n",
+ " tp = 0\n",
+ " fp = 0\n",
+ " tn = 0\n",
+ " fn = 0\n",
+ " for i in range(len(row['WORDS_REAL'])):\n",
+ " if row['WORDS_REAL'][i] == 1 and row['WORDS_PRED'][i] == 1:\n",
+ " tp += 1\n",
+ " elif row['WORDS_REAL'][i] == 0 and row['WORDS_PRED'][i] == 1:\n",
+ " fp += 1\n",
+ " elif row['WORDS_REAL'][i] == 0 and row['WORDS_PRED'][i] == 0:\n",
+ " tn += 1\n",
+ " elif row['WORDS_REAL'][i] == 1 and row['WORDS_PRED'][i] == 0:\n",
+ " fn += 1\n",
+ " return tp, fp, tn, fn\n",
+ "df[['ROW_TP', 'ROW_FP', 'ROW_TN', 'ROW_FN']] = df.apply(calculate_metrics, axis=1, result_type='expand')\n",
+ "df"
+ ],
+ "metadata": {
+ "id": "WI83u4mjsEvy"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# prompt: 4 new column : ROW_ACC , ROW_PREC , ROW_REC , ROW_F1 based on ROW_TN,ROW_TP,ROW_FN,ROW_FP\n",
+ "def calculate_row_metrics(row):\n",
+ " tp = row['ROW_TP']\n",
+ " fp = row['ROW_FP']\n",
+ " tn = row['ROW_TN']\n",
+ " fn = row['ROW_FN']\n",
+ " if (tp + tn + fp + fn) == 0:\n",
+ " accuracy = 0\n",
+ " else:\n",
+ " accuracy = (tp + tn) / (tp + tn + fp + fn)\n",
+ " if (tp + fp) == 0:\n",
+ " precision = 0\n",
+ " else:\n",
+ " precision = tp / (tp + fp)\n",
+ " if (tp + fn) == 0:\n",
+ " recall = 0\n",
+ " else:\n",
+ " recall = tp / (tp + fn)\n",
+ " if (precision + recall) == 0:\n",
+ " f1_score = 0\n",
+ " else:\n",
+ " f1_score = 2 * (precision * recall) / (precision + recall)\n",
+ " return accuracy, precision, recall, f1_score\n",
+ "df[['ROW_ACC', 'ROW_PREC', 'ROW_REC', 'ROW_F1']] = df.apply(calculate_row_metrics, axis=1, result_type='expand')\n",
+ "df"
+ ],
+ "metadata": {
+ "id": "6PnV_NwCsJNG",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 614
+ },
+ "outputId": "8a24d645-bf50-4531-cb84-8fcef0d3d206"
+ },
+ "execution_count": 37,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " ISO LLM used Type Data Split \\\n",
+ "0 SPA PPLX-Sonar-Large Partial Test \n",
+ "1 SPA Amazon-Nova-Pro-1.0 Unchanged Test \n",
+ "2 SPA GPT-4o Partial Test \n",
+ "3 SPA Command-R-Plus Partial Test \n",
+ "4 SPA Gemini-Pro-1.5 Rewritten Test \n",
+ "... ... ... ... ... \n",
+ "59857 SPA PPLX-Sonar-Large Partial Test \n",
+ "59858 SPA Amazon-Nova-Pro-1.0 Unchanged Test \n",
+ "59859 SPA Claude-Sonnet-3.5 Partial Test \n",
+ "59860 SPA Claude-Sonnet-3.5 Partial Test \n",
+ "59861 SPA Amazon-Nova-Pro-1.0 Rewritten Test \n",
+ "\n",
+ " Original text Original Word Count \\\n",
+ "0 Bendodo destacó que a la actual situación polí... 80 \n",
+ "1 Se espera que este sábado Rousseff pronuncie d... 68 \n",
+ "2 La mujer accedió de forma irregular a los regi... 68 \n",
+ "3 'Es muy difícil predecir, pero hemos visto una... 55 \n",
+ "4 Pues bien, Chepuya ya tiene su video, el cual ... 41 \n",
+ "... ... ... \n",
+ "59857 Pin Arboledas considera que se necesita «otra ... 84 \n",
+ "59858 A ver si lo entiendes, si me avisas con varios... 41 \n",
+ "59859 En Táchira se produjeron enfrentamientos. En e... 438 \n",
+ "59860 Duque anunció que los militares se 'mantendrán... 462 \n",
+ "59861 El miércoles, mientras Barack Obama celebraba ... 135 \n",
+ "\n",
+ " Original Char Count Split Location \\\n",
+ "0 508 29 \n",
+ "1 399 68 \n",
+ "2 361 21 \n",
+ "3 329 21 \n",
+ "4 250 0 \n",
+ "... ... ... \n",
+ "59857 507 41 \n",
+ "59858 223 41 \n",
+ "59859 2805 296 \n",
+ "59860 2996 304 \n",
+ "59861 810 0 \n",
+ "\n",
+ " Modified text New Word Count ... \\\n",
+ "0 Bendodo destacó que a la actual situación polí... 184 ... \n",
+ "1 Se espera que este sábado Rousseff pronuncie d... 68 ... \n",
+ "2 La mujer accedió de forma irregular a los regi... 81 ... \n",
+ "3 'Es muy difícil predecir, pero hemos visto una... 81 ... \n",
+ "4 Actualización: El video de Chepuya, dirigido y... 64 ... \n",
+ "... ... ... ... \n",
+ "59857 Pin Arboledas considera que se necesita «otra ... 202 ... \n",
+ "59858 A ver si lo entiendes, si me avisas con varios... 41 ... \n",
+ "59859 En Táchira se produjeron enfrentamientos. En e... 380 ... \n",
+ "59860 Duque anunció que los militares se 'mantendrán... 386 ... \n",
+ "59861 Jueves: Mientras Barack Obama continúa consoli... 135 ... \n",
+ "\n",
+ " ROW_TP ROW_FP ROW_TN ROW_FN ROW_ACC ROW_PREC ROW_REC ROW_F1 \\\n",
+ "0 152 0 29 3 0.983696 1.000000 0.980645 0.990228 \n",
+ "1 0 68 0 0 0.000000 0.000000 0.000000 0.000000 \n",
+ "2 60 0 21 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "3 60 0 21 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "4 64 0 0 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "... ... ... ... ... ... ... ... ... \n",
+ "59857 161 1 40 0 0.995050 0.993827 1.000000 0.996904 \n",
+ "59858 0 1 40 0 0.975610 0.000000 0.000000 0.000000 \n",
+ "59859 84 0 296 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "59860 82 156 148 0 0.595855 0.344538 1.000000 0.512500 \n",
+ "59861 135 0 0 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "\n",
+ " Label : 1 Label : 0 \n",
+ "0 0.826087 0.173913 \n",
+ "1 1.000000 0.000000 \n",
+ "2 0.740741 0.259259 \n",
+ "3 0.740741 0.259259 \n",
+ "4 1.000000 0.000000 \n",
+ "... ... ... \n",
+ "59857 0.801980 0.198020 \n",
+ "59858 0.024390 0.975610 \n",
+ "59859 0.221053 0.778947 \n",
+ "59860 0.616580 0.383420 \n",
+ "59861 1.000000 0.000000 \n",
+ "\n",
+ "[59862 rows x 29 columns]"
+ ],
+ "text/html": [
+ "\n",
+ " \n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " ISO | \n",
+ " LLM used | \n",
+ " Type | \n",
+ " Data Split | \n",
+ " Original text | \n",
+ " Original Word Count | \n",
+ " Original Char Count | \n",
+ " Split Location | \n",
+ " Modified text | \n",
+ " New Word Count | \n",
+ " ... | \n",
+ " ROW_TP | \n",
+ " ROW_FP | \n",
+ " ROW_TN | \n",
+ " ROW_FN | \n",
+ " ROW_ACC | \n",
+ " ROW_PREC | \n",
+ " ROW_REC | \n",
+ " ROW_F1 | \n",
+ " Label : 1 | \n",
+ " Label : 0 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " SPA | \n",
+ " PPLX-Sonar-Large | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Bendodo destacó que a la actual situación polí... | \n",
+ " 80 | \n",
+ " 508 | \n",
+ " 29 | \n",
+ " Bendodo destacó que a la actual situación polí... | \n",
+ " 184 | \n",
+ " ... | \n",
+ " 152 | \n",
+ " 0 | \n",
+ " 29 | \n",
+ " 3 | \n",
+ " 0.983696 | \n",
+ " 1.000000 | \n",
+ " 0.980645 | \n",
+ " 0.990228 | \n",
+ " 0.826087 | \n",
+ " 0.173913 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Unchanged | \n",
+ " Test | \n",
+ " Se espera que este sábado Rousseff pronuncie d... | \n",
+ " 68 | \n",
+ " 399 | \n",
+ " 68 | \n",
+ " Se espera que este sábado Rousseff pronuncie d... | \n",
+ " 68 | \n",
+ " ... | \n",
+ " 0 | \n",
+ " 68 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " SPA | \n",
+ " GPT-4o | \n",
+ " Partial | \n",
+ " Test | \n",
+ " La mujer accedió de forma irregular a los regi... | \n",
+ " 68 | \n",
+ " 361 | \n",
+ " 21 | \n",
+ " La mujer accedió de forma irregular a los regi... | \n",
+ " 81 | \n",
+ " ... | \n",
+ " 60 | \n",
+ " 0 | \n",
+ " 21 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.740741 | \n",
+ " 0.259259 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " SPA | \n",
+ " Command-R-Plus | \n",
+ " Partial | \n",
+ " Test | \n",
+ " 'Es muy difícil predecir, pero hemos visto una... | \n",
+ " 55 | \n",
+ " 329 | \n",
+ " 21 | \n",
+ " 'Es muy difícil predecir, pero hemos visto una... | \n",
+ " 81 | \n",
+ " ... | \n",
+ " 60 | \n",
+ " 0 | \n",
+ " 21 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.740741 | \n",
+ " 0.259259 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " SPA | \n",
+ " Gemini-Pro-1.5 | \n",
+ " Rewritten | \n",
+ " Test | \n",
+ " Pues bien, Chepuya ya tiene su video, el cual ... | \n",
+ " 41 | \n",
+ " 250 | \n",
+ " 0 | \n",
+ " Actualización: El video de Chepuya, dirigido y... | \n",
+ " 64 | \n",
+ " ... | \n",
+ " 64 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 59857 | \n",
+ " SPA | \n",
+ " PPLX-Sonar-Large | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Pin Arboledas considera que se necesita «otra ... | \n",
+ " 84 | \n",
+ " 507 | \n",
+ " 41 | \n",
+ " Pin Arboledas considera que se necesita «otra ... | \n",
+ " 202 | \n",
+ " ... | \n",
+ " 161 | \n",
+ " 1 | \n",
+ " 40 | \n",
+ " 0 | \n",
+ " 0.995050 | \n",
+ " 0.993827 | \n",
+ " 1.000000 | \n",
+ " 0.996904 | \n",
+ " 0.801980 | \n",
+ " 0.198020 | \n",
+ "
\n",
+ " \n",
+ " | 59858 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Unchanged | \n",
+ " Test | \n",
+ " A ver si lo entiendes, si me avisas con varios... | \n",
+ " 41 | \n",
+ " 223 | \n",
+ " 41 | \n",
+ " A ver si lo entiendes, si me avisas con varios... | \n",
+ " 41 | \n",
+ " ... | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 40 | \n",
+ " 0 | \n",
+ " 0.975610 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.024390 | \n",
+ " 0.975610 | \n",
+ "
\n",
+ " \n",
+ " | 59859 | \n",
+ " SPA | \n",
+ " Claude-Sonnet-3.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " En Táchira se produjeron enfrentamientos. En e... | \n",
+ " 438 | \n",
+ " 2805 | \n",
+ " 296 | \n",
+ " En Táchira se produjeron enfrentamientos. En e... | \n",
+ " 380 | \n",
+ " ... | \n",
+ " 84 | \n",
+ " 0 | \n",
+ " 296 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.221053 | \n",
+ " 0.778947 | \n",
+ "
\n",
+ " \n",
+ " | 59860 | \n",
+ " SPA | \n",
+ " Claude-Sonnet-3.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Duque anunció que los militares se 'mantendrán... | \n",
+ " 462 | \n",
+ " 2996 | \n",
+ " 304 | \n",
+ " Duque anunció que los militares se 'mantendrán... | \n",
+ " 386 | \n",
+ " ... | \n",
+ " 82 | \n",
+ " 156 | \n",
+ " 148 | \n",
+ " 0 | \n",
+ " 0.595855 | \n",
+ " 0.344538 | \n",
+ " 1.000000 | \n",
+ " 0.512500 | \n",
+ " 0.616580 | \n",
+ " 0.383420 | \n",
+ "
\n",
+ " \n",
+ " | 59861 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Rewritten | \n",
+ " Test | \n",
+ " El miércoles, mientras Barack Obama celebraba ... | \n",
+ " 135 | \n",
+ " 810 | \n",
+ " 0 | \n",
+ " Jueves: Mientras Barack Obama continúa consoli... | \n",
+ " 135 | \n",
+ " ... | \n",
+ " 135 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
59862 rows × 29 columns
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "dataframe",
+ "variable_name": "df"
+ }
+ },
+ "metadata": {},
+ "execution_count": 37
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "def calculate_percentage_of_ones(row):\n",
+ " series = row['WORDS_PRED']\n",
+ " if len(series) == 0:\n",
+ " return 0\n",
+ " else:\n",
+ " return sum(series) / len(series)\n",
+ "df[\"Label : 1\"] = df.apply(calculate_percentage_of_ones, axis=1)\n",
+ "df[\"Label : 0\"] = 1.0 - df[\"Label : 1\"]\n",
+ "df"
+ ],
+ "metadata": {
+ "id": "Yp3FO_HVsLiA",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 614
+ },
+ "outputId": "d136c653-bb8b-4372-a975-309179d0dfce"
+ },
+ "execution_count": 38,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " ISO LLM used Type Data Split \\\n",
+ "0 SPA PPLX-Sonar-Large Partial Test \n",
+ "1 SPA Amazon-Nova-Pro-1.0 Unchanged Test \n",
+ "2 SPA GPT-4o Partial Test \n",
+ "3 SPA Command-R-Plus Partial Test \n",
+ "4 SPA Gemini-Pro-1.5 Rewritten Test \n",
+ "... ... ... ... ... \n",
+ "59857 SPA PPLX-Sonar-Large Partial Test \n",
+ "59858 SPA Amazon-Nova-Pro-1.0 Unchanged Test \n",
+ "59859 SPA Claude-Sonnet-3.5 Partial Test \n",
+ "59860 SPA Claude-Sonnet-3.5 Partial Test \n",
+ "59861 SPA Amazon-Nova-Pro-1.0 Rewritten Test \n",
+ "\n",
+ " Original text Original Word Count \\\n",
+ "0 Bendodo destacó que a la actual situación polí... 80 \n",
+ "1 Se espera que este sábado Rousseff pronuncie d... 68 \n",
+ "2 La mujer accedió de forma irregular a los regi... 68 \n",
+ "3 'Es muy difícil predecir, pero hemos visto una... 55 \n",
+ "4 Pues bien, Chepuya ya tiene su video, el cual ... 41 \n",
+ "... ... ... \n",
+ "59857 Pin Arboledas considera que se necesita «otra ... 84 \n",
+ "59858 A ver si lo entiendes, si me avisas con varios... 41 \n",
+ "59859 En Táchira se produjeron enfrentamientos. En e... 438 \n",
+ "59860 Duque anunció que los militares se 'mantendrán... 462 \n",
+ "59861 El miércoles, mientras Barack Obama celebraba ... 135 \n",
+ "\n",
+ " Original Char Count Split Location \\\n",
+ "0 508 29 \n",
+ "1 399 68 \n",
+ "2 361 21 \n",
+ "3 329 21 \n",
+ "4 250 0 \n",
+ "... ... ... \n",
+ "59857 507 41 \n",
+ "59858 223 41 \n",
+ "59859 2805 296 \n",
+ "59860 2996 304 \n",
+ "59861 810 0 \n",
+ "\n",
+ " Modified text New Word Count ... \\\n",
+ "0 Bendodo destacó que a la actual situación polí... 184 ... \n",
+ "1 Se espera que este sábado Rousseff pronuncie d... 68 ... \n",
+ "2 La mujer accedió de forma irregular a los regi... 81 ... \n",
+ "3 'Es muy difícil predecir, pero hemos visto una... 81 ... \n",
+ "4 Actualización: El video de Chepuya, dirigido y... 64 ... \n",
+ "... ... ... ... \n",
+ "59857 Pin Arboledas considera que se necesita «otra ... 202 ... \n",
+ "59858 A ver si lo entiendes, si me avisas con varios... 41 ... \n",
+ "59859 En Táchira se produjeron enfrentamientos. En e... 380 ... \n",
+ "59860 Duque anunció que los militares se 'mantendrán... 386 ... \n",
+ "59861 Jueves: Mientras Barack Obama continúa consoli... 135 ... \n",
+ "\n",
+ " ROW_TP ROW_FP ROW_TN ROW_FN ROW_ACC ROW_PREC ROW_REC ROW_F1 \\\n",
+ "0 152 0 29 3 0.983696 1.000000 0.980645 0.990228 \n",
+ "1 0 68 0 0 0.000000 0.000000 0.000000 0.000000 \n",
+ "2 60 0 21 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "3 60 0 21 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "4 64 0 0 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "... ... ... ... ... ... ... ... ... \n",
+ "59857 161 1 40 0 0.995050 0.993827 1.000000 0.996904 \n",
+ "59858 0 1 40 0 0.975610 0.000000 0.000000 0.000000 \n",
+ "59859 84 0 296 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "59860 82 156 148 0 0.595855 0.344538 1.000000 0.512500 \n",
+ "59861 135 0 0 0 1.000000 1.000000 1.000000 1.000000 \n",
+ "\n",
+ " Label : 1 Label : 0 \n",
+ "0 0.826087 0.173913 \n",
+ "1 1.000000 0.000000 \n",
+ "2 0.740741 0.259259 \n",
+ "3 0.740741 0.259259 \n",
+ "4 1.000000 0.000000 \n",
+ "... ... ... \n",
+ "59857 0.801980 0.198020 \n",
+ "59858 0.024390 0.975610 \n",
+ "59859 0.221053 0.778947 \n",
+ "59860 0.616580 0.383420 \n",
+ "59861 1.000000 0.000000 \n",
+ "\n",
+ "[59862 rows x 29 columns]"
+ ],
+ "text/html": [
+ "\n",
+ " \n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " ISO | \n",
+ " LLM used | \n",
+ " Type | \n",
+ " Data Split | \n",
+ " Original text | \n",
+ " Original Word Count | \n",
+ " Original Char Count | \n",
+ " Split Location | \n",
+ " Modified text | \n",
+ " New Word Count | \n",
+ " ... | \n",
+ " ROW_TP | \n",
+ " ROW_FP | \n",
+ " ROW_TN | \n",
+ " ROW_FN | \n",
+ " ROW_ACC | \n",
+ " ROW_PREC | \n",
+ " ROW_REC | \n",
+ " ROW_F1 | \n",
+ " Label : 1 | \n",
+ " Label : 0 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " SPA | \n",
+ " PPLX-Sonar-Large | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Bendodo destacó que a la actual situación polí... | \n",
+ " 80 | \n",
+ " 508 | \n",
+ " 29 | \n",
+ " Bendodo destacó que a la actual situación polí... | \n",
+ " 184 | \n",
+ " ... | \n",
+ " 152 | \n",
+ " 0 | \n",
+ " 29 | \n",
+ " 3 | \n",
+ " 0.983696 | \n",
+ " 1.000000 | \n",
+ " 0.980645 | \n",
+ " 0.990228 | \n",
+ " 0.826087 | \n",
+ " 0.173913 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Unchanged | \n",
+ " Test | \n",
+ " Se espera que este sábado Rousseff pronuncie d... | \n",
+ " 68 | \n",
+ " 399 | \n",
+ " 68 | \n",
+ " Se espera que este sábado Rousseff pronuncie d... | \n",
+ " 68 | \n",
+ " ... | \n",
+ " 0 | \n",
+ " 68 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " SPA | \n",
+ " GPT-4o | \n",
+ " Partial | \n",
+ " Test | \n",
+ " La mujer accedió de forma irregular a los regi... | \n",
+ " 68 | \n",
+ " 361 | \n",
+ " 21 | \n",
+ " La mujer accedió de forma irregular a los regi... | \n",
+ " 81 | \n",
+ " ... | \n",
+ " 60 | \n",
+ " 0 | \n",
+ " 21 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.740741 | \n",
+ " 0.259259 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " SPA | \n",
+ " Command-R-Plus | \n",
+ " Partial | \n",
+ " Test | \n",
+ " 'Es muy difícil predecir, pero hemos visto una... | \n",
+ " 55 | \n",
+ " 329 | \n",
+ " 21 | \n",
+ " 'Es muy difícil predecir, pero hemos visto una... | \n",
+ " 81 | \n",
+ " ... | \n",
+ " 60 | \n",
+ " 0 | \n",
+ " 21 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.740741 | \n",
+ " 0.259259 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " SPA | \n",
+ " Gemini-Pro-1.5 | \n",
+ " Rewritten | \n",
+ " Test | \n",
+ " Pues bien, Chepuya ya tiene su video, el cual ... | \n",
+ " 41 | \n",
+ " 250 | \n",
+ " 0 | \n",
+ " Actualización: El video de Chepuya, dirigido y... | \n",
+ " 64 | \n",
+ " ... | \n",
+ " 64 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 59857 | \n",
+ " SPA | \n",
+ " PPLX-Sonar-Large | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Pin Arboledas considera que se necesita «otra ... | \n",
+ " 84 | \n",
+ " 507 | \n",
+ " 41 | \n",
+ " Pin Arboledas considera que se necesita «otra ... | \n",
+ " 202 | \n",
+ " ... | \n",
+ " 161 | \n",
+ " 1 | \n",
+ " 40 | \n",
+ " 0 | \n",
+ " 0.995050 | \n",
+ " 0.993827 | \n",
+ " 1.000000 | \n",
+ " 0.996904 | \n",
+ " 0.801980 | \n",
+ " 0.198020 | \n",
+ "
\n",
+ " \n",
+ " | 59858 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Unchanged | \n",
+ " Test | \n",
+ " A ver si lo entiendes, si me avisas con varios... | \n",
+ " 41 | \n",
+ " 223 | \n",
+ " 41 | \n",
+ " A ver si lo entiendes, si me avisas con varios... | \n",
+ " 41 | \n",
+ " ... | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 40 | \n",
+ " 0 | \n",
+ " 0.975610 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.000000 | \n",
+ " 0.024390 | \n",
+ " 0.975610 | \n",
+ "
\n",
+ " \n",
+ " | 59859 | \n",
+ " SPA | \n",
+ " Claude-Sonnet-3.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " En Táchira se produjeron enfrentamientos. En e... | \n",
+ " 438 | \n",
+ " 2805 | \n",
+ " 296 | \n",
+ " En Táchira se produjeron enfrentamientos. En e... | \n",
+ " 380 | \n",
+ " ... | \n",
+ " 84 | \n",
+ " 0 | \n",
+ " 296 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.221053 | \n",
+ " 0.778947 | \n",
+ "
\n",
+ " \n",
+ " | 59860 | \n",
+ " SPA | \n",
+ " Claude-Sonnet-3.5 | \n",
+ " Partial | \n",
+ " Test | \n",
+ " Duque anunció que los militares se 'mantendrán... | \n",
+ " 462 | \n",
+ " 2996 | \n",
+ " 304 | \n",
+ " Duque anunció que los militares se 'mantendrán... | \n",
+ " 386 | \n",
+ " ... | \n",
+ " 82 | \n",
+ " 156 | \n",
+ " 148 | \n",
+ " 0 | \n",
+ " 0.595855 | \n",
+ " 0.344538 | \n",
+ " 1.000000 | \n",
+ " 0.512500 | \n",
+ " 0.616580 | \n",
+ " 0.383420 | \n",
+ "
\n",
+ " \n",
+ " | 59861 | \n",
+ " SPA | \n",
+ " Amazon-Nova-Pro-1.0 | \n",
+ " Rewritten | \n",
+ " Test | \n",
+ " El miércoles, mientras Barack Obama celebraba ... | \n",
+ " 135 | \n",
+ " 810 | \n",
+ " 0 | \n",
+ " Jueves: Mientras Barack Obama continúa consoli... | \n",
+ " 135 | \n",
+ " ... | \n",
+ " 135 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
59862 rows × 29 columns
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "dataframe",
+ "variable_name": "df"
+ }
+ },
+ "metadata": {},
+ "execution_count": 38
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df_unchanged = df[df['Type'] == 'Unchanged']\n",
+ "df_rewritten = df[df['Type'] == 'Rewritten']\n",
+ "df_partial = df[df['Type'] == 'Partial']\n",
+ "print(\"######################################\")\n",
+ "print(\" METRICS BY TEXT TYPE : \")\n",
+ "print(\"######################################\")\n",
+ "AVG_ACC = df_partial['ROW_ACC'].mean()\n",
+ "AVG_PREC = df_partial['ROW_PREC'].mean()\n",
+ "AVG_REC = df_partial['ROW_REC'].mean()\n",
+ "AVG_F1 = df_partial['ROW_F1'].mean()\n",
+ "print(\"Partial Cases : Average Accuracy : \" , AVG_ACC )\n",
+ "print(\"Partial Cases : Average Precision : \" , AVG_PREC)\n",
+ "print(\"Partial Cases : Average Recall : \" , AVG_REC )\n",
+ "print(\"Partial Cases : Average F1-score : \" , AVG_F1 )\n",
+ "AVG_ACC = df_unchanged['ROW_ACC'].mean()\n",
+ "AVG_PREC = df_unchanged['ROW_PREC'].mean()\n",
+ "AVG_REC = df_unchanged['ROW_REC'].mean()\n",
+ "AVG_F1 = df_unchanged['ROW_F1'].mean()\n",
+ "print(\"Unchanged Cases : Average Accuracy : \" , AVG_ACC )\n",
+ "print(\"Unchanged Cases : Average Precision : \" , AVG_PREC)\n",
+ "print(\"Unchanged Cases : Average Recall : \" , AVG_REC )\n",
+ "print(\"Unchanged Cases : Average F1-score : \" , AVG_F1 )\n",
+ "AVG_ACC = df_rewritten['ROW_ACC'].mean()\n",
+ "AVG_PREC = df_rewritten['ROW_PREC'].mean()\n",
+ "AVG_REC = df_rewritten['ROW_REC'].mean()\n",
+ "AVG_F1 = df_rewritten['ROW_F1'].mean()\n",
+ "print(\"Rewritten Cases : Average Accuracy : \" , AVG_ACC )\n",
+ "print(\"Rewritten Cases : Average Precision : \" , AVG_PREC)\n",
+ "print(\"Rewritten Cases : Average Recall : \" , AVG_REC )\n",
+ "print(\"Rewritten Cases : Average F1-score : \" , AVG_F1 )\n",
+ "print(\"######################################\")\n",
+ "print(\" METRICS OVERALL : \")\n",
+ "print(\"######################################\")\n",
+ "# prompt: print AVG_ACC, AVG_PREC , AVG_REC , AVG_F1 as mean of values in columns ROW_ACC , ROW_REC , ROW_PREC , ROW_F1 from dataframe df\n",
+ "AVG_ACC = df['ROW_ACC'].mean()\n",
+ "AVG_PREC = df['ROW_PREC'].mean()\n",
+ "AVG_REC = df['ROW_REC'].mean()\n",
+ "AVG_F1 = df['ROW_F1'].mean()\n",
+ "print(\"All Cases : Average Accuracy:\", AVG_ACC)\n",
+ "print(\"All Cases : Average Precision:\", AVG_PREC)\n",
+ "print(\"All Cases : Average Recall:\", AVG_REC)\n",
+ "print(\"All Cases : Average F1-score:\", AVG_F1)\n",
+ "print(\"######################################\")\n",
+ "# prompt: Also print overall ACC,PREC,REC,F1 based on values of columns ROW_TN,ROW_TP,ROW_FN,ROW_FP\n",
+ "total_tp = df['ROW_TP'].sum()\n",
+ "total_fp = df['ROW_FP'].sum()\n",
+ "total_tn = df['ROW_TN'].sum()\n",
+ "total_fn = df['ROW_FN'].sum()\n",
+ "if (total_tp + total_tn + total_fp + total_fn) == 0:\n",
+ " accuracy = 0\n",
+ "else:\n",
+ " accuracy = (total_tp + total_tn) / (total_tp + total_tn + total_fp + total_fn)\n",
+ "if (total_tp + total_fp) == 0:\n",
+ " precision = 0\n",
+ "else:\n",
+ " precision = total_tp / (total_tp + total_fp)\n",
+ "if (total_tp + total_fn) == 0:\n",
+ " recall = 0\n",
+ "else:\n",
+ " recall = total_tp / (total_tp + total_fn)\n",
+ "if (precision + recall) == 0:\n",
+ " f1_score = 0\n",
+ "else:\n",
+ " f1_score = 2 * (precision * recall) / (precision + recall)\n",
+ "print(\"Overall Accuracy:\", accuracy)\n",
+ "print(\"Overall Precision:\", precision)\n",
+ "print(\"Overall Recall:\", recall)\n",
+ "print(\"Overall F1-score:\", f1_score)"
+ ],
+ "metadata": {
+ "id": "cuuc9gPjsU_T",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "98173cb3-0ba2-40b8-97be-545480186495"
+ },
+ "execution_count": 34,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "######################################\n",
+ " METRICS BY TEXT TYPE : \n",
+ "######################################\n",
+ "Partial Cases : Average Accuracy : 0.9480135741139243\n",
+ "Partial Cases : Average Precision : 0.9265031674761011\n",
+ "Partial Cases : Average Recall : 0.9907989832189773\n",
+ "Partial Cases : Average F1-score : 0.9444397217138533\n",
+ "Unchanged Cases : Average Accuracy : 0.6048775478461459\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9776854908736639\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9776854908736639\n",
+ "Rewritten Cases : Average F1-score : 0.9849404764979288\n",
+ "######################################\n",
+ " METRICS OVERALL : \n",
+ "######################################\n",
+ "All Cases : Average Accuracy: 0.9163944674341203\n",
+ "All Cases : Average Precision: 0.8404723318372287\n",
+ "All Cases : Average Recall: 0.8897114286279633\n",
+ "All Cases : Average F1-score: 0.8533332250116303\n",
+ "######################################\n",
+ "Overall Accuracy: 0.8786219913394281\n",
+ "Overall Precision: 0.7855302354918241\n",
+ "Overall Recall: 0.9905690139759805\n",
+ "Overall F1-score: 0.8762144469714908\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "llm_values = df['LLM used'].unique()\n",
+ "for llm in llm_values:\n",
+ " print(\"LLM used:\", llm)\n",
+ " df_llm = df[df['LLM used'] == llm]\n",
+ " for text_type in ['Partial', 'Unchanged', 'Rewritten']:\n",
+ " df_subset = df_llm[df_llm['Type'] == text_type]\n",
+ " if df_subset.empty:\n",
+ " continue\n",
+ " avg_acc = df_subset['ROW_ACC'].mean()\n",
+ " avg_prec = df_subset['ROW_PREC'].mean()\n",
+ " avg_rec = df_subset['ROW_REC'].mean()\n",
+ " avg_f1 = df_subset['ROW_F1'].mean()\n",
+ " print(f\"{text_type} Cases : Average Accuracy : {avg_acc}\")\n",
+ " print(f\"{text_type} Cases : Average Precision : {avg_prec}\")\n",
+ " print(f\"{text_type} Cases : Average Recall : {avg_rec}\")\n",
+ " print(f\"{text_type} Cases : Average F1-score : {avg_f1}\")\n",
+ " print(\"######################################\")"
+ ],
+ "metadata": {
+ "id": "9PwzmDF9xJzl",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "ff044e1a-b45f-46c3-d39e-e4bcaeb4a8b0"
+ },
+ "execution_count": 35,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "LLM used: PPLX-Sonar-Large\n",
+ "Partial Cases : Average Accuracy : 0.9329911314727828\n",
+ "Partial Cases : Average Precision : 0.9216561203385422\n",
+ "Partial Cases : Average Recall : 0.9809841964637238\n",
+ "Partial Cases : Average F1-score : 0.938904536867434\n",
+ "Unchanged Cases : Average Accuracy : 0.6167079730325277\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9990847448172787\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9990847448172787\n",
+ "Rewritten Cases : Average F1-score : 0.9995025685940441\n",
+ "######################################\n",
+ "LLM used: Amazon-Nova-Pro-1.0\n",
+ "Partial Cases : Average Accuracy : 0.9514380829275699\n",
+ "Partial Cases : Average Precision : 0.932222224304805\n",
+ "Partial Cases : Average Recall : 0.9946543848118379\n",
+ "Partial Cases : Average F1-score : 0.9534378540991558\n",
+ "Unchanged Cases : Average Accuracy : 0.6035378960763924\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9801605075197923\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9801605075197923\n",
+ "Rewritten Cases : Average F1-score : 0.9861447651965538\n",
+ "######################################\n",
+ "LLM used: GPT-4o\n",
+ "Partial Cases : Average Accuracy : 0.9164054607349822\n",
+ "Partial Cases : Average Precision : 0.8771606744897349\n",
+ "Partial Cases : Average Recall : 0.985758784847983\n",
+ "Partial Cases : Average F1-score : 0.9117643961658807\n",
+ "Unchanged Cases : Average Accuracy : 0.6011609263542105\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9395769223745478\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9395769223745478\n",
+ "Rewritten Cases : Average F1-score : 0.9575390460837993\n",
+ "######################################\n",
+ "LLM used: Command-R-Plus\n",
+ "Partial Cases : Average Accuracy : 0.9618744085146932\n",
+ "Partial Cases : Average Precision : 0.9530353404857457\n",
+ "Partial Cases : Average Recall : 0.9934669651394302\n",
+ "Partial Cases : Average F1-score : 0.9666560366693671\n",
+ "Unchanged Cases : Average Accuracy : 0.6112534639385996\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9848192949369747\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9848192949369747\n",
+ "Rewritten Cases : Average F1-score : 0.9910505487800161\n",
+ "######################################\n",
+ "LLM used: Gemini-Pro-1.5\n",
+ "Partial Cases : Average Accuracy : 0.9256046842442286\n",
+ "Partial Cases : Average Precision : 0.893076175475127\n",
+ "Partial Cases : Average Recall : 0.987961187237944\n",
+ "Partial Cases : Average F1-score : 0.9148358882126914\n",
+ "Unchanged Cases : Average Accuracy : 0.6327106304413165\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9951443231357987\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9951443231357987\n",
+ "Rewritten Cases : Average F1-score : 0.9958858744822964\n",
+ "######################################\n",
+ "LLM used: Amazon-Nova-Lite-1.0\n",
+ "Partial Cases : Average Accuracy : 0.9624864875838155\n",
+ "Partial Cases : Average Precision : 0.9526623165711376\n",
+ "Partial Cases : Average Recall : 0.992074672397983\n",
+ "Partial Cases : Average F1-score : 0.9646743590784106\n",
+ "Unchanged Cases : Average Accuracy : 0.6094423196859707\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9838076327937956\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9838076327937956\n",
+ "Rewritten Cases : Average F1-score : 0.9889568404845078\n",
+ "######################################\n",
+ "LLM used: Aya-23\n",
+ "Partial Cases : Average Accuracy : 0.8931057663473119\n",
+ "Partial Cases : Average Precision : 0.8653802979806265\n",
+ "Partial Cases : Average Recall : 0.9709812177566044\n",
+ "Partial Cases : Average F1-score : 0.8905931206215059\n",
+ "Unchanged Cases : Average Accuracy : 0.6069348595051993\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9556844171864266\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9556844171864266\n",
+ "Rewritten Cases : Average F1-score : 0.9733405566952376\n",
+ "######################################\n",
+ "LLM used: Claude-Haiku-3.5\n",
+ "Partial Cases : Average Accuracy : 0.9736609331424448\n",
+ "Partial Cases : Average Precision : 0.9558579325282317\n",
+ "Partial Cases : Average Recall : 0.9983339599552327\n",
+ "Partial Cases : Average F1-score : 0.9643233605390681\n",
+ "Unchanged Cases : Average Accuracy : 0.6154131109278546\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9412343403324779\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9412343403324779\n",
+ "Rewritten Cases : Average F1-score : 0.957423832221833\n",
+ "######################################\n",
+ "LLM used: Claude-Sonnet-3.5\n",
+ "Partial Cases : Average Accuracy : 0.9758616952904872\n",
+ "Partial Cases : Average Precision : 0.9606241699998136\n",
+ "Partial Cases : Average Recall : 0.9986917220142588\n",
+ "Partial Cases : Average F1-score : 0.9689053603761294\n",
+ "Unchanged Cases : Average Accuracy : 0.5987679540865936\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9993025840511254\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9993025840511254\n",
+ "Rewritten Cases : Average F1-score : 0.9996160133444537\n",
+ "######################################\n",
+ "LLM used: GPT-o1\n",
+ "Partial Cases : Average Accuracy : 0.9882121672133931\n",
+ "Partial Cases : Average Precision : 0.9840358008115242\n",
+ "Partial Cases : Average Recall : 0.9966761290972426\n",
+ "Partial Cases : Average F1-score : 0.9893318729364172\n",
+ "Unchanged Cases : Average Accuracy : 0.598518898657254\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9578995344942773\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9578995344942773\n",
+ "Rewritten Cases : Average F1-score : 0.9725994847180799\n",
+ "######################################\n",
+ "LLM used: Gemini-Flash-1.5\n",
+ "Partial Cases : Average Accuracy : 0.9555402517652475\n",
+ "Partial Cases : Average Precision : 0.9237185346606368\n",
+ "Partial Cases : Average Recall : 0.9979587356840902\n",
+ "Partial Cases : Average F1-score : 0.9428788124840521\n",
+ "Unchanged Cases : Average Accuracy : 0.5911862865359713\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9993870967741936\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9993870967741936\n",
+ "Rewritten Cases : Average F1-score : 0.9996380952380953\n",
+ "######################################\n",
+ "LLM used: Mistral-Large-2411\n",
+ "Partial Cases : Average Accuracy : 0.9389038344077513\n",
+ "Partial Cases : Average Precision : 0.8987956049995653\n",
+ "Partial Cases : Average Recall : 0.9919039837186756\n",
+ "Partial Cases : Average F1-score : 0.9270860457858414\n",
+ "Unchanged Cases : Average Accuracy : 0.5730271971808857\n",
+ "Unchanged Cases : Average Precision : 0.0\n",
+ "Unchanged Cases : Average Recall : 0.0\n",
+ "Unchanged Cases : Average F1-score : 0.0\n",
+ "Rewritten Cases : Average Accuracy : 0.9928384816297622\n",
+ "Rewritten Cases : Average Precision : 1.0\n",
+ "Rewritten Cases : Average Recall : 0.9928384816297622\n",
+ "Rewritten Cases : Average F1-score : 0.9951469843329812\n",
+ "######################################\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "llm_values = df['LLM used'].unique()\n",
+ "for llm in llm_values:\n",
+ " print(\"LLM used:\", llm)\n",
+ " df_llm = df[df['LLM used'] == llm]\n",
+ " total_tp = df_llm['ROW_TP'].sum()\n",
+ " total_fp = df_llm['ROW_FP'].sum()\n",
+ " total_tn = df_llm['ROW_TN'].sum()\n",
+ " total_fn = df_llm['ROW_FN'].sum()\n",
+ " if (total_tp + total_tn + total_fp + total_fn) == 0:\n",
+ " accuracy = 0\n",
+ " else:\n",
+ " accuracy = (total_tp + total_tn) / (total_tp + total_tn + total_fp + total_fn)\n",
+ " if (total_tp + total_fp) == 0:\n",
+ " precision = 0\n",
+ " else:\n",
+ " precision = total_tp / (total_tp + total_fp)\n",
+ " if (total_tp + total_fn) == 0:\n",
+ " recall = 0\n",
+ " else:\n",
+ " recall = total_tp / (total_tp + total_fn)\n",
+ " if (precision + recall) == 0:\n",
+ " f1_score = 0\n",
+ " else:\n",
+ " f1_score = 2 * (precision * recall) / (precision + recall)\n",
+ " print(\"Overall Accuracy:\", accuracy)\n",
+ " print(\"Overall Precision:\", precision)\n",
+ " print(\"Overall Recall:\", recall)\n",
+ " print(\"Overall F1-score:\", f1_score)\n",
+ " print(\"######################################\")"
+ ],
+ "metadata": {
+ "id": "02ubnS2dxq1x",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "b148a808-848b-445b-e889-70eb606b1bf8"
+ },
+ "execution_count": 36,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "LLM used: PPLX-Sonar-Large\n",
+ "Overall Accuracy: 0.8737936118451916\n",
+ "Overall Precision: 0.8042630918449823\n",
+ "Overall Recall: 0.9852293601886473\n",
+ "Overall F1-score: 0.8855959247006469\n",
+ "######################################\n",
+ "LLM used: Amazon-Nova-Pro-1.0\n",
+ "Overall Accuracy: 0.8820035906753493\n",
+ "Overall Precision: 0.8116313575951851\n",
+ "Overall Recall: 0.9934666957999966\n",
+ "Overall F1-score: 0.8933904964565692\n",
+ "######################################\n",
+ "LLM used: GPT-4o\n",
+ "Overall Accuracy: 0.8399398999563633\n",
+ "Overall Precision: 0.6911571647511082\n",
+ "Overall Recall: 0.979672953735665\n",
+ "Overall F1-score: 0.8105048784977908\n",
+ "######################################\n",
+ "LLM used: Command-R-Plus\n",
+ "Overall Accuracy: 0.900196449536563\n",
+ "Overall Precision: 0.8240140051357329\n",
+ "Overall Recall: 0.991684418072407\n",
+ "Overall F1-score: 0.9001074613731364\n",
+ "######################################\n",
+ "LLM used: Gemini-Pro-1.5\n",
+ "Overall Accuracy: 0.8521351155569294\n",
+ "Overall Precision: 0.7269608896201091\n",
+ "Overall Recall: 0.9907053242663633\n",
+ "Overall F1-score: 0.8385843746096473\n",
+ "######################################\n",
+ "LLM used: Amazon-Nova-Lite-1.0\n",
+ "Overall Accuracy: 0.8965333291098415\n",
+ "Overall Precision: 0.843622138372216\n",
+ "Overall Recall: 0.9917552089598118\n",
+ "Overall F1-score: 0.9117107730905254\n",
+ "######################################\n",
+ "LLM used: Aya-23\n",
+ "Overall Accuracy: 0.8522233939111739\n",
+ "Overall Precision: 0.7675751029467742\n",
+ "Overall Recall: 0.9789505539770339\n",
+ "Overall F1-score: 0.8604718393570143\n",
+ "######################################\n",
+ "LLM used: Claude-Haiku-3.5\n",
+ "Overall Accuracy: 0.87443306815432\n",
+ "Overall Precision: 0.7419633667739556\n",
+ "Overall Recall: 0.9916421637164268\n",
+ "Overall F1-score: 0.8488230401733042\n",
+ "######################################\n",
+ "LLM used: Claude-Sonnet-3.5\n",
+ "Overall Accuracy: 0.8933503864016549\n",
+ "Overall Precision: 0.7780082902151587\n",
+ "Overall Recall: 0.9987872318500923\n",
+ "Overall F1-score: 0.8746811176529797\n",
+ "######################################\n",
+ "LLM used: GPT-o1\n",
+ "Overall Accuracy: 0.9420987878609767\n",
+ "Overall Precision: 0.895255001996475\n",
+ "Overall Recall: 0.9939026025821116\n",
+ "Overall F1-score: 0.942003223344022\n",
+ "######################################\n",
+ "LLM used: Gemini-Flash-1.5\n",
+ "Overall Accuracy: 0.8630709669419077\n",
+ "Overall Precision: 0.7351484928960061\n",
+ "Overall Recall: 0.9978833558081295\n",
+ "Overall F1-score: 0.846600073341866\n",
+ "######################################\n",
+ "LLM used: Mistral-Large-2411\n",
+ "Overall Accuracy: 0.8428958303744905\n",
+ "Overall Precision: 0.6966736768513822\n",
+ "Overall Recall: 0.992035860270467\n",
+ "Overall F1-score: 0.8185247434807161\n",
+ "######################################\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.info()"
+ ],
+ "metadata": {
+ "id": "mr8VT4S9whud"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "df.to_csv(\"SPA-INFERENCE-5.csv\")"
+ ],
+ "metadata": {
+ "id": "AEEjGzfkw0le"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "print(\"CLICK CTRL+S, WAIT 2 SEC FOR IT TO BE SAVED, DOWNLOAD BOTH CODE AND THE CSV FILE FROM RUNTIME\")"
+ ],
+ "metadata": {
+ "id": "T6TKnuFjx9ZE"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [],
+ "metadata": {
+ "id": "-4QvATtXJPCT"
+ },
+ "execution_count": null,
+ "outputs": []
+ }
+ ]
+}
\ No newline at end of file