Skip to content

Instantly share code, notes, and snippets.

@evanthebouncy
Last active July 28, 2022 01:27
Show Gist options
  • Save evanthebouncy/53a6c4f7156433c52ea7eb2b975f4cbb to your computer and use it in GitHub Desktop.
Save evanthebouncy/53a6c4f7156433c52ea7eb2b975f4cbb to your computer and use it in GitHub Desktop.
hugging_face_alchemy_world_model.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "hugging_face_alchemy_world_model.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"1a05d091bfe840bdad0ce8761e6a6f84": {
"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_e0e86ef480164b4dae11422c05fe536b",
"IPY_MODEL_f1ca82e156ef49b6b05ff8e430e245da",
"IPY_MODEL_49d1f8cdd00a4af88f8af4f52bec088d"
],
"layout": "IPY_MODEL_ff1b89673ae84ef993b5e3856efe852a"
}
},
"e0e86ef480164b4dae11422c05fe536b": {
"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_5cf76c304d7d4fb980442f584f37bfc8",
"placeholder": "​",
"style": "IPY_MODEL_a1616a3e79c64ece9411a9949cdb44fe",
"value": "Downloading tokenizer_config.json: 100%"
}
},
"f1ca82e156ef49b6b05ff8e430e245da": {
"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_47a41575d93c47f7b5673e11cda2acb5",
"max": 2593,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_eb105d97d68547d6a08e15f060269b44",
"value": 2593
}
},
"49d1f8cdd00a4af88f8af4f52bec088d": {
"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_589eefacfc9041d9adb14a809152e811",
"placeholder": "​",
"style": "IPY_MODEL_76b9396bd8584408b173686f56470233",
"value": " 2.53k/2.53k [00:00<00:00, 35.7kB/s]"
}
},
"ff1b89673ae84ef993b5e3856efe852a": {
"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
}
},
"5cf76c304d7d4fb980442f584f37bfc8": {
"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
}
},
"a1616a3e79c64ece9411a9949cdb44fe": {
"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": ""
}
},
"47a41575d93c47f7b5673e11cda2acb5": {
"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
}
},
"eb105d97d68547d6a08e15f060269b44": {
"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": ""
}
},
"589eefacfc9041d9adb14a809152e811": {
"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
}
},
"76b9396bd8584408b173686f56470233": {
"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": ""
}
},
"4f0581d084684fd4aa030ff93245a469": {
"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_b9134cf3d0e64c82814bbda58bfca76c",
"IPY_MODEL_63ac7cbaf9cd43ef9b7502910f55bdab",
"IPY_MODEL_68fb13a8b4e445c38397d38de1002da7"
],
"layout": "IPY_MODEL_e83f7a59850d4ee089d1e1ea69156c81"
}
},
"b9134cf3d0e64c82814bbda58bfca76c": {
"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_79a77557d1c74e4a8ad4085c59fc3c5c",
"placeholder": "​",
"style": "IPY_MODEL_c3b21efbe0c84887aa7471877319a726",
"value": "Downloading config.json: 100%"
}
},
"63ac7cbaf9cd43ef9b7502910f55bdab": {
"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_110f55a1f50a402a8ee72cfff5528bb5",
"max": 721,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_a07f4934507b4606bdb88347a227b72f",
"value": 721
}
},
"68fb13a8b4e445c38397d38de1002da7": {
"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_73d30edfb5a746a8876b7586b183af43",
"placeholder": "​",
"style": "IPY_MODEL_fa66daa417d747708fcc3a68b168face",
"value": " 721/721 [00:00<00:00, 10.0kB/s]"
}
},
"e83f7a59850d4ee089d1e1ea69156c81": {
"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
}
},
"79a77557d1c74e4a8ad4085c59fc3c5c": {
"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
}
},
"c3b21efbe0c84887aa7471877319a726": {
"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": ""
}
},
"110f55a1f50a402a8ee72cfff5528bb5": {
"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
}
},
"a07f4934507b4606bdb88347a227b72f": {
"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": ""
}
},
"73d30edfb5a746a8876b7586b183af43": {
"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
}
},
"fa66daa417d747708fcc3a68b168face": {
"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": ""
}
},
"eb4ee11df06d4f6bb1a171c68c0cbfe4": {
"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_caab7617bd9e428682413d49217063e3",
"IPY_MODEL_622abbde6d704511a5b594ea6d865ca5",
"IPY_MODEL_ca1ac2c5352b44bc81058609130a946d"
],
"layout": "IPY_MODEL_c972ab454f49449b8b5d31acb65519b3"
}
},
"caab7617bd9e428682413d49217063e3": {
"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_031e684264ca4d5f9eb10a56422ebfbe",
"placeholder": "​",
"style": "IPY_MODEL_49052642b3e74228be33f34faf0aaad4",
"value": "Downloading special_tokens_map.json: 100%"
}
},
"622abbde6d704511a5b594ea6d865ca5": {
"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_bed73294aa11414094aa6badf3ad2ff9",
"max": 2503,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_9f55f1c144a7460180aa49475b2d82a3",
"value": 2503
}
},
"ca1ac2c5352b44bc81058609130a946d": {
"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_323e35d98c3b46ea8d6aa6133f36bde4",
"placeholder": "​",
"style": "IPY_MODEL_ba9d91a0ae64401d863c20354d286e12",
"value": " 2.44k/2.44k [00:00<00:00, 80.1kB/s]"
}
},
"c972ab454f49449b8b5d31acb65519b3": {
"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
}
},
"031e684264ca4d5f9eb10a56422ebfbe": {
"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
}
},
"49052642b3e74228be33f34faf0aaad4": {
"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": ""
}
},
"bed73294aa11414094aa6badf3ad2ff9": {
"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
}
},
"9f55f1c144a7460180aa49475b2d82a3": {
"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": ""
}
},
"323e35d98c3b46ea8d6aa6133f36bde4": {
"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
}
},
"ba9d91a0ae64401d863c20354d286e12": {
"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": ""
}
},
"51387b574066496390d4733f96aa6c65": {
"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_c2a07c1577f24e9a9cc9717e71b8e21d",
"IPY_MODEL_976d5e14f6194bb7b57127b603df6cea",
"IPY_MODEL_c09e5357049546eaa8a69befe0e885a0"
],
"layout": "IPY_MODEL_a56c2c474be14de7aaaf2aba9ed68f71"
}
},
"c2a07c1577f24e9a9cc9717e71b8e21d": {
"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_fde4467d0e7d44b6b794ec49f1d63342",
"placeholder": "​",
"style": "IPY_MODEL_4888c184492e4fbd9cf94f6c6a6293b7",
"value": "Downloading pytorch_model.bin: 100%"
}
},
"976d5e14f6194bb7b57127b603df6cea": {
"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_432b2ec1469c435ba7c65cc3e1f88d87",
"max": 2326727132,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_16757d3921cf4cb9bc65ad017944f620",
"value": 2326727132
}
},
"c09e5357049546eaa8a69befe0e885a0": {
"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_67fddb1cb0a5432f8f7bb33883b1efa7",
"placeholder": "​",
"style": "IPY_MODEL_35b019d8b8ee40718a1d4e842593ebfa",
"value": " 2.17G/2.17G [00:53<00:00, 32.6MB/s]"
}
},
"a56c2c474be14de7aaaf2aba9ed68f71": {
"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
}
},
"fde4467d0e7d44b6b794ec49f1d63342": {
"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
}
},
"4888c184492e4fbd9cf94f6c6a6293b7": {
"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": ""
}
},
"432b2ec1469c435ba7c65cc3e1f88d87": {
"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
}
},
"16757d3921cf4cb9bc65ad017944f620": {
"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": ""
}
},
"67fddb1cb0a5432f8f7bb33883b1efa7": {
"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
}
},
"35b019d8b8ee40718a1d4e842593ebfa": {
"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": ""
}
}
}
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/evanthebouncy/53a6c4f7156433c52ea7eb2b975f4cbb/hugging_face_alchemy_world_model.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"find the corresponding data, \"alchemy-train.tsv\", \"ahchemy-test.tsv\" here\n",
"https://worksheets.codalab.org/worksheets/0x974941631ffb47d68da16325ff6aa4c2 \n",
"under \"Datasets / alchemy\""
],
"metadata": {
"id": "4LknbqD1ZiDE"
}
},
{
"cell_type": "code",
"source": [
"gpu_info = !nvidia-smi\n",
"gpu_info = '\\n'.join(gpu_info)\n",
"if gpu_info.find('failed') >= 0:\n",
" print('Not connected to a GPU')\n",
"else:\n",
" print(gpu_info)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7fuej1ZkHzKV",
"outputId": "5f02a5da-2f85-474f-b707-282e3cecd2bf"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Wed Jul 27 20:16:35 2022 \n",
"+-----------------------------------------------------------------------------+\n",
"| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
"|-------------------------------+----------------------+----------------------+\n",
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
"| | | MIG M. |\n",
"|===============================+======================+======================|\n",
"| 0 Tesla P100-PCIE... Off | 00000000:00:04.0 Off | 0 |\n",
"| N/A 40C P0 28W / 250W | 0MiB / 16280MiB | 0% Default |\n",
"| | | N/A |\n",
"+-------------------------------+----------------------+----------------------+\n",
" \n",
"+-----------------------------------------------------------------------------+\n",
"| Processes: |\n",
"| GPU GI CI PID Type Process name GPU Memory |\n",
"| ID ID Usage |\n",
"|=============================================================================|\n",
"| No running processes found |\n",
"+-----------------------------------------------------------------------------+\n"
]
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Kfzt_cH8Frty",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "7933c821-2607-4006-d1fd-d80b9848712d"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"18285\n"
]
}
],
"source": [
"import csv\n",
"\n",
"def process_data(file_name):\n",
" # open and read the csv file called \"alchemy-train.tsv\" and parse it as a list of elements\n",
" with open(file_name, 'r') as csv_file:\n",
" reader = csv.reader(csv_file, delimiter='\\t')\n",
" alchemy_train = list(reader)\n",
"\n",
" trajectories = []\n",
" for row in alchemy_train:\n",
" trajectories.append(row[1:])\n",
"\n",
" # the trajectories is of the form [ [s0, a0, s1, a1, s2, ... sn], ...]\n",
" # we want to convert it to a list of [(s0, a0, s1), (s1, a1, s2), ...]\n",
" converted = []\n",
" for trajectory in trajectories:\n",
" for i in range(0, len(trajectory) - 2, 2):\n",
" converted.append((trajectory[i], trajectory[i+1], trajectory[i+2]))\n",
" return converted\n",
"\n",
"converted = process_data('alchemy-train.tsv')\n",
"print (len(converted))"
]
},
{
"cell_type": "code",
"source": [
"!pip install transformers datasets"
],
"metadata": {
"id": "o41uJD4yGSxM",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "b37b4d51-d460-4acb-d1e2-371a009d807f"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting transformers\n",
" Downloading transformers-4.21.0-py3-none-any.whl (4.7 MB)\n",
"\u001b[K |████████████████████████████████| 4.7 MB 7.0 MB/s \n",
"\u001b[?25hCollecting datasets\n",
" Downloading datasets-2.4.0-py3-none-any.whl (365 kB)\n",
"\u001b[K |████████████████████████████████| 365 kB 65.8 MB/s \n",
"\u001b[?25hRequirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from transformers) (2.23.0)\n",
"Collecting tokenizers!=0.11.3,<0.13,>=0.11.1\n",
" Downloading tokenizers-0.12.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (6.6 MB)\n",
"\u001b[K |████████████████████████████████| 6.6 MB 31.8 MB/s \n",
"\u001b[?25hCollecting huggingface-hub<1.0,>=0.1.0\n",
" Downloading huggingface_hub-0.8.1-py3-none-any.whl (101 kB)\n",
"\u001b[K |████████████████████████████████| 101 kB 12.4 MB/s \n",
"\u001b[?25hCollecting pyyaml>=5.1\n",
" Downloading PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (596 kB)\n",
"\u001b[K |████████████████████████████████| 596 kB 74.0 MB/s \n",
"\u001b[?25hRequirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.7/dist-packages (from transformers) (21.3)\n",
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (1.21.6)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.7/dist-packages (from transformers) (2022.6.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.7/dist-packages (from transformers) (3.7.1)\n",
"Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.7/dist-packages (from transformers) (4.12.0)\n",
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.7/dist-packages (from transformers) (4.64.0)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.7/dist-packages (from huggingface-hub<1.0,>=0.1.0->transformers) (4.1.1)\n",
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging>=20.0->transformers) (3.0.9)\n",
"Requirement already satisfied: multiprocess in /usr/local/lib/python3.7/dist-packages (from datasets) (0.70.13)\n",
"Requirement already satisfied: dill<0.3.6 in /usr/local/lib/python3.7/dist-packages (from datasets) (0.3.5.1)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.7/dist-packages (from datasets) (1.3.5)\n",
"Requirement already satisfied: aiohttp in /usr/local/lib/python3.7/dist-packages (from datasets) (3.8.1)\n",
"Collecting xxhash\n",
" Downloading xxhash-3.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (212 kB)\n",
"\u001b[K |████████████████████████████████| 212 kB 74.3 MB/s \n",
"\u001b[?25hRequirement already satisfied: pyarrow>=6.0.0 in /usr/local/lib/python3.7/dist-packages (from datasets) (6.0.1)\n",
"Collecting fsspec[http]>=2021.11.1\n",
" Downloading fsspec-2022.5.0-py3-none-any.whl (140 kB)\n",
"\u001b[K |████████████████████████████████| 140 kB 72.5 MB/s \n",
"\u001b[?25hCollecting responses<0.19\n",
" Downloading responses-0.18.0-py3-none-any.whl (38 kB)\n",
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (1.24.3)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2022.6.15)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (2.10)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->transformers) (3.0.4)\n",
"Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1\n",
" Downloading urllib3-1.25.11-py2.py3-none-any.whl (127 kB)\n",
"\u001b[K |████████████████████████████████| 127 kB 75.5 MB/s \n",
"\u001b[?25hRequirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.7.2)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.3.0)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (1.2.0)\n",
"Requirement already satisfied: asynctest==0.13.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (0.13.0)\n",
"Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (2.1.0)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (4.0.2)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (21.4.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.7/dist-packages (from aiohttp->datasets) (6.0.2)\n",
"Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata->transformers) (3.8.1)\n",
"Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas->datasets) (2.8.2)\n",
"Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas->datasets) (2022.1)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.7.3->pandas->datasets) (1.15.0)\n",
"Installing collected packages: urllib3, pyyaml, fsspec, xxhash, tokenizers, responses, huggingface-hub, transformers, datasets\n",
" Attempting uninstall: urllib3\n",
" Found existing installation: urllib3 1.24.3\n",
" Uninstalling urllib3-1.24.3:\n",
" Successfully uninstalled urllib3-1.24.3\n",
" Attempting uninstall: pyyaml\n",
" Found existing installation: PyYAML 3.13\n",
" Uninstalling PyYAML-3.13:\n",
" Successfully uninstalled PyYAML-3.13\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible.\u001b[0m\n",
"Successfully installed datasets-2.4.0 fsspec-2022.5.0 huggingface-hub-0.8.1 pyyaml-6.0 responses-0.18.0 tokenizers-0.12.1 transformers-4.21.0 urllib3-1.25.11 xxhash-3.0.0\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"from transformers import T5ForConditionalGeneration, AutoTokenizer"
],
"metadata": {
"id": "U7jRrP37H2pi"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"tokenizer = AutoTokenizer.from_pretrained('google/byt5-base')\n",
"model = T5ForConditionalGeneration.from_pretrained('google/byt5-base')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 145,
"referenced_widgets": [
"1a05d091bfe840bdad0ce8761e6a6f84",
"e0e86ef480164b4dae11422c05fe536b",
"f1ca82e156ef49b6b05ff8e430e245da",
"49d1f8cdd00a4af88f8af4f52bec088d",
"ff1b89673ae84ef993b5e3856efe852a",
"5cf76c304d7d4fb980442f584f37bfc8",
"a1616a3e79c64ece9411a9949cdb44fe",
"47a41575d93c47f7b5673e11cda2acb5",
"eb105d97d68547d6a08e15f060269b44",
"589eefacfc9041d9adb14a809152e811",
"76b9396bd8584408b173686f56470233",
"4f0581d084684fd4aa030ff93245a469",
"b9134cf3d0e64c82814bbda58bfca76c",
"63ac7cbaf9cd43ef9b7502910f55bdab",
"68fb13a8b4e445c38397d38de1002da7",
"e83f7a59850d4ee089d1e1ea69156c81",
"79a77557d1c74e4a8ad4085c59fc3c5c",
"c3b21efbe0c84887aa7471877319a726",
"110f55a1f50a402a8ee72cfff5528bb5",
"a07f4934507b4606bdb88347a227b72f",
"73d30edfb5a746a8876b7586b183af43",
"fa66daa417d747708fcc3a68b168face",
"eb4ee11df06d4f6bb1a171c68c0cbfe4",
"caab7617bd9e428682413d49217063e3",
"622abbde6d704511a5b594ea6d865ca5",
"ca1ac2c5352b44bc81058609130a946d",
"c972ab454f49449b8b5d31acb65519b3",
"031e684264ca4d5f9eb10a56422ebfbe",
"49052642b3e74228be33f34faf0aaad4",
"bed73294aa11414094aa6badf3ad2ff9",
"9f55f1c144a7460180aa49475b2d82a3",
"323e35d98c3b46ea8d6aa6133f36bde4",
"ba9d91a0ae64401d863c20354d286e12",
"51387b574066496390d4733f96aa6c65",
"c2a07c1577f24e9a9cc9717e71b8e21d",
"976d5e14f6194bb7b57127b603df6cea",
"c09e5357049546eaa8a69befe0e885a0",
"a56c2c474be14de7aaaf2aba9ed68f71",
"fde4467d0e7d44b6b794ec49f1d63342",
"4888c184492e4fbd9cf94f6c6a6293b7",
"432b2ec1469c435ba7c65cc3e1f88d87",
"16757d3921cf4cb9bc65ad017944f620",
"67fddb1cb0a5432f8f7bb33883b1efa7",
"35b019d8b8ee40718a1d4e842593ebfa"
]
},
"id": "ll6u-IT_H8Te",
"outputId": "c020f6e6-b6fe-416a-b01c-73797420ab43"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Downloading tokenizer_config.json: 0%| | 0.00/2.53k [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "1a05d091bfe840bdad0ce8761e6a6f84"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Downloading config.json: 0%| | 0.00/721 [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "4f0581d084684fd4aa030ff93245a469"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Downloading special_tokens_map.json: 0%| | 0.00/2.44k [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "eb4ee11df06d4f6bb1a171c68c0cbfe4"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Downloading pytorch_model.bin: 0%| | 0.00/2.17G [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "51387b574066496390d4733f96aa6c65"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"model.to('cuda')"
],
"metadata": {
"id": "BsGwfufw6wYf"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from torch.utils.data import Dataset, DataLoader\n",
"\n",
"class FactoringDataset(Dataset):\n",
" def __init__(self, dataset_itself):\n",
" self.data = list()\n",
" self.data = dataset_itself\n",
" \n",
" def __getitem__(self, idx):\n",
" return self.data[idx]\n",
" \n",
" def __len__(self):\n",
" return len(self.data)\n",
"\n",
"dataset = FactoringDataset(converted)"
],
"metadata": {
"id": "nXwklMKguN_c"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# for batch in dataloader:\n",
"# src_tokens = tokenizer(batch[0], padding=True, return_tensors='pt')\n",
"# tgt_tokens = tokenizer(batch[1], padding=True, return_tensors='pt')\n",
"\n",
"# outputs = model()"
],
"metadata": {
"id": "Ty4brRKeyslq"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from transformers import Seq2SeqTrainer\n",
"\n",
"class Collator:\n",
" def __init__(self, tokenizer):\n",
" self.tokenizer = tokenizer\n",
"\n",
" def __call__(self, batch):\n",
" # for bb in batch:\n",
" # print (bb)\n",
" ret = {\"input_ids\": self.tokenizer([entry[0]+\";\"+entry[1] for entry in batch], padding=True, return_tensors='pt').input_ids, \n",
" \"labels\": self.tokenizer([entry[2] for entry in batch], padding=True, return_tensors='pt').input_ids}\n",
" # print (ret)\n",
" # assert 0\n",
" return ret\n",
" \n",
"# dataloader = DataLoader(dataset, batch_size=4, shuffle=True)\n",
"# collator1 = Collator(tokenizer)\n",
"# hiyo = collator1(dataset[0])\n",
"# print (hiyo)"
],
"metadata": {
"id": "OX7xXP52Jkof"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
" \n",
"trainer = Seq2SeqTrainer(\n",
" model=model,\n",
" train_dataset=dataset,\n",
" eval_dataset=None,\n",
" tokenizer=tokenizer,\n",
" compute_metrics=None,\n",
" data_collator=Collator(tokenizer)\n",
" )\n",
"\n",
"trainer.train()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "CC9M6HQzcWrA",
"outputId": "c6dda075-8cf1-4f04-a053-b8bbafdfade5"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"No `TrainingArguments` passed, using `output_dir=tmp_trainer`.\n",
"PyTorch: setting up devices\n",
"The default value for the training argument `--report_to` will change in v5 (from all installed integrations to none). In v5, you will need to use `--report_to all` to get the same behavior as now. You should start updating your code and make this info disappear :-).\n",
"/usr/local/lib/python3.7/dist-packages/transformers/optimization.py:310: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning\n",
" FutureWarning,\n",
"***** Running training *****\n",
" Num examples = 18285\n",
" Num Epochs = 3\n",
" Instantaneous batch size per device = 8\n",
" Total train batch size (w. parallel, distributed & accumulation) = 8\n",
" Gradient Accumulation steps = 1\n",
" Total optimization steps = 6858\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.HTML object>"
],
"text/html": [
"\n",
" <div>\n",
" \n",
" <progress value='6858' max='6858' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
" [6858/6858 1:07:28, Epoch 3/3]\n",
" </div>\n",
" <table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: left;\">\n",
" <th>Step</th>\n",
" <th>Training Loss</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>500</td>\n",
" <td>0.906400</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1000</td>\n",
" <td>0.102700</td>\n",
" </tr>\n",
" <tr>\n",
" <td>1500</td>\n",
" <td>0.075000</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2000</td>\n",
" <td>0.063100</td>\n",
" </tr>\n",
" <tr>\n",
" <td>2500</td>\n",
" <td>0.052600</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3000</td>\n",
" <td>0.046600</td>\n",
" </tr>\n",
" <tr>\n",
" <td>3500</td>\n",
" <td>0.040300</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4000</td>\n",
" <td>0.035200</td>\n",
" </tr>\n",
" <tr>\n",
" <td>4500</td>\n",
" <td>0.030800</td>\n",
" </tr>\n",
" <tr>\n",
" <td>5000</td>\n",
" <td>0.027200</td>\n",
" </tr>\n",
" <tr>\n",
" <td>5500</td>\n",
" <td>0.025500</td>\n",
" </tr>\n",
" <tr>\n",
" <td>6000</td>\n",
" <td>0.022400</td>\n",
" </tr>\n",
" <tr>\n",
" <td>6500</td>\n",
" <td>0.021800</td>\n",
" </tr>\n",
" </tbody>\n",
"</table><p>"
]
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Saving model checkpoint to tmp_trainer/checkpoint-500\n",
"Configuration saved in tmp_trainer/checkpoint-500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-1000\n",
"Configuration saved in tmp_trainer/checkpoint-1000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-1000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-1000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-1000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-1500\n",
"Configuration saved in tmp_trainer/checkpoint-1500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-1500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-1500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-1500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-2000\n",
"Configuration saved in tmp_trainer/checkpoint-2000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-2000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-2000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-2000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-2500\n",
"Configuration saved in tmp_trainer/checkpoint-2500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-2500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-2500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-2500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-3000\n",
"Configuration saved in tmp_trainer/checkpoint-3000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-3000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-3000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-3000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-3500\n",
"Configuration saved in tmp_trainer/checkpoint-3500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-3500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-3500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-3500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-4000\n",
"Configuration saved in tmp_trainer/checkpoint-4000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-4000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-4000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-4000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-4500\n",
"Configuration saved in tmp_trainer/checkpoint-4500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-4500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-4500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-4500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-5000\n",
"Configuration saved in tmp_trainer/checkpoint-5000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-5000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-5000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-5000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-5500\n",
"Configuration saved in tmp_trainer/checkpoint-5500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-5500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-5500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-5500/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-6000\n",
"Configuration saved in tmp_trainer/checkpoint-6000/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-6000/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-6000/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-6000/special_tokens_map.json\n",
"Saving model checkpoint to tmp_trainer/checkpoint-6500\n",
"Configuration saved in tmp_trainer/checkpoint-6500/config.json\n",
"Model weights saved in tmp_trainer/checkpoint-6500/pytorch_model.bin\n",
"tokenizer config file saved in tmp_trainer/checkpoint-6500/tokenizer_config.json\n",
"Special tokens file saved in tmp_trainer/checkpoint-6500/special_tokens_map.json\n",
"\n",
"\n",
"Training completed. Do not forget to share your model on huggingface.co/models =)\n",
"\n",
"\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"TrainOutput(global_step=6858, training_loss=0.10680131385193584, metrics={'train_runtime': 4048.6688, 'train_samples_per_second': 13.549, 'train_steps_per_second': 1.694, 'total_flos': 2.0622126330372096e+16, 'train_loss': 0.10680131385193584, 'epoch': 3.0})"
]
},
"metadata": {},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"source": [
"outputs = model.generate(tokenizer(\"1:ggg 2:rr 3:pp 4:gg 5:rrrr 6:pp 7:pp;throw away three units of fifth beaker red chemical\", return_tensors='pt').input_ids.to('cuda'), max_length=64, num_beams=100, num_return_sequences=100)\n",
"# right answer is 1:ggg 2:rr 3:pp 4:gg 5:r 6:pp 7:pp\n",
"results = tokenizer.batch_decode(outputs, skip_special_tokens=True)\n",
"result_dicts = []\n",
"for result in results[:10]:\n",
" print (result)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "MGNVO8Ty1s9Z",
"outputId": "8014fe01-3f7a-4e06-c80f-358ac481915a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"1:ggg 2:rr 3:pp 4:gg 5:r 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:rr 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:rrrr 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5: 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:r2 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:r 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:rpp 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:r4:gg 6:pp 7:pp\n",
"1:ggg 2:rr 3:pp 4:gg 5:r 6:pp 7:pp\n",
"1:ggg 2: 3:pp 4:gg 5:r 6:pp 7:pp\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"test_data = process_data('alchemy-test.tsv')\n",
"print (len(test_data))"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "FpeNekSEm5SF",
"outputId": "8589a331-00a8-4986-825b-c5cecafb67eb"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"4495\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# is the first state proposed by the model correct ?\n",
"def first_correct(data_point):\n",
" # print (data_point)\n",
" input_str = data_point[0]+';'+data_point[1]\n",
" output_gt = data_point[2]\n",
" outputs = model.generate(tokenizer(input_str, return_tensors='pt').input_ids.to('cuda'), max_length=64, num_beams=100, num_return_sequences=100)\n",
" results = tokenizer.batch_decode(outputs, skip_special_tokens=True)\n",
" for i, result in enumerate(results):\n",
" if result == output_gt:\n",
" return i\n",
" return None\n",
"\n",
"first_correct(test_data[0])"
],
"metadata": {
"id": "UOP0T2jJ44lB",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "0a49c6c2-fb6d-4796-ca1c-d3d58558e61a"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1"
]
},
"metadata": {},
"execution_count": 19
}
]
},
{
"cell_type": "code",
"source": [
"num_till_correct = []\n",
"for i, t_data in enumerate(test_data):\n",
" correct_idx = first_correct(t_data)\n",
" print (i, correct_idx, t_data)\n",
" num_till_correct.append(correct_idx)\n"
],
"metadata": {
"id": "flpNyp8pofWN"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"first_is_correct = num_till_correct.count(0)\n",
"print (f\"first proposal is correct {first_is_correct} out of {len(num_till_correct)}, or {first_is_correct / len(num_till_correct)}\")"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "oshZ0KCkPqHN",
"outputId": "c93ceaee-4665-43da-a52e-62e16653cfc5"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"first proposal is correct 3363 out of 4495, or 0.7481646273637375\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import matplotlib.pyplot as plt\n",
"hist_data = [(lambda x: x if x is not None else 100)(x) for x in num_till_correct]\n",
"plt.hist(hist_data, bins=range(max(hist_data)+1))\n",
"plt.figure(dpi=300)\n",
"plt.show()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 285
},
"id": "5Rvi6J0oNpWK",
"outputId": "c143cece-bfa2-4d1a-fd0c-aaa9748e27e7"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
],
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD6CAYAAABNu5eFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAASxUlEQVR4nO3dcayd9X3f8fenNiFpUtWm3Fmubc1e6zVyKsWgO6BKNTFYwJBpplIXgaZiRUjuJFCTKdpquj9okiERqQ0rUorkBjemyqCMpMOiXpnrUEX5A/AldR0ModwAmW0ZfFsDSRaNFvbdH+fn6szc63uvfe41ub/3Szo6z/N9fs9zfj891uc89zm/c5yqQpLUh5843x2QJC0eQ1+SOmLoS1JHDH1J6oihL0kdMfQlqSOzhn6S9yZ5KslfJTmc5DOt/uUkLyU52B6bWz1J7kkymeRQkkuHjrUtyQvtsW3hhiVJms7yObR5E7iqqn6Y5ALgm0n+R9v2H6rq4dPaXwdsbI/LgXuBy5NcBNwBjAMFPJ1kT1W9NtMLX3zxxbV+/fp5DUiSevf000//TVWNTbdt1tCvwbe3fthWL2iPM32jaytwf9vviSQrkqwGrgT2VdVJgCT7gC3AAzMdaP369UxMTMzWRUnSkCTfm2nbnO7pJ1mW5CBwgkFwP9k23dlu4dyd5MJWWwM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xSDs3wCeZmmf51NmOq8jy7WlGPpdSfIB4KvAp6rq+8PbajAfd8nMyU3yr4ATVfX0+e7LIloOXArcW1WXAP+b027lLMHzvJLBle0G4GeB9/PO2yBL3kKd16UY+t381EOSCxgE/leq6mut/OqpP/va84nz1b8F8BHgXyd5mcFtu6sY3O9e0W4DwNI730eBo1X1ZFt/mMGbwFI+z/8SeKmqpqrq74GvMTj3S/k8nzLTeR1Zri3F0O/ipx7avez7gOeq6gtDm/YA29ryNuCRxe7bQqmq26tqbVWtZ3Bev15V/xZ4HPjV1mypjfkV4EiSX2ilqxn8FPmSPc8MbutckeQn27/zU2Nesud5yEzndQ9wc5vFcwXwxtBtoPmpqiX3AK4H/hr4LvCfznd/FmiMv8zgT79DwMH2uJ7BPe79wAvAnwMXne++LtD4rwQebcv/BHgKmAT+G3Dh+e7fiMe6GZho5/q/AyuX+nkGPgN8B3gG+CPgwqV2noEHGHxm8fcM/qK7ZabzCoTBrMTvAt9mMLPprF7Xn2GQpI4sxds7kqQZGPqS1BFDX5I6YuhLUkcMfUnqiKEvSR0x9CWpI/8P3/s7lVkXB5AAAAAASUVORK5CYII=\n"
},
"metadata": {
"needs_background": "light"
}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 1800x1200 with 0 Axes>"
]
},
"metadata": {}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment