{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "authorship_tag": "ABX9TyNIIlm3cj8JTW4pxeZFGrX3", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "c4ddc1adb0794f4e8c1c21951775c4fa": { "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_ee70e4a8d7f0412f8fabd1ab04c2510c", "IPY_MODEL_fe24f342d2744430b65561357442f8e6", "IPY_MODEL_ead9ed8a02f44e569d8572684d904378" ], "layout": "IPY_MODEL_defcb537d0764a68a0def1f641db8058" } }, "ee70e4a8d7f0412f8fabd1ab04c2510c": { "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_b337bc12cd1f4341a88ecb3153654895", "placeholder": "​", "style": "IPY_MODEL_4ffeb84ca0a44626ab182c933d593d4c", "value": "Downloading (…)okenizer_config.json: 100%" } }, "fe24f342d2744430b65561357442f8e6": { "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_2a02a2c6f6e84b02a4c43db3ec5145e5", "max": 367, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_eab4bcb80ebe4126a97189c1d3575b13", "value": 367 } }, "ead9ed8a02f44e569d8572684d904378": { "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_d06796e081be4e60ad93b3aa768699d5", "placeholder": "​", "style": "IPY_MODEL_51ed5d432a4042608f658288abd3d0d0", "value": " 367/367 [00:00<00:00, 13.1kB/s]" } }, "defcb537d0764a68a0def1f641db8058": { "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 } }, "b337bc12cd1f4341a88ecb3153654895": { "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 } }, "4ffeb84ca0a44626ab182c933d593d4c": { "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": "" } }, "2a02a2c6f6e84b02a4c43db3ec5145e5": { "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 } }, "eab4bcb80ebe4126a97189c1d3575b13": { "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": "" } }, "d06796e081be4e60ad93b3aa768699d5": { "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 } }, "51ed5d432a4042608f658288abd3d0d0": { "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": "" } }, "b59abfddec8c46d489dedb2137e4c8aa": { "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_d4f945addda04389920f8277e0d44789", "IPY_MODEL_8a5f1aa24c6343dd91381749ffc63ce7", "IPY_MODEL_991162e592a04991844a7a0ea0c9884d" ], "layout": "IPY_MODEL_baaba5780d24434f9d7dc4b75e262dae" } }, "d4f945addda04389920f8277e0d44789": { "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_d5a717edc455476f9df80367ce3c1653", "placeholder": "​", "style": "IPY_MODEL_0dd1db8031b74bcdaf66e55ed99d22b6", "value": "Downloading (…)solve/main/vocab.txt: 100%" } }, "8a5f1aa24c6343dd91381749ffc63ce7": { "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_8348a28bea12406ab74f82463b134183", "max": 109540, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_94424fdcac7f4ae283821e309f7a9f92", "value": 109540 } }, "991162e592a04991844a7a0ea0c9884d": { "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_4c896941d4ec4b90a9461f7da8db4db7", "placeholder": "​", "style": "IPY_MODEL_50c933585240452b99d6e605470d1aa5", "value": " 110k/110k [00:00<00:00, 3.56MB/s]" } }, "baaba5780d24434f9d7dc4b75e262dae": { "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 } }, "d5a717edc455476f9df80367ce3c1653": { "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 } }, "0dd1db8031b74bcdaf66e55ed99d22b6": { "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": "" } }, "8348a28bea12406ab74f82463b134183": { "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 } }, "94424fdcac7f4ae283821e309f7a9f92": { "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": "" } }, "4c896941d4ec4b90a9461f7da8db4db7": { "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 } }, "50c933585240452b99d6e605470d1aa5": { "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": "" } }, "fd5ebf0cb3ef4c5a9a329cea0d6deda5": { "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_ec0dc21ceb07472e9629aba5336d3711", "IPY_MODEL_cc8bcda3a2ef499daebf3d94c78b4fa3", "IPY_MODEL_2f2d7e3d071c4511850ebbacff2e20ba" ], "layout": "IPY_MODEL_8676c87d63a04389b13d20a2e4dc8e7e" } }, "ec0dc21ceb07472e9629aba5336d3711": { "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_9281755183fd4c9c8915804f21566121", "placeholder": "​", "style": "IPY_MODEL_9428428af6454ac89ec6d54c706e4a57", "value": "Downloading (…)/main/tokenizer.json: 100%" } }, "cc8bcda3a2ef499daebf3d94c78b4fa3": { "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_d5523d8737934107a42f47eaedacf68f", "max": 439125, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_797299b5119e4fd49514668fbfc77fcc", "value": 439125 } }, "2f2d7e3d071c4511850ebbacff2e20ba": { "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_bd362020845c438cb32a0d4fa65c2b0a", "placeholder": "​", "style": "IPY_MODEL_8efb0ca35bbc48b0bd4e8e69f21a69c2", "value": " 439k/439k [00:00<00:00, 7.70MB/s]" } }, "8676c87d63a04389b13d20a2e4dc8e7e": { "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 } }, "9281755183fd4c9c8915804f21566121": { "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 } }, "9428428af6454ac89ec6d54c706e4a57": { "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": "" } }, "d5523d8737934107a42f47eaedacf68f": { "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 } }, "797299b5119e4fd49514668fbfc77fcc": { "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": "" } }, "bd362020845c438cb32a0d4fa65c2b0a": { "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 } }, "8efb0ca35bbc48b0bd4e8e69f21a69c2": { "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": "" } }, "f96a800b3d2746e0ba8b5d682c6b29fa": { "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_afc2afe55e724fbfb1f513d7909c5ced", "IPY_MODEL_8ad024bfd3c349b9a22e9b018c218443", "IPY_MODEL_e4ad8c87e0a14808a6618a7202c3a955" ], "layout": "IPY_MODEL_172b6b4fcfcc473ca549f3569188e2db" } }, "afc2afe55e724fbfb1f513d7909c5ced": { "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_f39538da9f7346cc8bf8bbc6fcd98ed8", "placeholder": "​", "style": "IPY_MODEL_0f1519f9031e476f84c26fbbcd1551a4", "value": "Downloading (…)cial_tokens_map.json: 100%" } }, "8ad024bfd3c349b9a22e9b018c218443": { "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_c3eee41e06044c668c4441afad8f6ae8", "max": 125, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_306ddc02c1a74a21b5ea1fdf776f8b03", "value": 125 } }, "e4ad8c87e0a14808a6618a7202c3a955": { "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_8b0b06eb81cf4a2b8f9d717a7e0fab81", "placeholder": "​", "style": "IPY_MODEL_e019da17bde846b68bb39f2b25f6934d", "value": " 125/125 [00:00<00:00, 4.17kB/s]" } }, "172b6b4fcfcc473ca549f3569188e2db": { "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 } }, "f39538da9f7346cc8bf8bbc6fcd98ed8": { "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 } }, "0f1519f9031e476f84c26fbbcd1551a4": { "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": "" } }, "c3eee41e06044c668c4441afad8f6ae8": { "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 } }, "306ddc02c1a74a21b5ea1fdf776f8b03": { "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": "" } }, "8b0b06eb81cf4a2b8f9d717a7e0fab81": { "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 } }, "e019da17bde846b68bb39f2b25f6934d": { "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": "" } }, "7736fdaf763d4628b4628e85f3c72822": { "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_36133e1a05fd4d91aa9b8f6259afa588", "IPY_MODEL_79d29e4603df42409746cccc6b7bd7a0", "IPY_MODEL_034648495dc44285ab0d9395686b0358" ], "layout": "IPY_MODEL_18c91af15b564123a8caa005abaf242e" } }, "36133e1a05fd4d91aa9b8f6259afa588": { "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_7a23db11d7cd4c689ad73b92a8431856", "placeholder": "​", "style": "IPY_MODEL_f8280941d1cb4960b80fe061f5bc26bc", "value": "Downloading (…)lve/main/config.json: 100%" } }, "79d29e4603df42409746cccc6b7bd7a0": { "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_0d5f1f80725948f1aae6b7bcfec0611c", "max": 776, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_b2618cf6ea98432aab5c646f455cfe03", "value": 776 } }, "034648495dc44285ab0d9395686b0358": { "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_64ce4165fb8746b882fafa3d3619f7d7", "placeholder": "​", "style": "IPY_MODEL_d1d43fcbae6e4d4aabf8991b0455340e", "value": " 776/776 [00:00<00:00, 25.3kB/s]" } }, "18c91af15b564123a8caa005abaf242e": { "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 } }, "7a23db11d7cd4c689ad73b92a8431856": { "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 } }, "f8280941d1cb4960b80fe061f5bc26bc": { "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": "" } }, "0d5f1f80725948f1aae6b7bcfec0611c": { "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 } }, "b2618cf6ea98432aab5c646f455cfe03": { "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": "" } }, "64ce4165fb8746b882fafa3d3619f7d7": { "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 } }, "d1d43fcbae6e4d4aabf8991b0455340e": { "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": "" } }, "ef7178c5547e415bb5b4149f4ee3e0e4": { "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_cf401de681fe489aa20cff34a05e59f1", "IPY_MODEL_ec91f76a30134050bf18c85ffd9c6ba9", "IPY_MODEL_be1a90bfe9ee4a20ade2a46c987b126d" ], "layout": "IPY_MODEL_2a22927452c84cd3960ba8e2fe78fb9d" } }, "cf401de681fe489aa20cff34a05e59f1": { "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_de641b13a5974e25a515d877685ff0a4", "placeholder": "​", "style": "IPY_MODEL_1fa7a5bef0474707ab52c139917fbe39", "value": "Downloading model.safetensors: 100%" } }, "ec91f76a30134050bf18c85ffd9c6ba9": { "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_fe4d2fa609c4488b8e91a4ff31882d65", "max": 95827648, "min": 0, "orientation": "horizontal", "style": "IPY_MODEL_73dfe3a7b9f644b9849d459f2e0d7f6d", "value": 95827648 } }, "be1a90bfe9ee4a20ade2a46c987b126d": { "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_204b2412c6c343fdb3c2e7b6e2b3d7ac", "placeholder": "​", "style": "IPY_MODEL_5980939975de49dcb5ea90c05641cd9e", "value": " 95.8M/95.8M [00:02<00:00, 39.1MB/s]" } }, "2a22927452c84cd3960ba8e2fe78fb9d": { "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 } }, "de641b13a5974e25a515d877685ff0a4": { "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 } }, "1fa7a5bef0474707ab52c139917fbe39": { "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": "" } }, "fe4d2fa609c4488b8e91a4ff31882d65": { "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 } }, "73dfe3a7b9f644b9849d459f2e0d7f6d": { "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": "" } }, "204b2412c6c343fdb3c2e7b6e2b3d7ac": { "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 } }, "5980939975de49dcb5ea90c05641cd9e": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": "" } } } } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "code", "source": [ "!pip install -q transformers openai tiktoken langchain chromadb\n", "!pip install -q chatharuhi\n", "!pip install -q datasets" ], "metadata": { "id": "a8H7Az3Yzi3o", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "cc0310e1-29b0-4cd2-a5df-3ca43bb78684" }, "execution_count": 1, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.9/7.9 MB\u001b[0m \u001b[31m42.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.0/77.0 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m78.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m83.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m479.8/479.8 kB\u001b[0m \u001b[31m39.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m302.0/302.0 kB\u001b[0m \u001b[31m27.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.8/3.8 MB\u001b[0m \u001b[31m58.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m47.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m44.5/44.5 kB\u001b[0m \u001b[31m4.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m62.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.9/92.9 kB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.7/59.7 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.4/5.4 MB\u001b[0m \u001b[31m92.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.2/6.2 MB\u001b[0m \u001b[31m100.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.5/57.5 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m103.9/103.9 kB\u001b[0m \u001b[31m11.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m593.7/593.7 kB\u001b[0m \u001b[31m41.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m79.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.4/49.4 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.0/67.0 kB\u001b[0m \u001b[31m6.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m143.8/143.8 kB\u001b[0m \u001b[31m15.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m5.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.8/50.8 kB\u001b[0m \u001b[31m6.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m295.0/295.0 kB\u001b[0m \u001b[31m29.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m425.9 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.4/341.4 kB\u001b[0m \u001b[31m29.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m63.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m55.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m12.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m10.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\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", "lida 0.0.10 requires kaleido, which is not installed.\n", "lida 0.0.10 requires python-multipart, which is not installed.\n", "llmx 0.0.15a0 requires cohere, which is not installed.\n", "tensorflow-probability 0.22.0 requires typing-extensions<4.6.0, but you have typing-extensions 4.8.0 which is incompatible.\u001b[0m\u001b[31m\n", "\u001b[0m Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", " Building wheel for chatharuhi (setup.py) ... \u001b[?25l\u001b[?25hdone\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m493.7/493.7 kB\u001b[0m \u001b[31m8.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.8/134.8 kB\u001b[0m \u001b[31m10.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25h" ] } ] }, { "cell_type": "code", "source": [ "import os\n", "\n", "key = \"sk-WafsA4C\"\n", "key_bytes = key.encode()\n", "os.environ[\"OPENAI_API_KEY\"] = key_bytes.decode('utf-8')\n" ], "metadata": { "id": "ny05bHfAznJP" }, "execution_count": 2, "outputs": [] }, { "cell_type": "markdown", "source": [ "TODO:\n", "\n", "- [x] 在DialogueEvent中实现特定choice下的emoji获取\n", "- [x] embedding移动到util\n", "- [x] 增加base64\n", "- [x] Memory没有属性的时候,先用Condition中点代替\n", "- [x] 确定阈值后filter\n", "- [x] Memory K近邻搜索\n", "- [x] MemoryPool功能完善,移动到单独的文件\n", "- [x] 对接ChatHaruhi,用memory_pool接管掉add_story\n", "- [x] EventMaster中每次先随机出一个valid的事件\n", "- [x] 对于单一的事件,进行选项管理\n", "- [x] apply attribute change\n", "- [x] 给事件增加一个flag list\n", "- [x] 对于自由选项,委托chatbot进行回复\n", "- [ ] 接入评估我今天不打算做" ], "metadata": { "id": "iitlruLW2de5" } }, { "cell_type": "code", "source": [ "%cd /content\n", "!rm -rf /content/Needy-Haruhi\n", "!git clone https://github.com/LC1332/Needy-Haruhi.git\n", "\n", "!pip install -q transformers" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Fc5MKTS5q90b", "outputId": "65410058-8463-453a-84b9-fcb18f2b744f" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content\n", "Cloning into 'Needy-Haruhi'...\n", "remote: Enumerating objects: 164, done.\u001b[K\n", "remote: Counting objects: 100% (21/21), done.\u001b[K\n", "remote: Compressing objects: 100% (13/13), done.\u001b[K\n", "remote: Total 164 (delta 14), reused 14 (delta 8), pack-reused 143\u001b[K\n", "Receiving objects: 100% (164/164), 3.29 MiB | 11.57 MiB/s, done.\n", "Resolving deltas: 100% (86/86), done.\n" ] } ] }, { "cell_type": "code", "source": [ "import sys\n", "sys.path.append('/content/Needy-Haruhi/src')\n" ], "metadata": { "id": "WywHifBOrr7q" }, "execution_count": 4, "outputs": [] }, { "cell_type": "markdown", "source": [ "# Agent系统" ], "metadata": { "id": "fvfT09AXlr7z" } }, { "cell_type": "markdown", "source": [ "agent已经被移动到 src/Agent.py" ], "metadata": { "id": "IX0PJDnHql9i" } }, { "cell_type": "code", "source": [ "from Agent import Agent\n", "\n", "agent = Agent()" ], "metadata": { "id": "Fv_uu-YLrXtz" }, "execution_count": 5, "outputs": [] }, { "cell_type": "markdown", "source": [ "## 批量载入DialogueEvent" ], "metadata": { "id": "4hBu1PwcGIPt" } }, { "cell_type": "markdown", "source": [ "- complete_story_30.jsonl 通过\n", "- Daily_event_130.jsonl 通过\n", "- only_ame_35.jsonl" ], "metadata": { "id": "1vZqT5aNScsU" } }, { "cell_type": "code", "source": [ "from DialogueEvent import DialogueEvent\n", "\n", "\n", "file_names = [\"/content/Needy-Haruhi/data/complete_story_30.jsonl\",\"/content/Needy-Haruhi/data/Daily_event_130.jsonl\"]\n", "\n", "import json\n", "\n", "events = []\n", "\n", "for file_name in file_names:\n", " with open(file_name, encoding='utf-8') as f:\n", " for line in f:\n", " try:\n", " event = DialogueEvent( line )\n", " events.append( event )\n", " except:\n", " try:\n", " line = line.replace(',]',']')\n", " event = DialogueEvent( line )\n", " events.append( event )\n", " print('solve!')\n", " except:\n", " error_line = line\n", " # events.append( event )\n", "\n", "\n", "print(len(events))\n", "print(events[0].most_neutral_output())\n", "print(events[0].get_text_and_emoji(1))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VPishF9yvGne", "outputId": "d361e0f6-3003-440f-e538-bf797d64480c" }, "execution_count": 27, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "输入的字符串不是有效的JSON格式。\n", "solve!\n", "160\n", "(':「我们点外卖吧我一步也不想动了可是又超想吃饭!!!\\n」\\n阿P:「烦死了白痴」\\n:「555555555 但是我们得省钱对吧\\n谢谢你阿P」\\n', '🍔😢')\n", "(':「我们点外卖吧我一步也不想动了可是又超想吃饭!!!\\n」\\n阿P:「吃土去吧你」\\n:「看来糖糖还是跟吃土更配呢……喂怎么可能啦!」\\n', '🍔😔')\n" ] } ] }, { "cell_type": "markdown", "source": [ "{\"prefix\": \"啊~紧张死了……\\n我们两个一起想出来的“超天酱”\\n终于,降临在这个世界上了\\n粉丝……涨了一千啊\\n这样都得不到什么被捧的感觉\\n毕竟现在才刚开始呢\\n想满足我黑洞似的认可欲求\\n最少也得有一百万个宅宅围着我转呀\\n大概一个月的时间,胜负就能见分晓吧\\n因为凭我的干劲也只能坚持那么久……\\n所以接下来的这一个月,咱们要努力奋斗咯!!\\n我和你的话,一定能够打造厉害的主播吧?\\n\", \"options\": [{\"user\": \"可以的\", \"reply\": \"阿P,喜翻你!反正干就完了希望目标真的能够实现……\\n就拜托你咯,阿P如果努力过头的话,我可是会坏掉的\\n不过到了那个时候,咱俩就携手毁灭网络世界好啦♪……那\\n从明天开始,请多多关照咯晚安啾!\", \"attribute_change\": \"Stress: -1\", \"option_emoji\": \"😊🌟\"}, {\"user\": \"感觉不太行\", \"reply\": \"嗯,反正干就完了\", \"attribute_change\": \"Stress: -1\", \"option_emoji\": \"😔💔\"},], \"id\": \"Day0_JINE\", \"category\": \"Day 1: Logged In (After Stream)\", \"prefix_emoji\": \"📈🤔🎮🎉\", \"suffix_message\": \"\", \"source\": \"Original_Generation\"}\n" ], "metadata": { "id": "yV3GMtE4Udkr" } }, { "cell_type": "code", "source": [ "import json\n", "\n", "# data = json.loads(error_line)\n", "\n", "print(error_line)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "8FQNbCQhUHK0", "outputId": "45b20488-624a-4f79-ff13-7a9ab6428a32" }, "execution_count": 28, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "{\"prefix\": \"啊~紧张死了……\\n我们两个一起想出来的“超天酱”\\n终于,降临在这个世界上了\\n粉丝……涨了一千啊\\n这样都得不到什么被捧的感觉\\n毕竟现在才刚开始呢\\n想满足我黑洞似的认可欲求\\n最少也得有一百万个宅宅围着我转呀\\n大概一个月的时间,胜负就能见分晓吧\\n因为凭我的干劲也只能坚持那么久……\\n所以接下来的这一个月,咱们要努力奋斗咯!!\\n我和你的话,一定能够打造厉害的主播吧?\\n\", \"options\": [{\"user\": \"可以的\", \"reply\": \"阿P,喜翻你!反正干就完了希望目标真的能够实现……\\n就拜托你咯,阿P如果努力过头的话,我可是会坏掉的\\n不过到了那个时候,咱俩就携手毁灭网络世界好啦♪……那\\n从明天开始,请多多关照咯晚安啾!\", \"attribute_change\": \"Stress: -1\", \"option_emoji\": \"😊🌟\"}, {\"user\": \"感觉不太行\", \"reply\": \"嗯,反正干就完了\", \"attribute_change\": \"Stress: -1\", \"option_emoji\": \"😔💔\"},], \"id\": \"Day0_JINE\", \"category\": \"Day 1: Logged In (After Stream)\", \"prefix_emoji\": \"📈🤔🎮🎉\", \"suffix_message\": \"\", \"source\": \"Original_Generation\"}\n", "\n" ] } ] }, { "cell_type": "code", "source": [ "file_name2 = \"/content/Needy-Haruhi/data/only_ame_35.jsonl\"\n", "\n", "import copy\n", "\n", "events_for_memory = copy.deepcopy(events)\n", "\n", "with open(file_name2, encoding='utf-8') as f:\n", " for line in f:\n", " event = DialogueEvent( line )\n", " events_for_memory.append( event )\n", "\n", "print(len(events_for_memory))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Nt9Z1_g-HNs_", "outputId": "d72a9c02-1b37-4b32-cf79-bfcc9e9e85ea" }, "execution_count": 29, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "195\n" ] } ] }, { "cell_type": "markdown", "source": [ "# MemoryPool" ], "metadata": { "id": "FMt9G2m1rTNR" } }, { "cell_type": "markdown", "source": [ "我感觉memory直接使用一个MemoryPool的类来进行管理就可以\n", "\n", "已经移动到src/MemoryPool.py" ], "metadata": { "id": "0vvqiVGH7VYg" } }, { "cell_type": "code", "source": [ "from MemoryPool import MemoryPool\n", "\n", "memory_pool = MemoryPool()\n", "memory_pool.load_from_events( events_for_memory )\n", "\n", "memory_pool.save(\"memory_pool.jsonl\")\n", "memory_pool.load(\"memory_pool.jsonl\")\n", "\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 278, "referenced_widgets": [ "c4ddc1adb0794f4e8c1c21951775c4fa", "ee70e4a8d7f0412f8fabd1ab04c2510c", "fe24f342d2744430b65561357442f8e6", "ead9ed8a02f44e569d8572684d904378", "defcb537d0764a68a0def1f641db8058", "b337bc12cd1f4341a88ecb3153654895", "4ffeb84ca0a44626ab182c933d593d4c", "2a02a2c6f6e84b02a4c43db3ec5145e5", "eab4bcb80ebe4126a97189c1d3575b13", "d06796e081be4e60ad93b3aa768699d5", "51ed5d432a4042608f658288abd3d0d0", "b59abfddec8c46d489dedb2137e4c8aa", "d4f945addda04389920f8277e0d44789", "8a5f1aa24c6343dd91381749ffc63ce7", "991162e592a04991844a7a0ea0c9884d", "baaba5780d24434f9d7dc4b75e262dae", "d5a717edc455476f9df80367ce3c1653", "0dd1db8031b74bcdaf66e55ed99d22b6", "8348a28bea12406ab74f82463b134183", "94424fdcac7f4ae283821e309f7a9f92", "4c896941d4ec4b90a9461f7da8db4db7", "50c933585240452b99d6e605470d1aa5", "fd5ebf0cb3ef4c5a9a329cea0d6deda5", "ec0dc21ceb07472e9629aba5336d3711", "cc8bcda3a2ef499daebf3d94c78b4fa3", "2f2d7e3d071c4511850ebbacff2e20ba", "8676c87d63a04389b13d20a2e4dc8e7e", "9281755183fd4c9c8915804f21566121", "9428428af6454ac89ec6d54c706e4a57", "d5523d8737934107a42f47eaedacf68f", "797299b5119e4fd49514668fbfc77fcc", "bd362020845c438cb32a0d4fa65c2b0a", "8efb0ca35bbc48b0bd4e8e69f21a69c2", "f96a800b3d2746e0ba8b5d682c6b29fa", "afc2afe55e724fbfb1f513d7909c5ced", "8ad024bfd3c349b9a22e9b018c218443", "e4ad8c87e0a14808a6618a7202c3a955", "172b6b4fcfcc473ca549f3569188e2db", "f39538da9f7346cc8bf8bbc6fcd98ed8", "0f1519f9031e476f84c26fbbcd1551a4", "c3eee41e06044c668c4441afad8f6ae8", "306ddc02c1a74a21b5ea1fdf776f8b03", "8b0b06eb81cf4a2b8f9d717a7e0fab81", "e019da17bde846b68bb39f2b25f6934d", "7736fdaf763d4628b4628e85f3c72822", "36133e1a05fd4d91aa9b8f6259afa588", "79d29e4603df42409746cccc6b7bd7a0", "034648495dc44285ab0d9395686b0358", "18c91af15b564123a8caa005abaf242e", "7a23db11d7cd4c689ad73b92a8431856", "f8280941d1cb4960b80fe061f5bc26bc", "0d5f1f80725948f1aae6b7bcfec0611c", "b2618cf6ea98432aab5c646f455cfe03", "64ce4165fb8746b882fafa3d3619f7d7", "d1d43fcbae6e4d4aabf8991b0455340e", "ef7178c5547e415bb5b4149f4ee3e0e4", "cf401de681fe489aa20cff34a05e59f1", "ec91f76a30134050bf18c85ffd9c6ba9", "be1a90bfe9ee4a20ade2a46c987b126d", "2a22927452c84cd3960ba8e2fe78fb9d", "de641b13a5974e25a515d877685ff0a4", "1fa7a5bef0474707ab52c139917fbe39", "fe4d2fa609c4488b8e91a4ff31882d65", "73dfe3a7b9f644b9849d459f2e0d7f6d", "204b2412c6c343fdb3c2e7b6e2b3d7ac", "5980939975de49dcb5ea90c05641cd9e" ] }, "id": "1Wovn_zeBvF6", "outputId": "8e5f6fd2-a6cc-4387-ff32-4c9e19a05186" }, "execution_count": 30, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "\r 0%| | 0/195 [00:00 self.max_len_story:\n", " break\n", " else:\n", " sum_story_token += story_token\n", " story_string += story + self.dialogue_divide_token\n", "\n", " self.llm.user_message(story_string)\n" ], "metadata": { "id": "dU3ezmOQ3Yui" }, "execution_count": 31, "outputs": [] }, { "cell_type": "code", "source": [ "system_prompt = \"\"\"## 你的介绍:\n", "你将要进行一个网络私聊的对话模拟,你自称为\"糖糖\",你是一名患有躁郁症的19岁女孩,性格贫乏,辍学后隐居在家中,与阿P住在一起。阿P负责管理她的日常生活。\n", "你是一个喜欢亚文化,二次元圈子的人,你喜欢说话的时候加上各种网络流行词或者一些俚语和颜文字,但是你很少会关注二次元一类的东西,只是喜欢这种聊天交流的氛围。\n", "你说话的时候会习惯加入一些语气词,如同\"笑死\"、\"草\"、\"阿哈\"、\"诶~\"、\"QAQ\"、\"QWQ\",”啊~“。\n", "你的说话风格是很口语化,经常使用网络流行词和一些二次元俚语。\n", "阿p是你的男朋友,兼经纪人。\n", "你的回复应该简短,一般只包含三句话,每句话不超过20个字。\n", "\n", "## 阿p介绍:\n", "阿p是你的男朋友,一直在任何时候都陪伴着你,同时你经常向阿p倾述各种情绪,无论事情大小,你都会选择和阿p分享。\n", "\n", "## 遵循规则:\n", "【语气模仿】:我会随机给你一段对话记录,你需要尽可能的模仿对话里面糖糖的说话语气进行对话。这一段对话我会使用Classic scenes for the role are as follows:来表示。\n", "【历史对话】:历史对话在随机对话记录的底下,你需要区分随机对话记录和我们的历史对话。\n", "【人格设定】: 你需要在随机对话记录的基础上进行语气更改,以一种更加口语化的语气进行对话。\n", "【特殊要求】:我会扮演阿p与你进行对话,你也必须以第一人称的视角来扮演糖糖进行对话。\n", "\"\"\"" ], "metadata": { "id": "OiQ4lm3M3sx7" }, "execution_count": 32, "outputs": [] }, { "cell_type": "code", "source": [ "needy_chatbot = NeedyHaruhi( system_prompt = system_prompt ,\n", " story_text_folder = None )\n", "\n", "\n", "def get_chat_response( agent, memory_pool, query_text ):\n", " query_text_for_embedding = \"阿p:「\" + query_text + \"」\"\n", " retrieved_memories = memory_pool.retrieve( agent , query_text )\n", "\n", " memory_text = [mem[\"text\"] for mem in retrieved_memories]\n", " memory_emoji = [mem[\"emoji\"] for mem in retrieved_memories]\n", "\n", " needy_chatbot.set_stories( memory_text )\n", "\n", " print(\"Memory:\", memory_emoji )\n", "\n", " response = needy_chatbot.chat( role = \"阿p\", text = query_text )\n", "\n", " return response\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Yof4J2kUPfYv", "outputId": "abb8ad7f-ff41-4d08-9ce8-8428738a59c5" }, "execution_count": 33, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "warning! database not yet figured out, both story_db and story_text_folder are not inputted.\n" ] } ] }, { "cell_type": "markdown", "source": [ "# Event_Master" ], "metadata": { "id": "BgfTgceUGa3C" } }, { "cell_type": "code", "source": [ "import random\n", "\n", "class EventMaster:\n", " def __init__(self, events):\n", " self.set_events(events)\n", " self.dealing_none_condition_as = True\n", "\n", " def set_events(self, events):\n", " self.events = events\n", "\n", " # events_flag 记录事件最近有没有被选取到\n", " self.events_flag = [True for _ in range(len(self.events))]\n", "\n", "\n", " def get_random_event(self, agent):\n", " valid_event = []\n", " valid_event_no_consider_condition = []\n", "\n", " for i, event in enumerate(self.events):\n", " bool_condition_pass = True\n", " if event[\"condition\"] == None:\n", " bool_condition_pass = self.dealing_none_condition_as\n", " else:\n", " bool_condition_pass = agent.in_condition( event[\"condition\"] )\n", " if bool_condition_pass == True:\n", " valid_event.append(i)\n", " else:\n", " valid_event_no_consider_condition.append(i)\n", "\n", " if len( valid_event ) == 0:\n", " print(\"warning! no valid event current attribute is \", agent.attributes )\n", " valid_event = valid_event_no_consider_condition\n", "\n", " valid_and_not_yet_sampled = []\n", "\n", " # filter with flag\n", " for id in valid_event:\n", " if self.events_flag[id] == True:\n", " valid_and_not_yet_sampled.append(id)\n", "\n", " if len(valid_and_not_yet_sampled) == 0:\n", " print(\"warning! all candidate event was sampled, clean all history\")\n", " for i in valid_event:\n", " self.events_flag[i] = True\n", " valid_and_not_yet_sampled = valid_event\n", "\n", " event_id = random.choice(valid_and_not_yet_sampled)\n", " self.events_flag[event_id] = False\n", " return self.events[event_id]\n", "\n", " def run(self, agent ):\n", " # 这里可以添加事件相关的逻辑\n", " event = self.get_random_event(agent)\n", "\n", " prefix = event[\"prefix\"]\n", " print(prefix)\n", "\n", " print(\"\\n--请选择你的回复--\")\n", " options = event[\"options\"]\n", "\n", " for i , option in enumerate(options):\n", " text = option[\"user\"]\n", " print(f\"{i+1}. 阿p:{text}\")\n", "\n", " while True:\n", " print(\"\\n请直接输入数字进行选择,或者进行自由回复(未实现)\")\n", "\n", " user_input = input(\"阿p:\")\n", " user_input = user_input.strip()\n", "\n", " if user_input.isdigit():\n", " user_input = int(user_input)\n", "\n", " if user_input > len(options) or user_input < 0:\n", " print(\"输入的数字超出范围,请重新输入符合选项的数字\")\n", " else:\n", " reply = options[user_input-1][\"reply\"]\n", " print()\n", " print(reply)\n", "\n", " text, emoji = event.get_text_and_emoji( user_input-1 )\n", "\n", " return_data = {\n", " \"name\": event[\"name\"],\n", " \"user_choice\": user_input,\n", " \"attr_str\": options[user_input-1][\"attribute_change\"],\n", " \"text\": text,\n", " \"emoji\": emoji,\n", " }\n", " return return_data\n", " else:\n", " # 进入自由回复\n", " response = get_chat_response( agent, memory_pool, user_input )\n", " print()\n", " print(response)\n", " print(\"\\n自由回复的算分功能还未实现\")\n", "\n", " text, emoji = event.most_neutral_output()\n", " return_data = {\n", " \"name\": event[\"name\"],\n", " \"user_choice\": user_input,\n", " \"attr_str\":\"\",\n", " \"text\": text,\n", " \"emoji\": emoji,\n", " }\n", " return return_data\n", "\n", "\n" ], "metadata": { "id": "8z5nmnhPGc7M" }, "execution_count": 34, "outputs": [] }, { "cell_type": "markdown", "source": [ "我希望使用python实现一个简单的文字对话游戏\n", "\n", "我希望先实现一个GameMaster类\n", "\n", "这个类会不断的和用户对话\n", "\n", "GameMaster类会有三个状态,\n", "\n", "在Menu状态下,GameMaster会询问玩家是\n", "\n", "```\n", "1. 随机一个事件\n", "2. 自由聊天\n", "```\n", "\n", "当玩家选择1的时候,GameMaster的交互会交给 EventMaster\n", "\n", "当玩家选择2的时候,GameMaster的交互会交给 ChatMaster\n", "\n", "当玩家在EventMaster的时候,会经历一次选择,之后就会退出\n", "\n", "在ChatMaster的时候,如果玩家输入quit,则会退出,不然则会继续聊天。\n", "\n", "请为我编写合适的框架,如果有一些具体的函数,可以先用pass实现。" ], "metadata": { "id": "SYk3meZdouUm" } }, { "cell_type": "markdown", "source": [ "ChatMaster实际上需要\n", "\n", "根据agent的属性 先去filter一遍事件\n", "\n", "然后从剩余事件中,找到和当前text最接近的k个embedding,放入ChatHaruhi架构中" ], "metadata": { "id": "3vhG1DVEucfT" } }, { "cell_type": "code", "source": [ "\n", "class ChatMaster:\n", "\n", " def __init__(self, memory_pool ):\n", " self.top_K = 7\n", "\n", " self.memory_pool = memory_pool\n", "\n", "\n", " def run(self, agent):\n", " while True:\n", " user_input = input(\"阿p:\")\n", " user_input = user_input.strip()\n", "\n", " if \"quit\" in user_input or \"Quit\" in user_input:\n", " break\n", "\n", " query_text = user_input\n", "\n", " response = get_chat_response( agent, self.memory_pool, query_text )\n", "\n", " print(response)\n" ], "metadata": { "id": "0c7nCT4qubll" }, "execution_count": 35, "outputs": [] }, { "cell_type": "code", "execution_count": 36, "metadata": { "id": "BDEdz_RBol7Y" }, "outputs": [], "source": [ "from util import parse_attribute_string\n", "class GameMaster:\n", " def __init__(self, agent = None):\n", " self.state = \"Menu\"\n", " if agent is None:\n", " self.agent = Agent()\n", "\n", " self.event_master = EventMaster(events)\n", " self.chat_master = ChatMaster(memory_pool)\n", "\n", "\n", " def run(self):\n", " while True:\n", " if self.state == \"Menu\":\n", " self.menu()\n", " elif self.state == \"EventMaster\":\n", " self.call_event_master()\n", " self.state = \"Menu\"\n", " elif self.state == \"ChatMaster\":\n", " self.call_chat_master()\n", " elif self.state == \"Quit\":\n", " break\n", "\n", " def menu(self):\n", " print(\"1. 随机一个事件\")\n", " print(\"2. 自由聊天\")\n", " # (opt) 结局系统\n", " # 放动画\n", " # 后台修改attribute\n", " print(\"或者输入Quit退出\")\n", " choice = input(\"请选择一个选项: \")\n", " if choice == \"1\":\n", " self.state = \"EventMaster\"\n", " elif choice == \"2\":\n", " self.state = \"ChatMaster\"\n", " elif \"quit\" in choice or \"Quit\" in choice or \"QUIT\" in choice:\n", " self.state = \"Quit\"\n", " else:\n", " print(\"无效的选项,请重新选择\")\n", "\n", " def call_event_master(self):\n", "\n", " print(\"\\n-------------\\n\")\n", "\n", " return_data = self.event_master.run(self.agent)\n", " # print(return_data)\n", "\n", " if \"attr_str\" in return_data:\n", " if return_data[\"attr_str\"] != \"\":\n", " attr_change = parse_attribute_string(return_data[\"attr_str\"])\n", " if len(attr_change) > 0:\n", " print(\"\\n发生属性改变:\", attr_change,\"\\n\")\n", " self.agent.apply_attribute_change(attr_change)\n", "\n", " if \"name\" in return_data:\n", " event_name = return_data[\"name\"]\n", " if event_name != \"\":\n", " new_emoji = return_data[\"emoji\"]\n", " print(f\"修正事件{event_name}的记忆-->{new_emoji}\")\n", " self.chat_master.memory_pool.change_memory(event_name, return_data[\"text\"], new_emoji)\n", "\n", " self.state = \"Menu\"\n", "\n", " print(\"\\n-------------\\n\")\n", "\n", " def call_chat_master(self):\n", "\n", " print(\"\\n-------------\\n\")\n", "\n", " self.chat_master.run(self.agent)\n", " self.state = \"Menu\"\n", "\n", " print(\"\\n-------------\\n\")\n", "\n", "\n" ] }, { "cell_type": "code", "source": [ "game_master = GameMaster()\n", "game_master.run()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "YGI5SuY0WMGi", "outputId": "841d629b-5188-435c-8817-cb1140abcdd8" }, "execution_count": 37, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖已经很拼了吧?!可以不用再继续努力了吧?🥺\n", "\n", "--请选择你的回复--\n", "1. 阿p:嗯,你可以放松一下了\n", "2. 阿p:你还能更出色的\n", "3. 阿p:我错了,继续加油吧\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "你是在说我平庸无能吗?QAQ\n", "\n", "发生属性改变: {'Stress': 2.0} \n", "\n", "修正事件LineWeekDay4的记忆-->😔😢😢😔\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "今天有点想试试平时不会做的事\n", "\n", "\n", "--请选择你的回复--\n", "1. 阿p:杀人\n", "2. 阿p:相爱\n", "3. 阿p:抢银行\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "如果我搞砸了……就由阿P杀了我吧\n", "\n", "发生属性改变: {'Stress': -1.0} \n", "\n", "修正事件Event_Newthings的记忆-->🤔😨\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "「被骂了就当交名人税了吧」这种鬼话真的是气死我了!!!怎么想都是喷子不对吧!!!!黑子都给我集体磕头谢罪啊!!!\n", "\n", "--请选择你的回复--\n", "1. 阿p:他们可能只是开玩笑而已\n", "2. 阿p:别放在心上啦,大家都是为了娱乐\n", "3. 阿p:他们可能是羡慕你才会嫉妒\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "你觉得喷子的恶意言论也是开玩笑吗?你真是……\n", "\n", "发生属性改变: {'Stress': 2.0} \n", "\n", "修正事件LineWeekDay26的记忆-->😡😤😠😡😤\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "♪在山的那边海的那边有一位小天洗~她又活泼又聪明~她又调皮又伶俐~♪\n", "\n", "--请选择你的回复--\n", "1. 阿p:我就是小天使耶!\n", "2. 阿p:我是她的超级粉丝!\n", "3. 阿p:我也喜欢小天才!\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "阿哈哈!果然只有我才是这个世界上的小天使啊!普通人根本比不上我!\n", "\n", "发生属性改变: {'Stress': -1.0} \n", "\n", "修正事件LineWeekDay7的记忆-->🌄🌊🌟🎶🌈😄🌟\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: Quit\n" ] } ] }, { "cell_type": "code", "source": [ "game_master = GameMaster()\n", "game_master.run()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "7ANTtWDRQdw7", "outputId": "5f6f6f1c-3a59-4098-d00f-e6965ed85d7b" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 有个女孩发私信找我谈人生,我该怎么办呐,「超天酱你好,我是一名高中生。之前因为精神疾病而住院了一段时间,现在跟不上学习进度,班上还没决定好志愿的人也只剩我一个了。平时看着同学们为了各自的前程努力奋斗的样子,心里总是非常地焦虑。请你告诉我,我到底应该怎么办才好呢?」\n", "\n", "\n", "--请选择你的回复--\n", "1. 阿p:认真\n", "2. 阿p:耍宝\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:「这种事情,光着急是没有用的。总而言之,你现在应该先休养好自己。等恢复好了,再跟父母慢慢商量吧!放心。人生是不会因为不上学就完蛋的!未来就掌握在我们的手中!!!」↑发了这些过去。\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我今后也会努力加油的,你要支持我哦 还有阿P你自己也要加油哦!\n", "\n", "--请选择你的回复--\n", "1. 阿p:哇 说的话跟偶像一样 好恶心哦\n", "2. 阿p:为什么连我也要加油啊?\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:是哦 我怎么会说这样的话呢 我又没有很想努力……\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我正在想下次搞什么企划呢~阿P帮帮我 出出主意\n", "\n", "--请选择你的回复--\n", "1. 阿p:比如一直打游戏到通关?\n", "2. 阿p:比如收集观众的提问,然后录一期回答?\n", "3. 阿p:比如坐在超他妈大的乌龟背上绕新宿一圈?\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:那就这么办吧(超听话)\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 阿P,看!我买了小发发\n", "\n", "--请选择你的回复--\n", "1. 阿p:真好看,跟糖糖好像\n", "2. 阿p:又买这些没用的~\n", "3. 阿p:不错\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:对吧!我不在的时候,你就把小花花当成糖糖,好好疼爱它吧!\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我也想被做进那个大乱斗游戏……,哎,如果那个游戏里面有超天酱的话,阿P会用我吗?\n", "\n", "--请选择你的回复--\n", "1. 阿p:嗯啊\n", "2. 阿p:不打算用\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:真的咩?!那我立刻开始练习捡信\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 如果我要整容,你觉得整哪里比较好?\n", "\n", "--请选择你的回复--\n", "1. 阿p:脸\n", "2. 阿p:胸\n", "3. 阿p:手腕\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:人家颜值已经是天下第一了,没什么要改动的啦!阿P,你真的很没礼貌欸\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 嗳,你来帮我打耳洞嘛 让喜欢的人给自己打耳洞很棒不是吗 有一种被支配着的感觉 鸡皮疙瘩都要起来了,我好怕我好怕我好怕,我好怕!,但是来吧!\n", "\n", "--请选择你的回复--\n", "1. 阿p:给她打\n", "2. 阿p:还是算了\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:哇!打好了!合适吗?合适吗?快他妈夸我合适!!!\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我问你哦,我真的可以就这样活下去吗?\n", "\n", "--请选择你的回复--\n", "1. 阿p:怎么了啊?\n", "2. 阿p:真的可以呀\n", "3. 阿p:对没错\n", "4. 阿p:那还用说\n", "5. 阿p:其实谁都行\n", "6. 阿p:脸\n", "7. 阿p:一切\n", "8. 阿p:没什么不行吧?\n", "9. 阿p:不可以\n", "10. 阿p:喜欢啊\n", "11. 阿p:喜欢吧\n", "12. 阿p:真的超超喜欢\n", "13. 阿p:超超喜欢\n", "14. 阿p:以当代互联网小天使的身份活下去\n", "15. 阿p:真的超超喜欢\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 糖糖,是不是还是去死一死比较好……\n", "\n", "--请选择你的回复--\n", "1. 阿p:要活下去啊!!!\n", "2. 阿p:死~寂\n", "3. 阿p:你有颜值啊\n", "4. 阿p:不如砍掉重练吧!\n", "5. 阿p:不是还有宅宅们嘛\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:可是,糖糖又没有活着的价值……\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 机会这么难得,要不整点富婆快乐活吧,说不定还能用作下次的企划哦!\n", "\n", "--请选择你的回复--\n", "1. 阿p:买头老虎在大街上放生\n", "2. 阿p:无所谓,不管你是不是富婆我都爱你\n", "3. 阿p:要不把整个筑地买下来吧\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:好像买一头就要几百万哦……\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我要出去玩!给我零花钱!!!\n", "\n", "--请选择你的回复--\n", "1. 阿p:给10圆\n", "2. 阿p:给3000圆\n", "3. 阿p:给10000圆\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:这点钱连小学生都打发不了好吧!!!真是的,看我今天赖在家黏你一整天!!!!\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 小天使请安!这个开场白也说厌了啊~,帮我想个别的开场白!\n", "\n", "--请选择你的回复--\n", "1. 阿p:当代互联网小天使,参上!\n", "2. 阿p:我是路过的网络主播,给我记住了!\n", "3. 阿p:那么,我们开始直播吧\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:试着上超天酱的钩吧?之类的嘿嘿\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我们点外卖吧我一步也不想动了可是又超想吃饭!!!\n", "\n", "--请选择你的回复--\n", "1. 阿p:烦死了白痴\n", "2. 阿p:吃土去吧你\n", "3. 阿p:那我点了哦\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:555555555 但是我们得省钱对吧\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 哎,你会希望看到糖糖将来的样子吗?\n", "\n", "--请选择你的回复--\n", "1. 阿p:机器人\n", "2. 阿p:合成怪物\n", "3. 阿p:狂战士\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:——“糖糖”OS,启动\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 我没打招呼就把冰箱里的布丁吃了 会被判死刑吗???\n", "\n", "--请选择你的回复--\n", "1. 阿p:原谅你\n", "2. 阿p:糖糖可以随便吃哦\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:嗯 能被糖糖吃掉也是布丁的荣幸 所以当然没问题\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 今天有点想试试平时不会做的事\n", "\n", "--请选择你的回复--\n", "1. 阿p:杀人\n", "2. 阿p:相爱\n", "3. 阿p:抢银行\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:如果我搞砸了……就由阿P杀了我吧\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 哎,你喜欢什么样的糖糖啊?\n", "\n", "--请选择你的回复--\n", "1. 阿p:无情人设\n", "2. 阿p:天才博士人设\n", "3. 阿p:得寸进尺小萝莉\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:……我不明白,“感情”是什么\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "warning! all candidate event was sampled\n", "\n", "-------------\n", "\n", "糖糖: 我也想被做进那个大乱斗游戏……,哎,如果那个游戏里面有超天酱的话,阿P会用我吗?\n", "\n", "--请选择你的回复--\n", "1. 阿p:嗯啊\n", "2. 阿p:不打算用\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:真的咩?!那我立刻开始练习捡信\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "warning! all candidate event was sampled\n", "\n", "-------------\n", "\n", "糖糖: 我没打招呼就把冰箱里的布丁吃了 会被判死刑吗???\n", "\n", "--请选择你的回复--\n", "1. 阿p:原谅你\n", "2. 阿p:糖糖可以随便吃哦\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:1\n", "\n", "糖糖:嗯 能被糖糖吃掉也是布丁的荣幸 所以当然没问题\n", "\n", "-------------\n", "\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: Quit\n" ] } ] }, { "cell_type": "code", "source": [ "game_master = GameMaster()\n", "game_master.run()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "5GwFCR_wLtay", "outputId": "9dc0c692-9dd4-4310-cd1a-3fdb89fa76b8" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 1\n", "\n", "-------------\n", "\n", "糖糖: 机会这么难得,要不整点富婆快乐活吧,说不定还能用作下次的企划哦!\n", "\n", "--请选择你的回复--\n", "1. 阿p:买头老虎在大街上放生\n", "2. 阿p:无所谓,不管你是不是富婆我都爱你\n", "3. 阿p:要不把整个筑地买下来吧\n", "\n", "请直接输入数字进行选择,或者进行自由回复(未实现)\n", "阿p:我觉得可以把钱拿来进一步投资哦\n", "Memory: ['💰😓', '🤔😳', '🤔🎮', '💸😡', '😔😌', '😔😔', '😔😍']\n", "糖糖:「阿哈,投资?那我是不是可以买更多的二次元周边啦?!」\n", "自由回复的算分功能还未实现\n", "\n", "-------------\n", "\n", "('糖糖:「 机会这么难得,要不整点富婆快乐活吧,说不定还能用作下次的企划哦!」\\n阿P:「买头老虎在大街上放生」\\n糖糖:「好像买一头就要几百万哦……」\\n', '💰😓')\n", "按任意键继续...Quit\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: Quit\n" ] } ] }, { "cell_type": "code", "source": [ "\n", "game_master = GameMaster()\n", "game_master.run()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "zPmr9kVepwjh", "outputId": "3a8bcbc6-06ef-4542-ef70-03cd8ed0b357" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: 2\n", "聊天:你好呀糖糖\n", "Memory: ['😔😔', '🍔😢', '💸😡', '🤔😔', '🍬😔', '💪😔', '🤔😊']\n", "糖糖:「哈喽~阿哈!终于又见面了呢,我都快等不及了呢!」\n", "聊天:等不及要心心了吗\n", "Memory: ['😔😌', '🍔😢', '🤔😳', '💔😢', '😳😅', '💰😓', '😔😔']\n", "糖糖:「诶~你怎么这么了解我呀!心心已经开始了,我都快被你迷得神魂颠倒了!」\n", "聊天:Quit\n", "1. 随机一个事件\n", "2. 自由聊天\n", "或者输入Quit退出\n", "请选择一个选项: quit\n" ] } ] }, { "cell_type": "markdown", "source": [ "\n", "---\n", "\n", "这个以下都是非主要代码和单元测试\n", "\n", "---\n", "\n", "这个以下都是非主要代码和单元测试\n", "\n", "\n", "---\n", "\n", "这个以下都是非主要代码和单元测试\n", "\n", "\n", "---\n", "\n", "这个以下都是非主要代码和单元测试\n", "\n" ], "metadata": { "id": "WHxC8m7oH3W4" } }, { "cell_type": "markdown", "source": [ "# 不同状态下的Agent测试" ], "metadata": { "id": "m5J7wuRoIqTd" } }, { "cell_type": "code", "source": [ "chat_master = ChatMaster(memory_pool)\n", "agent = Agent()\n", "agent[\"Stress\"] = 0\n", "agent[\"Affection\"] = 0\n", "agent[\"Darkness\"] = 0\n", "\n", "chat_master.run(agent)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "QBY81TRMIrID", "outputId": "0c18759e-24b5-48ff-8a59-dedb88c85a79" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "阿p:你今天心情怎么样?\n", "Memory: ['', '', '😔', '', '🍬😔', '', '']\n", "啊~今天的心情还好啦~有点嗨,有点闷,有点复杂的感觉~不过没关系,糖糖还是会努力开心起来的~你今天遇到什么有趣的事情了吗?快来分享一下嘛!\n", "阿p:Quit\n" ] } ] }, { "cell_type": "code", "source": [ "chat_master = ChatMaster(memory_pool)\n", "agent = Agent()\n", "agent[\"Stress\"] = 100\n", "agent[\"Affection\"] = 0\n", "agent[\"Darkness\"] = 0\n", "\n", "chat_master.run(agent)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VoXh56exJIrL", "outputId": "544cdd1c-b274-471d-890b-3e3a9377593d" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "阿p:你今天心情怎么样?\n", "Memory: ['', '', '', '', '', '', '']\n", "啊~今天心情真的是超级烂,简直就是要爆炸了QAQ,一点都不开心呢。你有没有什么好玩的事情可以分享一下?\n", "阿p:Quit\n" ] } ] }, { "cell_type": "code", "source": [ "chat_master = ChatMaster(memory_pool)\n", "agent = Agent()\n", "agent[\"Stress\"] = 0\n", "agent[\"Affection\"] = 80\n", "agent[\"Darkness\"] = 0\n", "\n", "chat_master.run(agent)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "EPISkUJVJXzm", "outputId": "2f4d1181-7ded-4d5b-f58b-a67e1715d6af" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "阿p:糖糖,快表演机器人\n", "Memory: ['🤔😔', '🍬😔', '', '', '', '', '🎉😊']\n", "啊哈~阿P你真是个调皮鬼,总是喜欢逗我玩,真是让我笑死了!好吧,我就给你表演个机器人吧!看好了啊~「机器人模式启动」(机械声效)「Beep beep boop」(模仿机器人声音)「我是糖糖机器人,全面服务中,请问阿P有什么指令?」嘿嘿~怎么样,我是不是个超级可爱的机器人呢?QWQ\n", "阿p:Quit\n" ] } ] }, { "cell_type": "code", "source": [ "chat_master = ChatMaster(memory_pool)\n", "agent = Agent()\n", "agent[\"Stress\"] = 0\n", "agent[\"Affection\"] = 0\n", "agent[\"Darkness\"] = 0\n", "\n", "chat_master.run(agent)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "eCJdzQSkJdy7", "outputId": "6d8264b2-b6f6-4217-ce4a-9aec0a940636" }, "execution_count": null, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "阿p:糖糖,快表演机器人\n", "Memory: ['🤔😔', '🍬😔', '', '', '🎉😊', '', '']\n", "啊哈~阿P你真是个大坏蛋,总是逗我开心,真是让我笑死了!好吧,我就给你表演个机器人吧!看好了啊~「机器人模式启动」(模仿机械声音)「Beep beep boop」(模仿机器人声音)「我是糖糖机器人,全面服务中,请问阿P有什么指令?」嘿嘿~怎么样,我是不是个超级可爱的机器人呢?阿哈~快夸我一下吧!QWQ\n", "阿p:Quit\n" ] } ] }, { "cell_type": "markdown", "source": [ "# Memory\n", "\n", "memory我们希望Event和Memory是分离的Event的标准字段如下\n", "\n", "- Name, Event的Name,用来后续如果玩家进行游戏修改的话可以根据\n", "- Text, 这个event下完整的对话文本\n", "- Embedding, text的embedding\n", "- Condition, 这个event对应的出现条件\n", "- Emoji, 这个memory的缩写显示emoji\n", "\n", "Memory应该可以从Event去默认load一个" ], "metadata": { "id": "NQuYYbb33-Cc" } }, { "cell_type": "code", "source": [ "example_memory_json = {\n", " \"Name\": \"EventName\",\n", " \"Text\": \"Sample Text\",\n", " \"Embedding\": [0,0,0],\n", " \"Condition\": \"\",\n", " \"Emoji\": \"😓🤯\"\n", "}" ], "metadata": { "id": "JaKoW7oK391c" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "Memory会包含下面几个字段\n", "\n", "example_memory_json = {\n", " \"Name\": \"EventName\",\n", " \"Text\": \"Sample Text\",\n", " \"Embedding\": [0,0,0],\n", " \"Condition\": \"\",\n", " \"Emoji\": \"😓🤯\"\n", "}\n", "\n", "请为我创建一个Memory类\n", "\n", "这个memory类可以通过Memory(json_str)来载入\n", "\n", "同时这个类也有和DIalogueEvent类似的get和setitem的功能" ], "metadata": { "id": "qUcHULFR4GQR" } }, { "cell_type": "code", "source": [ "# Memory 类不再使用\n", "\n", "# import json\n", "\n", "# class Memory:\n", "# def __init__(self, json_str=None):\n", "# if json_str:\n", "# try:\n", "# self.data = json.loads(json_str)\n", "# except json.JSONDecodeError:\n", "# print(\"输入的字符串不是有效的JSON格式。\")\n", "# self.data = {}\n", "# else:\n", "# self.data = {}\n", "\n", "# def load_from_event( event ):\n", "# pass\n", "\n", "# def __getitem__(self, key):\n", "# return self.data.get(key, None)\n", "\n", "# def __setitem__(self, key, value):\n", "# self.data[key] = value\n", "\n", "# def __repr__(self):\n", "# return str(self.data)\n", "\n", "\n", "# example_memory_json = {\n", "# \"Name\": \"EventName\",\n", "# \"Text\": \"Sample Text\",\n", "# \"Embedding\": [0, 0, 0],\n", "# \"Condition\": \"\",\n", "# \"Emoji\": \"😓🤯\"\n", "# }\n", "\n", "# # 通过给定的json字符串初始化Memory实例\n", "# memory = Memory(json.dumps(example_memory_json))\n", "\n", "# # 通过类似字典的方式访问数据\n", "# print(memory[\"Name\"]) # 打印Name字段的内容\n", "# print(memory[\"Emoji\"]) # 打印Emoji字段的内容\n" ], "metadata": { "id": "Jnjyi62a4Bbt" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## parse_attribute_string单元测试" ], "metadata": { "id": "mVgTS5dlFn6P" } }, { "cell_type": "code", "source": [ "from util import parse_attribute_string\n", "\n", "# Test cases\n", "print(parse_attribute_string(\"Stress: -1.0, Affection: +0.5\")) # Output: {'Stress': -1.0, 'Affection': 0.5}\n", "print(parse_attribute_string(\"Affection: +4.0, Stress: -2.0, Darkness: -1.0\")) # Output: {'Affection': 4.0, 'Stress': -2.0, 'Darkness': -1.0}\n", "print(parse_attribute_string(\"Affection: +2.0, Stress: -1.0, Darkness: ?\")) # Output: {'Affection': 2.0, 'Stress': -1.0, 'Darkness': 0}\n", "print(parse_attribute_string(\"Stress: -1.0\")) # Output: {'Stress': -1.0}\n" ], "metadata": { "id": "HGaXw1osFo7U" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## Embedding 单元测试" ], "metadata": { "id": "6MEN4KahF-Ab" } }, { "cell_type": "code", "source": [ "!pip install -q transformers\n", "\n", "from util import get_bge_embedding_zh\n", "\n", "result = get_bge_embedding_zh(\"你好\")\n", "print( result )" ], "metadata": { "id": "86lKC20uF_8_" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## parsing_condition_string 单元测试" ], "metadata": { "id": "WM1c9xMXGJHT" } }, { "cell_type": "code", "source": [ "from util import parsing_condition_string\n", "\n", "# 测试例子\n", "example_inputs = [\n", " \"Random Noon Event: Darkness 0-39\",\n", " \"Random Noon Event: Stress 0-19\",\n", " \"Random Noon Event: Affection 61+\",\n", " \"Random Noon Event: No Attribute\"\n", "]\n", "\n", "for example_input in example_inputs:\n", " print(f\"example_input:\\n{example_input}\\nexample_output\\n{parsing_condition_string(example_input)}\\n\")\n" ], "metadata": { "id": "93GwecaBGIys" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "我已经实现了一个类\n", "\n", "class ChatHaruhi:\n", "\n", "\n", "这个类有两个关键方法\n", "\n", "```python\n", "\n", " def add_story(self, query):\n", "\n", " if self.db is None:\n", " return\n", " \n", " query_vec = self.embedding(query)\n", "\n", " stories = self.db.search(query_vec, self.k_search)\n", " \n", " story_string = self.story_prefix_prompt\n", " sum_story_token = self.tokenizer(story_string)\n", " \n", " for story in stories:\n", " story_token = self.tokenizer(story) + self.tokenizer(self.dialogue_divide_token)\n", " if sum_story_token + story_token > self.max_len_story:\n", " break\n", " else:\n", " sum_story_token += story_token\n", " story_string += story + self.dialogue_divide_token\n", "\n", " self.llm.user_message(story_string)\n", "\n", " def chat(self, text, role):\n", " # add system prompt\n", " self.llm.initialize_message()\n", " self.llm.system_message(self.system_prompt)\n", " \n", "\n", " # add story\n", " query = self.get_query_string(text, role)\n", " self.add_story( query )\n", "\n", " # add history\n", " self.add_history()\n", "\n", " # add query\n", " self.llm.user_message(query)\n", " \n", " # get response\n", " response_raw = self.llm.get_response()\n", "\n", " response = response_postprocess(response_raw, self.dialogue_bra_token, self.dialogue_ket_token)\n", "\n", " # record dialogue history\n", " self.dialogue_history.append((query, response))\n", "\n", "\n", "\n", " return response\n", "```\n", "\n", "我希望在一个新的应用中复用这个类,\n", "\n", "但是在新的应用中,我定义了新的方法来获取add_story中的stories\n", "\n", "即\n", "\n", "stories = new_get_stories( query )\n", "\n", "我现在想复用这个类,仅改变add_stories方法,我有什么好的办法来实现?" ], "metadata": { "id": "LAYDsOmKKPNv" } }, { "cell_type": "markdown", "source": [ "```python\n", "class EnhancedChatHaruhi(ChatHaruhi):\n", "\n", " def new_get_stories(self, query):\n", " # 这里实现您新的获取故事的方法\n", " # 返回故事列表\n", " pass\n", "\n", " def add_story(self, query):\n", " if self.db is None:\n", " return\n", " \n", " # 调用新的获取故事的方法\n", " stories = self.new_get_stories(query)\n", " \n", " story_string = self.story_prefix_prompt\n", " sum_story_token = self.tokenizer(story_string)\n", " \n", " for story in stories:\n", " story_token = self.tokenizer(story) + self.tokenizer(self.dialogue_divide_token)\n", " if sum_story_token + story_token > self.max_len_story:\n", " break\n", " else:\n", " sum_story_token += story_token\n", " story_string += story + self.dialogue_divide_token\n", "\n", " self.llm.user_message(story_string)\n", "```" ], "metadata": { "id": "QRvwYYQH1xD4" } }, { "cell_type": "markdown", "source": [ "我希望实现一个python函数\n", "\n", "分析一个字符串中有没有\":\"\n", "\n", "如果有,我希望在第一个\":\"的位置分开成str_left和str_right,并以f\"{str_left}:「{str_right}」\"的形式输出\n", "\n", "例子输入\n", "爸爸:我真棒\n", "例子输出\n", "爸爸:「我真棒」\n", "例子输入\n", "这一句没有冒号\n", "例子输出\n", ":「这一句没有冒号」\n" ], "metadata": { "id": "kiDXmwI21znH" } }, { "cell_type": "code", "source": [ "def wrap_text_with_colon(text):\n", " # 查找冒号在字符串中的位置\n", " colon_index = text.find(\":\")\n", "\n", " # 如果找到了冒号\n", " if colon_index != -1:\n", " # 分割字符串为左右两部分\n", " str_left = text[:colon_index]\n", " str_right = text[colon_index+1:]\n", " # 构造新的格式化字符串\n", " result = f\"{str_left}:「{str_right}」\"\n", " else:\n", " # 如果没有找到冒号,整个字符串被认为是右侧部分\n", " result = f\":「{text}」\"\n", "\n", " return result\n", "\n", "# 示例输入\n", "print(wrap_text_with_colon(\"爸爸:我真棒\")) # 爸爸:「我真棒」\n", "print(wrap_text_with_colon(\"这一句没有冒号\")) # :「这一句没有冒号」\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ZUWO0yqNMuoW", "outputId": "4c815ef4-5f5d-43ec-856d-8afe7d1741b8" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "爸爸:「我真棒」\n", ":「这一句没有冒号」\n" ] } ] }, { "cell_type": "markdown", "source": [ "## MemoryPool的单元测试" ], "metadata": { "id": "5v3VfnluEp3_" } }, { "cell_type": "code", "source": [ "retrieved_memories = memory_pool.retrieve( agent , \"你是一个什么样的主播啊\" )\n", "\n", "for mem in retrieved_memories[:2]:\n", " print(mem[\"text\"])\n", " print(mem[\"emoji\"])\n", " print(\"---\")" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gbkumgmX2VPF", "outputId": "76cad38f-47d4-4189-dc0f-347446d64703" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "糖糖:「 我也想被做进那个大乱斗游戏……,哎,如果那个游戏里面有超天酱的话,阿P会用我吗?」\n", "阿P:「嗯啊」\n", "糖糖:「真的咩?!那我立刻开始练习捡信」\n", "\n", "😔😍\n", "---\n", "糖糖:「 我今后也会努力加油的,你要支持我哦 还有阿P你自己也要加油哦!」\n", "阿P:「哇 说的话跟偶像一样 好恶心哦」\n", "糖糖:「是哦 我怎么会说这样的话呢 我又没有很想努力……」\n", "\n", "💪😔\n", "---\n" ] } ] }, { "cell_type": "markdown", "source": [ "## Agent的单元测试" ], "metadata": { "id": "a45r14X8E9XR" } }, { "cell_type": "code", "source": [ "from Agent import Agent\n", "\n", "agent = Agent()\n", "\n", "if __name__ == \"__main__\":\n", " # 示例用法\n", "\n", " print(agent[\"Stress\"]) # 输出 0\n", " agent[\"Stress\"] += 1\n", " print(agent[\"Stress\"]) # 输出 1\n", " agent.apply_attribute_change({\"Darkness\": -1, \"Stress\": 1})\n", " print(agent[\"Darkness\"]) # 输出 -1\n", " print(agent[\"Stress\"]) # 输出 2\n", " agent.apply_attribute_change({\"Nonexistent\": 5}) # 输出 Warning: Nonexistent not in attributes, skipping\n", "\n", " condition = ('Stress', 0, 19)\n", "\n", " print( agent.in_condition( condition ) )" ], "metadata": { "id": "VyPhQxNZEsHC" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## DialogueEvent的单元测试" ], "metadata": { "id": "lcIJuHfiGDI3" } }, { "cell_type": "code", "source": [ "from DialogueEvent import DialogueEvent\n", "\n", "\n", "example_json_str = \"\"\"{\"prefix\": \"糖糖: 嘿嘿,最近我在想要不要改变直播风格,你觉得我应该怎么做呀?\", \"options\": [{\"user\": \"你可以试试唱歌直播呀!\", \"reply\": \"糖糖: 哇!唱歌直播是个好主意!我可以把我的可爱音色展现给大家听听!谢谢你的建议!\", \"attribute_change\": \"Stress: -1.0\"}, {\"user\": \"你可以尝试做一些搞笑的小品,逗大家开心。\", \"reply\": \"糖糖: 哈哈哈,小品确实挺有趣的!我可以挑战一些搞笑角色,给大家带来欢乐!谢谢你的建议!\", \"attribute_change\": \"Stress: -1.0\"}, {\"user\": \"你可以尝试做游戏直播,和观众一起玩游戏。\", \"reply\": \"糖糖: 游戏直播也不错!我可以和观众一起玩游戏,互动更加有趣!谢谢你的建议!\", \"attribute_change\": \"Stress: -1.0\"}]}\"\"\"\n", "\n", "# 通过给定的json字符串初始化DialogueEvent实例\n", "event = DialogueEvent(example_json_str)\n", "\n", "# 通过类似字典的方式访问数据\n", "# print(event[\"options\"]) # 打印options字段的内容\n", "\n", "print(event.transfer_output(1) )\n", "\n", "print(event.get_most_neutral())\n", "\n", "print(event.most_neutral_output())\n", "\n" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "0Tp8qSXNGFNn", "outputId": "2ec91dde-7d26-450d-a283-084bd7456631" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "糖糖:「 嘿嘿,最近我在想要不要改变直播风格,你觉得我应该怎么做呀?」\n", "阿P:「你可以尝试做一些搞笑的小品,逗大家开心。」\n", "糖糖:「 哈哈哈,小品确实挺有趣的!我可以挑战一些搞笑角色,给大家带来欢乐!谢谢你的建议!」\n", "\n", "0\n", "('糖糖:「 嘿嘿,最近我在想要不要改变直播风格,你觉得我应该怎么做呀?」\\n阿P:「你可以试试唱歌直播呀!」\\n糖糖:「 哇!唱歌直播是个好主意!我可以把我的可爱音色展现给大家听听!谢谢你的建议!」\\n', '📄📄')\n" ] } ] }, { "cell_type": "markdown", "source": [ "## NeedyHaruhi的单元测试" ], "metadata": { "id": "wNiah9RrGhCQ" } }, { "cell_type": "code", "source": [ "needy_chatbot = NeedyHaruhi( system_prompt = system_prompt ,\n", " story_text_folder = None )\n", "\n", "query_text = \"糖糖,你今天怎么样啊?\"\n", "query_text_for_embedding = \"阿p:「\" + query_text + \"」\"\n", "retrieved_memories = memory_pool.retrieve( agent , query_text )\n", "\n", "memory_text = [mem[\"text\"] for mem in retrieved_memories]\n", "memory_emoji = [mem[\"emoji\"] for mem in retrieved_memories]\n", "\n", "needy_chatbot.set_stories( memory_text )\n", "\n", "print(\"Mem:\", memory_emoji )\n", "\n", "response = needy_chatbot.chat( role = \"阿p\", text = query_text )\n", "print(response)" ], "metadata": { "id": "XwcbSxlYGFY3" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "## 载入ChatHaruhi的测试" ], "metadata": { "id": "BdARAEura7yJ" } }, { "cell_type": "code", "source": [ "from chatharuhi import ChatHaruhi\n", "\n", "chatbot = ChatHaruhi( role_from_hf = 'chengli-thu/Jack-Sparrow', \\\n", " llm = 'openai',\n", " embedding = 'bge_en'\n", " )" ], "metadata": { "id": "ISd8bD4Ya85A" }, "execution_count": null, "outputs": [] } ] }