{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"colab":{"provenance":[],"toc_visible":true},"widgets":{"application/vnd.jupyter.widget-state+json":{"9dd744f6393943f2959c27ac89e93ba1":{"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_27b05fd0ecb34c10ae93eac9d4cdc1c5","IPY_MODEL_025ddae40b4541a684f1d76c5b289ab6","IPY_MODEL_bd4b2fd97cb34f5f900e91969cc588c7"],"layout":"IPY_MODEL_48641e4f73954da987f034a74c3b8b5e"}},"27b05fd0ecb34c10ae93eac9d4cdc1c5":{"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_c8177522a2e64f4eafef0d6cbc1f6cdd","placeholder":"​","style":"IPY_MODEL_29a4704b56cf4d4fa145fac101dbcb8d","value":"TrainGemma2.gameintro.queries.lf.csv: 100%"}},"025ddae40b4541a684f1d76c5b289ab6":{"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_c345a572c5d4493d93423618f0a6f143","max":32325930,"min":0,"orientation":"horizontal","style":"IPY_MODEL_813942f77ed3426a8a6261ac60542f48","value":32325930}},"bd4b2fd97cb34f5f900e91969cc588c7":{"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_e35595cc50a24fcca6f812997c8c8dc5","placeholder":"​","style":"IPY_MODEL_63175136102c4135acce3e700bf92cf8","value":" 32.3M/32.3M [00:00<00:00, 34.5MB/s]"}},"48641e4f73954da987f034a74c3b8b5e":{"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}},"c8177522a2e64f4eafef0d6cbc1f6cdd":{"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}},"29a4704b56cf4d4fa145fac101dbcb8d":{"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":""}},"c345a572c5d4493d93423618f0a6f143":{"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}},"813942f77ed3426a8a6261ac60542f48":{"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":""}},"e35595cc50a24fcca6f812997c8c8dc5":{"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}},"63175136102c4135acce3e700bf92cf8":{"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":""}},"528f68abd3af4761b1b00b40599e0fbf":{"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_f84cfa74576a46e88caa9989161d08fc","IPY_MODEL_5d03f9e044f146b7b36b34cdcf21153a","IPY_MODEL_498c133792ea4cd38b6385be5f7f8c62"],"layout":"IPY_MODEL_141a311668984b2ebaca90db0c57d815"}},"f84cfa74576a46e88caa9989161d08fc":{"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_e04c52ea5941431f9d1dd12d2f41654a","placeholder":"​","style":"IPY_MODEL_27daab81e7b64087abae1b5e2a3c0c5d","value":"Generating train split: "}},"5d03f9e044f146b7b36b34cdcf21153a":{"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_14b2db86f938477696e3e54b321caeed","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_fdb857f832a54286ba504046a177a883","value":1}},"498c133792ea4cd38b6385be5f7f8c62":{"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_ec1882dbce7d46e28580b8cf2b4da19b","placeholder":"​","style":"IPY_MODEL_860d1a845d764ff6853ae56e6ac3afcc","value":" 28599/0 [00:00<00:00, 35222.06 examples/s]"}},"141a311668984b2ebaca90db0c57d815":{"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}},"e04c52ea5941431f9d1dd12d2f41654a":{"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}},"27daab81e7b64087abae1b5e2a3c0c5d":{"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":""}},"14b2db86f938477696e3e54b321caeed":{"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":"20px"}},"fdb857f832a54286ba504046a177a883":{"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":""}},"ec1882dbce7d46e28580b8cf2b4da19b":{"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}},"860d1a845d764ff6853ae56e6ac3afcc":{"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":""}},"b43311c7e443439d9776c1cb51f07baf":{"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_c121083f404b494f881cab7d9ec122d6","IPY_MODEL_729a4366db2d4203adb0fd2b0fb2dd4c","IPY_MODEL_96b6572ec6184bfcb655ba62329631ec"],"layout":"IPY_MODEL_ca83618081ae48ee88976c512c3f2022"}},"c121083f404b494f881cab7d9ec122d6":{"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_5f4a077a96ad446cb41241108eac2618","placeholder":"​","style":"IPY_MODEL_4a562f7c91b849599ff06f76da226c85","value":"Map: 100%"}},"729a4366db2d4203adb0fd2b0fb2dd4c":{"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_3a7e8f584e72412c8fa4fd8063630e2b","max":28599,"min":0,"orientation":"horizontal","style":"IPY_MODEL_39d9dd8bc753487f9a50c939b9ed38e5","value":28599}},"96b6572ec6184bfcb655ba62329631ec":{"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_523070898a474b74bde2d365c69dddff","placeholder":"​","style":"IPY_MODEL_fced41bbaf3a496aa62080a6b88e1afc","value":" 28599/28599 [00:00<00:00, 50440.48 examples/s]"}},"ca83618081ae48ee88976c512c3f2022":{"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}},"5f4a077a96ad446cb41241108eac2618":{"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}},"4a562f7c91b849599ff06f76da226c85":{"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":""}},"3a7e8f584e72412c8fa4fd8063630e2b":{"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}},"39d9dd8bc753487f9a50c939b9ed38e5":{"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":""}},"523070898a474b74bde2d365c69dddff":{"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}},"fced41bbaf3a496aa62080a6b88e1afc":{"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":""}}}},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":11293954,"sourceType":"datasetVersion","datasetId":7061846}],"dockerImageVersionId":30919,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Training on Your Private Data - by NathMath @ bilibili","metadata":{"id":"Wj4lhJCuMYcm"}},{"cell_type":"markdown","source":"大家好,这里是Nathmath。我将用一个系列给你们讲解如何基于预训练好的底模进行大语言模型的私有数据微调。\n> * 区别于部分UP主,我可能会“废话”很多。但是,“废话”才是你们学习的基础。因为我的“废话”是在讲解原理,让你们`能“鱼”也能“渔”`(钓鱼),意思是懂得原理,就可以不仅仅学会这一个微调,并且能够自己用在其他需要的地方,迁移学习。而不是仅仅学会我这一个东西,无法举一反三。\n\n> * 本系列视频特别推荐大家动手。以本期视频举例,很多同学还不会准备数据集,没事,请一定要拿我的数据先跑一遍,遍跑遍听我的讲解,理解每一步在做什么;我后面的视频会继续教你们怎么准备数据集(会的同学仅看本期就可以),以及怎么进行多轮对话训练、怎么进行思考训练、怎么进行其他模型的训练;当然,最基础的,建议大家自己`先照猫画虎把我的Notebook跑通`,然后再自己尝试自己的数据。\n\n> * 微调和训练是很难很难的内容。包括训练数据准备。在行内,有着“`数据处理80%,建模训练20%`”的行话,意思是数据处理所消耗的时间和精力占到整个机器学习的80%,其也决定了你模型的质量的80%,因为\"garbage in, garbage out\"(进去的是垃圾,出来的也是垃圾)。大家`一定不要灰心`,如果想学的话,踏踏实实学,有问题就问ChatGPT/DeepSeek,它能解决很多问题。\n\n> * 关于在线训练平台。UP个人推荐Kaggle。原因是`每周`有30小时的免费的T4(16G)x2的GPU使用,需要注册并完成手机号认证(认证时候中国手机记着加上86)。另外提醒,数据特别敏感的个人或者企业用户请自己花钱租用服务器。","metadata":{}},{"cell_type":"markdown","source":"v20 版本更新的内容:\n* 使用了冷启动,将ckpt-1418的模型导入并继续训练\n* 新增了基于同内容的多轮对话生成,改善了多轮对话生成不同游戏内容的能力,防止过拟合。\n* 继续训练了基于多轮对话的训练集,防止了过拟合","metadata":{}},{"cell_type":"markdown","source":"## 1. Prepare the Environment","metadata":{"id":"IlrY86-MNfjf"}},{"cell_type":"code","source":"# Reference https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing#scrollTo=FqfebeAdT073\n# 参考文献","metadata":{"id":"0AhWNVC9U9B4","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"* Unsloth supports Llama, Mistral, Phi-3, Gemma, Yi, DeepSeek, Qwen, TinyLlama, Vicuna, Open Hermes etc\n* Unsloth supports 16bit LoRA or 4bit QLoRA. Both 2x faster.\n* With [PR 26037](https://github.com/huggingface/transformers/pull/26037), we support downloading 4bit models **4x faster**! [Our repo](https://huggingface.co/unsloth) has Llama, Mistral 4bit models.","metadata":{"id":"8l_HaJMosoVY"}},{"cell_type":"code","source":"# Modified Auther NathMath, open-sourced with Apache-2.0 Licence\n# 修改作者:NathMath,以Apache-2.0 Licence许可证开源","metadata":{"id":"7FXuUqc9j1dw","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Use Multi-GPUs if available\n# 可行时使用双CPU,适用于Kaggle T4x2\n\nimport os\nos.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0,1\"\nprint(\"Completed\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:26:01.660290Z","iopub.execute_input":"2025-04-08T05:26:01.660650Z","iopub.status.idle":"2025-04-08T05:26:01.665503Z","shell.execute_reply.started":"2025-04-08T05:26:01.660622Z","shell.execute_reply":"2025-04-08T05:26:01.664768Z"}},"outputs":[{"name":"stdout","text":"Completed\n","output_type":"stream"}],"execution_count":1},{"cell_type":"code","source":"# Install or import unsloth\n# 安装或导入用于微调的unsloth库\nif \"Mute\" != None:\n # 静音安装\n !pip install unsloth==\"2025.3.18\" > /dev/null\nelse:\n !pip install unsloth==\"2025.3.18\"\n\n# It is slow; so be patient\n# 这一步很慢请耐心等待","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:26:11.535996Z","iopub.execute_input":"2025-04-08T05:26:11.536307Z","iopub.status.idle":"2025-04-08T05:30:27.136968Z","shell.execute_reply.started":"2025-04-08T05:26:11.536242Z","shell.execute_reply":"2025-04-08T05:30:27.135901Z"}},"outputs":[{"name":"stdout","text":"\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.\nfastai 2.7.18 requires torch<2.6,>=1.10, but you have torch 2.6.0 which is incompatible.\nlangchain 0.3.12 requires async-timeout<5.0.0,>=4.0.0; python_version < \"3.11\", but you have async-timeout 5.0.1 which is incompatible.\npylibcugraph-cu12 24.10.0 requires pylibraft-cu12==24.10.*, but you have pylibraft-cu12 25.2.0 which is incompatible.\npylibcugraph-cu12 24.10.0 requires rmm-cu12==24.10.*, but you have rmm-cu12 25.2.0 which is incompatible.\ntensorflow-decision-forests 1.10.0 requires tensorflow==2.17.0, but you have tensorflow 2.17.1 which is incompatible.\ntorchaudio 2.5.1+cu121 requires torch==2.5.1, but you have torch 2.6.0 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0m","output_type":"stream"}],"execution_count":3},{"cell_type":"code","source":"# DO NOT CARE BUG \"ERROR: pip's dependency resolver does not currently take into account\"\n# 这个报错不用管:“ERROR: pip's dependency resolver does not currently take into account”","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Import torch backend\n# 导入torch后端\nimport torch\n\ntorch_version = torch.cuda.get_device_capability()\ntorch_major_v, torch_minor_v = torch_version\nprint(torch_major_v, torch_minor_v)\n# The first version digit must be greater or equal to 7, or a bug will be raised\n# 第一个数大版本必须为7或者以上,否则会提示CUDA运算版本不足bug\n\n# If an error is thrown here, then it means you DO NOT have a valid NVIDIA accelerator\n# 如果这里报错,那么意味着你没有一个有效的NVIDIA显卡作为运算加速器,请选择T4x2而不是P100,P100会提示版本不足","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:41:49.612616Z","iopub.execute_input":"2025-04-08T05:41:49.612908Z","iopub.status.idle":"2025-04-08T05:41:51.695290Z","shell.execute_reply.started":"2025-04-08T05:41:49.612886Z","shell.execute_reply":"2025-04-08T05:41:51.694559Z"}},"outputs":[{"name":"stdout","text":"7 5\n","output_type":"stream"}],"execution_count":4},{"cell_type":"code","source":"# Install other dependences\n# 安装其他依赖项\nif \"Mute\" != None:\n # 静音安装\n !pip install xformers trl peft accelerate bitsandbytes > /dev/null\nelse:\n !pip install xformers trl peft accelerate bitsandbytes ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:41:55.651899Z","iopub.execute_input":"2025-04-08T05:41:55.652331Z","iopub.status.idle":"2025-04-08T05:42:03.348910Z","shell.execute_reply.started":"2025-04-08T05:41:55.652304Z","shell.execute_reply":"2025-04-08T05:42:03.347897Z"}},"outputs":[],"execution_count":5},{"cell_type":"code","source":"# Import unsloth FastLanguageModel\n# 导入FastLanguageModel\nfrom unsloth import FastLanguageModel","metadata":{"id":"1IGsxSprNG63","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:42:46.085651Z","iopub.execute_input":"2025-04-08T05:42:46.085959Z","iopub.status.idle":"2025-04-08T05:43:25.929876Z","shell.execute_reply.started":"2025-04-08T05:42:46.085936Z","shell.execute_reply":"2025-04-08T05:43:25.929192Z"}},"outputs":[{"name":"stdout","text":"🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.\nUnsloth: Failed to patch Gemma3ForConditionalGeneration.\n🦥 Unsloth Zoo will now patch everything to make training faster!\n","output_type":"stream"}],"execution_count":6},{"cell_type":"code","source":"# See if both GPUs are activated\n# 看看是否两个GPU都被激活了\n\ngpu_count = torch.cuda.device_count()\nprint(\"GPU Number:\", gpu_count)\nfor i in range(gpu_count):\n print(f\"GPU {i}: {torch.cuda.get_device_name(i)}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:43:59.860873Z","iopub.execute_input":"2025-04-08T05:43:59.861310Z","iopub.status.idle":"2025-04-08T05:43:59.867419Z","shell.execute_reply.started":"2025-04-08T05:43:59.861253Z","shell.execute_reply":"2025-04-08T05:43:59.866618Z"}},"outputs":[{"name":"stdout","text":"GPU Number: 2\nGPU 0: Tesla T4\nGPU 1: Tesla T4\n","output_type":"stream"}],"execution_count":7},{"cell_type":"code","source":"# Import training utilities\n# 导入其他训练工具\nfrom trl import SFTTrainer\nfrom transformers import TrainingArguments\nfrom unsloth import is_bfloat16_supported","metadata":{"id":"vrYjQLxTSFjN","colab":{"base_uri":"https://localhost:8080/","height":387},"outputId":"ce5ca1de-43d8-414b-b72f-8f811d7e42cf","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:01.919847Z","iopub.execute_input":"2025-04-08T05:44:01.920172Z","iopub.status.idle":"2025-04-08T05:44:01.924196Z","shell.execute_reply.started":"2025-04-08T05:44:01.920132Z","shell.execute_reply":"2025-04-08T05:44:01.923332Z"}},"outputs":[],"execution_count":8},{"cell_type":"code","source":"# Import data science packeges\n# 导入数据科学使用的包\nimport random\nimport numpy as np\nimport pandas as pd","metadata":{"id":"GLUb83gYSxMW","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:04.863784Z","iopub.execute_input":"2025-04-08T05:44:04.864063Z","iopub.status.idle":"2025-04-08T05:44:04.867713Z","shell.execute_reply.started":"2025-04-08T05:44:04.864041Z","shell.execute_reply":"2025-04-08T05:44:04.866917Z"}},"outputs":[],"execution_count":9},{"cell_type":"code","source":"# By Nathmath","metadata":{"id":"iaZJQxXascfv","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:07.966416Z","iopub.execute_input":"2025-04-08T05:44:07.966688Z","iopub.status.idle":"2025-04-08T05:44:07.970427Z","shell.execute_reply.started":"2025-04-08T05:44:07.966668Z","shell.execute_reply":"2025-04-08T05:44:07.969542Z"}},"outputs":[],"execution_count":10},{"cell_type":"markdown","source":"## 2. Configurate the underlying model","metadata":{"id":"YK_VnKgONnIe"}},{"cell_type":"code","source":"# HF token\n# HF 的token,如果你需要把训练好的模型保存到hugging face时需要\n_global_hf_token = \"\"","metadata":{"id":"Gm712pctXX3V","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:10.811668Z","iopub.execute_input":"2025-04-08T05:44:10.811951Z","iopub.status.idle":"2025-04-08T05:44:10.815570Z","shell.execute_reply.started":"2025-04-08T05:44:10.811931Z","shell.execute_reply":"2025-04-08T05:44:10.814722Z"}},"outputs":[],"execution_count":11},{"cell_type":"code","source":"# Model configuration\n# 模型设定\n_global_model_name = \"unsloth/gemma-2-9b-bnb-4bit\" # HF 模型识别名称\n_global_model_max_seqlen = 4096 # 模型的最长输出tokens数,小说设置到8192,但显著增加训练时间\n # v-20 更改到4096, 原2048\n_global_model_dtype = None\n_global_model_load_in_4bit = True\n","metadata":{"id":"PMXPujtPN0I1","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:29.826804Z","iopub.execute_input":"2025-04-08T05:44:29.827125Z","iopub.status.idle":"2025-04-08T05:44:29.830719Z","shell.execute_reply.started":"2025-04-08T05:44:29.827100Z","shell.execute_reply":"2025-04-08T05:44:29.829986Z"}},"outputs":[],"execution_count":12},{"cell_type":"code","source":"# Model training seed configuration\n# 模型训练时的种子,随机生成一个,你也可以自己设定一个\n_train_seed = int(np.random.rand() * 2 ** 32)\n_train_seed","metadata":{"id":"epDSH2s4Sosn","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:44:33.255059Z","iopub.execute_input":"2025-04-08T05:44:33.255407Z","iopub.status.idle":"2025-04-08T05:44:33.266474Z","shell.execute_reply.started":"2025-04-08T05:44:33.255376Z","shell.execute_reply":"2025-04-08T05:44:33.265704Z"}},"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"4127228089"},"metadata":{}}],"execution_count":13},{"cell_type":"markdown","source":"## 2.1. Load the base model into the environment","metadata":{}},{"cell_type":"code","source":"# Load the pretrained model\n# 导入HF上预训练好的底模\nif False:\n _global_model, _global_tokenizer = FastLanguageModel.from_pretrained(\n model_name=_global_model_name,\n max_seq_length=_global_model_max_seqlen,\n dtype = _global_model_dtype,\n load_in_4bit = _global_model_load_in_4bit\n)\nelse:\n _global_model, _global_tokenizer = FastLanguageModel.from_pretrained(\n model_name=\"DOFOFFICIAL/ThisIsNewTmp\", # Your previously saved model\n max_seq_length=_global_model_max_seqlen,\n dtype = _global_model_dtype,\n load_in_4bit = _global_model_load_in_4bit\n)\n# You must see Tesla T4. Num GPUs = 2. here, or you only have 1 GPU\n# 在这里你必须看到GPU数量=2否则你只有1个GPU,训练会慢很多","metadata":{"id":"HzK6KLZUSnml","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:45:26.258122Z","iopub.execute_input":"2025-04-08T05:45:26.258621Z","iopub.status.idle":"2025-04-08T05:45:58.091371Z","shell.execute_reply.started":"2025-04-08T05:45:26.258592Z","shell.execute_reply":"2025-04-08T05:45:58.090682Z"}},"outputs":[{"name":"stdout","text":"==((====))== Unsloth 2025.3.18: Fast Gemma2 patching. Transformers: 4.51.0.\n \\\\ /| Tesla T4. Num GPUs = 2. Max memory: 14.741 GB. Platform: Linux.\nO^O/ \\_/ \\ Torch: 2.6.0+cu124. CUDA: 7.5. CUDA Toolkit: 12.4. Triton: 3.2.0\n\\ / Bfloat16 = FALSE. FA [Xformers = 0.0.29.post3. FA2 = False]\n \"-____-\" Free license: http://github.com/unslothai/unsloth\nUnsloth: Fast downloading is enabled - ignore downloading bars which are red colored!\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"model.safetensors: 0%| | 0.00/6.13G [00:00### Instruction:\\n请根据游戏名和游戏特色编写游戏介绍:【游戏名】:葬花·暗黑桃花源,【游戏特色】:民俗。\\n\\n### Response:\\n迷途者于深山误入传说中的桃花源。\\n桃花源的村民过了两千年与世隔绝的生活,维持着古代的生活习惯,迷途者逐渐融入村子,与村民们建立了良好的关系。\\n然而,桃花源的秘密也开始浮现——村民在白天时纯朴友好,晚上时则狂暴放纵,白天时清纯可爱的神女大人,晚上时则妖艳妩媚,村民们没有后代,也不会衰老.....\\n一切谜团似乎都与秦始皇渴求的“长生不老之术”有关......\\n终有一天,迷途者会看清这里的真相,然后做出选择:\\n——留下\\n还是离开?\\n\\n### Instruction:\\n请根据游戏名和游戏特色编写游戏介绍:【游戏名】:青春x好奇相伴的三角恋爱 - スキとスキとでサンカク恋愛,【游戏特色】:ASaProject, 卯衣, 颜艺社, 纯爱, 幼なじみ, 北見六花, 实妹, 幼驯染, 日常, 义妹, 搞笑, 废萌。\\n\\n### Response:\\n在某个乡下城镇过着学园生活的主人公「宗介」,因为父亲再婚的原因,从度过幼年时期后开始,就和义妹「七瑠」、青梅竹马「真帆」等人一起,在学园中的OTAKU部(通称B研)里享受着愉快的宅生活。\\n平稳的每一天……\\n然而,暑假还有近一个月就要开始的某一天,突然发生了事件。\\n「我一直都好想你……哥哥!!」\\n在幼年时期一直住在一起,之后被母亲带走的亲妹妹「铃」竟然回来了!\\n在学园、在家、在外面,静静地发挥着自己亲妹妹力量的亲妹妹。\\n一直显得不自在的义妹。\\n义妹:「就算你现在说妹妹什么的——这家伙(哥哥)早就已经被调教完成了——咕嘿嘿」\\n亲妹:「那我就再重新调教一次」\\n糟糕。我的两个妹妹糟透了。\\n本来已经是非常危急的状况了,却又突然出现了毫不讲理突然迷上自己的前辈「志衣菜」,\\n再加上青梅竹马「真帆」的情况也开始有点奇怪了。\\n这情况该怎么办,会变成怎么样呢!!\\n宗介就这样,被卷入了炎炎夏日都会冻上的三角关系\\n\\n'}"},"metadata":{}}],"execution_count":22},{"cell_type":"code","source":"# Shuffle the dataset for randomness\n# 混淆重排序,为了防止过拟合\nshuffled_dataset = dataset_format.shuffle(seed = 253831246211)\nshuffled_dataset","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:47:10.002134Z","iopub.execute_input":"2025-04-08T05:47:10.002473Z","iopub.status.idle":"2025-04-08T05:47:10.022374Z","shell.execute_reply.started":"2025-04-08T05:47:10.002444Z","shell.execute_reply":"2025-04-08T05:47:10.021609Z"}},"outputs":[{"execution_count":23,"output_type":"execute_result","data":{"text/plain":"Dataset({\n features: ['Unnamed: 0', 'system', 'user', 'assistant', 'formatted'],\n num_rows: 28599\n})"},"metadata":{}}],"execution_count":23},{"cell_type":"code","source":"# Slice the dataset to avoid entire loading that costs VRAM too much\n# 对数据集进行切片,以避免整个加载耗费过多的 VRAM,如果显存爆了调用这个\nif True:\n # L R + 1 step\n sliced_dataset = shuffled_dataset.select(range( 0, 4200, 1))\n print(sliced_dataset)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:47:39.797433Z","iopub.execute_input":"2025-04-08T05:47:39.797734Z","iopub.status.idle":"2025-04-08T05:47:39.805711Z","shell.execute_reply.started":"2025-04-08T05:47:39.797713Z","shell.execute_reply":"2025-04-08T05:47:39.804914Z"}},"outputs":[{"name":"stdout","text":"Dataset({\n features: ['Unnamed: 0', 'system', 'user', 'assistant', 'formatted'],\n num_rows: 4200\n})\n","output_type":"stream"}],"execution_count":24},{"cell_type":"markdown","source":"## 4. Setup the trainer","metadata":{"id":"dJzvujwnR_r2"}},{"cell_type":"code","source":"# Configurate the model to train\n# 设置你训练模型的训练参数\ntrainer = SFTTrainer(\n model = _global_model,\n tokenizer = _global_tokenizer, \n train_dataset = sliced_dataset, # 这是你formatted格式化后,shuffle后的数据,也可以是slice后的数据\n dataset_text_field = \"formatted\", # 这个字段需要与之前format函数中新建的字段保持一致\n max_seq_length = _global_model_max_seqlen,\n dataset_num_proc = 4, # 建议设置为4如果你使用的是colab或者kaggle\n packing = False,\n args = TrainingArguments(\n per_device_train_batch_size = 1, # 每一个GPU训练的batchsize,建议设置为1或2或4或8如果你使用的是colab或者kaggle\n # * 这是最推荐你们微调的参数,如果你的底模很大,选择更小的值;反之亦然\n # * 如果提示爆显存了,那么设置成更小的值(最小为1);但是,过小的值会使得训练变慢\n gradient_accumulation_steps = 12, # 梯度累积的步数,建议设置为4或8或12,8会使得梯度更稳定,4会防止局部鞍点,不能过高,否则梯度调整次数不够\n warmup_steps = 5, # · 冷启动参数,在训练开始时,学习率通常从较小的值逐渐增加到设定的初始学习率,\n # · 以避免训练初期模型不稳定或收敛困难的情况,定义了这一预热阶段所持续的训练步数\n # · 在初次训练时候应该设置更大的值,例如10或者20;微调和instruct中可以设置很小的值\n num_train_epochs = 1, # 继续训练几个epoch,一般1足够了,如果你的数据集特别特殊且样本量较小,设为2\n # · 什么是epoch和step? 一个step指的是一次数据传递,一个batch包含传递了所有数据的k个steps\n learning_rate = 15e-5, # 学习率,权重更新的速度,在微调中设置较低的值防止过拟合,不能过低,否则会陷入局部鞍点\n # * 这是第二推荐你们微调的参数,如果你的数据是正常数据,约有大几千或者几万个,1e-4是推荐的值\n # * 如果你的数据样本量很小,或者格式/语言并非常规的,可以考虑使用更大的值,但是封顶建议2e-4\n # * 此外,如果你的batch_size设置的较大,等效learning_rate会降低,因此也建议选更大的值\n fp16 = not is_bfloat16_supported(),\n bf16 = is_bfloat16_supported(),\n logging_steps = 1,\n optim = \"adamw_8bit\",\n weight_decay = 0.01, # L2正则化,UP试了很久,不建议设置太大,否则会丢模型原始数据\n lr_scheduler_type = \"linear\",\n seed = _train_seed,\n output_dir = \"outputs\",\n report_to = \"none\",\n dataloader_num_workers = 4, \n # If using multi-GPUS set these, 如果使用了多GPU,保留下面的内容否则注释掉\n dataloader_pin_memory = True,\n local_rank = -1, \n ddp_find_unused_parameters = False,\n ),\n)","metadata":{"id":"Vmj5pSNdSDau","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:48:53.892464Z","iopub.execute_input":"2025-04-08T05:48:53.892818Z","iopub.status.idle":"2025-04-08T05:49:04.764285Z","shell.execute_reply.started":"2025-04-08T05:48:53.892795Z","shell.execute_reply":"2025-04-08T05:49:04.763343Z"}},"outputs":[{"output_type":"display_data","data":{"text/plain":"Unsloth: Tokenizing [\"formatted\"] (num_proc=4): 0%| | 0/4200 [00:00你是一个游戏剧情规划师。请你根据我提供的游戏名和游戏特色规划剧情,写出一段引人入胜的游戏介绍。\\n\\n### Instruction:\\n请根据游戏名编写游戏介绍:【游戏名】:在终焉的世界里寻找盛开的花。\\n\\n### Response:\\n在某个世界中,存在着一位女神。\\n女神创造了万物,创造了世界。\\n她创造了无数的生物,创造了广阔的土地,创造了蔚蓝的大海。\\n她创造了人类,创造了动物,创造了植物。\\n她创造了天空,创造了大地,创造了时间。\\n她创造了世界。\\n女神创造了世界,她创造了万物。\\n然而,女神却无法创造出令自己满意的“智慧生命体”。\\n于是,女神反复尝试着创造出智慧生命体。\\n然而,创造出来的智慧生命体却无法成长,都是些只会本能地行动的傻瓜。\\n女神对这些傻瓜们感到厌恶,她将他们全部贬到了广袤无边的“荒野”之地。\\n在那里,智慧生命体无法生存。\\n在那里,智慧生命体只能被当作牲畜对待。\\n在那里,智慧生命体只能被当作愚蠢的动物对待。\\n女神将这些傻瓜们贬到了荒野之地。\\n然而,傻瓜们最终在荒野之地创造出了文明。\\n他们创造出了国家,他们创造出了秩序。\\n他们创造出了智慧。\\n被贬到了荒野']"},"metadata":{}}],"execution_count":52},{"cell_type":"code","source":"# Inference in stream mode\n# 流式推理测试\nFastLanguageModel.for_inference(_global_model)\ninputs = _global_tokenizer(\n[\n # Use Infer when doing inference\n alpaca_prompt_infer.format(\n \"你是一个游戏剧情规划师。请你根据我提供的游戏名和游戏特色规划剧情,写出一段引人入胜的游戏介绍。\", # system\n \"请根据游戏名和游戏特色编写游戏介绍:【游戏名】:风陇之歌 ~Tracking the footprints of time~,【游戏特色】:奇幻, 哲学, 冒险, 宗教, 神话, 白毛。\", # input\n \"\", # output - 留空等待AI生成\n )\n], return_tensors = \"pt\").to(\"cuda\")\n\nfrom transformers import TextStreamer\ntext_streamer = TextStreamer(_global_tokenizer)\n_ = _global_model.generate(**inputs, streamer = text_streamer, max_new_tokens = 2048)","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"fIJ415USTvOe","outputId":"95b525e2-f2b3-4707-f023-85d57790e502","trusted":true,"execution":{"iopub.status.busy":"2025-04-08T05:51:26.714888Z","iopub.execute_input":"2025-04-08T05:51:26.715236Z","iopub.status.idle":"2025-04-08T05:51:40.429592Z","shell.execute_reply.started":"2025-04-08T05:51:26.715210Z","shell.execute_reply":"2025-04-08T05:51:40.428688Z"}},"outputs":[{"name":"stdout","text":"你是一个游戏剧情规划师。请你根据我提供的游戏名和游戏特色规划剧情,写出一段引人入胜的游戏介绍。\n\n### Instruction:\n请根据游戏名和游戏特色编写游戏介绍:【游戏名】:风陇之歌 ~Tracking the footprints of time~,【游戏特色】:奇幻, 哲学, 冒险, 宗教, 神话, 白毛。\n\n### Response:\n《风岭之歌》是一款以“时间”为主题的纯文字冒险游戏。\n在故事中,玩家将扮演一名普通的大学生,因意外事故而穿越时空,\n与神秘美少女“风岭”一同,在两个时代中展开寻人寻物等一系列任务。\n随着故事的推进,真相也逐渐浮出水面……\n\n\n","output_type":"stream"}],"execution_count":29},{"cell_type":"markdown","source":"## 7. Save the model","metadata":{"id":"ttGAEGntVavo"}},{"cell_type":"code","source":"# Save model as the native huggingface version - local\n# 保存模型为原生的huggingface模型到本地\n_global_model.save_pretrained(\"my_gameintro_gemma9b\")\n_global_tokenizer.save_pretrained(\"my_gameintro_gemma9b\")\n\n# Save the merged - locel\n# 保存融合的模型(包括底模)到本地\n_global_model.save_pretrained_merged(\"my_gameintro_gemma9b_merged\", _global_tokenizer, save_method = \"merged_16bit\",)","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"_boIgrvbT30O","outputId":"3e0bd437-23c0-4bb9-9ecb-f7c0948b5ad3","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Save model as the native huggingface version - hf, costs time\n# 保存模型为原生的huggingface模型到hf模型站,消耗时间!请为你的运行时留足时间\n_global_model.push_to_hub(\"DOFOFFICIAL/ThisIsNewTmp\", token = \"hf_...\")\n_global_tokenizer.push_to_hub(\"DOFOFFICIAL/ThisIsNewTmp\", token = \"hf_...\") \n\n# Save the merged - hf, costs time\n# 保存融合的模型(包括底模)到hf模型站,消耗时间!请为你的运行时留足时间\n_global_model.push_to_hub_merged(\"DOFOFFICIAL/NathUI-Tutorial\", _global_tokenizer, save_method = \"merged_16bit\", token = \"hf_...\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Save as quanted, costs time\n# 保存为量化后的模型,消耗时间!请为你的运行时留足时间\n\n# Save to Q8_0\n# 保存为量化的gguf Q8_0\n# _global_model.save_pretrained_gguf(\"my_gameintro_gemma9b_Q8_0\", _global_tokenizer, quantization_method = \"q8_0\")\n_global_model.push_to_hub_gguf(\"DOFOFFICIAL/ThisIsTmp\", _global_tokenizer, quantization_method = \"q8_0\", token = \"hf_...\")\n\n# Save to Q4_K_M\n# 保存为量化的gguf Q4_K_M\n# _global_model.save_pretrained_gguf(\"my_gameintro_gemma9b_Q4_K_M\", _global_tokenizer, quantization_method = \"q4_K_M\")\n_global_model.push_to_hub_gguf(\"DOFOFFICIAL/ThisIsTmp\", _global_tokenizer, quantization_method = \"q4_K_M\", token = \"hf_...\")\n","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"tHIKsMlqVwB_","outputId":"c0631069-7724-4f1d-d7cc-24d12786192a","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Modified Auther NathMath, open-sourced with Apache-2.0 Licence\n# 修改作者:NathMath,以Apache-2.0 Licence许可证开源","metadata":{"id":"3AmGcJfh3B_o","trusted":true},"outputs":[],"execution_count":null}]}