{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "ddefb3129871463c9c5ed9a3701bdaa3": { "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_0b9c1ac1832c4adc84d8b0777bed779d", "IPY_MODEL_be96b3ea50b14568a635ec2c2dbb54d1", "IPY_MODEL_2521f37bd5ca4ca485407e2a4e48b74d" ], "layout": "IPY_MODEL_8cae0d12ae6e4f5bb7aa3b7d02973b9f" } }, "0b9c1ac1832c4adc84d8b0777bed779d": { "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_c530d758dc804f8389d55be661def1bd", "placeholder": "​", "style": "IPY_MODEL_6c06b784368248cb95d529a2f381e61f", "value": "tokenizer_config.json: 100%" } }, "be96b3ea50b14568a635ec2c2dbb54d1": { "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_c390d81abd054ad6aa561c181e5137a7", "max": 48, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_bdfa68bfab2943079b550365125a371f", "value": 48 } }, "2521f37bd5ca4ca485407e2a4e48b74d": { "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_3bc32ad1603043b7a5cc0d1a48ccd95f", "placeholder": "​", "style": "IPY_MODEL_e293cb963b814885adda4c0adfeb2608", "value": " 48.0/48.0 [00:00<00:00, 1.65kB/s]" } }, "8cae0d12ae6e4f5bb7aa3b7d02973b9f": { "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 } }, "c530d758dc804f8389d55be661def1bd": { "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 } }, "6c06b784368248cb95d529a2f381e61f": { "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": "" } }, "c390d81abd054ad6aa561c181e5137a7": { "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 } }, "bdfa68bfab2943079b550365125a371f": { "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": "" } }, "3bc32ad1603043b7a5cc0d1a48ccd95f": { "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 } }, "e293cb963b814885adda4c0adfeb2608": { "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": "" } }, "a0725c2e950f42b291e89f9c05ec5a9b": { "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_ae1374bdc51a49f1aae30c920ef51597", "IPY_MODEL_1f765d6a82aa46cc9feb7192181384fb", "IPY_MODEL_234bdb28557e45479683365647347ba7" ], "layout": "IPY_MODEL_929e85dc4e4f4e69b54034baad90fddb" } }, "ae1374bdc51a49f1aae30c920ef51597": { "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_a3827fe07a8941559d7561327acd2728", "placeholder": "​", "style": "IPY_MODEL_ea6dcccdd28c440aa40f4b456665eeea", "value": "vocab.txt: 100%" } }, "1f765d6a82aa46cc9feb7192181384fb": { "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_d92445027c434585b08b0823d4f5caef", "max": 231508, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_2417e2ee32f8428a870b3a6aa655901e", "value": 231508 } }, "234bdb28557e45479683365647347ba7": { "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_59c7ce3011e644d4b1ab0e7a253f2832", "placeholder": "​", "style": "IPY_MODEL_505b6e76012c413aaadfc8d356f70106", "value": " 232k/232k [00:00<00:00, 2.95MB/s]" } }, "929e85dc4e4f4e69b54034baad90fddb": { "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 } }, "a3827fe07a8941559d7561327acd2728": { "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 } }, "ea6dcccdd28c440aa40f4b456665eeea": { "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": "" } }, "d92445027c434585b08b0823d4f5caef": { "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 } }, "2417e2ee32f8428a870b3a6aa655901e": { "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": "" } }, "59c7ce3011e644d4b1ab0e7a253f2832": { "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 } }, "505b6e76012c413aaadfc8d356f70106": { "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": "" } }, "b9f13091017440fda5333457ed78e3af": { "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_e9522478fcff46adb3e6d89a816570de", "IPY_MODEL_fb1e4b52bb124c68859993b127830828", "IPY_MODEL_609ec4e2fcab46ae98a69d29237344c0" ], "layout": "IPY_MODEL_14d0c0e1fa884f9cba15fa842c96943b" } }, "e9522478fcff46adb3e6d89a816570de": { "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_9f33f8f425dd474594ee9e2eafbbc815", "placeholder": "​", "style": "IPY_MODEL_9b677f233cd84ba4bd3afe61190e1f49", "value": "tokenizer.json: 100%" } }, "fb1e4b52bb124c68859993b127830828": { "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_9d0feae1b964477283d0fc610bbc347c", "max": 466062, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_a50de7d14a734da283d7d640cb66f10e", "value": 466062 } }, "609ec4e2fcab46ae98a69d29237344c0": { "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_caadefbbfde043838ab85ae5803d75dd", "placeholder": "​", "style": "IPY_MODEL_a93a6fc08ab340f5b5e2bf0d216ebb58", "value": " 466k/466k [00:00<00:00, 6.91MB/s]" } }, "14d0c0e1fa884f9cba15fa842c96943b": { "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 } }, "9f33f8f425dd474594ee9e2eafbbc815": { "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 } }, "9b677f233cd84ba4bd3afe61190e1f49": { "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": "" } }, "9d0feae1b964477283d0fc610bbc347c": { "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 } }, "a50de7d14a734da283d7d640cb66f10e": { "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": "" } }, "caadefbbfde043838ab85ae5803d75dd": { "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 } }, "a93a6fc08ab340f5b5e2bf0d216ebb58": { "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": "" } }, "e91997d6840d4d418abe7360591b85d3": { "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_f3e81276e34c472a93f4082a0a4cf40b", "IPY_MODEL_c5a7d924c9454d1dbbea1e871b726304", "IPY_MODEL_7a82951125aa488699701536e5ec79aa" ], "layout": "IPY_MODEL_ef285b6d299a4c2c917dc21368781e2a" } }, "f3e81276e34c472a93f4082a0a4cf40b": { "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_b565b4084a5040c695f09724dae638d3", "placeholder": "​", "style": "IPY_MODEL_460d501977644071a6799ffcff1fb681", "value": "config.json: 100%" } }, "c5a7d924c9454d1dbbea1e871b726304": { "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_fd211d5a988c4793b9e9d3ab35bc808b", "max": 570, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_8217b519e3b8469997cdc9746b0c5701", "value": 570 } }, "7a82951125aa488699701536e5ec79aa": { "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_ceed087de35a40f182abfe3d5e067395", "placeholder": "​", "style": "IPY_MODEL_a42e41fa377c49ba9bf79ba1bc2c97b6", "value": " 570/570 [00:00<00:00, 32.8kB/s]" } }, "ef285b6d299a4c2c917dc21368781e2a": { "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 } }, "b565b4084a5040c695f09724dae638d3": { "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 } }, "460d501977644071a6799ffcff1fb681": { "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": "" } }, "fd211d5a988c4793b9e9d3ab35bc808b": { "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 } }, "8217b519e3b8469997cdc9746b0c5701": { "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": "" } }, "ceed087de35a40f182abfe3d5e067395": { "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 } }, "a42e41fa377c49ba9bf79ba1bc2c97b6": { "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": "" } }, "532e8a53c3034fbf8bff74ade2735a09": { "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_ccb24460a8904e068420d793de8c189a", "IPY_MODEL_fce108786e0746b2b63d0dca8e4f621a", "IPY_MODEL_d06bac10f54a4e58961a7cf803bafbb3" ], "layout": "IPY_MODEL_726ea14f0b85482580d4e4e429eabe95" } }, "ccb24460a8904e068420d793de8c189a": { "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_4a1efe610d4a441591a939ea2f04892c", "placeholder": "​", "style": "IPY_MODEL_5917d8cacc0a4a04a4f174cad6fc2c6e", "value": "model.safetensors: 100%" } }, "fce108786e0746b2b63d0dca8e4f621a": { "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_e69e2012919547ef931f240217ebf9de", "max": 440449768, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_1f5bba1e68e7409199bff8c891f09198", "value": 440449768 } }, "d06bac10f54a4e58961a7cf803bafbb3": { "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_f23222411b9b446caeb1d7232a8d5167", "placeholder": "​", "style": "IPY_MODEL_906298a990754176b6c7fae7a8f9d468", "value": " 440M/440M [00:02<00:00, 246MB/s]" } }, "726ea14f0b85482580d4e4e429eabe95": { "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 } }, "4a1efe610d4a441591a939ea2f04892c": { "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 } }, "5917d8cacc0a4a04a4f174cad6fc2c6e": { "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": "" } }, "e69e2012919547ef931f240217ebf9de": { "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 } }, "1f5bba1e68e7409199bff8c891f09198": { "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": "" } }, "f23222411b9b446caeb1d7232a8d5167": { "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 } }, "906298a990754176b6c7fae7a8f9d468": { "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": "markdown", "source": [ "#Problem Statement\n", "**The goal is to automatically tag and analyze tweets for entities like people, companies, locations, and more, without relying on hashtags. Named Entity Recognition (NER) will identify and classify these entities. This project could enhance social media analysis, targeted marketing, and trend tracking.**\n", "\n", "#Applications\n", "- **Social Media Monitoring: Analyze trending topics and public sentiment.**\n", "- **Targeted Advertising: Identify key topics for better ad targeting.**\n", "- **Trend Detection: Recognize shifts in interest around entities, like companies or locations.**" ], "metadata": { "id": "kArLsCUJfp2W" } }, { "cell_type": "markdown", "source": [ "# Import Libraries and Download Data" ], "metadata": { "id": "WwZnZunUgCo6" } }, { "cell_type": "code", "source": [ "import pandas as pd\n", "import numpy as np\n", "import torch\n", "from transformers import BertTokenizer, TFBertForTokenClassification\n", "from sklearn.metrics import accuracy_score, classification_report, confusion_matrix\n", "from sklearn.model_selection import train_test_split\n", "import gdown\n", "\n", "# Download dataset from Google Drive folder link\n", "url = 'https://drive.google.com/drive/folders/14IgdWzzpjp166rhNhp9UFenjUp_czaGo?usp=share_link'\n", "gdown.download_folder(url, quiet=True)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "K3gCb47re60Q", "outputId": "c26cea26-8f85-44c9-b88a-0832e3cc46a7" }, "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "['/content/Datasets/wnut 16.txt.conll',\n", " '/content/Datasets/wnut 16test.txt.conll']" ] }, "metadata": {}, "execution_count": 1 } ] }, { "cell_type": "markdown", "source": [ "# Data Loading and Exploration\n", "**Load the CoNLL-format data file, where each word is labeled line by line. Sentences are separated by empty lines.**" ], "metadata": { "id": "U8DQ9w8pgJ-c" } }, { "cell_type": "code", "source": [ "def load_data(file_path):\n", " sentences = []\n", " labels = []\n", " sentence = []\n", " label = []\n", " with open(file_path, 'r') as file:\n", " for line in file:\n", " if line.strip(): # Non-empty line\n", " word, tag = line.strip().split()\n", " sentence.append(word)\n", " label.append(tag)\n", " else: # Empty line indicates end of a sentence\n", " sentences.append(sentence)\n", " labels.append(label)\n", " sentence = []\n", " label = []\n", " # Append the last sentence if the file doesn’t end with a blank line\n", " if sentence:\n", " sentences.append(sentence)\n", " labels.append(label)\n", " return sentences, labels\n", "\n", "train_file_path = '/content/wnut 16.txt.conll'\n", "test_file_path = '/content/wnut 16test.txt.conll'\n", "train_sentences, train_labels = load_data(train_file_path)\n", "test_sentences, test_labels = load_data(test_file_path)\n" ], "metadata": { "id": "ObuxjRf-esiV" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "# Exploratory Data Analysis (EDA)\n", "\n", "1. **Checking the structure of the data**\n", "\n", "Print a few sample sentences and labels to understand the structure" ], "metadata": { "id": "Rs4P-JCqgUbI" } }, { "cell_type": "code", "source": [ "print(\"Sample sentence:\", train_sentences[0])\n", "print(\"Sample labels:\", train_labels[0])" ], "metadata": { "id": "o1cIpQf0esez", "outputId": "73055cfc-73a3-4a14-9af4-a6d50ccc54e4", "colab": { "base_uri": "https://localhost:8080/" } }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Sample sentence: ['@SammieLynnsMom', '@tg10781', 'they', 'will', 'be', 'all', 'done', 'by', 'Sunday', 'trust', 'me', '*wink*']\n", "Sample labels: ['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O']\n" ] } ] }, { "cell_type": "code", "source": [ "# Check unique labels\n", "unique_labels = set(label for labels in train_labels for label in labels)\n", "print(\"Unique labels:\", unique_labels)" ], "metadata": { "id": "OjLxXt99escy", "outputId": "01ca4f72-41fa-4486-b157-0c51a64922d5", "colab": { "base_uri": "https://localhost:8080/" } }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Unique labels: {'I-facility', 'I-person', 'B-sportsteam', 'B-other', 'B-product', 'B-facility', 'B-geo-loc', 'O', 'B-musicartist', 'I-movie', 'I-musicartist', 'I-company', 'I-product', 'I-geo-loc', 'B-tvshow', 'B-company', 'B-movie', 'B-person', 'I-tvshow', 'I-sportsteam', 'I-other'}\n" ] } ] }, { "cell_type": "markdown", "source": [ "**2. Summary Statistics**\n", "\n", "Calculate basic statistics like the average sentence length and label distribution." ], "metadata": { "id": "3jdiK2M5gwUc" } }, { "cell_type": "code", "source": [ "sentence_lengths = [len(sentence) for sentence in train_sentences]\n", "print(\"Average sentence length:\", np.mean(sentence_lengths))\n", "print(\"Label distribution:\", pd.Series([lbl for labels in train_labels for lbl in labels]).value_counts())\n" ], "metadata": { "id": "KA9WSmajgr2P", "outputId": "77979eb0-54f5-4de4-9acb-e2c6ae9b4d90", "colab": { "base_uri": "https://localhost:8080/" } }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Average sentence length: 19.41060985797828\n", "Label distribution: O 44007\n", "B-person 449\n", "I-other 320\n", "B-geo-loc 276\n", "B-other 225\n", "I-person 215\n", "B-company 171\n", "I-facility 105\n", "B-facility 104\n", "B-product 97\n", "I-product 80\n", "I-musicartist 61\n", "B-musicartist 55\n", "B-sportsteam 51\n", "I-geo-loc 49\n", "I-movie 46\n", "I-company 36\n", "B-movie 34\n", "B-tvshow 34\n", "I-tvshow 31\n", "I-sportsteam 23\n", "Name: count, dtype: int64\n" ] } ] }, { "cell_type": "markdown", "source": [ "# Data Preprocessing\n" ], "metadata": { "id": "I5Lt4OmthS9k" } }, { "cell_type": "code", "source": [ "# Initialize tokenizer\n", "tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')" ], "metadata": { "id": "g0WOl51Bl-_b", "outputId": "c475d302-616f-45d7-f9a6-7234c97748ef", "colab": { "base_uri": "https://localhost:8080/", "height": 269, "referenced_widgets": [ "ddefb3129871463c9c5ed9a3701bdaa3", "0b9c1ac1832c4adc84d8b0777bed779d", "be96b3ea50b14568a635ec2c2dbb54d1", "2521f37bd5ca4ca485407e2a4e48b74d", "8cae0d12ae6e4f5bb7aa3b7d02973b9f", "c530d758dc804f8389d55be661def1bd", "6c06b784368248cb95d529a2f381e61f", "c390d81abd054ad6aa561c181e5137a7", "bdfa68bfab2943079b550365125a371f", "3bc32ad1603043b7a5cc0d1a48ccd95f", "e293cb963b814885adda4c0adfeb2608", "a0725c2e950f42b291e89f9c05ec5a9b", "ae1374bdc51a49f1aae30c920ef51597", "1f765d6a82aa46cc9feb7192181384fb", "234bdb28557e45479683365647347ba7", "929e85dc4e4f4e69b54034baad90fddb", "a3827fe07a8941559d7561327acd2728", "ea6dcccdd28c440aa40f4b456665eeea", "d92445027c434585b08b0823d4f5caef", "2417e2ee32f8428a870b3a6aa655901e", "59c7ce3011e644d4b1ab0e7a253f2832", "505b6e76012c413aaadfc8d356f70106", "b9f13091017440fda5333457ed78e3af", "e9522478fcff46adb3e6d89a816570de", "fb1e4b52bb124c68859993b127830828", "609ec4e2fcab46ae98a69d29237344c0", "14d0c0e1fa884f9cba15fa842c96943b", "9f33f8f425dd474594ee9e2eafbbc815", "9b677f233cd84ba4bd3afe61190e1f49", "9d0feae1b964477283d0fc610bbc347c", "a50de7d14a734da283d7d640cb66f10e", "caadefbbfde043838ab85ae5803d75dd", "a93a6fc08ab340f5b5e2bf0d216ebb58", "e91997d6840d4d418abe7360591b85d3", "f3e81276e34c472a93f4082a0a4cf40b", "c5a7d924c9454d1dbbea1e871b726304", "7a82951125aa488699701536e5ec79aa", "ef285b6d299a4c2c917dc21368781e2a", "b565b4084a5040c695f09724dae638d3", "460d501977644071a6799ffcff1fb681", "fd211d5a988c4793b9e9d3ab35bc808b", "8217b519e3b8469997cdc9746b0c5701", "ceed087de35a40f182abfe3d5e067395", "a42e41fa377c49ba9bf79ba1bc2c97b6" ] } }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_auth.py:94: 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/48.0 [00:00:4: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.\n", "Instructions for updating:\n", "Use `tf.config.list_physical_devices('GPU')` instead.\n" ] } ] }, { "cell_type": "code", "source": [ "# Compile model\n", "model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=1e-5),\n", " loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n", " metrics=['accuracy'])" ], "metadata": { "id": "Tc6UXMdC06fe" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Train model\n", "train_inputs = tf.convert_to_tensor(train_inputs)\n", "train_labels = tf.convert_to_tensor(train_labels)\n", "test_inputs = tf.convert_to_tensor(test_inputs)\n", "test_labels = tf.convert_to_tensor(test_labels)\n" ], "metadata": { "id": "gP5hGicY2v-D" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Train model\n", "model.fit(train_inputs, train_labels, epochs=5, batch_size=32, validation_data=(test_inputs, test_labels))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "T2H_GNIC8dqg", "outputId": "f0b97a20-7dd4-422e-c827-69a76fcaad4e" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Epoch 1/5\n", "1/1 [==============================] - 4s 4s/step - loss: 1.2786 - accuracy: 0.9453 - val_loss: 1.1207 - val_accuracy: 0.9062\n", "Epoch 2/5\n", "1/1 [==============================] - 4s 4s/step - loss: 1.0599 - accuracy: 0.9453 - val_loss: 0.9593 - val_accuracy: 0.9062\n", "Epoch 3/5\n", "1/1 [==============================] - 4s 4s/step - loss: 0.9132 - accuracy: 0.9453 - val_loss: 0.8314 - val_accuracy: 0.9062\n", "Epoch 4/5\n", "1/1 [==============================] - 3s 3s/step - loss: 0.7635 - accuracy: 0.9453 - val_loss: 0.7333 - val_accuracy: 0.9062\n", "Epoch 5/5\n", "1/1 [==============================] - 3s 3s/step - loss: 0.6473 - accuracy: 0.9531 - val_loss: 0.6603 - val_accuracy: 0.9062\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ "" ] }, "metadata": {}, "execution_count": 18 } ] }, { "cell_type": "code", "source": [ "# Evaluate model\n", "test_loss, test_acc = model.evaluate(test_inputs, test_labels)\n", "print(f'Test loss: {test_loss:.3f}, Test accuracy: {test_acc:.3f}')" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Xaqfc2CI8uRr", "outputId": "2b473448-c00e-40be-90ad-fe5a118f6a3e" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "1/1 [==============================] - 1s 859ms/step - loss: 0.6603 - accuracy: 0.9062\n", "Test loss: 0.660, Test accuracy: 0.906\n" ] } ] }, { "cell_type": "code", "source": [ "# Make predictions\n", "predictions = model.predict(test_inputs)\n", "predicted_labels = np.argmax(predictions)\n", "\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VCeH8n4-9IzZ", "outputId": "db5225e7-06ae-47de-fd21-18cb6152ed03" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "1/1 [==============================] - 1s 831ms/step\n" ] } ] }, { "cell_type": "code", "source": [ "label_map_tensor = tf.constant(list(label_map.values()))\n", "predicted_label = tf.gather(label_map_tensor, predicted_labels)\n" ], "metadata": { "id": "1gKdU8Xp-ZGl" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Convert predicted labels back to original labels\n", "label_map_tensor = tf.constant(list(label_map.values()))\n", "predicted_label = tf.gather(label_map_tensor, predicted_labels)" ], "metadata": { "id": "k0-cjNEs-ZDP" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Pad the test_labels list to ensure all tensors have the same length\n", "max_length = max(len(label) for label in test_labels)\n", "padded_test_labels = [tf.pad(label, [[0, max_length - len(label)]], 'constant') for label in test_labels]\n", "\n", "# Pad the padded_test_labels list to match the length of the test_sentences list\n", "num_sentences = len(test_sentences)\n", "padded_test_labels += [tf.zeros((max_length,))] * (num_sentences - len(padded_test_labels))\n", "\n", "# Print sample predictions\n", "for i in range(5):\n", " print(\"Sentence:\", test_sentences[i])\n", " print(\"Actual label:\", padded_test_labels[i].numpy())\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "NohfFc8N_5dg", "outputId": "0ce04303-fe94-40d8-cb8a-275b3175354d" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Sentence: ['New', 'Orleans', 'Mother', \"'s\", 'Day', 'Parade', 'shooting', '.', 'One', 'of', 'the', 'people', 'hurt', 'was', 'a', '10-year-old', 'girl', '.', 'WHAT', 'THE', 'HELL', 'IS', 'WRONG', 'WITH', 'PEOPLE', '?']\n", "Actual label: [7 7 7 7 7 7 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n", "Sentence: ['RT', '@hxranspizza', ':', 'Going', 'into', 'school', 'tomorrow', 'like', '#KCA', '#Vote1DUK', 'http://t.co/vvkoEEMjMX']\n", "Actual label: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0.]\n", "Sentence: ['May', 'e', 'just', 'a', 'smile', 'in', 'your', 'heart', 'EILY', 'CountdownBegins', '#PushAwardsLizQuens']\n", "Actual label: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0.]\n", "Sentence: ['I', 'could', 'so', 'do', 'Thursday', 'Club', 'right', 'now']\n", "Actual label: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0.]\n", "Sentence: ['@therealdaftbear', 'Albert', 'Nobbs', '(', 'Glenn', 'Close)is', 'a', 'woman', 'living', 'as', 'a', 'man', 'in', 'order', 'to', 'find', 'work', 'in', 'the', 'harsh', 'environment', 'of', '19th-century', 'Ireland']\n", "Actual label: [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0. 0. 0.]\n" ] } ] }, { "cell_type": "markdown", "source": [ "# Insights and Recommendations:\n", "\n", "** Data Quality and Quantity: **\n", "\n", "- Data Quality: Ensure data is clean, accurate, and relevant to the NER task.\n", "- Data Quantity: Sufficient training data is crucial for model performance. Consider data augmentation techniques if needed.\n", "\n", "** Model Architecture: **\n", "\n", "- BERT-Based Models: Utilize pre-trained BERT models for strong performance.\n", "- Fine-tuning: Fine-tune the pre-trained model on the specific NER task.\n", "- Experimentation: Try different model architectures and hyperparameters to optimize results.\n", "\n", "** Training and Evaluation:**\n", "\n", "- Hyperparameter Tuning: Experiment with learning rate, batch size, and other hyperparameters.\n", "- Early Stopping: Implement early stopping to prevent overfitting.\n", "- Evaluation Metrics: Use appropriate metrics like precision, recall, and F1-score to assess model performance.\n", "\n", "**Deployment and Inference:**\n", "\n", "- Model Serving: Deploy the model using a framework like TensorFlow Serving or TorchServe.\n", "- Batch Processing: Process multiple tweets at once for efficiency.\n", "- Real-time Inference: Consider using a streaming framework like Kafka for real-time processing.\n", "\n", "**Ethical Considerations:**\n", "\n", "- Bias and Fairness: Ensure the model is fair and unbiased, especially for sensitive topics.\n", "- Privacy: Protect user privacy and data security.\n", "\n", "**Future Directions:**\n", "\n", "- Contextual Understanding: Explore models that can capture deeper contextual information.\n", "- Multi-lingual NER: Develop models that can handle multiple languages.\n", "- Domain-Specific NER: Fine-tune models for specific domains like finance or healthcare." ], "metadata": { "id": "atPT0HjhAgK0" } }, { "cell_type": "code", "source": [], "metadata": { "id": "Awq80LkmABWC" }, "execution_count": null, "outputs": [] } ] }