Skip to content

Instantly share code, notes, and snippets.

@iam-abbas
Created December 31, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iam-abbas/f13433374e780d194f9dfaeb44162b1d to your computer and use it in GitHub Desktop.
Save iam-abbas/f13433374e780d194f9dfaeb44162b1d to your computer and use it in GitHub Desktop.
Using GPT-2 Horror Stories Model
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Using GPT-2 Horror Stories Model",
"provenance": [],
"authorship_tag": "ABX9TyMj54Q3p17RJUzYx8q3s9Rl",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"37bee902ecd7447f9f0559588f2629ef": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_2cc3877b3eba4c049aeb3982e9331709",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_df0c7ca7ce99406ebdcef1895b99f71d",
"IPY_MODEL_6ae1d73d795b4cc3b3493ac11f03e4f2"
]
}
},
"2cc3877b3eba4c049aeb3982e9331709": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"df0c7ca7ce99406ebdcef1895b99f71d": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_8b12828c12ed485e833a167447376bd6",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 768,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 768,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_105eaf8fdb2a466fb514186c4ef23d6b"
}
},
"6ae1d73d795b4cc3b3493ac11f03e4f2": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_c7a665377aa44e9fa3df6312f34d7780",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 768/768 [00:00<00:00, 19.8kB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_9d0d4a2849454cb59f821ffe98072c7a"
}
},
"8b12828c12ed485e833a167447376bd6": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"105eaf8fdb2a466fb514186c4ef23d6b": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"c7a665377aa44e9fa3df6312f34d7780": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"9d0d4a2849454cb59f821ffe98072c7a": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"4d6187baa13d422f8c33dd0811ea54a3": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_9e3897bb2b7d411db349a88ab66c896c",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_f80340f545554f0da9e1fdecaa446957",
"IPY_MODEL_3494ee3e345742d28fd61cbbbf851756"
]
}
},
"9e3897bb2b7d411db349a88ab66c896c": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"f80340f545554f0da9e1fdecaa446957": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_5117a2f71e884555b3e7769d64e11102",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 798156,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 798156,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_bbdc17832df64564b8500b6f2f6a5302"
}
},
"3494ee3e345742d28fd61cbbbf851756": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_b0096c08224d47d6a840fd36f93f35a7",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 798k/798k [00:02<00:00, 316kB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_407ae378a1394061b6f18e7ddd212198"
}
},
"5117a2f71e884555b3e7769d64e11102": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"bbdc17832df64564b8500b6f2f6a5302": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"b0096c08224d47d6a840fd36f93f35a7": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"407ae378a1394061b6f18e7ddd212198": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"ecab461591364384a8c1fb896c046561": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_8f845d3dcace4d009a69b7d3f02c5069",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_f19b0c859bff4f068744cd68e9da279e",
"IPY_MODEL_5ef997c0b0084013a0980efb2cbb38f1"
]
}
},
"8f845d3dcace4d009a69b7d3f02c5069": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"f19b0c859bff4f068744cd68e9da279e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_d95639b4057d4cedb01d273a0748513f",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 456356,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 456356,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_473e9d51c5bd4c6a8765bd7fc0048663"
}
},
"5ef997c0b0084013a0980efb2cbb38f1": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_7fff7bab70b2457d85346a54686799c3",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 456k/456k [00:01<00:00, 298kB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_53899b088b2847f8a7657c0a07859143"
}
},
"d95639b4057d4cedb01d273a0748513f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"473e9d51c5bd4c6a8765bd7fc0048663": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"7fff7bab70b2457d85346a54686799c3": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"53899b088b2847f8a7657c0a07859143": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"d64722a6c44b4f768b3069c5e0d5335e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_a6562d60cc7349eca0dc6b0e79734df8",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_fe27ed397c3d4faaa0675d9087e5c39e",
"IPY_MODEL_af90e5f7cc7143a48cc1330fe08191cd"
]
}
},
"a6562d60cc7349eca0dc6b0e79734df8": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"fe27ed397c3d4faaa0675d9087e5c39e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_67973c3e7936441abf2a2b008fd46f1b",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 90,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 90,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_0d8f2094f31440d090836fe3577bbae4"
}
},
"af90e5f7cc7143a48cc1330fe08191cd": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_0e096a1cd557467cb6bff65bdfc3d84d",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 90.0/90.0 [00:00<00:00, 126B/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_87a4b79cd4b74b8ea963a51ccb601b8d"
}
},
"67973c3e7936441abf2a2b008fd46f1b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"0d8f2094f31440d090836fe3577bbae4": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"0e096a1cd557467cb6bff65bdfc3d84d": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"87a4b79cd4b74b8ea963a51ccb601b8d": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"b2af4ab5ebfc420eb464a7001faae69f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_d8350130c3dc45e5a2cbe8e2e49ac01c",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_834f6a0b023c4fb98c586d745fb022f5",
"IPY_MODEL_11b2d400de7741af8e845f5f89b1096a"
]
}
},
"d8350130c3dc45e5a2cbe8e2e49ac01c": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"834f6a0b023c4fb98c586d745fb022f5": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_f49671b5ba554ce199d487b5d8d9b79e",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 167,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 167,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_a0076a6ed5dd43a2ac13006328fb7261"
}
},
"11b2d400de7741af8e845f5f89b1096a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_c0494e64a15d4588a68103700430ea90",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 167/167 [00:00<00:00, 1.31kB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_8b926028abd44c87b12e663b37a6f188"
}
},
"f49671b5ba554ce199d487b5d8d9b79e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"a0076a6ed5dd43a2ac13006328fb7261": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"c0494e64a15d4588a68103700430ea90": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"8b926028abd44c87b12e663b37a6f188": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"d2f8e393d43849b8999b8b0d6b52da16": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"state": {
"_view_name": "HBoxView",
"_dom_classes": [],
"_model_name": "HBoxModel",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_37ef4f9e19e941eea6e1b2e600d4cc28",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_f2768c61cbae40168a472046938b9dd0",
"IPY_MODEL_755dbf49ced14e39bc0cdecbe05c394f"
]
}
},
"37ef4f9e19e941eea6e1b2e600d4cc28": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"f2768c61cbae40168a472046938b9dd0": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_0a60a46cdfb1403680416f781232db72",
"_dom_classes": [],
"description": "Downloading: 100%",
"_model_name": "FloatProgressModel",
"bar_style": "success",
"max": 510406559,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 510406559,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_33605f7141ac4087afbf5bc8f87958a4"
}
},
"755dbf49ced14e39bc0cdecbe05c394f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"state": {
"_view_name": "HTMLView",
"style": "IPY_MODEL_2036996e924c451d8a8bcca25638d617",
"_dom_classes": [],
"description": "",
"_model_name": "HTMLModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": " 510M/510M [00:18<00:00, 27.5MB/s]",
"_view_count": null,
"_view_module_version": "1.5.0",
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_84ccdb801c5e42109e8f229c7560db8c"
}
},
"0a60a46cdfb1403680416f781232db72": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "initial",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"33605f7141ac4087afbf5bc8f87958a4": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"2036996e924c451d8a8bcca25638d617": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"84ccdb801c5e42109e8f229c7560db8c": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/iam-abbas/f13433374e780d194f9dfaeb44162b1d/using-gpt-2-horror-stories-model.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eO1hXmwbt75y"
},
"source": [
"## Usage of `abbas/gpt-horror-stories` model on huggingface."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nry5KMAruDrI"
},
"source": [
"## Installing transformers"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Ucic3GTwai7R",
"outputId": "12dc40c7-29b7-46be-da48-441c93308596"
},
"source": [
"!pip install transformers"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting transformers\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/50/0c/7d5950fcd80b029be0a8891727ba21e0cd27692c407c51261c3c921f6da3/transformers-4.1.1-py3-none-any.whl (1.5MB)\n",
"\r\u001b[K |▏ | 10kB 20.9MB/s eta 0:00:01\r\u001b[K |▍ | 20kB 28.5MB/s eta 0:00:01\r\u001b[K |▋ | 30kB 25.7MB/s eta 0:00:01\r\u001b[K |▉ | 40kB 19.2MB/s eta 0:00:01\r\u001b[K |█ | 51kB 16.5MB/s eta 0:00:01\r\u001b[K |█▎ | 61kB 18.1MB/s eta 0:00:01\r\u001b[K |█▌ | 71kB 15.0MB/s eta 0:00:01\r\u001b[K |█▊ | 81kB 15.1MB/s eta 0:00:01\r\u001b[K |██ | 92kB 15.2MB/s eta 0:00:01\r\u001b[K |██▏ | 102kB 13.9MB/s eta 0:00:01\r\u001b[K |██▍ | 112kB 13.9MB/s eta 0:00:01\r\u001b[K |██▋ | 122kB 13.9MB/s eta 0:00:01\r\u001b[K |██▉ | 133kB 13.9MB/s eta 0:00:01\r\u001b[K |███ | 143kB 13.9MB/s eta 0:00:01\r\u001b[K |███▎ | 153kB 13.9MB/s eta 0:00:01\r\u001b[K |███▌ | 163kB 13.9MB/s eta 0:00:01\r\u001b[K |███▊ | 174kB 13.9MB/s eta 0:00:01\r\u001b[K |████ | 184kB 13.9MB/s eta 0:00:01\r\u001b[K |████▏ | 194kB 13.9MB/s eta 0:00:01\r\u001b[K |████▎ | 204kB 13.9MB/s eta 0:00:01\r\u001b[K |████▌ | 215kB 13.9MB/s eta 0:00:01\r\u001b[K |████▊ | 225kB 13.9MB/s eta 0:00:01\r\u001b[K |█████ | 235kB 13.9MB/s eta 0:00:01\r\u001b[K |█████▏ | 245kB 13.9MB/s eta 0:00:01\r\u001b[K |█████▍ | 256kB 13.9MB/s eta 0:00:01\r\u001b[K |█████▋ | 266kB 13.9MB/s eta 0:00:01\r\u001b[K |█████▉ | 276kB 13.9MB/s eta 0:00:01\r\u001b[K |██████ | 286kB 13.9MB/s eta 0:00:01\r\u001b[K |██████▎ | 296kB 13.9MB/s eta 0:00:01\r\u001b[K |██████▌ | 307kB 13.9MB/s eta 0:00:01\r\u001b[K |██████▊ | 317kB 13.9MB/s eta 0:00:01\r\u001b[K |███████ | 327kB 13.9MB/s eta 0:00:01\r\u001b[K |███████▏ | 337kB 13.9MB/s eta 0:00:01\r\u001b[K |███████▍ | 348kB 13.9MB/s eta 0:00:01\r\u001b[K |███████▋ | 358kB 13.9MB/s eta 0:00:01\r\u001b[K |███████▉ | 368kB 13.9MB/s eta 0:00:01\r\u001b[K |████████ | 378kB 13.9MB/s eta 0:00:01\r\u001b[K |████████▎ | 389kB 13.9MB/s eta 0:00:01\r\u001b[K |████████▌ | 399kB 13.9MB/s eta 0:00:01\r\u001b[K |████████▋ | 409kB 13.9MB/s eta 0:00:01\r\u001b[K |████████▉ | 419kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████ | 430kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████▎ | 440kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████▌ | 450kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████▊ | 460kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████ | 471kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████▏ | 481kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████▍ | 491kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████▋ | 501kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████▉ | 512kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████ | 522kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████▎ | 532kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████▌ | 542kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████▊ | 552kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████ | 563kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████▏ | 573kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████▍ | 583kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████▋ | 593kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████▉ | 604kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████ | 614kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████▏ | 624kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████▍ | 634kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████▋ | 645kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████▉ | 655kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████ | 665kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████▎ | 675kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████▌ | 686kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████▊ | 696kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████ | 706kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████▏ | 716kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████▍ | 727kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████▋ | 737kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████▉ | 747kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████ | 757kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████▎ | 768kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████▌ | 778kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████▊ | 788kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████ | 798kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████ | 808kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████▎ | 819kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████▌ | 829kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████▊ | 839kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████ | 849kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████▏ | 860kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████▍ | 870kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████▋ | 880kB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████▉ | 890kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████ | 901kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████▎ | 911kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████▌ | 921kB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████▊ | 931kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████ | 942kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████▏ | 952kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████▍ | 962kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████▋ | 972kB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████▉ | 983kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████ | 993kB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████▎ | 1.0MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████▍ | 1.0MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████▋ | 1.0MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████▉ | 1.0MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 1.0MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████▎ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████▌ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████▊ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████▏ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████▍ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████▋ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████▉ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████▎ | 1.1MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████▌ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████▊ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████▏ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████▍ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████▋ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████▊ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████▏ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████▍ | 1.2MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████▋ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████▉ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████▎ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████▌ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████▊ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████▏ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████▍ | 1.3MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████▋ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████▉ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████████ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▎ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▌ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▊ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▉ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▎ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▌ | 1.4MB 13.9MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▊ | 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▏| 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▍| 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▋| 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▉| 1.5MB 13.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 1.5MB 13.9MB/s \n",
"\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.6/dist-packages (from transformers) (3.0.12)\n",
"Collecting tokenizers==0.9.4\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/0f/1c/e789a8b12e28be5bc1ce2156cf87cb522b379be9cadc7ad8091a4cc107c4/tokenizers-0.9.4-cp36-cp36m-manylinux2010_x86_64.whl (2.9MB)\n",
"\u001b[K |████████████████████████████████| 2.9MB 51.5MB/s \n",
"\u001b[?25hRequirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.6/dist-packages (from transformers) (4.41.1)\n",
"Requirement already satisfied: dataclasses; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from transformers) (0.8)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.6/dist-packages (from transformers) (20.8)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from transformers) (2.23.0)\n",
"Collecting sacremoses\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/7d/34/09d19aff26edcc8eb2a01bed8e98f13a1537005d31e95233fd48216eed10/sacremoses-0.0.43.tar.gz (883kB)\n",
"\u001b[K |████████████████████████████████| 890kB 50.8MB/s \n",
"\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from transformers) (1.19.4)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.6/dist-packages (from transformers) (2019.12.20)\n",
"Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from packaging->transformers) (2.4.7)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (3.0.4)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (1.24.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (2020.12.5)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->transformers) (2.10)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (1.15.0)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (7.1.2)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.6/dist-packages (from sacremoses->transformers) (1.0.0)\n",
"Building wheels for collected packages: sacremoses\n",
" Building wheel for sacremoses (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for sacremoses: filename=sacremoses-0.0.43-cp36-none-any.whl size=893261 sha256=7ddf65a991a0bf19b646d180e58a7d065a5ee8f35b3d53dae2d1d78c0bca4182\n",
" Stored in directory: /root/.cache/pip/wheels/29/3c/fd/7ce5c3f0666dab31a50123635e6fb5e19ceb42ce38d4e58f45\n",
"Successfully built sacremoses\n",
"Installing collected packages: tokenizers, sacremoses, transformers\n",
"Successfully installed sacremoses-0.0.43 tokenizers-0.9.4 transformers-4.1.1\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HhR7n_LeuGpV"
},
"source": [
"## Importing all the required libraries"
]
},
{
"cell_type": "code",
"metadata": {
"id": "bD1psnjxagWf"
},
"source": [
"from transformers import AutoTokenizer, AutoModelWithLMHead\r\n",
"import torch\r\n",
"import numpy as np"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "wBr8dCqbuL4q"
},
"source": [
"## Using cuda if available else cpu"
]
},
{
"cell_type": "code",
"metadata": {
"id": "JMwzTzAJfLDm"
},
"source": [
"device = 'cpu'\r\n",
"if torch.cuda.is_available():\r\n",
" device = 'cuda'"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "jHq9HQ2-uQFt"
},
"source": [
"## Downloading the model"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 383,
"referenced_widgets": [
"37bee902ecd7447f9f0559588f2629ef",
"2cc3877b3eba4c049aeb3982e9331709",
"df0c7ca7ce99406ebdcef1895b99f71d",
"6ae1d73d795b4cc3b3493ac11f03e4f2",
"8b12828c12ed485e833a167447376bd6",
"105eaf8fdb2a466fb514186c4ef23d6b",
"c7a665377aa44e9fa3df6312f34d7780",
"9d0d4a2849454cb59f821ffe98072c7a",
"4d6187baa13d422f8c33dd0811ea54a3",
"9e3897bb2b7d411db349a88ab66c896c",
"f80340f545554f0da9e1fdecaa446957",
"3494ee3e345742d28fd61cbbbf851756",
"5117a2f71e884555b3e7769d64e11102",
"bbdc17832df64564b8500b6f2f6a5302",
"b0096c08224d47d6a840fd36f93f35a7",
"407ae378a1394061b6f18e7ddd212198",
"ecab461591364384a8c1fb896c046561",
"8f845d3dcace4d009a69b7d3f02c5069",
"f19b0c859bff4f068744cd68e9da279e",
"5ef997c0b0084013a0980efb2cbb38f1",
"d95639b4057d4cedb01d273a0748513f",
"473e9d51c5bd4c6a8765bd7fc0048663",
"7fff7bab70b2457d85346a54686799c3",
"53899b088b2847f8a7657c0a07859143",
"d64722a6c44b4f768b3069c5e0d5335e",
"a6562d60cc7349eca0dc6b0e79734df8",
"fe27ed397c3d4faaa0675d9087e5c39e",
"af90e5f7cc7143a48cc1330fe08191cd",
"67973c3e7936441abf2a2b008fd46f1b",
"0d8f2094f31440d090836fe3577bbae4",
"0e096a1cd557467cb6bff65bdfc3d84d",
"87a4b79cd4b74b8ea963a51ccb601b8d",
"b2af4ab5ebfc420eb464a7001faae69f",
"d8350130c3dc45e5a2cbe8e2e49ac01c",
"834f6a0b023c4fb98c586d745fb022f5",
"11b2d400de7741af8e845f5f89b1096a",
"f49671b5ba554ce199d487b5d8d9b79e",
"a0076a6ed5dd43a2ac13006328fb7261",
"c0494e64a15d4588a68103700430ea90",
"8b926028abd44c87b12e663b37a6f188",
"d2f8e393d43849b8999b8b0d6b52da16",
"37ef4f9e19e941eea6e1b2e600d4cc28",
"f2768c61cbae40168a472046938b9dd0",
"755dbf49ced14e39bc0cdecbe05c394f",
"0a60a46cdfb1403680416f781232db72",
"33605f7141ac4087afbf5bc8f87958a4",
"2036996e924c451d8a8bcca25638d617",
"84ccdb801c5e42109e8f229c7560db8c"
]
},
"id": "lGnd3lJxcSfn",
"outputId": "245b9337-204d-403e-9907-2abe3ac4a63e"
},
"source": [
"tokenizer = AutoTokenizer.from_pretrained(\"abbas/gpt2-horror-stories\")\r\n",
"model = AutoModelWithLMHead.from_pretrained(\"abbas/gpt2-horror-stories\")\r\n",
"model.to(device)\r\n",
"device"
],
"execution_count": 4,
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "37bee902ecd7447f9f0559588f2629ef",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=768.0, style=ProgressStyle(description_…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d6187baa13d422f8c33dd0811ea54a3",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=798156.0, style=ProgressStyle(descripti…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ecab461591364384a8c1fb896c046561",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=456356.0, style=ProgressStyle(descripti…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d64722a6c44b4f768b3069c5e0d5335e",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=90.0, style=ProgressStyle(description_w…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b2af4ab5ebfc420eb464a7001faae69f",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=167.0, style=ProgressStyle(description_…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/dist-packages/transformers/models/auto/modeling_auto.py:890: FutureWarning: The class `AutoModelWithLMHead` is deprecated and will be removed in a future version. Please use `AutoModelForCausalLM` for causal language models, `AutoModelForMaskedLM` for masked language models and `AutoModelForSeq2SeqLM` for encoder-decoder models.\n",
" FutureWarning,\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d2f8e393d43849b8999b8b0d6b52da16",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, description='Downloading', max=510406559.0, style=ProgressStyle(descri…"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'cuda'"
]
},
"metadata": {
"tags": []
},
"execution_count": 4
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dfDtcBcPuTQs"
},
"source": [
"## Function to generate samples"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Jt8echeGaozd"
},
"source": [
"def choose_from_top(probs, n=10):\r\n",
" ind = np.argpartition(probs, -n)[-n:]\r\n",
" top_prob = probs[ind]\r\n",
" top_prob = top_prob / np.sum(top_prob)\r\n",
" choice = np.random.choice(n, 1, p = top_prob)\r\n",
" token_id = ind[choice][0]\r\n",
" return int(token_id)\r\n",
"\r\n",
"def generate_text(input_str, text_len = 100):\r\n",
" cur_ids = torch.tensor(tokenizer.encode(input_str)).unsqueeze(0).long().to(device)\r\n",
" model.eval()\r\n",
" with torch.no_grad():\r\n",
" for i in range(text_len):\r\n",
" outputs = model(cur_ids, labels=cur_ids)\r\n",
" loss, logits = outputs[:2]\r\n",
" softmax_logits = torch.softmax(logits[0,-1], dim=0) \r\n",
" next_token_id = choose_from_top(softmax_logits.to('cpu').numpy(), n=10)\r\n",
" cur_ids = torch.cat([cur_ids, torch.ones((1,1)).long().to(device) * next_token_id], dim = 1) # Add the last word\r\n",
" output_list = list(cur_ids.squeeze().to('cpu').numpy())\r\n",
" output_text = tokenizer.decode(output_list)\r\n",
" output_text = output_text.replace('<|endoftext|>', ' ')\r\n",
" print(output_text)"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4RY5zvA8uWNv"
},
"source": [
"## Generating Samples"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "se-wcWi8b6y3",
"outputId": "d1c871df-584a-4d9a-a5e4-4a8ca33c201b"
},
"source": [
"generate_text(\"It was a scary\", 200)"
],
"execution_count": 34,
"outputs": [
{
"output_type": "stream",
"text": [
"It was a scary night. We heard a loud crash and the sound of a heavy metal door slamming behind us. We ran, I saw my brother standing right in the doorway of my room at the time. He looked like he was frozen in place, and his skin was pale. I saw my brother, standing there. “What’s wrong?” I asked him. My brother’s voice cracked open and he said something in a very low voice, “We’re going home. I’m going to get you some rest.” His words were almost a whisper, like the sound of a person being held prisoner, with no voice, no memory, and no reason to talk, no one to speak to. We were alone, and we were in the house, I could feel the door swing open and there we were. I saw my brothers face. I was in shock, I couldn’t believe what I’\n"
],
"name": "stdout"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment