{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "gpuType": "T4" }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU", "widgets": { "application/vnd.jupyter.widget-state+json": { "42fafb26b3cb4f0daeb4b561aea8f29f": { "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_132aa00a3220429c8438de04b84649b4", "IPY_MODEL_93286e40b3024fa4a96769f05856962e", "IPY_MODEL_0b5acca09b4e4e99908a2f8121861cf4" ], "layout": "IPY_MODEL_3cdaf59d8ac34e91a14555d91f4c0610" } }, "132aa00a3220429c8438de04b84649b4": { "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_b533ffea5bc6415bb8c7c6f40e2c01e9", "placeholder": "​", "style": "IPY_MODEL_9c2c390f7b5c4523bc462f00e3607d31", "value": "100%" } }, "93286e40b3024fa4a96769f05856962e": { "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_24415a2652d44b1485bec6b75ce293d9", "max": 34000, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_e7e78bef4cc7468c8d7742371f100f01", "value": 34000 } }, "0b5acca09b4e4e99908a2f8121861cf4": { "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_953957cffa914c09a80389d1fecdead1", "placeholder": "​", "style": "IPY_MODEL_59434af8f0964872b3f512d564d00d6b", "value": " 34000/34000 [00:27<00:00, 1270.15it/s]" } }, "3cdaf59d8ac34e91a14555d91f4c0610": { "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 } }, "b533ffea5bc6415bb8c7c6f40e2c01e9": { "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 } }, "9c2c390f7b5c4523bc462f00e3607d31": { "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": "" } }, "24415a2652d44b1485bec6b75ce293d9": { "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 } }, "e7e78bef4cc7468c8d7742371f100f01": { "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": "" } }, "953957cffa914c09a80389d1fecdead1": { "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 } }, "59434af8f0964872b3f512d564d00d6b": { "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": "" } }, "7fc47a59aab047d4953737d9466b963a": { "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_88117a56737040308c207947e44d7741", "IPY_MODEL_fe4807db4d124ce0833274c19086aef6", "IPY_MODEL_a5a8e52d3b67483ca38ed5b524c59b5b" ], "layout": "IPY_MODEL_4bec7500009149abb659b72ffdd646ea" } }, "88117a56737040308c207947e44d7741": { "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_34602b10009148bf8b7e931405fc3082", "placeholder": "​", "style": "IPY_MODEL_8df642d0d1ff494ab409045771ac4b75", "value": "Epoch 1 of 5:   0%" } }, "fe4807db4d124ce0833274c19086aef6": { "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": "danger", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_51cc2e53ef9d40f5968c00cd3432db01", "max": 5, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_859b9dfe9ecf4cef8851fab464b69c60", "value": 0 } }, "a5a8e52d3b67483ca38ed5b524c59b5b": { "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_2ac8cebe32eb41d48e10ddcf4fa681b7", "placeholder": "​", "style": "IPY_MODEL_7bfab4172ee442268bdfd73fb224de0b", "value": " 0/5 [00:33<?, ?it/s]" } }, "4bec7500009149abb659b72ffdd646ea": { "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 } }, "34602b10009148bf8b7e931405fc3082": { "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 } }, "8df642d0d1ff494ab409045771ac4b75": { "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": "" } }, "51cc2e53ef9d40f5968c00cd3432db01": { "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 } }, "859b9dfe9ecf4cef8851fab464b69c60": { "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": "" } }, "2ac8cebe32eb41d48e10ddcf4fa681b7": { "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 } }, "7bfab4172ee442268bdfd73fb224de0b": { "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": "" } }, "11a822a797144419bc1f4a2fa372a8de": { "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_9f7f2d99ad754c47a822c781e648b6d3", "IPY_MODEL_d3d8fcffe8974e45b5efffe0801675c6", "IPY_MODEL_d95acd1a8c5f40bb9a96ddea36df17ef" ], "layout": "IPY_MODEL_53d3bf4b26654adea9c7b2d825ad51d5" } }, "9f7f2d99ad754c47a822c781e648b6d3": { "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_2f0ca4cdef9f45e693fccca16b33dc21", "placeholder": "​", "style": "IPY_MODEL_e411372e08b54141a519f59ba0db3a88", "value": "Epochs 0/5. Running Loss:    2.6828:   1%" } }, "d3d8fcffe8974e45b5efffe0801675c6": { "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": "danger", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_9b881f1b19a6454cb786c7f1b19e8dd5", "max": 4250, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_2c8148869a35467098818392e410c4e1", "value": 32 } }, "d95acd1a8c5f40bb9a96ddea36df17ef": { "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_05a2b18e87b0448e84c7831ccf28eb05", "placeholder": "​", "style": "IPY_MODEL_cfe1f694dd5e46669e1b7ddb702fe340", "value": " 32/4250 [00:33<1:12:31,  1.03s/it]" } }, "53d3bf4b26654adea9c7b2d825ad51d5": { "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 } }, "2f0ca4cdef9f45e693fccca16b33dc21": { "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 } }, "e411372e08b54141a519f59ba0db3a88": { "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": "" } }, "9b881f1b19a6454cb786c7f1b19e8dd5": { "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 } }, "2c8148869a35467098818392e410c4e1": { "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": "" } }, "05a2b18e87b0448e84c7831ccf28eb05": { "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 } }, "cfe1f694dd5e46669e1b7ddb702fe340": { "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": { "id": "8c8s6PNOvn2p" }, "outputs": [], "source": [ "#from google.colab import drive\n", "#drive.mount('/content/drive')" ] }, { "cell_type": "code", "source": [ "!pip install datasets" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "EuzO7di90z5T", "outputId": "61c41ef5-0024-4225-991b-357bf3e916a1" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (2.20.0)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets) (3.15.3)\n", "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (1.25.2)\n", "Requirement already satisfied: pyarrow>=15.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (16.1.0)\n", "Requirement already satisfied: pyarrow-hotfix in /usr/local/lib/python3.10/dist-packages (from datasets) (0.6)\n", "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.3.8)\n", "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (2.0.3)\n", "Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.10/dist-packages (from datasets) (2.32.3)\n", "Requirement already satisfied: tqdm>=4.66.3 in /usr/local/lib/python3.10/dist-packages (from datasets) (4.66.4)\n", "Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets) (3.4.1)\n", "Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets) (0.70.16)\n", "Requirement already satisfied: fsspec[http]<=2024.5.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (2023.6.0)\n", "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.9.5)\n", "Requirement already satisfied: huggingface-hub>=0.21.2 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.23.4)\n", "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets) (24.1)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (6.0.1)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.1)\n", "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (23.2.0)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.4.1)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.0.5)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.9.4)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.3)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.21.2->datasets) (4.12.2)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (3.7)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2.0.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.2->datasets) (2024.6.2)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2023.4)\n", "Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2024.1)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.16.0)\n" ] } ] }, { "cell_type": "code", "source": [ "from datasets import load_dataset\n", "\n", "ds = load_dataset(\"persiannlp/parsinlu_translation_en_fa\")" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "f2_sUUwE0y7K", "outputId": "11678547-45fc-48c5-8d9b-ac449e06dcbd" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:89: 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" ] } ] }, { "cell_type": "code", "source": [ "#import pandas as pd\n", "#dataframe=pd.read_csv('/content/contentdrive/MyDrive/MTM data/TR2EN.txt',sep='\\t')" ], "metadata": { "id": "W2ZP0ln-v8yk" }, "execution_count": 4, "outputs": [] }, { "cell_type": "code", "source": [ "ds.column_names" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "QIOf_1df1C3E", "outputId": "cf8ee4a8-1815-43ed-fb4f-19ffaa73c47c" }, "execution_count": 5, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "{'train': ['source', 'targets', 'category'],\n", " 'test': ['source', 'targets', 'category'],\n", " 'validation': ['source', 'targets', 'category']}" ] }, "metadata": {}, "execution_count": 5 } ] }, { "cell_type": "code", "source": [ "train_data= ds['train']\n", "test_set= ds['test']\n", "validation_set= ds['validation']" ], "metadata": { "id": "nzJBxGga1Mlk" }, "execution_count": 6, "outputs": [] }, { "cell_type": "code", "source": [ "train_data[0]" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "LXygIaV1KE9g", "outputId": "aadd0d38-3ec0-47c1-e875-3159df7b82de" }, "execution_count": 7, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "{'source': 'Due Thank You note by Egyptian blogger Abdel Monem Mahmoud: Following his release from prison, he wrote his first blog titled “Ana ikhwan… I am free”.',\n", " 'targets': ['بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد شدنش از زندان تیتر اولین مطلب خود را «من آزاد هستم» (عربی) انتخاب کرد.'],\n", " 'category': 'global_voices_en_fa'}" ] }, "metadata": {}, "execution_count": 7 } ] }, { "cell_type": "code", "source": [ "len(train_data)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "4rhaY-iAKaav", "outputId": "1679df13-7a00-4d68-de61-7dd9aaf3f351" }, "execution_count": 8, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "1621665" ] }, "metadata": {}, "execution_count": 8 } ] }, { "cell_type": "code", "source": [ "print(train_data[0]['source'])\n", "print(train_data[0]['targets'][0])" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "nqXoAs3P1cre", "outputId": "3d237d12-23f4-4273-d7bc-93b55f5e9081" }, "execution_count": 9, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Due Thank You note by Egyptian blogger Abdel Monem Mahmoud: Following his release from prison, he wrote his first blog titled “Ana ikhwan… I am free”.\n", "بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد شدنش از زندان تیتر اولین مطلب خود را «من آزاد هستم» (عربی) انتخاب کرد.\n" ] } ] }, { "cell_type": "code", "source": [ "train_data_source=[]\n", "train_data_targets=[]\n", "\n", "for i in range(40000):\n", " train_data_source.append(train_data[i]['source'])\n", " train_data_targets.append(train_data[i]['targets'][0])" ], "metadata": { "id": "cZZ7_UTk334W" }, "execution_count": 10, "outputs": [] }, { "cell_type": "code", "source": [ "print(len(train_data_source))\n", "print(len(train_data_targets))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "-Wh7uhVb5DGU", "outputId": "b2623840-4475-4734-c976-e8e8a16b4733" }, "execution_count": 11, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "40000\n", "40000\n" ] } ] }, { "cell_type": "code", "source": [ "print(train_data_source[3])\n", "print(train_data_targets[3])" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "qF1HgVLoKn15", "outputId": "33f8fc79-d9f0-4c6e-d811-bd27571ea906" }, "execution_count": 12, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "He had the intention to write about his last experience in detention, however he felt so overwhelmed with the sincere feelings from everyone around that he could not write but to thank everyone.\n", "وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زندان بنویسد ولی از احساسات تمامی اطرافیانش چنان به وجد آمده که فقط می‌تواند تشکر کند.\n" ] } ] }, { "cell_type": "markdown", "source": [], "metadata": { "id": "7PkfEZlJwZE0" } }, { "cell_type": "code", "source": [ "#data=[]\n", "#for item in dataframe[:10000] .iterrows():\n", " # data.append(['Eng to Tur', item[1].EN, item[1].TR])\n", "prefix=[]\n", "for i in range (40000):\n", " prefix.append('En to Fa translation')" ], "metadata": { "collapsed": true, "id": "QyT7SQSpwA4K" }, "execution_count": 13, "outputs": [] }, { "cell_type": "code", "source": [ "import pandas as pd" ], "metadata": { "id": "ei7sM8Ce51dp" }, "execution_count": 14, "outputs": [] }, { "cell_type": "code", "source": [ "ddata= [prefix,train_data_source,train_data_targets]\n", "maindata= pd.DataFrame(zip(*ddata), columns=['prefix','input_text', 'target_text'])" ], "metadata": { "id": "X36BN0mkyH37" }, "execution_count": 15, "outputs": [] }, { "cell_type": "markdown", "source": [], "metadata": { "id": "OkpKGdYn6tfX" } }, { "cell_type": "code", "source": [ "maindata.head()" ], "metadata": { "id": "zQquofm9A5th", "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "outputId": "b02b39b1-b41a-4703-8c43-94a882b2f0f3" }, "execution_count": 16, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " prefix input_text \\\n", "0 En to Fa translation Due Thank You note by Egyptian blogger Abdel M... \n", "1 En to Fa translation He thanked all fellow bloggers and organizatio... \n", "2 En to Fa translation He was extremely surprised and happy to receiv... \n", "3 En to Fa translation He had the intention to write about his last e... \n", "4 En to Fa translation He concludes his post saying that freedom is t... \n", "\n", " target_text \n", "0 بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش... \n", "1 وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ... \n", "2 وی همچنین از دریافت تعداد بسیار زیادی پیام تبر... \n", "3 وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن... \n", "4 وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ... " ], "text/html": [ "\n", "
\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
prefixinput_texttarget_text
0En to Fa translationDue Thank You note by Egyptian blogger Abdel M...بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش...
1En to Fa translationHe thanked all fellow bloggers and organizatio...وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ...
2En to Fa translationHe was extremely surprised and happy to receiv...وی همچنین از دریافت تعداد بسیار زیادی پیام تبر...
3En to Fa translationHe had the intention to write about his last e...وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن...
4En to Fa translationHe concludes his post saying that freedom is t...وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ...
\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", " \n", "
\n", "
\n", "
\n" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "dataframe", "variable_name": "maindata", "summary": "{\n \"name\": \"maindata\",\n \"rows\": 40000,\n \"fields\": [\n {\n \"column\": \"prefix\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"En to Fa translation\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"input_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39754,\n \"samples\": [\n \"Mugabe responded to allegations of rigging by telling critics to \\\"go hang.\\\"\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"target_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39730,\n \"samples\": [\n \"\\u0645\\u0623\\u0645\\u0648\\u0631 \\u067e\\u0644\\u06cc\\u0633: \\u062e\\u0628 \\u062f\\u06cc \\u06af\\u0647\\u060c \\u0628\\u0647 \\u0633\\u0647 \\u062f\\u06cc \\u06af\\u0647!\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" } }, "metadata": {}, "execution_count": 16 } ] }, { "cell_type": "code", "source": [ "maindata.head()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "HKL5phYEyidM", "outputId": "edc54791-aabd-4c9f-c776-dcf85d8e55e3" }, "execution_count": 17, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " prefix input_text \\\n", "0 En to Fa translation Due Thank You note by Egyptian blogger Abdel M... \n", "1 En to Fa translation He thanked all fellow bloggers and organizatio... \n", "2 En to Fa translation He was extremely surprised and happy to receiv... \n", "3 En to Fa translation He had the intention to write about his last e... \n", "4 En to Fa translation He concludes his post saying that freedom is t... \n", "\n", " target_text \n", "0 بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش... \n", "1 وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ... \n", "2 وی همچنین از دریافت تعداد بسیار زیادی پیام تبر... \n", "3 وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن... \n", "4 وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ... " ], "text/html": [ "\n", "
\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
prefixinput_texttarget_text
0En to Fa translationDue Thank You note by Egyptian blogger Abdel M...بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش...
1En to Fa translationHe thanked all fellow bloggers and organizatio...وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ...
2En to Fa translationHe was extremely surprised and happy to receiv...وی همچنین از دریافت تعداد بسیار زیادی پیام تبر...
3En to Fa translationHe had the intention to write about his last e...وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن...
4En to Fa translationHe concludes his post saying that freedom is t...وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ...
\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", " \n", "
\n", "
\n", "
\n" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "dataframe", "variable_name": "maindata", "summary": "{\n \"name\": \"maindata\",\n \"rows\": 40000,\n \"fields\": [\n {\n \"column\": \"prefix\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"En to Fa translation\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"input_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39754,\n \"samples\": [\n \"Mugabe responded to allegations of rigging by telling critics to \\\"go hang.\\\"\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"target_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 39730,\n \"samples\": [\n \"\\u0645\\u0623\\u0645\\u0648\\u0631 \\u067e\\u0644\\u06cc\\u0633: \\u062e\\u0628 \\u062f\\u06cc \\u06af\\u0647\\u060c \\u0628\\u0647 \\u0633\\u0647 \\u062f\\u06cc \\u06af\\u0647!\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" } }, "metadata": {}, "execution_count": 17 } ] }, { "cell_type": "code", "source": [ "train_df= maindata[:34000]\n", "eval_df = maindata [34000:40000]" ], "metadata": { "id": "fnFwgbhXyn8a" }, "execution_count": 18, "outputs": [] }, { "cell_type": "code", "source": [ "train_df" ], "metadata": { "collapsed": true, "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "id": "VeWR4t2My2sr", "outputId": "c2084a60-476e-4bed-9bf5-a82a04061bbf" }, "execution_count": 19, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " prefix \\\n", "0 En to Fa translation \n", "1 En to Fa translation \n", "2 En to Fa translation \n", "3 En to Fa translation \n", "4 En to Fa translation \n", "... ... \n", "33995 En to Fa translation \n", "33996 En to Fa translation \n", "33997 En to Fa translation \n", "33998 En to Fa translation \n", "33999 En to Fa translation \n", "\n", " input_text \\\n", "0 Due Thank You note by Egyptian blogger Abdel M... \n", "1 He thanked all fellow bloggers and organizatio... \n", "2 He was extremely surprised and happy to receiv... \n", "3 He had the intention to write about his last e... \n", "4 He concludes his post saying that freedom is t... \n", "... ... \n", "33995 Presently the talking to wore itself out in as... \n", "33996 The parents were now satisfied. \n", "33997 Dorothy had had her lesson and would doubtless... \n", "33998 they did not bear her any malice and were not ... \n", "33999 They said good bye to Mrs Creevy, said good by... \n", "\n", " target_text \n", "0 بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش... \n", "1 وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ... \n", "2 وی همچنین از دریافت تعداد بسیار زیادی پیام تبر... \n", "3 وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن... \n", "4 وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ... \n", "... ... \n", "33995 لحظاتی بعد تذکر دادن‌های خانم کری وی بالاخره ب... \n", "33996 پدر و مادرها دیگر راضی شده بودند \n", "33997 در وتی نیز درس عبرت لازم را گرفته و شکی نبود ک... \n", "33998 آن‌ها نیز در واقع هیچ خصومتی ‌نسبت به وی نداشت... \n", "33999 آنان با خانم کری وی و دروتی البته با لحنی سردت... \n", "\n", "[34000 rows x 3 columns]" ], "text/html": [ "\n", "
\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
prefixinput_texttarget_text
0En to Fa translationDue Thank You note by Egyptian blogger Abdel M...بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش...
1En to Fa translationHe thanked all fellow bloggers and organizatio...وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ...
2En to Fa translationHe was extremely surprised and happy to receiv...وی همچنین از دریافت تعداد بسیار زیادی پیام تبر...
3En to Fa translationHe had the intention to write about his last e...وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن...
4En to Fa translationHe concludes his post saying that freedom is t...وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ...
............
33995En to Fa translationPresently the talking to wore itself out in as...لحظاتی بعد تذکر دادن‌های خانم کری وی بالاخره ب...
33996En to Fa translationThe parents were now satisfied.پدر و مادرها دیگر راضی شده بودند
33997En to Fa translationDorothy had had her lesson and would doubtless...در وتی نیز درس عبرت لازم را گرفته و شکی نبود ک...
33998En to Fa translationthey did not bear her any malice and were not ...آن‌ها نیز در واقع هیچ خصومتی ‌نسبت به وی نداشت...
33999En to Fa translationThey said good bye to Mrs Creevy, said good by...آنان با خانم کری وی و دروتی البته با لحنی سردت...
\n", "

34000 rows × 3 columns

\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", " \n", "
\n", "
\n", "
\n" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "dataframe", "variable_name": "train_df", "summary": "{\n \"name\": \"train_df\",\n \"rows\": 34000,\n \"fields\": [\n {\n \"column\": \"prefix\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"En to Fa translation\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"input_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 33858,\n \"samples\": [\n \"So, organically, I was efficient in the desert, felt neither hunger nor surfeit, and was not distracted by thought of food.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"target_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 33814,\n \"samples\": [\n \"\\u0622\\u0646 \\u067e\\u0644\\u06cc \\u0628\\u0648\\u062f \\u06a9\\u0647 \\u0645\\u0627 \\u0627\\u0632 \\u0628\\u0627\\u0644\\u0627 \\u0645\\u06cc\\u200c\\u062f\\u06cc\\u062f\\u06cc\\u0645.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" } }, "metadata": {}, "execution_count": 19 } ] }, { "cell_type": "code", "source": [ "!pip install simpletransformers==0.61.0" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ou4tRtmQzTS6", "outputId": "e95e5b48-c3c6-4e55-ace1-aa476db1df8d" }, "execution_count": 20, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: simpletransformers==0.61.0 in /usr/local/lib/python3.10/dist-packages (0.61.0)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (1.25.2)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (2.32.3)\n", "Requirement already satisfied: tqdm>=4.47.0 in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (4.66.4)\n", "Requirement already satisfied: regex in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (2024.5.15)\n", "Requirement already satisfied: transformers>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (4.41.2)\n", "Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (1.11.4)\n", "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (1.2.2)\n", "Requirement already satisfied: seqeval in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (1.2.2)\n", "Requirement already satisfied: tensorboardx in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (2.6.2.2)\n", "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (2.0.3)\n", "Requirement already satisfied: tokenizers in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (0.19.1)\n", "Requirement already satisfied: wandb in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (0.17.3)\n", "Requirement already satisfied: streamlit in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (1.36.0)\n", "Requirement already satisfied: sentencepiece in /usr/local/lib/python3.10/dist-packages (from simpletransformers==0.61.0) (0.1.99)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from transformers>=4.2.0->simpletransformers==0.61.0) (3.15.3)\n", "Requirement already satisfied: huggingface-hub<1.0,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.2.0->simpletransformers==0.61.0) (0.23.4)\n", "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.2.0->simpletransformers==0.61.0) (24.1)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.2.0->simpletransformers==0.61.0) (6.0.1)\n", "Requirement already satisfied: safetensors>=0.4.1 in /usr/local/lib/python3.10/dist-packages (from transformers>=4.2.0->simpletransformers==0.61.0) (0.4.3)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->simpletransformers==0.61.0) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->simpletransformers==0.61.0) (2023.4)\n", "Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->simpletransformers==0.61.0) (2024.1)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->simpletransformers==0.61.0) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->simpletransformers==0.61.0) (3.7)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->simpletransformers==0.61.0) (2.0.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->simpletransformers==0.61.0) (2024.6.2)\n", "Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->simpletransformers==0.61.0) (1.4.2)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn->simpletransformers==0.61.0) (3.5.0)\n", "Requirement already satisfied: altair<6,>=4.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (4.2.2)\n", "Requirement already satisfied: blinker<2,>=1.0.0 in /usr/lib/python3/dist-packages (from streamlit->simpletransformers==0.61.0) (1.4)\n", "Requirement already satisfied: cachetools<6,>=4.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (5.3.3)\n", "Requirement already satisfied: click<9,>=7.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (8.1.7)\n", "Requirement already satisfied: pillow<11,>=7.1.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (9.4.0)\n", "Requirement already satisfied: protobuf<6,>=3.20 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (3.20.3)\n", "Requirement already satisfied: pyarrow>=7.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (16.1.0)\n", "Requirement already satisfied: rich<14,>=10.14.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (13.7.1)\n", "Requirement already satisfied: tenacity<9,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (8.4.1)\n", "Requirement already satisfied: toml<2,>=0.10.1 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (0.10.2)\n", "Requirement already satisfied: typing-extensions<5,>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (4.12.2)\n", "Requirement already satisfied: gitpython!=3.1.19,<4,>=3.0.7 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (3.1.43)\n", "Requirement already satisfied: pydeck<1,>=0.8.0b4 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (0.9.1)\n", "Requirement already satisfied: tornado<7,>=6.0.3 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (6.3.3)\n", "Requirement already satisfied: watchdog<5,>=2.1.5 in /usr/local/lib/python3.10/dist-packages (from streamlit->simpletransformers==0.61.0) (4.0.1)\n", "Requirement already satisfied: docker-pycreds>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (0.4.0)\n", "Requirement already satisfied: platformdirs in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (4.2.2)\n", "Requirement already satisfied: psutil>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (5.9.5)\n", "Requirement already satisfied: sentry-sdk>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (2.6.0)\n", "Requirement already satisfied: setproctitle in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (1.3.3)\n", "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from wandb->simpletransformers==0.61.0) (67.7.2)\n", "Requirement already satisfied: entrypoints in /usr/local/lib/python3.10/dist-packages (from altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (0.4)\n", "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (3.1.4)\n", "Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (4.19.2)\n", "Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (0.12.1)\n", "Requirement already satisfied: six>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from docker-pycreds>=0.4.0->wandb->simpletransformers==0.61.0) (1.16.0)\n", "Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/lib/python3.10/dist-packages (from gitpython!=3.1.19,<4,>=3.0.7->streamlit->simpletransformers==0.61.0) (4.0.11)\n", "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.23.0->transformers>=4.2.0->simpletransformers==0.61.0) (2023.6.0)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich<14,>=10.14.0->streamlit->simpletransformers==0.61.0) (3.0.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich<14,>=10.14.0->streamlit->simpletransformers==0.61.0) (2.16.1)\n", "Requirement already satisfied: smmap<6,>=3.0.1 in /usr/local/lib/python3.10/dist-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3.0.7->streamlit->simpletransformers==0.61.0) (5.0.1)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (2.1.5)\n", "Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (23.2.0)\n", "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (2023.12.1)\n", "Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (0.35.1)\n", "Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit->simpletransformers==0.61.0) (0.18.1)\n", "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich<14,>=10.14.0->streamlit->simpletransformers==0.61.0) (0.1.2)\n" ] } ] }, { "cell_type": "code", "source": [ "from simpletransformers.t5 import T5Model, T5Args" ], "metadata": { "id": "pD0PoLBNy7jh" }, "execution_count": 21, "outputs": [] }, { "cell_type": "markdown", "source": [], "metadata": { "id": "LN9lDWu4L0af" } }, { "cell_type": "code", "source": [ "model_args= T5Args()" ], "metadata": { "id": "eMBjjmyRzzxS" }, "execution_count": 22, "outputs": [] }, { "cell_type": "code", "source": [ "model_args.fp16= False\n", "model_args.max_seq_length= 128\n", "model_args.train_batch_size= 8\n", "model_args.eval_batch_size = 8\n", "model_args.num_train_epochs = 5\n", "model_args.evaluate_during_training= True\n", "model_args.evaluate_during_training_steps= 10000\n", "model_args.use_multiprocessing= False\n", "model_args.reprocess_input_data=True\n", "model_args.overwrite_output_dir= True\n", "model_args.save_steps=-1\n", "model_args.no_cache= True\n", "model_args.preprocess_inputs= False\n", "model_args.num_return_sequences = 1\n", "model_args.save_eval_checkpoints= False\n", "model_args.max_length=128\n", "model_args.num_beams=4\n" ], "metadata": { "id": "jPR0GUJv0AD6" }, "execution_count": 23, "outputs": [] }, { "cell_type": "code", "source": [ "model= T5Model (\"mt5\", \"google/mt5-base\",args=model_args, use_cuda=True)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "osAM_qp_1Yn7", "outputId": "69b8afd5-8a79-4050-e804-5b102ee2cdab" }, "execution_count": 24, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "/usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", " warnings.warn(\n", "You are using the default legacy behaviour of the . This is expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565\n" ] } ] }, { "cell_type": "code", "source": [ "print(len(train_df))\n", "print (len(eval_df))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "BQYFe5uC5qQx", "outputId": "27fab1ad-513e-4690-f7d2-975977a97f05" }, "execution_count": 25, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "34000\n", "6000\n" ] } ] }, { "cell_type": "code", "source": [ "train_df.head()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "jHNdZq2v7eRY", "outputId": "43d04331-23ef-4167-e81e-d49c18684665" }, "execution_count": 26, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " prefix input_text \\\n", "0 En to Fa translation Due Thank You note by Egyptian blogger Abdel M... \n", "1 En to Fa translation He thanked all fellow bloggers and organizatio... \n", "2 En to Fa translation He was extremely surprised and happy to receiv... \n", "3 En to Fa translation He had the intention to write about his last e... \n", "4 En to Fa translation He concludes his post saying that freedom is t... \n", "\n", " target_text \n", "0 بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش... \n", "1 وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ... \n", "2 وی همچنین از دریافت تعداد بسیار زیادی پیام تبر... \n", "3 وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن... \n", "4 وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ... " ], "text/html": [ "\n", "
\n", "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
prefixinput_texttarget_text
0En to Fa translationDue Thank You note by Egyptian blogger Abdel M...بلاگر مصری عبدل منعم محمود (عربی) پس از آزاد ش...
1En to Fa translationHe thanked all fellow bloggers and organizatio...وی از تمامی بلاگرها، سازمان‌ها و افرادی که از ...
2En to Fa translationHe was extremely surprised and happy to receiv...وی همچنین از دریافت تعداد بسیار زیادی پیام تبر...
3En to Fa translationHe had the intention to write about his last e...وی گفت در ابتدا قصد داشت درباره تجربه‌اش در زن...
4En to Fa translationHe concludes his post saying that freedom is t...وی در پایان نوشته‌اش می‌نویسد آزادی واقعا بها ...
\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", " \n", "\n", "\n", "\n", " \n", "
\n", "
\n", "
\n" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "dataframe", "variable_name": "train_df", "summary": "{\n \"name\": \"train_df\",\n \"rows\": 34000,\n \"fields\": [\n {\n \"column\": \"prefix\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"En to Fa translation\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"input_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 33858,\n \"samples\": [\n \"So, organically, I was efficient in the desert, felt neither hunger nor surfeit, and was not distracted by thought of food.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"target_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 33814,\n \"samples\": [\n \"\\u0622\\u0646 \\u067e\\u0644\\u06cc \\u0628\\u0648\\u062f \\u06a9\\u0647 \\u0645\\u0627 \\u0627\\u0632 \\u0628\\u0627\\u0644\\u0627 \\u0645\\u06cc\\u200c\\u062f\\u06cc\\u062f\\u06cc\\u0645.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" } }, "metadata": {}, "execution_count": 26 } ] }, { "cell_type": "code", "source": [ "model.train_model(train_data=train_df,eval_data=eval_df)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 816, "referenced_widgets": [ "42fafb26b3cb4f0daeb4b561aea8f29f", "132aa00a3220429c8438de04b84649b4", "93286e40b3024fa4a96769f05856962e", "0b5acca09b4e4e99908a2f8121861cf4", "3cdaf59d8ac34e91a14555d91f4c0610", "b533ffea5bc6415bb8c7c6f40e2c01e9", "9c2c390f7b5c4523bc462f00e3607d31", "24415a2652d44b1485bec6b75ce293d9", "e7e78bef4cc7468c8d7742371f100f01", "953957cffa914c09a80389d1fecdead1", "59434af8f0964872b3f512d564d00d6b", "7fc47a59aab047d4953737d9466b963a", "88117a56737040308c207947e44d7741", "fe4807db4d124ce0833274c19086aef6", "a5a8e52d3b67483ca38ed5b524c59b5b", "4bec7500009149abb659b72ffdd646ea", "34602b10009148bf8b7e931405fc3082", "8df642d0d1ff494ab409045771ac4b75", "51cc2e53ef9d40f5968c00cd3432db01", "859b9dfe9ecf4cef8851fab464b69c60", "2ac8cebe32eb41d48e10ddcf4fa681b7", "7bfab4172ee442268bdfd73fb224de0b", "11a822a797144419bc1f4a2fa372a8de", "9f7f2d99ad754c47a822c781e648b6d3", "d3d8fcffe8974e45b5efffe0801675c6", "d95acd1a8c5f40bb9a96ddea36df17ef", "53d3bf4b26654adea9c7b2d825ad51d5", "2f0ca4cdef9f45e693fccca16b33dc21", "e411372e08b54141a519f59ba0db3a88", "9b881f1b19a6454cb786c7f1b19e8dd5", "2c8148869a35467098818392e410c4e1", "05a2b18e87b0448e84c7831ccf28eb05", "cfe1f694dd5e46669e1b7ddb702fe340" ] }, "id": "cmWEw6HE2FIc", "outputId": "8ce70147-9011-4d2d-f0be-464f381b7074" }, "execution_count": 28, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ " 0%| | 0/34000 [00:00\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain_model\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrain_df\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0meval_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0meval_df\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/simpletransformers/t5/t5_model.py\u001b[0m in \u001b[0;36mtrain_model\u001b[0;34m(self, train_data, output_dir, show_running_loss, args, eval_data, verbose, **kwargs)\u001b[0m\n\u001b[1;32m 198\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmakedirs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput_dir\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexist_ok\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 199\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 200\u001b[0;31m global_step, training_details = self.train(\n\u001b[0m\u001b[1;32m 201\u001b[0m \u001b[0mtrain_dataset\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 202\u001b[0m \u001b[0moutput_dir\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/simpletransformers/t5/t5_model.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, train_dataset, output_dir, show_running_loss, eval_data, verbose, **kwargs)\u001b[0m\n\u001b[1;32m 476\u001b[0m \u001b[0mscaler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 477\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 478\u001b[0;31m \u001b[0moptimizer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 479\u001b[0m \u001b[0mscheduler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Update learning rate schedule\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 480\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzero_grad\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/torch/optim/lr_scheduler.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_step_count\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[0mwrapped\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__get__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minstance\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 75\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapped\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 76\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;31m# Note that the returned function here is no longer a bound method,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/torch/optim/optimizer.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 389\u001b[0m )\n\u001b[1;32m 390\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 391\u001b[0;31m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 392\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_optimizer_step_code\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 393\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py\u001b[0m in \u001b[0;36mdecorate_context\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdecorate_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 114\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mctx_factory\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 115\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 116\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 117\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdecorate_context\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/transformers/optimization.py\u001b[0m in \u001b[0;36mstep\u001b[0;34m(self, closure)\u001b[0m\n\u001b[1;32m 872\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 873\u001b[0m \u001b[0mbeta2t\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1.0\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mmath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"step\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgroup\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"decay_rate\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 874\u001b[0;31m \u001b[0mupdate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mgrad\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mgroup\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"eps\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 875\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfactored\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 876\u001b[0m \u001b[0mexp_avg_sq_row\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"exp_avg_sq_row\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/torch/_tensor.py\u001b[0m in \u001b[0;36mwrapped\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mhas_torch_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mhandle_torch_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwrapped\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 40\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 41\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 42\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mNotImplemented\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ] }, { "cell_type": "code", "source": [ "!cp -r '/content/outputs/best_model' '/content/contentdrive/MyDrive/MT5 en to Persian MT'\n", "\n" ], "metadata": { "id": "RDJzUqcN-FJn" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "model.predict('this is a good day')" ], "metadata": { "id": "RTqFbR4g_DQQ" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "model.predict('this is a good day')" ], "metadata": { "id": "YbRujANwAMwo" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "y" ], "metadata": { "id": "ScZ9k_WkPsq2" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from transformers import (T5Tokenizer, MT5ForConditionalGeneration, Text2TextGenerationPipeline, )\n", "\n", "path = \"/content/outputs/best_model\"\n", "\n", "pipe = Text2TextGenerationPipeline( model=MT5ForConditionalGeneration.from_pretrained(path), tokenizer=T5Tokenizer.from_pretrained(path), )\n" ], "metadata": { "id": "Li13g670OA8N" }, "execution_count": 35, "outputs": [] }, { "cell_type": "code", "source": [ "sentence = \"How do yu know that this book is good.\"\n", "\n", "#res = pipe(sentence, max_length=100, num_beams=4\n", "\n", "res = pipe(sentence, max_length=128,num_beams=4)\n", "\n", "print(res[0]['generated_text'])" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "c_lDFMwPDws3", "outputId": "b64ee6d1-08f8-4439-9e05-23deb04b17ba" }, "execution_count": 36, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "این کتاب خوب است.\n" ] } ] } ] }