{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"a997f83e7aa64ad1849d5f622eec145d": {
"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_8889742d12364680a5a39470adde2873",
"IPY_MODEL_168e3e4172cc4e36b2ca0544e0fc42b4",
"IPY_MODEL_64f694d338294e5984e5895050d947c3"
],
"layout": "IPY_MODEL_ce354595738b45eeb03386728d316d69"
}
},
"8889742d12364680a5a39470adde2873": {
"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_d552cb6203ed4718b0504b6d80de581c",
"placeholder": "",
"style": "IPY_MODEL_ae2586c27aa24a0a8c96d88d5d160e70",
"value": "Generating train split: "
}
},
"168e3e4172cc4e36b2ca0544e0fc42b4": {
"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_b414fa4834174262a2608f6dfbe894e5",
"max": 1,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_ee5c0c7663a64c3c85ea68373f105b42",
"value": 1
}
},
"64f694d338294e5984e5895050d947c3": {
"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_0705592b068e4271bcc30a32791a47ca",
"placeholder": "",
"style": "IPY_MODEL_151b2379bb6849df8dc75848717e9490",
"value": " 57072/0 [00:00<00:00, 275058.13 examples/s]"
}
},
"ce354595738b45eeb03386728d316d69": {
"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
}
},
"d552cb6203ed4718b0504b6d80de581c": {
"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
}
},
"ae2586c27aa24a0a8c96d88d5d160e70": {
"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": ""
}
},
"b414fa4834174262a2608f6dfbe894e5": {
"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"
}
},
"ee5c0c7663a64c3c85ea68373f105b42": {
"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": ""
}
},
"0705592b068e4271bcc30a32791a47ca": {
"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
}
},
"151b2379bb6849df8dc75848717e9490": {
"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": ""
}
},
"d7cf2951869343e98322277dd3e52085": {
"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_864b8038624a40e899ddc8ee00d64996",
"IPY_MODEL_6d45c0ee7da34f28932ab54699bd4092",
"IPY_MODEL_8f86dd9f03214308b2bd9505bf249b80"
],
"layout": "IPY_MODEL_c4be6df7bcc34fdc95e5bb6e72eb44ff"
}
},
"864b8038624a40e899ddc8ee00d64996": {
"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_2ef30bae7c1a48329aa944559c539323",
"placeholder": "",
"style": "IPY_MODEL_55a90b62a4094cf1afbf8fe183751cf9",
"value": "Loading checkpoint shards: 100%"
}
},
"6d45c0ee7da34f28932ab54699bd4092": {
"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_67db80c7406a4ab7806e05451c234fdd",
"max": 3,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_b213c00ebe8243a78b0ca91b40261e33",
"value": 3
}
},
"8f86dd9f03214308b2bd9505bf249b80": {
"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_3a0bd7815630436982830f05768a52c3",
"placeholder": "",
"style": "IPY_MODEL_2ea41b0b43de4c7db6b690d3c53ee578",
"value": " 3/3 [01:09<00:00, 22.05s/it]"
}
},
"c4be6df7bcc34fdc95e5bb6e72eb44ff": {
"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
}
},
"2ef30bae7c1a48329aa944559c539323": {
"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
}
},
"55a90b62a4094cf1afbf8fe183751cf9": {
"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": ""
}
},
"67db80c7406a4ab7806e05451c234fdd": {
"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
}
},
"b213c00ebe8243a78b0ca91b40261e33": {
"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": ""
}
},
"3a0bd7815630436982830f05768a52c3": {
"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
}
},
"2ea41b0b43de4c7db6b690d3c53ee578": {
"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": ""
}
},
"6952dd69d233420c84f8931cd11d0b94": {
"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_1b90056f7f0a4ad681a025cf5012c607",
"IPY_MODEL_8c06c04a4cf44ec396992ae04f7ad53d",
"IPY_MODEL_0e09e908da8444eca0c9737dd9c93c34"
],
"layout": "IPY_MODEL_f5c7882a83094141b891d5fc8b9cbf17"
}
},
"1b90056f7f0a4ad681a025cf5012c607": {
"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_2e4a189f134343fe84dd0ed20939055f",
"placeholder": "",
"style": "IPY_MODEL_d6dfbb37ef7c4447aaa41cc6f6436163",
"value": "Map: 100%"
}
},
"8c06c04a4cf44ec396992ae04f7ad53d": {
"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_46bf9b6c73c34232a129e28176509b9a",
"max": 57072,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_330a4fb368c142a38a538d78cc70cc76",
"value": 57072
}
},
"0e09e908da8444eca0c9737dd9c93c34": {
"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_6144b49ad9e64ad2a68b4f85396f41bf",
"placeholder": "",
"style": "IPY_MODEL_936de9b40ae84efc8b5ecb7ed6172ddd",
"value": " 57072/57072 [00:24<00:00, 2290.68 examples/s]"
}
},
"f5c7882a83094141b891d5fc8b9cbf17": {
"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
}
},
"2e4a189f134343fe84dd0ed20939055f": {
"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
}
},
"d6dfbb37ef7c4447aaa41cc6f6436163": {
"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": ""
}
},
"46bf9b6c73c34232a129e28176509b9a": {
"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
}
},
"330a4fb368c142a38a538d78cc70cc76": {
"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": ""
}
},
"6144b49ad9e64ad2a68b4f85396f41bf": {
"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
}
},
"936de9b40ae84efc8b5ecb7ed6172ddd": {
"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": ""
}
},
"60003cd29e8241c3bd5caeacf7cd5626": {
"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_0520ce1f42b34a009d21b547a0555215",
"IPY_MODEL_602da4d2148142fb9bb34536a6eea10f",
"IPY_MODEL_d372b6688dd0414fb39cf3eee89c2ee6"
],
"layout": "IPY_MODEL_08d325c87f0343bdbd7f12fff31f254a"
}
},
"0520ce1f42b34a009d21b547a0555215": {
"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_7cd3bd2d9a584786ad1d7724d2557573",
"placeholder": "",
"style": "IPY_MODEL_981ae07b4d4545f1bcbd46d40e6faae9",
"value": "Generating train split: "
}
},
"602da4d2148142fb9bb34536a6eea10f": {
"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_ef198ccfca194060861b2a13df189e8a",
"max": 1,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_95c67b1454b64eb897ebce6db7863e10",
"value": 1
}
},
"d372b6688dd0414fb39cf3eee89c2ee6": {
"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_dfa1de4875dd472cb3672cd06f760b4e",
"placeholder": "",
"style": "IPY_MODEL_8abe94a5621b41188a4d900ce7a72fd5",
"value": " 57072/0 [00:00<00:00, 117896.92 examples/s]"
}
},
"08d325c87f0343bdbd7f12fff31f254a": {
"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
}
},
"7cd3bd2d9a584786ad1d7724d2557573": {
"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
}
},
"981ae07b4d4545f1bcbd46d40e6faae9": {
"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": ""
}
},
"ef198ccfca194060861b2a13df189e8a": {
"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"
}
},
"95c67b1454b64eb897ebce6db7863e10": {
"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": ""
}
},
"dfa1de4875dd472cb3672cd06f760b4e": {
"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
}
},
"8abe94a5621b41188a4d900ce7a72fd5": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
}
}
}
},
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"collapsed": true,
"id": "mDvF2OeHU4ol",
"outputId": "13970a60-9584-45ed-f368-b2e6b537495f"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",
"Requirement already satisfied: datasets in /usr/local/lib/python3.12/dist-packages (4.0.0)\n",
"Requirement already satisfied: transformers in /usr/local/lib/python3.12/dist-packages (4.57.0)\n",
"Requirement already satisfied: peft in /usr/local/lib/python3.12/dist-packages (0.17.1)\n",
"Requirement already satisfied: accelerate in /usr/local/lib/python3.12/dist-packages (1.10.1)\n",
"Collecting bitsandbytes\n",
" Downloading bitsandbytes-0.48.1-py3-none-manylinux_2_24_x86_64.whl.metadata (10 kB)\n",
"Requirement already satisfied: numpy>=1.26.0 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.0.2)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from datasets) (3.20.0)\n",
"Requirement already satisfied: pyarrow>=15.0.0 in /usr/local/lib/python3.12/dist-packages (from datasets) (18.1.0)\n",
"Requirement already satisfied: dill<0.3.9,>=0.3.0 in /usr/local/lib/python3.12/dist-packages (from datasets) (0.3.8)\n",
"Requirement already satisfied: requests>=2.32.2 in /usr/local/lib/python3.12/dist-packages (from datasets) (2.32.4)\n",
"Requirement already satisfied: tqdm>=4.66.3 in /usr/local/lib/python3.12/dist-packages (from datasets) (4.67.1)\n",
"Requirement already satisfied: xxhash in /usr/local/lib/python3.12/dist-packages (from datasets) (3.6.0)\n",
"Requirement already satisfied: multiprocess<0.70.17 in /usr/local/lib/python3.12/dist-packages (from datasets) (0.70.16)\n",
"Requirement already satisfied: fsspec<=2025.3.0,>=2023.1.0 in /usr/local/lib/python3.12/dist-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (2025.3.0)\n",
"Requirement already satisfied: huggingface-hub>=0.24.0 in /usr/local/lib/python3.12/dist-packages (from datasets) (0.35.3)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.12/dist-packages (from datasets) (25.0)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from datasets) (6.0.3)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.12/dist-packages (from transformers) (2024.11.6)\n",
"Requirement already satisfied: tokenizers<=0.23.0,>=0.22.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.22.1)\n",
"Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.6.2)\n",
"Requirement already satisfied: psutil in /usr/local/lib/python3.12/dist-packages (from peft) (5.9.5)\n",
"Requirement already satisfied: torch>=1.13.0 in /usr/local/lib/python3.12/dist-packages (from peft) (2.8.0+cu126)\n",
"Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /usr/local/lib/python3.12/dist-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (3.13.0)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=0.24.0->datasets) (4.15.0)\n",
"Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub>=0.24.0->datasets) (1.1.10)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n",
"Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.2->datasets) (3.4.3)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.2->datasets) (3.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.2->datasets) (2.5.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests>=2.32.2->datasets) (2025.10.5)\n",
"Requirement already satisfied: setuptools in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (75.2.0)\n",
"Requirement already satisfied: sympy>=1.13.3 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (1.13.3)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (3.5)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (3.1.6)\n",
"Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.77)\n",
"Requirement already satisfied: nvidia-cuda-runtime-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.77)\n",
"Requirement already satisfied: nvidia-cuda-cupti-cu12==12.6.80 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.80)\n",
"Requirement already satisfied: nvidia-cudnn-cu12==9.10.2.21 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (9.10.2.21)\n",
"Requirement already satisfied: nvidia-cublas-cu12==12.6.4.1 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.4.1)\n",
"Requirement already satisfied: nvidia-cufft-cu12==11.3.0.4 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (11.3.0.4)\n",
"Requirement already satisfied: nvidia-curand-cu12==10.3.7.77 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (10.3.7.77)\n",
"Requirement already satisfied: nvidia-cusolver-cu12==11.7.1.2 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (11.7.1.2)\n",
"Requirement already satisfied: nvidia-cusparse-cu12==12.5.4.2 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.5.4.2)\n",
"Requirement already satisfied: nvidia-cusparselt-cu12==0.7.1 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (0.7.1)\n",
"Requirement already satisfied: nvidia-nccl-cu12==2.27.3 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (2.27.3)\n",
"Requirement already satisfied: nvidia-nvtx-cu12==12.6.77 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.77)\n",
"Requirement already satisfied: nvidia-nvjitlink-cu12==12.6.85 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (12.6.85)\n",
"Requirement already satisfied: nvidia-cufile-cu12==1.11.1.6 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (1.11.1.6)\n",
"Requirement already satisfied: triton==3.4.0 in /usr/local/lib/python3.12/dist-packages (from torch>=1.13.0->peft) (3.4.0)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (2.6.1)\n",
"Requirement already satisfied: aiosignal>=1.4.0 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.4.0)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (25.4.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.8.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (6.7.0)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (0.3.2)\n",
"Requirement already satisfied: yarl<2.0,>=1.17.0 in /usr/local/lib/python3.12/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets) (1.22.0)\n",
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from sympy>=1.13.3->torch>=1.13.0->peft) (1.3.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2->torch>=1.13.0->peft) (3.0.3)\n",
"Downloading bitsandbytes-0.48.1-py3-none-manylinux_2_24_x86_64.whl (60.1 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.1/60.1 MB\u001b[0m \u001b[31m14.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: bitsandbytes\n",
"Successfully installed bitsandbytes-0.48.1\n"
]
}
],
"source": [
"pip install pandas datasets transformers peft accelerate bitsandbytes\n"
]
},
{
"cell_type": "code",
"source": [
"import pandas as pd\n",
"import json\n",
"import os\n",
"\n",
"files = [\n",
" \"/content/Stress.csv\",\n",
" \"/content/ds.csv\",\n",
" \"/content/ocd_patient_dataset.csv\",\n",
" \"/content/synthetic_ptsd_patients.csv\",\n",
" \"/content/Mental health Depression disorder Data.csv\",\n",
" \"/content/Copy of ds.csv\"\n",
"]\n",
"\n",
"question_cols = [\n",
" \"question\", \"questions\", \"prompt\", \"input\", \"q\", \"query\", \"text\", \"phrase\"\n",
"]\n",
"answer_cols = [\n",
" \"answer\", \"answers\", \"response\", \"output\", \"a\", \"completion\", \"reply\", \"label\", \"sentiment\"\n",
"]\n",
"\n",
"all_dfs = []\n",
"qa_examples = [] # For mental health depression dataset\n",
"\n",
"for f in files:\n",
" ext = os.path.splitext(f)[1].lower()\n",
" if ext != \".csv\":\n",
" print(f\"⚠️ Skipping non-CSV file: {f}\")\n",
" continue\n",
"\n",
" try:\n",
" try:\n",
" df = pd.read_csv(f, encoding=\"utf-8\")\n",
" except UnicodeDecodeError:\n",
" df = pd.read_csv(f, encoding=\"latin1\")\n",
" except Exception as e:\n",
" print(f\"⚠️ Could not read {f}: {e}\")\n",
" continue\n",
"\n",
" df.columns = [c.strip() for c in df.columns]\n",
"\n",
" # Process Mental health Depression disorder Data.csv using your working snippet\n",
" if os.path.basename(f) == \"Mental health Depression disorder Data.csv\":\n",
" disorder_cols = [\n",
" 'Schizophrenia (%)',\n",
" 'Bipolar disorder (%)',\n",
" 'Eating disorders (%)',\n",
" 'Anxiety disorders (%)',\n",
" 'Drug use disorders (%)',\n",
" 'Depression (%)',\n",
" 'Alcohol use disorders (%)'\n",
" ]\n",
"\n",
" for _, row in df.iterrows():\n",
" entity = row['Entity']\n",
" year = row['Year']\n",
" for disorder in disorder_cols:\n",
" value = row[disorder]\n",
" if pd.isna(value):\n",
" continue\n",
" question = f\"What is the percentage of {disorder.replace(' (%)', '')} in {entity} for year {year}?\"\n",
" answer = f\"{value}%\"\n",
" qa_examples.append({\n",
" \"instruction\": question,\n",
" \"input\": \"\",\n",
" \"output\": answer\n",
" })\n",
" print(f\"✅ Generated {len(qa_examples)} Q&A examples from {f}\")\n",
"\n",
" elif os.path.basename(f) == \"ocd_patient_dataset.csv\":\n",
" if \"Obsession Type\" in df.columns and \"Compulsion Type\" in df.columns:\n",
" df_sub = df[[\"Obsession Type\", \"Compulsion Type\"]].rename(columns={\n",
" \"Obsession Type\": \"Question\",\n",
" \"Compulsion Type\": \"Answer\"\n",
" })\n",
" df_sub = df_sub.dropna(subset=[\"Question\", \"Answer\"])\n",
" all_dfs.append(df_sub)\n",
" print(f\"✅ Loaded {len(df_sub)} rows from {f}\")\n",
" else:\n",
" print(f\"⚠️ Skipping {f}: Missing 'Obsession Type' or 'Compulsion Type' columns\")\n",
"\n",
" elif os.path.basename(f) == \"synthetic_ptsd_patients.csv\":\n",
" if \"trauma_type\" in df.columns and \"has_ptsd\" in df.columns:\n",
" df_sub = df[[\"trauma_type\", \"has_ptsd\"]].rename(columns={\n",
" \"trauma_type\": \"Question\",\n",
" \"has_ptsd\": \"Answer\"\n",
" })\n",
" df_sub = df_sub.dropna(subset=[\"Question\", \"Answer\"])\n",
" all_dfs.append(df_sub)\n",
" print(f\"✅ Loaded {len(df_sub)} rows from {f}\")\n",
" else:\n",
" print(f\"⚠️ Skipping {f}: Missing 'trauma_type' or 'has_ptsd' columns\")\n",
"\n",
" else:\n",
" # Generic Q&A detection for other files\n",
" df.columns = [c.lower() for c in df.columns] # normalize for matching\n",
" q_col = next((c for c in df.columns if c in [qc.lower() for qc in question_cols]), None)\n",
" a_col = next((c for c in df.columns if c in [ac.lower() for ac in answer_cols]), None)\n",
" if not q_col or not a_col:\n",
" print(f\"⚠️ Skipping {f}: Missing 'Question' or 'Answer' column\")\n",
" continue\n",
" df_sub = df[[q_col, a_col]].rename(columns={q_col: \"Question\", a_col: \"Answer\"})\n",
" df_sub = df_sub.dropna(subset=[\"Question\", \"Answer\"])\n",
" all_dfs.append(df_sub)\n",
" print(f\"✅ Loaded {len(df_sub)} rows from {f}\")\n",
"\n",
"# Combine normal Q/A datasets\n",
"if all_dfs:\n",
" df_combined = pd.concat(all_dfs, ignore_index=True)\n",
"else:\n",
" df_combined = pd.DataFrame(columns=[\"Question\", \"Answer\"])\n",
"\n",
"# Write all data to JSONL\n",
"with open(\"training_data.jsonl\", \"w\", encoding=\"utf-8\") as f_out:\n",
" for _, row in df_combined.iterrows():\n",
" q = str(row[\"Question\"]).strip()\n",
" a = str(row[\"Answer\"]).strip()\n",
" if q and a:\n",
" example = {\"instruction\": q, \"input\": \"\", \"output\": a}\n",
" f_out.write(json.dumps(example, ensure_ascii=False) + \"\\n\")\n",
"\n",
" for example in qa_examples:\n",
" f_out.write(json.dumps(example, ensure_ascii=False) + \"\\n\")\n",
"\n",
"total = len(df_combined) + len(qa_examples)\n",
"print(f\"✅ Saved merged dataset with {total} examples to training_data.jsonl\")\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Xysu5AtqZ9mn",
"outputId": "6466af2a-424d-45d4-ab7f-6b9ae379001c"
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"✅ Loaded 2838 rows from /content/Stress.csv\n",
"✅ Loaded 3479 rows from /content/ds.csv\n",
"✅ Loaded 1500 rows from /content/ocd_patient_dataset.csv\n",
"✅ Loaded 500 rows from /content/synthetic_ptsd_patients.csv\n",
"✅ Generated 45276 Q&A examples from /content/Mental health Depression disorder Data.csv\n",
"✅ Loaded 3479 rows from /content/Copy of ds.csv\n",
"✅ Saved merged dataset with 57072 examples to training_data.jsonl\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Show head of each loaded CSV / processed DF\n",
"for f in files:\n",
" ext = os.path.splitext(f)[1].lower()\n",
" if ext != \".csv\":\n",
" continue\n",
"\n",
" try:\n",
" try:\n",
" df = pd.read_csv(f, encoding=\"utf-8\")\n",
" except UnicodeDecodeError:\n",
" df = pd.read_csv(f, encoding=\"latin1\")\n",
" except Exception as e:\n",
" print(f\"⚠️ Could not read {f}: {e}\")\n",
" continue\n",
"\n",
" print(f\"\\n📄 Head of {os.path.basename(f)}:\")\n",
" display(df.head(5)) # top 5 rows\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "FNvKM7TRZbRJ",
"outputId": "00eb85c6-f5de-418e-dd96-4f6268504a57"
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of Stress.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" subreddit post_id sentence_range \\\n",
"0 ptsd 8601tu (15, 20) \n",
"1 assistance 8lbrx9 (0, 5) \n",
"2 ptsd 9ch1zh (15, 20) \n",
"3 relationships 7rorpp [5, 10] \n",
"4 survivorsofabuse 9p2gbc [0, 5] \n",
"\n",
" text label confidence \\\n",
"0 He said he had not felt that way before, sugge... 1 0.8 \n",
"1 Hey there r/assistance, Not sure if this is th... 0 1.0 \n",
"2 My mom then hit me with the newspaper and it s... 1 0.8 \n",
"3 until i met my new boyfriend, he is amazing, h... 1 0.6 \n",
"4 October is Domestic Violence Awareness Month a... 1 0.8 \n",
"\n",
" social_timestamp \n",
"0 1521614353 \n",
"1 1527009817 \n",
"2 1535935605 \n",
"3 1516429555 \n",
"4 1539809005 "
],
"text/html": [
"\n",
"
\n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" subreddit | \n",
" post_id | \n",
" sentence_range | \n",
" text | \n",
" label | \n",
" confidence | \n",
" social_timestamp | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ptsd | \n",
" 8601tu | \n",
" (15, 20) | \n",
" He said he had not felt that way before, sugge... | \n",
" 1 | \n",
" 0.8 | \n",
" 1521614353 | \n",
"
\n",
" \n",
" | 1 | \n",
" assistance | \n",
" 8lbrx9 | \n",
" (0, 5) | \n",
" Hey there r/assistance, Not sure if this is th... | \n",
" 0 | \n",
" 1.0 | \n",
" 1527009817 | \n",
"
\n",
" \n",
" | 2 | \n",
" ptsd | \n",
" 9ch1zh | \n",
" (15, 20) | \n",
" My mom then hit me with the newspaper and it s... | \n",
" 1 | \n",
" 0.8 | \n",
" 1535935605 | \n",
"
\n",
" \n",
" | 3 | \n",
" relationships | \n",
" 7rorpp | \n",
" [5, 10] | \n",
" until i met my new boyfriend, he is amazing, h... | \n",
" 1 | \n",
" 0.6 | \n",
" 1516429555 | \n",
"
\n",
" \n",
" | 4 | \n",
" survivorsofabuse | \n",
" 9p2gbc | \n",
" [0, 5] | \n",
" October is Domestic Violence Awareness Month a... | \n",
" 1 | \n",
" 0.8 | \n",
" 1539809005 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"subreddit\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"assistance\",\n \"survivorsofabuse\",\n \"ptsd\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"post_id\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"8lbrx9\",\n \"9p2gbc\",\n \"9ch1zh\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentence_range\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"(0, 5)\",\n \"[0, 5]\",\n \"(15, 20)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"Hey there r/assistance, Not sure if this is the right place to post this.. but here goes =) I'm currently a student intern at Sandia National Labs and working on a survey to help improve our marketing outreach efforts at the many schools we recruit at around the country. We're looking for current undergrad/grad STEM students so if you're a STEM student or know STEM students, I would greatly appreciate if you can help take or pass along this short survey. As a thank you, everyone who helps take the survey will be entered in to a drawing for chance to win one of three $50 Amazon gcs.\",\n \"October is Domestic Violence Awareness Month and I am a domestic violence survivor who is still struggling, even after over four years. Lately I have been feeling very angry. Angry that my abusive ex received no real consequences for his actions. This man abused me in all manners: physically, sexually, emotionally, verbally, financially, etc. I was granted a restraining order against him (and it was renewed a year later) but I was unable to press criminal charges against him because I didn\\u2019t have enough evidence to have a case.\",\n \"My mom then hit me with the newspaper and it shocked me that she would do this, she knows I don't like play hitting, smacking, striking, hitting or violence of any sort on my person. Do I send out this vibe asking for it from the universe? Then yesterday I decided to take my friend to go help another \\\"friend\\\" move to a new place. While we were driving the friend we are moving strikes me on my shoulder. And I address it immediately because this is the 4th time I have told him not to do these things, then my other friend who is driving nearly gets into an collision with another car i think because he was high on marijuana and the friend we are moving in the backseat is like \\\"you have to understand I was just trying to get your attention\\\" you know the thing 5 year olds do to get peoples attention by smacking them, this guy is in his 60's.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"label\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"confidence\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.14142135623730953,\n \"min\": 0.6,\n \"max\": 1.0,\n \"num_unique_values\": 3,\n \"samples\": [\n 0.8,\n 1.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"social_timestamp\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 9720225,\n \"min\": 1516429555,\n \"max\": 1539809005,\n \"num_unique_values\": 5,\n \"samples\": [\n 1527009817,\n 1539809005\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of ds.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" phrase sentiment\n",
"0 \"I love spending time with my family.\" positive\n",
"1 \"Sunshine always brightens my day.\" positive\n",
"2 \"Helping others is so rewarding.\" positive\n",
"3 \"A good book can transport you to another world.\" positive\n",
"4 \"The smell of freshly baked bread is amazing.\" positive"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" phrase | \n",
" sentiment | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" \"I love spending time with my family.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 1 | \n",
" \"Sunshine always brightens my day.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 2 | \n",
" \"Helping others is so rewarding.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 3 | \n",
" \"A good book can transport you to another world.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 4 | \n",
" \"The smell of freshly baked bread is amazing.\" | \n",
" positive | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"phrase\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"\\\"Sunshine always brightens my day.\\\"\",\n \"\\\"The smell of freshly baked bread is amazing.\\\"\",\n \"\\\"Helping others is so rewarding.\\\"\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of ocd_patient_dataset.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" Patient ID Age Gender Ethnicity Marital Status Education Level \\\n",
"0 1018 32 Female African Single Some College \n",
"1 2406 69 Male African Divorced Some College \n",
"2 1188 57 Male Hispanic Divorced College Degree \n",
"3 6200 27 Female Hispanic Married College Degree \n",
"4 5824 56 Female Hispanic Married High School \n",
"\n",
" OCD Diagnosis Date Duration of Symptoms (months) Previous Diagnoses \\\n",
"0 2016-07-15 203 MDD \n",
"1 2017-04-28 180 NaN \n",
"2 2018-02-02 173 MDD \n",
"3 2014-08-25 126 PTSD \n",
"4 2022-02-20 168 PTSD \n",
"\n",
" Family History of OCD Obsession Type Compulsion Type \\\n",
"0 No Harm-related Checking \n",
"1 Yes Harm-related Washing \n",
"2 No Contamination Checking \n",
"3 Yes Symmetry Washing \n",
"4 Yes Hoarding Ordering \n",
"\n",
" Y-BOCS Score (Obsessions) Y-BOCS Score (Compulsions) Depression Diagnosis \\\n",
"0 17 10 Yes \n",
"1 21 25 Yes \n",
"2 3 4 No \n",
"3 14 28 Yes \n",
"4 39 18 No \n",
"\n",
" Anxiety Diagnosis Medications \n",
"0 Yes SNRI \n",
"1 Yes SSRI \n",
"2 No Benzodiazepine \n",
"3 Yes SSRI \n",
"4 No NaN "
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Patient ID | \n",
" Age | \n",
" Gender | \n",
" Ethnicity | \n",
" Marital Status | \n",
" Education Level | \n",
" OCD Diagnosis Date | \n",
" Duration of Symptoms (months) | \n",
" Previous Diagnoses | \n",
" Family History of OCD | \n",
" Obsession Type | \n",
" Compulsion Type | \n",
" Y-BOCS Score (Obsessions) | \n",
" Y-BOCS Score (Compulsions) | \n",
" Depression Diagnosis | \n",
" Anxiety Diagnosis | \n",
" Medications | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 1018 | \n",
" 32 | \n",
" Female | \n",
" African | \n",
" Single | \n",
" Some College | \n",
" 2016-07-15 | \n",
" 203 | \n",
" MDD | \n",
" No | \n",
" Harm-related | \n",
" Checking | \n",
" 17 | \n",
" 10 | \n",
" Yes | \n",
" Yes | \n",
" SNRI | \n",
"
\n",
" \n",
" | 1 | \n",
" 2406 | \n",
" 69 | \n",
" Male | \n",
" African | \n",
" Divorced | \n",
" Some College | \n",
" 2017-04-28 | \n",
" 180 | \n",
" NaN | \n",
" Yes | \n",
" Harm-related | \n",
" Washing | \n",
" 21 | \n",
" 25 | \n",
" Yes | \n",
" Yes | \n",
" SSRI | \n",
"
\n",
" \n",
" | 2 | \n",
" 1188 | \n",
" 57 | \n",
" Male | \n",
" Hispanic | \n",
" Divorced | \n",
" College Degree | \n",
" 2018-02-02 | \n",
" 173 | \n",
" MDD | \n",
" No | \n",
" Contamination | \n",
" Checking | \n",
" 3 | \n",
" 4 | \n",
" No | \n",
" No | \n",
" Benzodiazepine | \n",
"
\n",
" \n",
" | 3 | \n",
" 6200 | \n",
" 27 | \n",
" Female | \n",
" Hispanic | \n",
" Married | \n",
" College Degree | \n",
" 2014-08-25 | \n",
" 126 | \n",
" PTSD | \n",
" Yes | \n",
" Symmetry | \n",
" Washing | \n",
" 14 | \n",
" 28 | \n",
" Yes | \n",
" Yes | \n",
" SSRI | \n",
"
\n",
" \n",
" | 4 | \n",
" 5824 | \n",
" 56 | \n",
" Female | \n",
" Hispanic | \n",
" Married | \n",
" High School | \n",
" 2022-02-20 | \n",
" 168 | \n",
" PTSD | \n",
" Yes | \n",
" Hoarding | \n",
" Ordering | \n",
" 39 | \n",
" 18 | \n",
" No | \n",
" No | \n",
" NaN | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"Patient ID\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 2512,\n \"min\": 1018,\n \"max\": 6200,\n \"num_unique_values\": 5,\n \"samples\": [\n 2406,\n 5824,\n 1188\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Age\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 17,\n \"min\": 27,\n \"max\": 69,\n \"num_unique_values\": 5,\n \"samples\": [\n 69,\n 56,\n 57\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Gender\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Male\",\n \"Female\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Ethnicity\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Hispanic\",\n \"African\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Marital Status\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"Single\",\n \"Divorced\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Education Level\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"Some College\",\n \"College Degree\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"OCD Diagnosis Date\",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"2017-04-28\",\n \"2022-02-20\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Duration of Symptoms (months)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 28,\n \"min\": 126,\n \"max\": 203,\n \"num_unique_values\": 5,\n \"samples\": [\n 180,\n 168\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Previous Diagnoses\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"PTSD\",\n \"MDD\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Family History of OCD\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Yes\",\n \"No\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Obsession Type\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"Contamination\",\n \"Hoarding\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Compulsion Type\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"Checking\",\n \"Washing\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Y-BOCS Score (Obsessions)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 13,\n \"min\": 3,\n \"max\": 39,\n \"num_unique_values\": 5,\n \"samples\": [\n 21,\n 39\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Y-BOCS Score (Compulsions)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 10,\n \"min\": 4,\n \"max\": 28,\n \"num_unique_values\": 5,\n \"samples\": [\n 25,\n 18\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Depression Diagnosis\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"No\",\n \"Yes\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Anxiety Diagnosis\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"No\",\n \"Yes\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Medications\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"SNRI\",\n \"SSRI\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of synthetic_ptsd_patients.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" patient_id age gender trauma_type intrusive_thoughts nightmares \\\n",
"0 1 56 Female Accident 2 3 \n",
"1 2 69 Male Combat-related 4 1 \n",
"2 3 46 Male Other 2 3 \n",
"3 4 32 Female Other 1 1 \n",
"4 5 60 Male Natural disaster 0 4 \n",
"\n",
" avoidance negative_mood hypervigilance pcl5_score has_ptsd \n",
"0 3 1 4 52 1 \n",
"1 2 1 4 48 1 \n",
"2 4 2 1 48 1 \n",
"3 3 0 4 27 0 \n",
"4 4 0 4 36 1 "
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" patient_id | \n",
" age | \n",
" gender | \n",
" trauma_type | \n",
" intrusive_thoughts | \n",
" nightmares | \n",
" avoidance | \n",
" negative_mood | \n",
" hypervigilance | \n",
" pcl5_score | \n",
" has_ptsd | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 1 | \n",
" 56 | \n",
" Female | \n",
" Accident | \n",
" 2 | \n",
" 3 | \n",
" 3 | \n",
" 1 | \n",
" 4 | \n",
" 52 | \n",
" 1 | \n",
"
\n",
" \n",
" | 1 | \n",
" 2 | \n",
" 69 | \n",
" Male | \n",
" Combat-related | \n",
" 4 | \n",
" 1 | \n",
" 2 | \n",
" 1 | \n",
" 4 | \n",
" 48 | \n",
" 1 | \n",
"
\n",
" \n",
" | 2 | \n",
" 3 | \n",
" 46 | \n",
" Male | \n",
" Other | \n",
" 2 | \n",
" 3 | \n",
" 4 | \n",
" 2 | \n",
" 1 | \n",
" 48 | \n",
" 1 | \n",
"
\n",
" \n",
" | 3 | \n",
" 4 | \n",
" 32 | \n",
" Female | \n",
" Other | \n",
" 1 | \n",
" 1 | \n",
" 3 | \n",
" 0 | \n",
" 4 | \n",
" 27 | \n",
" 0 | \n",
"
\n",
" \n",
" | 4 | \n",
" 5 | \n",
" 60 | \n",
" Male | \n",
" Natural disaster | \n",
" 0 | \n",
" 4 | \n",
" 4 | \n",
" 0 | \n",
" 4 | \n",
" 36 | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"patient_id\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 5,\n \"num_unique_values\": 5,\n \"samples\": [\n 2,\n 5,\n 3\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"age\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14,\n \"min\": 32,\n \"max\": 69,\n \"num_unique_values\": 5,\n \"samples\": [\n 69,\n 60,\n 46\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"gender\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Male\",\n \"Female\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"trauma_type\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"Combat-related\",\n \"Natural disaster\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"intrusive_thoughts\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 0,\n \"max\": 4,\n \"num_unique_values\": 4,\n \"samples\": [\n 4,\n 0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"nightmares\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 4,\n \"num_unique_values\": 3,\n \"samples\": [\n 3,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"avoidance\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 2,\n \"max\": 4,\n \"num_unique_values\": 3,\n \"samples\": [\n 3,\n 2\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"negative_mood\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 2,\n \"num_unique_values\": 3,\n \"samples\": [\n 1,\n 2\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"hypervigilance\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 4,\n \"num_unique_values\": 2,\n \"samples\": [\n 1,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"pcl5_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 10,\n \"min\": 27,\n \"max\": 52,\n \"num_unique_values\": 4,\n \"samples\": [\n 48,\n 36\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"has_ptsd\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of Mental health Depression disorder Data.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" Entity Code Year Schizophrenia (%) Bipolar disorder (%) \\\n",
"0 Afghanistan AFG 1990 0.160560 0.697779 \n",
"1 Afghanistan AFG 1991 0.160312 0.697961 \n",
"2 Afghanistan AFG 1992 0.160135 0.698107 \n",
"3 Afghanistan AFG 1993 0.160037 0.698257 \n",
"4 Afghanistan AFG 1994 0.160022 0.698469 \n",
"\n",
" Eating disorders (%) Anxiety disorders (%) Drug use disorders (%) \\\n",
"0 0.101855 4.828830 1.677082 \n",
"1 0.099313 4.829740 1.684746 \n",
"2 0.096692 4.831108 1.694334 \n",
"3 0.094336 4.830864 1.705320 \n",
"4 0.092439 4.829423 1.716069 \n",
"\n",
" Depression (%) Alcohol use disorders (%) \n",
"0 4.071831 0.672404 \n",
"1 4.079531 0.671768 \n",
"2 4.088358 0.670644 \n",
"3 4.096190 0.669738 \n",
"4 4.099582 0.669260 "
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Entity | \n",
" Code | \n",
" Year | \n",
" Schizophrenia (%) | \n",
" Bipolar disorder (%) | \n",
" Eating disorders (%) | \n",
" Anxiety disorders (%) | \n",
" Drug use disorders (%) | \n",
" Depression (%) | \n",
" Alcohol use disorders (%) | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Afghanistan | \n",
" AFG | \n",
" 1990 | \n",
" 0.160560 | \n",
" 0.697779 | \n",
" 0.101855 | \n",
" 4.828830 | \n",
" 1.677082 | \n",
" 4.071831 | \n",
" 0.672404 | \n",
"
\n",
" \n",
" | 1 | \n",
" Afghanistan | \n",
" AFG | \n",
" 1991 | \n",
" 0.160312 | \n",
" 0.697961 | \n",
" 0.099313 | \n",
" 4.829740 | \n",
" 1.684746 | \n",
" 4.079531 | \n",
" 0.671768 | \n",
"
\n",
" \n",
" | 2 | \n",
" Afghanistan | \n",
" AFG | \n",
" 1992 | \n",
" 0.160135 | \n",
" 0.698107 | \n",
" 0.096692 | \n",
" 4.831108 | \n",
" 1.694334 | \n",
" 4.088358 | \n",
" 0.670644 | \n",
"
\n",
" \n",
" | 3 | \n",
" Afghanistan | \n",
" AFG | \n",
" 1993 | \n",
" 0.160037 | \n",
" 0.698257 | \n",
" 0.094336 | \n",
" 4.830864 | \n",
" 1.705320 | \n",
" 4.096190 | \n",
" 0.669738 | \n",
"
\n",
" \n",
" | 4 | \n",
" Afghanistan | \n",
" AFG | \n",
" 1994 | \n",
" 0.160022 | \n",
" 0.698469 | \n",
" 0.092439 | \n",
" 4.829423 | \n",
" 1.716069 | \n",
" 4.099582 | \n",
" 0.669260 | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"Entity\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"Afghanistan\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Code\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"AFG\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Year\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1990,\n \"max\": 1994,\n \"num_unique_values\": 5,\n \"samples\": [\n 1991\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Schizophrenia (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.00022538296141507444,\n \"min\": 0.160022297338,\n \"max\": 0.160559542157,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.16031189863\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Bipolar disorder (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0002655595027180787,\n \"min\": 0.697779384535,\n \"max\": 0.69846911816,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.697960594942\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Eating disorders (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.003771125331541788,\n \"min\": 0.0924393209042,\n \"max\": 0.101854863459,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.0993127900960999\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Anxiety disorders (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0009674370993802713,\n \"min\": 4.82882970499999,\n \"max\": 4.83110836569,\n \"num_unique_values\": 5,\n \"samples\": [\n 4.82974037241\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Drug use disorders (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.015618469098137576,\n \"min\": 1.67708194479,\n \"max\": 1.71606858137,\n \"num_unique_values\": 5,\n \"samples\": [\n 1.68474573106\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Depression (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.01151549909830738,\n \"min\": 4.07183117706,\n \"max\": 4.09958157816,\n \"num_unique_values\": 5,\n \"samples\": [\n 4.07953093539999\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Alcohol use disorders (%)\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.0013255693766667934,\n \"min\": 0.669259592734,\n \"max\": 0.672404086186,\n \"num_unique_values\": 5,\n \"samples\": [\n 0.671768123935\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"\n",
"📄 Head of Copy of ds.csv:\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" phrase sentiment\n",
"0 \"I love spending time with my family.\" positive\n",
"1 \"Sunshine always brightens my day.\" positive\n",
"2 \"Helping others is so rewarding.\" positive\n",
"3 \"A good book can transport you to another world.\" positive\n",
"4 \"The smell of freshly baked bread is amazing.\" positive"
],
"text/html": [
"\n",
" \n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" phrase | \n",
" sentiment | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" \"I love spending time with my family.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 1 | \n",
" \"Sunshine always brightens my day.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 2 | \n",
" \"Helping others is so rewarding.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 3 | \n",
" \"A good book can transport you to another world.\" | \n",
" positive | \n",
"
\n",
" \n",
" | 4 | \n",
" \"The smell of freshly baked bread is amazing.\" | \n",
" positive | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
"
\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"summary": "{\n \"name\": \" display(df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"phrase\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"\\\"Sunshine always brightens my day.\\\"\",\n \"\\\"The smell of freshly baked bread is amazing.\\\"\",\n \"\\\"Helping others is so rewarding.\\\"\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
"from datasets import load_dataset\n",
"\n",
"# Load the JSONL dataset\n",
"dataset = load_dataset(\n",
" \"json\",\n",
" data_files=\"/content/training_data.jsonl\", # or training_data.jsonl\n",
" split=\"train\"\n",
")\n",
"\n",
"print(dataset[0]) # preview first item\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 86,
"referenced_widgets": [
"60003cd29e8241c3bd5caeacf7cd5626",
"0520ce1f42b34a009d21b547a0555215",
"602da4d2148142fb9bb34536a6eea10f",
"d372b6688dd0414fb39cf3eee89c2ee6",
"08d325c87f0343bdbd7f12fff31f254a",
"7cd3bd2d9a584786ad1d7724d2557573",
"981ae07b4d4545f1bcbd46d40e6faae9",
"ef198ccfca194060861b2a13df189e8a",
"95c67b1454b64eb897ebce6db7863e10",
"dfa1de4875dd472cb3672cd06f760b4e",
"8abe94a5621b41188a4d900ce7a72fd5"
]
},
"id": "7ab9H8n9S6Qg",
"outputId": "7f39f974-2d8d-4331-fe28-31c0cd231710"
},
"execution_count": 6,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Generating train split: 0 examples [00:00, ? examples/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "60003cd29e8241c3bd5caeacf7cd5626"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"{'instruction': 'He said he had not felt that way before, suggeted I go rest and so ..TRIGGER AHEAD IF YOUI\\'RE A HYPOCONDRIAC LIKE ME: i decide to look up \"feelings of doom\" in hopes of maybe getting sucked into some rabbit hole of ludicrous conspiracy, a stupid \"are you psychic\" test or new age b.s., something I could even laugh at down the road. No, I ended up reading that this sense of doom can be indicative of various health ailments; one of which I am prone to.. So on top of my \"doom\" to my gloom..I am now f\\'n worried about my heart. I do happen to have a physical in 48 hours.', 'input': '', 'output': '1'}\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"import torch\n",
"torch.cuda.empty_cache()\n"
],
"metadata": {
"id": "UVYcx_zagCjn"
},
"execution_count": 7,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import os\n",
"os.environ[\"PYTORCH_CUDA_ALLOC_CONF\"] = \"max_split_size_mb:128\"\n"
],
"metadata": {
"id": "2lZ2A97_gEx4"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from datasets import load_dataset\n",
"from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments, BitsAndBytesConfig\n",
"from peft import LoraConfig, get_peft_model\n",
"import torch\n",
"\n",
"model_name = \"tanusrich/Mental_Health_Chatbot\"\n",
"data_path = \"training_data.jsonl\"\n",
"\n",
"# Load dataset\n",
"dataset = load_dataset(\"json\", data_files=data_path, split=\"train\")\n",
"\n",
"# Load tokenizer and model with 4-bit quantization using BitsAndBytesConfig (new way)\n",
"bnb_config = BitsAndBytesConfig(load_in_4bit=True)\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
"model = AutoModelForCausalLM.from_pretrained(\n",
" model_name,\n",
" quantization_config=bnb_config,\n",
" device_map=\"auto\",\n",
" torch_dtype=torch.float16, # Added this parameter\n",
")\n",
"\n",
"# LoRA configuration for LLaMA-based model\n",
"lora_config = LoraConfig(\n",
" r=64,\n",
" lora_alpha=16,\n",
" target_modules=[\"q_proj\", \"v_proj\"], # typical for LLaMA\n",
" lora_dropout=0.1,\n",
" bias=\"none\",\n",
" task_type=\"CAUSAL_LM\"\n",
")\n",
"\n",
"model = get_peft_model(model, lora_config)\n",
"\n",
"# Tokenization helper (fixed)\n",
"def preprocess(examples):\n",
" inputs = [\n",
" instr + \"\\n\" + inp if inp else instr\n",
" for instr, inp in zip(\n",
" examples[\"instruction\"],\n",
" examples.get(\"input\", [\"\"] * len(examples[\"instruction\"]))\n",
" )\n",
" ]\n",
" outputs = examples[\"output\"]\n",
"\n",
" model_inputs = tokenizer(inputs, max_length=512, truncation=True, padding=\"max_length\")\n",
" labels = tokenizer(outputs, max_length=512, truncation=True, padding=\"max_length\").input_ids\n",
"\n",
" model_inputs[\"labels\"] = labels\n",
" return model_inputs\n",
"\n",
"# Apply preprocessing\n",
"tokenized_dataset = dataset.map(\n",
" preprocess,\n",
" batched=True,\n",
" remove_columns=dataset.column_names,\n",
")\n",
"\n",
"# Training arguments\n",
"training_args = TrainingArguments(\n",
" output_dir=\"./lora_mht_chatbot_finetuned\",\n",
" per_device_train_batch_size=1, # Reduced batch size\n",
" gradient_accumulation_steps=4, # Adjusted accumulation steps\n",
" num_train_epochs=3,\n",
" learning_rate=3e-4,\n",
" fp16=True,\n",
" save_strategy=\"epoch\",\n",
" optim=\"paged_adamw_32bit\",\n",
" logging_steps=10,\n",
" save_total_limit=2,\n",
" report_to=\"none\",\n",
")\n",
"\n",
"# Trainer\n",
"trainer = Trainer(\n",
" model=model,\n",
" args=training_args,\n",
" train_dataset=tokenized_dataset,\n",
" tokenizer=tokenizer,\n",
")\n",
"\n",
"trainer.train()\n",
"\n",
"# Save adapters and tokenizer\n",
"model.save_pretrained(\"./lora_mht_chatbot_finetuned\")\n",
"tokenizer.save_pretrained(\"./lora_mht_chatbot_finetuned\")\n",
"\n",
"print(\"✅ Fine-tuning complete and saved!\")"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000,
"referenced_widgets": [
"a997f83e7aa64ad1849d5f622eec145d",
"8889742d12364680a5a39470adde2873",
"168e3e4172cc4e36b2ca0544e0fc42b4",
"64f694d338294e5984e5895050d947c3",
"ce354595738b45eeb03386728d316d69",
"d552cb6203ed4718b0504b6d80de581c",
"ae2586c27aa24a0a8c96d88d5d160e70",
"b414fa4834174262a2608f6dfbe894e5",
"ee5c0c7663a64c3c85ea68373f105b42",
"0705592b068e4271bcc30a32791a47ca",
"151b2379bb6849df8dc75848717e9490",
"d7cf2951869343e98322277dd3e52085",
"864b8038624a40e899ddc8ee00d64996",
"6d45c0ee7da34f28932ab54699bd4092",
"8f86dd9f03214308b2bd9505bf249b80",
"c4be6df7bcc34fdc95e5bb6e72eb44ff",
"2ef30bae7c1a48329aa944559c539323",
"55a90b62a4094cf1afbf8fe183751cf9",
"67db80c7406a4ab7806e05451c234fdd",
"b213c00ebe8243a78b0ca91b40261e33",
"3a0bd7815630436982830f05768a52c3",
"2ea41b0b43de4c7db6b690d3c53ee578",
"6952dd69d233420c84f8931cd11d0b94",
"1b90056f7f0a4ad681a025cf5012c607",
"8c06c04a4cf44ec396992ae04f7ad53d",
"0e09e908da8444eca0c9737dd9c93c34",
"f5c7882a83094141b891d5fc8b9cbf17",
"2e4a189f134343fe84dd0ed20939055f",
"d6dfbb37ef7c4447aaa41cc6f6436163",
"46bf9b6c73c34232a129e28176509b9a",
"330a4fb368c142a38a538d78cc70cc76",
"6144b49ad9e64ad2a68b4f85396f41bf",
"936de9b40ae84efc8b5ecb7ed6172ddd"
]
},
"id": "beEGorh7eN3I",
"outputId": "0055144c-85fb-422d-dbb2-d49b60a4e49e"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Generating train split: 0 examples [00:00, ? examples/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "a997f83e7aa64ad1849d5f622eec145d"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"`torch_dtype` is deprecated! Use `dtype` instead!\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Loading checkpoint shards: 0%| | 0/3 [00:00, ?it/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "d7cf2951869343e98322277dd3e52085"
}
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"Map: 0%| | 0/57072 [00:00, ? examples/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "6952dd69d233420c84f8931cd11d0b94"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"/tmp/ipython-input-437242006.py:75: FutureWarning: `tokenizer` is deprecated and will be removed in version 5.0.0 for `Trainer.__init__`. Use `processing_class` instead.\n",
" trainer = Trainer(\n",
"The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'pad_token_id': 2}.\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
""
],
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" [ 743/42804 1:02:40 < 59:17:37, 0.20 it/s, Epoch 0.05/3]\n",
"
\n",
" \n",
" \n",
" \n",
" | Step | \n",
" Training Loss | \n",
"
\n",
" \n",
" \n",
" \n",
" | 10 | \n",
" 23.653100 | \n",
"
\n",
" \n",
" | 20 | \n",
" 23.332900 | \n",
"
\n",
" \n",
" | 30 | \n",
" 23.227600 | \n",
"
\n",
" \n",
" | 40 | \n",
" 23.208500 | \n",
"
\n",
" \n",
" | 50 | \n",
" 23.424900 | \n",
"
\n",
" \n",
" | 60 | \n",
" 23.403100 | \n",
"
\n",
" \n",
" | 70 | \n",
" 23.305700 | \n",
"
\n",
" \n",
" | 80 | \n",
" 23.368200 | \n",
"
\n",
" \n",
" | 90 | \n",
" 23.283600 | \n",
"
\n",
" \n",
" | 100 | \n",
" 23.233000 | \n",
"
\n",
" \n",
" | 110 | \n",
" 23.211700 | \n",
"
\n",
" \n",
" | 120 | \n",
" 23.203100 | \n",
"
\n",
" \n",
" | 130 | \n",
" 23.178200 | \n",
"
\n",
" \n",
" | 140 | \n",
" 23.331000 | \n",
"
\n",
" \n",
" | 150 | \n",
" 23.031700 | \n",
"
\n",
" \n",
" | 160 | \n",
" 23.388000 | \n",
"
\n",
" \n",
" | 170 | \n",
" 23.361600 | \n",
"
\n",
" \n",
" | 180 | \n",
" 23.361800 | \n",
"
\n",
" \n",
" | 190 | \n",
" 23.193500 | \n",
"
\n",
" \n",
" | 200 | \n",
" 23.318700 | \n",
"
\n",
" \n",
" | 210 | \n",
" 23.331800 | \n",
"
\n",
" \n",
" | 220 | \n",
" 23.256900 | \n",
"
\n",
" \n",
" | 230 | \n",
" 23.349100 | \n",
"
\n",
" \n",
" | 240 | \n",
" 23.115400 | \n",
"
\n",
" \n",
" | 250 | \n",
" 23.023700 | \n",
"
\n",
" \n",
" | 260 | \n",
" 23.321400 | \n",
"
\n",
" \n",
" | 270 | \n",
" 22.990600 | \n",
"
\n",
" \n",
" | 280 | \n",
" 23.115500 | \n",
"
\n",
" \n",
" | 290 | \n",
" 23.204400 | \n",
"
\n",
" \n",
" | 300 | \n",
" 23.366000 | \n",
"
\n",
" \n",
" | 310 | \n",
" 22.765200 | \n",
"
\n",
" \n",
" | 320 | \n",
" 23.341900 | \n",
"
\n",
" \n",
" | 330 | \n",
" 23.242800 | \n",
"
\n",
" \n",
" | 340 | \n",
" 23.098100 | \n",
"
\n",
" \n",
" | 350 | \n",
" 23.304000 | \n",
"
\n",
" \n",
" | 360 | \n",
" 23.417000 | \n",
"
\n",
" \n",
" | 370 | \n",
" 23.369900 | \n",
"
\n",
" \n",
" | 380 | \n",
" 23.214200 | \n",
"
\n",
" \n",
" | 390 | \n",
" 23.324600 | \n",
"
\n",
" \n",
" | 400 | \n",
" 23.313600 | \n",
"
\n",
" \n",
" | 410 | \n",
" 23.023900 | \n",
"
\n",
" \n",
" | 420 | \n",
" 23.100000 | \n",
"
\n",
" \n",
" | 430 | \n",
" 23.174100 | \n",
"
\n",
" \n",
" | 440 | \n",
" 23.301800 | \n",
"
\n",
" \n",
" | 450 | \n",
" 23.268000 | \n",
"
\n",
" \n",
" | 460 | \n",
" 23.215000 | \n",
"
\n",
" \n",
" | 470 | \n",
" 22.954800 | \n",
"
\n",
" \n",
" | 480 | \n",
" 23.131900 | \n",
"
\n",
" \n",
" | 490 | \n",
" 23.396800 | \n",
"
\n",
" \n",
" | 500 | \n",
" 23.423600 | \n",
"
\n",
" \n",
" | 510 | \n",
" 23.040500 | \n",
"
\n",
" \n",
" | 520 | \n",
" 23.399400 | \n",
"
\n",
" \n",
" | 530 | \n",
" 23.193900 | \n",
"
\n",
" \n",
" | 540 | \n",
" 23.395100 | \n",
"
\n",
" \n",
" | 550 | \n",
" 23.196200 | \n",
"
\n",
" \n",
" | 560 | \n",
" 23.387200 | \n",
"
\n",
" \n",
" | 570 | \n",
" 23.189700 | \n",
"
\n",
" \n",
" | 580 | \n",
" 23.188200 | \n",
"
\n",
" \n",
" | 590 | \n",
" 23.192300 | \n",
"
\n",
" \n",
" | 600 | \n",
" 23.410800 | \n",
"
\n",
" \n",
" | 610 | \n",
" 22.736500 | \n",
"
\n",
" \n",
" | 620 | \n",
" 23.095600 | \n",
"
\n",
" \n",
" | 630 | \n",
" 22.848800 | \n",
"
\n",
" \n",
" | 640 | \n",
" 23.120600 | \n",
"
\n",
" \n",
" | 650 | \n",
" 23.184200 | \n",
"
\n",
" \n",
" | 660 | \n",
" 23.107900 | \n",
"
\n",
" \n",
" | 670 | \n",
" 23.187900 | \n",
"
\n",
" \n",
" | 680 | \n",
" 23.264400 | \n",
"
\n",
" \n",
" | 690 | \n",
" 23.334400 | \n",
"
\n",
" \n",
" | 700 | \n",
" 23.149400 | \n",
"
\n",
" \n",
" | 710 | \n",
" 23.125700 | \n",
"
\n",
" \n",
" | 720 | \n",
" 23.182100 | \n",
"
\n",
" \n",
" | 730 | \n",
" 23.260400 | \n",
"
\n",
" \n",
" | 740 | \n",
" 22.861800 | \n",
"
\n",
" \n",
"
"
]
},
"metadata": {}
}
]
}
]
}