Commit 03be09f4 by 前钰

Upload New File

parent 014d32d2
{
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "V100"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"b04a519af1964bd4b0f7b19ee44f5fa3": {
"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_4dd8b610416042b09b26443933ed0602",
"IPY_MODEL_8575e545db08497aaac2320c4c62426c",
"IPY_MODEL_2a5f13c153d64b62b757d1c3d311c517"
],
"layout": "IPY_MODEL_6e39968f380c4e9e952a83cad30e1e76"
}
},
"4dd8b610416042b09b26443933ed0602": {
"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_3ec8e7ab9e264b6a9f5a3835ec23a5e4",
"placeholder": "​",
"style": "IPY_MODEL_df84086ee40d42bc97de5e3809334b68",
"value": "tokenizer_config.json: 100%"
}
},
"8575e545db08497aaac2320c4c62426c": {
"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_eebbaf3473824eb7907fedfd10b201e6",
"max": 28,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_0f050420da70491383cb1c0d16553fc3",
"value": 28
}
},
"2a5f13c153d64b62b757d1c3d311c517": {
"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_514844a2d2984969b02137ed15bd28b9",
"placeholder": "​",
"style": "IPY_MODEL_941265075eea4fe8843f043bede7311b",
"value": " 28.0/28.0 [00:00<00:00, 1.58kB/s]"
}
},
"6e39968f380c4e9e952a83cad30e1e76": {
"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
}
},
"3ec8e7ab9e264b6a9f5a3835ec23a5e4": {
"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
}
},
"df84086ee40d42bc97de5e3809334b68": {
"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": ""
}
},
"eebbaf3473824eb7907fedfd10b201e6": {
"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
}
},
"0f050420da70491383cb1c0d16553fc3": {
"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": ""
}
},
"514844a2d2984969b02137ed15bd28b9": {
"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
}
},
"941265075eea4fe8843f043bede7311b": {
"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": ""
}
},
"07ea2f85ca20456a82d8e873ec989c64": {
"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_d6562e6fb6e343c8865f7a09af7c96e0",
"IPY_MODEL_5cd3c31d7f9e44f7ad9ac826f5bf614f",
"IPY_MODEL_956f79222e4d4dbe8a12ce1f72d1c048"
],
"layout": "IPY_MODEL_6071abab310e478a8d31845944742392"
}
},
"d6562e6fb6e343c8865f7a09af7c96e0": {
"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_be2ee82d36ba48cd9b8a1dfb598be892",
"placeholder": "​",
"style": "IPY_MODEL_1ff7810f1508454c98e21f2c9e379d10",
"value": "vocab.txt: 100%"
}
},
"5cd3c31d7f9e44f7ad9ac826f5bf614f": {
"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_c9d803829934415684c8cd764a32629d",
"max": 231508,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_c772617a73d74e0bb14a758ed9cc0891",
"value": 231508
}
},
"956f79222e4d4dbe8a12ce1f72d1c048": {
"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_a048890ea9174c47837f937c58e1c9a3",
"placeholder": "​",
"style": "IPY_MODEL_d054b5a86837422e85aab167cba8de1c",
"value": " 232k/232k [00:00<00:00, 1.41MB/s]"
}
},
"6071abab310e478a8d31845944742392": {
"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
}
},
"be2ee82d36ba48cd9b8a1dfb598be892": {
"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
}
},
"1ff7810f1508454c98e21f2c9e379d10": {
"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": ""
}
},
"c9d803829934415684c8cd764a32629d": {
"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
}
},
"c772617a73d74e0bb14a758ed9cc0891": {
"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": ""
}
},
"a048890ea9174c47837f937c58e1c9a3": {
"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
}
},
"d054b5a86837422e85aab167cba8de1c": {
"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": ""
}
},
"0df952395f9e47aa954aea9d4cfbd09b": {
"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_f45b052e2bac4cf8835bcb2099ec0c8d",
"IPY_MODEL_4e69f9df5625466c911d7fe87ac68088",
"IPY_MODEL_12108d6e6c7841f9aa38106ef0df73c0"
],
"layout": "IPY_MODEL_df145ef969d243bda04b6b3ab335a6aa"
}
},
"f45b052e2bac4cf8835bcb2099ec0c8d": {
"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_a0bb928c3eb44c9788c806828663bdf5",
"placeholder": "​",
"style": "IPY_MODEL_7ecd86acc000450db8e6500566476c35",
"value": "tokenizer.json: 100%"
}
},
"4e69f9df5625466c911d7fe87ac68088": {
"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_a8a182195555477498400bcbe0c7a9a7",
"max": 466062,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_8d11a93882054e54bb049a4e5f6b0c1d",
"value": 466062
}
},
"12108d6e6c7841f9aa38106ef0df73c0": {
"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_68de3fa29a1c40229bc31d01915c04d1",
"placeholder": "​",
"style": "IPY_MODEL_cce3d736774847dc83b0cc207d3f8e0e",
"value": " 466k/466k [00:00<00:00, 1.88MB/s]"
}
},
"df145ef969d243bda04b6b3ab335a6aa": {
"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
}
},
"a0bb928c3eb44c9788c806828663bdf5": {
"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
}
},
"7ecd86acc000450db8e6500566476c35": {
"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": ""
}
},
"a8a182195555477498400bcbe0c7a9a7": {
"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
}
},
"8d11a93882054e54bb049a4e5f6b0c1d": {
"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": ""
}
},
"68de3fa29a1c40229bc31d01915c04d1": {
"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
}
},
"cce3d736774847dc83b0cc207d3f8e0e": {
"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": ""
}
},
"bf9df892e95e4063935e042ed27f70ce": {
"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_a8d374ccf1ae4bbdb22d73108100bfe0",
"IPY_MODEL_4d6f8fa134fd4332b939caf785b1bf2f",
"IPY_MODEL_71d8614fbc9445e88346b5794585b7f5"
],
"layout": "IPY_MODEL_e7181bf4094141fc8da7729badd20999"
}
},
"a8d374ccf1ae4bbdb22d73108100bfe0": {
"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_6a565f18a6ff45f195da7c42896fe4a6",
"placeholder": "​",
"style": "IPY_MODEL_88034acf375043c8b846ad7c44e1e78e",
"value": "config.json: 100%"
}
},
"4d6f8fa134fd4332b939caf785b1bf2f": {
"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_da388392bd0e47e7aaa63e487e57918e",
"max": 570,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_deebc8d87f1c4ef28ab360cb8a8107d7",
"value": 570
}
},
"71d8614fbc9445e88346b5794585b7f5": {
"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_7d2b921ae2f94fc18a14264ab29f0c57",
"placeholder": "​",
"style": "IPY_MODEL_cc50dbdd40ae406a995375dba55e4c01",
"value": " 570/570 [00:00<00:00, 41.6kB/s]"
}
},
"e7181bf4094141fc8da7729badd20999": {
"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
}
},
"6a565f18a6ff45f195da7c42896fe4a6": {
"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
}
},
"88034acf375043c8b846ad7c44e1e78e": {
"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": ""
}
},
"da388392bd0e47e7aaa63e487e57918e": {
"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
}
},
"deebc8d87f1c4ef28ab360cb8a8107d7": {
"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": ""
}
},
"7d2b921ae2f94fc18a14264ab29f0c57": {
"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
}
},
"cc50dbdd40ae406a995375dba55e4c01": {
"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": ""
}
},
"f3fd1a6130eb4abfb7abbc2accc22672": {
"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_7abf6e6880524922b73953f84a3928bd",
"IPY_MODEL_2059f4631bc7483d8da296f19f53598d",
"IPY_MODEL_1e167814d5384583a1ae6a069fbc9598"
],
"layout": "IPY_MODEL_5c92ad97c733448a8d64f2c28b6506e9"
}
},
"7abf6e6880524922b73953f84a3928bd": {
"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_bb0d9b1e6a5f4c80853bc6448f9152f0",
"placeholder": "​",
"style": "IPY_MODEL_52b79e57f95c4cc8819f801f3ce20f81",
"value": "model.safetensors: 100%"
}
},
"2059f4631bc7483d8da296f19f53598d": {
"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_64368a0f850546cfa485b6490a30cf2a",
"max": 440449768,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_d2fb25a6732a4299b810fa21c82ff03e",
"value": 440449768
}
},
"1e167814d5384583a1ae6a069fbc9598": {
"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_e439e171af6c4a5fa950ec32128f0b97",
"placeholder": "​",
"style": "IPY_MODEL_e50bb99c3a444f66b2208a91dce68d89",
"value": " 440M/440M [00:03<00:00, 189MB/s]"
}
},
"5c92ad97c733448a8d64f2c28b6506e9": {
"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
}
},
"bb0d9b1e6a5f4c80853bc6448f9152f0": {
"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
}
},
"52b79e57f95c4cc8819f801f3ce20f81": {
"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": ""
}
},
"64368a0f850546cfa485b6490a30cf2a": {
"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
}
},
"d2fb25a6732a4299b810fa21c82ff03e": {
"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": ""
}
},
"e439e171af6c4a5fa950ec32128f0b97": {
"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
}
},
"e50bb99c3a444f66b2208a91dce68d89": {
"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",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "aymx79AHLore",
"outputId": "2126f745-5ff1-4c26-dc7e-96030c48cabe"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting torchtext==0.5.0\n",
" Downloading torchtext-0.5.0-py3-none-any.whl (73 kB)\n",
"\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/73.2 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m73.2/73.2 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (4.66.1)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (2.31.0)\n",
"Requirement already satisfied: torch in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (2.1.0+cu121)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (1.23.5)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (1.16.0)\n",
"Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from torchtext==0.5.0) (0.1.99)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->torchtext==0.5.0) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->torchtext==0.5.0) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->torchtext==0.5.0) (2.0.7)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->torchtext==0.5.0) (2024.2.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (3.13.1)\n",
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (4.9.0)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (1.12)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (3.2.1)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (3.1.3)\n",
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (2023.6.0)\n",
"Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch->torchtext==0.5.0) (2.1.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch->torchtext==0.5.0) (2.1.5)\n",
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch->torchtext==0.5.0) (1.3.0)\n",
"Installing collected packages: torchtext\n",
" Attempting uninstall: torchtext\n",
" Found existing installation: torchtext 0.16.0\n",
" Uninstalling torchtext-0.16.0:\n",
" Successfully uninstalled torchtext-0.16.0\n",
"Successfully installed torchtext-0.5.0\n"
]
}
],
"source": [
"!pip install torchtext==0.5.0"
]
},
{
"cell_type": "code",
"source": [
"import torch\n",
"import torch.nn as nn\n",
"import torch.nn.functional as F\n",
"import torch.optim as optim\n",
"\n",
"from torchtext import data,datasets\n",
"\n",
"from transformers import BertTokenizer, BertModel\n",
"\n",
"import numpy as np\n",
"\n",
"import time\n",
"import random\n",
"import functools"
],
"metadata": {
"id": "mQQQwIPpYb2g"
},
"execution_count": 2,
"outputs": []
},
{
"cell_type": "code",
"source": [
"SEED = 1234\n",
"\n",
"random.seed(SEED)\n",
"np.random.seed(SEED)\n",
"torch.manual_seed(SEED)\n",
"torch.backends.cudnn.deterministic = True"
],
"metadata": {
"id": "lzJeqA9hYfMF"
},
"execution_count": 3,
"outputs": []
},
{
"cell_type": "code",
"source": [
"tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 272,
"referenced_widgets": [
"b04a519af1964bd4b0f7b19ee44f5fa3",
"4dd8b610416042b09b26443933ed0602",
"8575e545db08497aaac2320c4c62426c",
"2a5f13c153d64b62b757d1c3d311c517",
"6e39968f380c4e9e952a83cad30e1e76",
"3ec8e7ab9e264b6a9f5a3835ec23a5e4",
"df84086ee40d42bc97de5e3809334b68",
"eebbaf3473824eb7907fedfd10b201e6",
"0f050420da70491383cb1c0d16553fc3",
"514844a2d2984969b02137ed15bd28b9",
"941265075eea4fe8843f043bede7311b",
"07ea2f85ca20456a82d8e873ec989c64",
"d6562e6fb6e343c8865f7a09af7c96e0",
"5cd3c31d7f9e44f7ad9ac826f5bf614f",
"956f79222e4d4dbe8a12ce1f72d1c048",
"6071abab310e478a8d31845944742392",
"be2ee82d36ba48cd9b8a1dfb598be892",
"1ff7810f1508454c98e21f2c9e379d10",
"c9d803829934415684c8cd764a32629d",
"c772617a73d74e0bb14a758ed9cc0891",
"a048890ea9174c47837f937c58e1c9a3",
"d054b5a86837422e85aab167cba8de1c",
"0df952395f9e47aa954aea9d4cfbd09b",
"f45b052e2bac4cf8835bcb2099ec0c8d",
"4e69f9df5625466c911d7fe87ac68088",
"12108d6e6c7841f9aa38106ef0df73c0",
"df145ef969d243bda04b6b3ab335a6aa",
"a0bb928c3eb44c9788c806828663bdf5",
"7ecd86acc000450db8e6500566476c35",
"a8a182195555477498400bcbe0c7a9a7",
"8d11a93882054e54bb049a4e5f6b0c1d",
"68de3fa29a1c40229bc31d01915c04d1",
"cce3d736774847dc83b0cc207d3f8e0e",
"bf9df892e95e4063935e042ed27f70ce",
"a8d374ccf1ae4bbdb22d73108100bfe0",
"4d6f8fa134fd4332b939caf785b1bf2f",
"71d8614fbc9445e88346b5794585b7f5",
"e7181bf4094141fc8da7729badd20999",
"6a565f18a6ff45f195da7c42896fe4a6",
"88034acf375043c8b846ad7c44e1e78e",
"da388392bd0e47e7aaa63e487e57918e",
"deebc8d87f1c4ef28ab360cb8a8107d7",
"7d2b921ae2f94fc18a14264ab29f0c57",
"cc50dbdd40ae406a995375dba55e4c01"
]
},
"id": "QAZg6xVOYg8f",
"outputId": "e6653cbb-7037-4d19-c0a5-8686f7d38d11"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: \n",
"The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
"To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
"You will be able to reuse this secret in all of your notebooks.\n",
"Please note that authentication is recommended but still optional to access public models or datasets.\n",
" warnings.warn(\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"tokenizer_config.json: 0%| | 0.00/28.0 [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "b04a519af1964bd4b0f7b19ee44f5fa3"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"vocab.txt: 0%| | 0.00/232k [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "07ea2f85ca20456a82d8e873ec989c64"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"tokenizer.json: 0%| | 0.00/466k [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "0df952395f9e47aa954aea9d4cfbd09b"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"config.json: 0%| | 0.00/570 [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "bf9df892e95e4063935e042ed27f70ce"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"init_token = tokenizer.cls_token\n",
"pad_token = tokenizer.pad_token\n",
"unk_token = tokenizer.unk_token\n",
"\n",
"print(init_token, pad_token, unk_token)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "O9W6TyKqYpOQ",
"outputId": "51201b17-2e70-45fb-df04-afa57446de52"
},
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[CLS] [PAD] [UNK]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"init_token_idx = tokenizer.convert_tokens_to_ids(init_token)\n",
"pad_token_idx = tokenizer.convert_tokens_to_ids(pad_token)\n",
"unk_token_idx = tokenizer.convert_tokens_to_ids(unk_token)\n",
"\n",
"print(init_token_idx, pad_token_idx, unk_token_idx)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "r2Rra5YpYrw4",
"outputId": "0f73c6e6-0a94-4346-a180-88d47bd72f69"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"101 0 100\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"max_input_length = tokenizer.max_model_input_sizes['bert-base-uncased']\n",
"\n",
"print(max_input_length)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "eofWHi-iYtVg",
"outputId": "1b883477-2e0c-480b-e325-3d06fd06183b"
},
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"512\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"def cut_and_convert_to_id(tokens, tokenizer, max_input_length):\n",
" tokens = tokens[:max_input_length-1]\n",
" tokens = tokenizer.convert_tokens_to_ids(tokens)\n",
" return tokens"
],
"metadata": {
"id": "VQuyJCxNYvBX"
},
"execution_count": 8,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def cut_to_max_length(tokens, max_input_length):\n",
" tokens = tokens[:max_input_length-1]\n",
" return tokens"
],
"metadata": {
"id": "TSwUvs-oYwni"
},
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"source": [
"text_preprocessor = functools.partial(cut_and_convert_to_id,\n",
" tokenizer = tokenizer,\n",
" max_input_length = max_input_length)\n",
"\n",
"tag_preprocessor = functools.partial(cut_to_max_length,\n",
" max_input_length = max_input_length)"
],
"metadata": {
"id": "iQ8aZAT6Yx4W"
},
"execution_count": 10,
"outputs": []
},
{
"cell_type": "code",
"source": [
"TEXT = data.Field(use_vocab = False,\n",
" lower = True,\n",
" preprocessing = text_preprocessor,\n",
" init_token = init_token_idx,\n",
" pad_token = pad_token_idx,\n",
" unk_token = unk_token_idx)\n",
"\n",
"UD_TAGS = data.Field(unk_token = None,\n",
" init_token = '<pad>',\n",
" preprocessing = tag_preprocessor)"
],
"metadata": {
"id": "QITICh3zYzYY"
},
"execution_count": 11,
"outputs": []
},
{
"cell_type": "code",
"source": [
"fields = ((\"text\", TEXT), (\"udtags\", UD_TAGS))"
],
"metadata": {
"id": "W78x96mwY1Ik"
},
"execution_count": 12,
"outputs": []
},
{
"cell_type": "code",
"source": [
"train_data, valid_data, test_data = datasets.UDPOS.splits(fields)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "9zKBEaKJY22f",
"outputId": "89520af0-11f5-4a6a-c2fb-44d3052dba36"
},
"execution_count": 13,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"downloading en-ud-v2.zip\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"en-ud-v2.zip: 100%|██████████| 688k/688k [00:00<00:00, 1.61MB/s]\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"extracting\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"print(vars(train_data.examples[0]))"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "neQhD6n8Y4Q2",
"outputId": "ea0ef77f-392c-4d0e-860b-c392df575ce2"
},
"execution_count": 14,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"{'text': [2632, 1011, 100, 1024, 2137, 2749, 2730, 100, 14093, 2632, 1011, 100, 1010, 1996, 14512, 2012, 1996, 8806, 1999, 1996, 2237, 1997, 100, 1010, 2379, 1996, 9042, 3675, 1012], 'udtags': ['PROPN', 'PUNCT', 'PROPN', 'PUNCT', 'ADJ', 'NOUN', 'VERB', 'PROPN', 'PROPN', 'PROPN', 'PUNCT', 'PROPN', 'PUNCT', 'DET', 'NOUN', 'ADP', 'DET', 'NOUN', 'ADP', 'DET', 'NOUN', 'ADP', 'PROPN', 'PUNCT', 'ADP', 'DET', 'ADJ', 'NOUN', 'PUNCT']}\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"UD_TAGS.build_vocab(train_data)\n",
"\n",
"print(UD_TAGS.vocab.stoi)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "6TAcJEuzY6gi",
"outputId": "2c163050-c01c-4c96-bb2e-3575944bcbfb"
},
"execution_count": 15,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"defaultdict(None, {'<pad>': 0, 'NOUN': 1, 'PUNCT': 2, 'VERB': 3, 'PRON': 4, 'ADP': 5, 'DET': 6, 'PROPN': 7, 'ADJ': 8, 'AUX': 9, 'ADV': 10, 'CCONJ': 11, 'PART': 12, 'NUM': 13, 'SCONJ': 14, 'X': 15, 'INTJ': 16, 'SYM': 17})\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"BATCH_SIZE = 32\n",
"\n",
"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
"\n",
"train_iterator, valid_iterator, test_iterator = data.BucketIterator.splits(\n",
" (train_data, valid_data, test_data),\n",
" batch_size = BATCH_SIZE,\n",
" device = device)"
],
"metadata": {
"id": "Qhe-y7NQY8CT"
},
"execution_count": 16,
"outputs": []
},
{
"cell_type": "code",
"source": [
"class BERTPoSTagger(nn.Module):\n",
" def __init__(self,\n",
" bert,\n",
" output_dim,\n",
" dropout):\n",
"\n",
" super().__init__()\n",
"\n",
" self.bert = bert\n",
"\n",
" embedding_dim = bert.config.to_dict()['hidden_size']\n",
"\n",
" self.fc = nn.Linear(embedding_dim, output_dim)\n",
"\n",
" self.dropout = nn.Dropout(dropout)\n",
"\n",
" def forward(self, text):\n",
"\n",
" #text = [sent len, batch size]\n",
"\n",
" text = text.permute(1, 0)\n",
"\n",
" #text = [batch size, sent len]\n",
"\n",
" embedded = self.dropout(self.bert(text)[0])\n",
"\n",
" #embedded = [batch size, seq len, emb dim]\n",
"\n",
" embedded = embedded.permute(1, 0, 2)\n",
"\n",
" #embedded = [sent len, batch size, emb dim]\n",
"\n",
" predictions = self.fc(self.dropout(embedded))\n",
"\n",
" #predictions = [sent len, batch size, output dim]\n",
"\n",
" return predictions"
],
"metadata": {
"id": "yef_QNp0Y9hF"
},
"execution_count": 17,
"outputs": []
},
{
"cell_type": "code",
"source": [
"bert = BertModel.from_pretrained('bert-base-uncased')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 49,
"referenced_widgets": [
"f3fd1a6130eb4abfb7abbc2accc22672",
"7abf6e6880524922b73953f84a3928bd",
"2059f4631bc7483d8da296f19f53598d",
"1e167814d5384583a1ae6a069fbc9598",
"5c92ad97c733448a8d64f2c28b6506e9",
"bb0d9b1e6a5f4c80853bc6448f9152f0",
"52b79e57f95c4cc8819f801f3ce20f81",
"64368a0f850546cfa485b6490a30cf2a",
"d2fb25a6732a4299b810fa21c82ff03e",
"e439e171af6c4a5fa950ec32128f0b97",
"e50bb99c3a444f66b2208a91dce68d89"
]
},
"id": "nsAWFIG_Y_rd",
"outputId": "84630339-d24d-4f87-8113-9dcdd34b7e24"
},
"execution_count": 18,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"model.safetensors: 0%| | 0.00/440M [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "f3fd1a6130eb4abfb7abbc2accc22672"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"OUTPUT_DIM = len(UD_TAGS.vocab)\n",
"DROPOUT = 0.25\n",
"\n",
"model = BERTPoSTagger(bert,\n",
" OUTPUT_DIM,\n",
" DROPOUT)"
],
"metadata": {
"id": "C4d7mqGMZByG"
},
"execution_count": 19,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def count_parameters(model):\n",
" return sum(p.numel() for p in model.parameters() if p.requires_grad)\n",
"\n",
"print(f'The model has {count_parameters(model):,} trainable parameters')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "T1fPO3NrZEO5",
"outputId": "3981a9da-5d9a-4c53-a499-5d5f545238e9"
},
"execution_count": 20,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"The model has 109,496,082 trainable parameters\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"LEARNING_RATE = 5e-5\n",
"\n",
"optimizer = optim.Adam(model.parameters(), lr = LEARNING_RATE)"
],
"metadata": {
"id": "vuhpt9nCZGHe"
},
"execution_count": 21,
"outputs": []
},
{
"cell_type": "code",
"source": [
"TAG_PAD_IDX = UD_TAGS.vocab.stoi[UD_TAGS.pad_token]\n",
"\n",
"criterion = nn.CrossEntropyLoss(ignore_index = TAG_PAD_IDX)"
],
"metadata": {
"id": "sCYtbbCHZH3g"
},
"execution_count": 22,
"outputs": []
},
{
"cell_type": "code",
"source": [
"model = model.to(device)\n",
"criterion = criterion.to(device)"
],
"metadata": {
"id": "oYQon7MqZJRB"
},
"execution_count": 23,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def categorical_accuracy(preds, y, tag_pad_idx):\n",
" \"\"\"\n",
" Returns accuracy per batch, i.e. if you get 8/10 right, this returns 0.8, NOT 8\n",
" \"\"\"\n",
" max_preds = preds.argmax(dim = 1, keepdim = True) # get the index of the max probability\n",
" non_pad_elements = (y != tag_pad_idx).nonzero()\n",
" correct = max_preds[non_pad_elements].squeeze(1).eq(y[non_pad_elements])\n",
" return correct.sum() / torch.FloatTensor([y[non_pad_elements].shape[0]]).to(device)"
],
"metadata": {
"id": "i2VsbTmgZKw6"
},
"execution_count": 24,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def train(model, iterator, optimizer, criterion, tag_pad_idx):\n",
"\n",
" epoch_loss = 0\n",
" epoch_acc = 0\n",
"\n",
" model.train()\n",
"\n",
" for batch in iterator:\n",
"\n",
" text = batch.text\n",
" tags = batch.udtags\n",
"\n",
" optimizer.zero_grad()\n",
"\n",
" #text = [sent len, batch size]\n",
"\n",
" predictions = model(text)\n",
"\n",
" #predictions = [sent len, batch size, output dim]\n",
" #tags = [sent len, batch size]\n",
"\n",
" predictions = predictions.view(-1, predictions.shape[-1])\n",
" tags = tags.view(-1)\n",
"\n",
" #predictions = [sent len * batch size, output dim]\n",
" #tags = [sent len * batch size]\n",
"\n",
" loss = criterion(predictions, tags)\n",
"\n",
" acc = categorical_accuracy(predictions, tags, tag_pad_idx)\n",
"\n",
" loss.backward()\n",
"\n",
" optimizer.step()\n",
"\n",
" epoch_loss += loss.item()\n",
" epoch_acc += acc.item()\n",
"\n",
" return epoch_loss / len(iterator), epoch_acc / len(iterator)"
],
"metadata": {
"id": "51NFGC1eZMYX"
},
"execution_count": 25,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def evaluate(model, iterator, criterion, tag_pad_idx):\n",
"\n",
" epoch_loss = 0\n",
" epoch_acc = 0\n",
"\n",
" model.eval()\n",
"\n",
" with torch.no_grad():\n",
"\n",
" for batch in iterator:\n",
"\n",
" text = batch.text\n",
" tags = batch.udtags\n",
"\n",
" predictions = model(text)\n",
"\n",
" predictions = predictions.view(-1, predictions.shape[-1])\n",
" tags = tags.view(-1)\n",
"\n",
" loss = criterion(predictions, tags)\n",
"\n",
" acc = categorical_accuracy(predictions, tags, tag_pad_idx)\n",
"\n",
" epoch_loss += loss.item()\n",
" epoch_acc += acc.item()\n",
"\n",
" return epoch_loss / len(iterator), epoch_acc / len(iterator)"
],
"metadata": {
"id": "ILVWUnwBZPO4"
},
"execution_count": 26,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def epoch_time(start_time, end_time):\n",
" elapsed_time = end_time - start_time\n",
" elapsed_mins = int(elapsed_time / 60)\n",
" elapsed_secs = int(elapsed_time - (elapsed_mins * 60))\n",
" return elapsed_mins, elapsed_secs"
],
"metadata": {
"id": "FY17XjJYZRFz"
},
"execution_count": 27,
"outputs": []
},
{
"cell_type": "code",
"source": [
"N_EPOCHS = 10\n",
"\n",
"best_valid_loss = float('inf')\n",
"\n",
"for epoch in range(N_EPOCHS):\n",
"\n",
" start_time = time.time()\n",
"\n",
" train_loss, train_acc = train(model, train_iterator, optimizer, criterion, TAG_PAD_IDX)\n",
" valid_loss, valid_acc = evaluate(model, valid_iterator, criterion, TAG_PAD_IDX)\n",
"\n",
" end_time = time.time()\n",
"\n",
" epoch_mins, epoch_secs = epoch_time(start_time, end_time)\n",
"\n",
" if valid_loss < best_valid_loss:\n",
" best_valid_loss = valid_loss\n",
" torch.save(model.state_dict(), 'tut2-model.pt')\n",
"\n",
" print(f'Epoch: {epoch+1:02} | Epoch Time: {epoch_mins}m {epoch_secs}s')\n",
" print(f'\\tTrain Loss: {train_loss:.3f} | Train Acc: {train_acc*100:.2f}%')\n",
" print(f'\\t Val. Loss: {valid_loss:.3f} | Val. Acc: {valid_acc*100:.2f}%')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "44khueucZS1J",
"outputId": "dd537416-5fde-4883-f4a5-8b6807bd62f5"
},
"execution_count": 28,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"We strongly recommend passing in an `attention_mask` since your input_ids may be padded. See https://huggingface.co/docs/transformers/troubleshooting#incorrect-output-when-padding-tokens-arent-masked.\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"Epoch: 01 | Epoch Time: 0m 40s\n",
"\tTrain Loss: 0.406 | Train Acc: 88.34%\n",
"\t Val. Loss: 0.309 | Val. Acc: 90.70%\n",
"Epoch: 02 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.117 | Train Acc: 96.64%\n",
"\t Val. Loss: 0.282 | Val. Acc: 91.23%\n",
"Epoch: 03 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.076 | Train Acc: 97.78%\n",
"\t Val. Loss: 0.254 | Val. Acc: 92.15%\n",
"Epoch: 04 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.053 | Train Acc: 98.47%\n",
"\t Val. Loss: 0.267 | Val. Acc: 92.33%\n",
"Epoch: 05 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.039 | Train Acc: 98.87%\n",
"\t Val. Loss: 0.282 | Val. Acc: 92.36%\n",
"Epoch: 06 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.029 | Train Acc: 99.19%\n",
"\t Val. Loss: 0.296 | Val. Acc: 91.75%\n",
"Epoch: 07 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.025 | Train Acc: 99.27%\n",
"\t Val. Loss: 0.288 | Val. Acc: 92.61%\n",
"Epoch: 08 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.021 | Train Acc: 99.38%\n",
"\t Val. Loss: 0.342 | Val. Acc: 91.88%\n",
"Epoch: 09 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.020 | Train Acc: 99.40%\n",
"\t Val. Loss: 0.323 | Val. Acc: 91.68%\n",
"Epoch: 10 | Epoch Time: 0m 37s\n",
"\tTrain Loss: 0.015 | Train Acc: 99.55%\n",
"\t Val. Loss: 0.329 | Val. Acc: 91.86%\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"model.load_state_dict(torch.load('tut2-model.pt'))\n",
"\n",
"test_loss, test_acc = evaluate(model, test_iterator, criterion, TAG_PAD_IDX)\n",
"\n",
"print(f'Test Loss: {test_loss:.3f} | Test Acc: {test_acc*100:.2f}%')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "PjQ9S1PhZU2H",
"outputId": "78d13174-9e45-4020-a105-ec018b078135"
},
"execution_count": 29,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Test Loss: 0.281 | Test Acc: 90.85%\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"def tag_sentence(model, device, sentence, tokenizer, text_field, tag_field):\n",
"\n",
" model.eval()\n",
"\n",
" if isinstance(sentence, str):\n",
" tokens = tokenizer.tokenize(sentence)\n",
" else:\n",
" tokens = sentence\n",
"\n",
" numericalized_tokens = tokenizer.convert_tokens_to_ids(tokens)\n",
" numericalized_tokens = [text_field.init_token] + numericalized_tokens\n",
"\n",
" unk_idx = text_field.unk_token\n",
"\n",
" unks = [t for t, n in zip(tokens, numericalized_tokens) if n == unk_idx]\n",
"\n",
" token_tensor = torch.LongTensor(numericalized_tokens)\n",
"\n",
" token_tensor = token_tensor.unsqueeze(-1).to(device)\n",
"\n",
" predictions = model(token_tensor)\n",
"\n",
" top_predictions = predictions.argmax(-1)\n",
"\n",
" predicted_tags = [tag_field.vocab.itos[t.item()] for t in top_predictions]\n",
"\n",
" predicted_tags = predicted_tags[1:]\n",
"\n",
" assert len(tokens) == len(predicted_tags)\n",
"\n",
" return tokens, predicted_tags, unks"
],
"metadata": {
"id": "E11tUcSeZXMj"
},
"execution_count": 30,
"outputs": []
},
{
"cell_type": "code",
"source": [
"sentence = 'The Queen will deliver a speech about the conflict in North Korea at 1pm tomorrow.'\n",
"\n",
"tokens, tags, unks = tag_sentence(model,\n",
" device,\n",
" sentence,\n",
" tokenizer,\n",
" TEXT,\n",
" UD_TAGS)\n",
"\n",
"print(unks)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "nsPkcCmfZZWU",
"outputId": "54bd77f2-2db3-4071-8bfa-c99eb2014dc9"
},
"execution_count": 31,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[]\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"print(\"Pred. Tag\\tToken\\n\")\n",
"\n",
"for token, tag in zip(tokens, tags):\n",
" print(f\"{tag}\\t\\t{token}\")"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "z2c-XT5jZbM4",
"outputId": "8a750de6-1bd8-434c-a657-d8e3cb6722a4"
},
"execution_count": 32,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Pred. Tag\tToken\n",
"\n",
"DET\t\tthe\n",
"NOUN\t\tqueen\n",
"AUX\t\twill\n",
"VERB\t\tdeliver\n",
"DET\t\ta\n",
"NOUN\t\tspeech\n",
"ADP\t\tabout\n",
"DET\t\tthe\n",
"NOUN\t\tconflict\n",
"ADP\t\tin\n",
"PROPN\t\tnorth\n",
"PROPN\t\tkorea\n",
"ADP\t\tat\n",
"NUM\t\t1\n",
"NOUN\t\t##pm\n",
"NOUN\t\ttomorrow\n",
"PUNCT\t\t.\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "tr_U6mN0ZdHT"
},
"execution_count": 32,
"outputs": []
}
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment