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
"display_name": "Python 3"
|
| 12 |
+
},
|
| 13 |
+
"language_info": {
|
| 14 |
+
"name": "python"
|
| 15 |
+
},
|
| 16 |
+
"accelerator": "GPU",
|
| 17 |
+
"widgets": {
|
| 18 |
+
"application/vnd.jupyter.widget-state+json": {
|
| 19 |
+
"cb82c295aa304cbab2c037caffc8d8d1": {
|
| 20 |
+
"model_module": "@jupyter-widgets/controls",
|
| 21 |
+
"model_name": "HBoxModel",
|
| 22 |
+
"model_module_version": "1.5.0",
|
| 23 |
+
"state": {
|
| 24 |
+
"_dom_classes": [],
|
| 25 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 26 |
+
"_model_module_version": "1.5.0",
|
| 27 |
+
"_model_name": "HBoxModel",
|
| 28 |
+
"_view_count": null,
|
| 29 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 30 |
+
"_view_module_version": "1.5.0",
|
| 31 |
+
"_view_name": "HBoxView",
|
| 32 |
+
"box_style": "",
|
| 33 |
+
"children": [
|
| 34 |
+
"IPY_MODEL_67367bae31384088aa07fc80aa68a081",
|
| 35 |
+
"IPY_MODEL_ed5621e9730641379c6b1c740c43ec1f",
|
| 36 |
+
"IPY_MODEL_4c31c17d684d434b88481c42404d5582"
|
| 37 |
+
],
|
| 38 |
+
"layout": "IPY_MODEL_9e300fa0cd094325ac4ce2f1aa5cca8b"
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"67367bae31384088aa07fc80aa68a081": {
|
| 42 |
+
"model_module": "@jupyter-widgets/controls",
|
| 43 |
+
"model_name": "HTMLModel",
|
| 44 |
+
"model_module_version": "1.5.0",
|
| 45 |
+
"state": {
|
| 46 |
+
"_dom_classes": [],
|
| 47 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 48 |
+
"_model_module_version": "1.5.0",
|
| 49 |
+
"_model_name": "HTMLModel",
|
| 50 |
+
"_view_count": null,
|
| 51 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 52 |
+
"_view_module_version": "1.5.0",
|
| 53 |
+
"_view_name": "HTMLView",
|
| 54 |
+
"description": "",
|
| 55 |
+
"description_tooltip": null,
|
| 56 |
+
"layout": "IPY_MODEL_2d58b05027644ae49d0d1c9b7a8c9f90",
|
| 57 |
+
"placeholder": "",
|
| 58 |
+
"style": "IPY_MODEL_0e9108eb5ada489a93719771ba9a8903",
|
| 59 |
+
"value": "Loading checkpoint shards: 100%"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
"ed5621e9730641379c6b1c740c43ec1f": {
|
| 63 |
+
"model_module": "@jupyter-widgets/controls",
|
| 64 |
+
"model_name": "FloatProgressModel",
|
| 65 |
+
"model_module_version": "1.5.0",
|
| 66 |
+
"state": {
|
| 67 |
+
"_dom_classes": [],
|
| 68 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 69 |
+
"_model_module_version": "1.5.0",
|
| 70 |
+
"_model_name": "FloatProgressModel",
|
| 71 |
+
"_view_count": null,
|
| 72 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 73 |
+
"_view_module_version": "1.5.0",
|
| 74 |
+
"_view_name": "ProgressView",
|
| 75 |
+
"bar_style": "success",
|
| 76 |
+
"description": "",
|
| 77 |
+
"description_tooltip": null,
|
| 78 |
+
"layout": "IPY_MODEL_8fea9e36d8a948c4a93e9613df9f9f48",
|
| 79 |
+
"max": 2,
|
| 80 |
+
"min": 0,
|
| 81 |
+
"orientation": "horizontal",
|
| 82 |
+
"style": "IPY_MODEL_51e33ef50f6f48e1b6c7d3da4ade7819",
|
| 83 |
+
"value": 2
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"4c31c17d684d434b88481c42404d5582": {
|
| 87 |
+
"model_module": "@jupyter-widgets/controls",
|
| 88 |
+
"model_name": "HTMLModel",
|
| 89 |
+
"model_module_version": "1.5.0",
|
| 90 |
+
"state": {
|
| 91 |
+
"_dom_classes": [],
|
| 92 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 93 |
+
"_model_module_version": "1.5.0",
|
| 94 |
+
"_model_name": "HTMLModel",
|
| 95 |
+
"_view_count": null,
|
| 96 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 97 |
+
"_view_module_version": "1.5.0",
|
| 98 |
+
"_view_name": "HTMLView",
|
| 99 |
+
"description": "",
|
| 100 |
+
"description_tooltip": null,
|
| 101 |
+
"layout": "IPY_MODEL_16ba2159038e4dafac854a238854cc93",
|
| 102 |
+
"placeholder": "",
|
| 103 |
+
"style": "IPY_MODEL_b15a25c37e714190a8a3032ce16d8944",
|
| 104 |
+
"value": " 2/2 [00:59<00:00, 27.15s/it]"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"9e300fa0cd094325ac4ce2f1aa5cca8b": {
|
| 108 |
+
"model_module": "@jupyter-widgets/base",
|
| 109 |
+
"model_name": "LayoutModel",
|
| 110 |
+
"model_module_version": "1.2.0",
|
| 111 |
+
"state": {
|
| 112 |
+
"_model_module": "@jupyter-widgets/base",
|
| 113 |
+
"_model_module_version": "1.2.0",
|
| 114 |
+
"_model_name": "LayoutModel",
|
| 115 |
+
"_view_count": null,
|
| 116 |
+
"_view_module": "@jupyter-widgets/base",
|
| 117 |
+
"_view_module_version": "1.2.0",
|
| 118 |
+
"_view_name": "LayoutView",
|
| 119 |
+
"align_content": null,
|
| 120 |
+
"align_items": null,
|
| 121 |
+
"align_self": null,
|
| 122 |
+
"border": null,
|
| 123 |
+
"bottom": null,
|
| 124 |
+
"display": null,
|
| 125 |
+
"flex": null,
|
| 126 |
+
"flex_flow": null,
|
| 127 |
+
"grid_area": null,
|
| 128 |
+
"grid_auto_columns": null,
|
| 129 |
+
"grid_auto_flow": null,
|
| 130 |
+
"grid_auto_rows": null,
|
| 131 |
+
"grid_column": null,
|
| 132 |
+
"grid_gap": null,
|
| 133 |
+
"grid_row": null,
|
| 134 |
+
"grid_template_areas": null,
|
| 135 |
+
"grid_template_columns": null,
|
| 136 |
+
"grid_template_rows": null,
|
| 137 |
+
"height": null,
|
| 138 |
+
"justify_content": null,
|
| 139 |
+
"justify_items": null,
|
| 140 |
+
"left": null,
|
| 141 |
+
"margin": null,
|
| 142 |
+
"max_height": null,
|
| 143 |
+
"max_width": null,
|
| 144 |
+
"min_height": null,
|
| 145 |
+
"min_width": null,
|
| 146 |
+
"object_fit": null,
|
| 147 |
+
"object_position": null,
|
| 148 |
+
"order": null,
|
| 149 |
+
"overflow": null,
|
| 150 |
+
"overflow_x": null,
|
| 151 |
+
"overflow_y": null,
|
| 152 |
+
"padding": null,
|
| 153 |
+
"right": null,
|
| 154 |
+
"top": null,
|
| 155 |
+
"visibility": null,
|
| 156 |
+
"width": null
|
| 157 |
+
}
|
| 158 |
+
},
|
| 159 |
+
"2d58b05027644ae49d0d1c9b7a8c9f90": {
|
| 160 |
+
"model_module": "@jupyter-widgets/base",
|
| 161 |
+
"model_name": "LayoutModel",
|
| 162 |
+
"model_module_version": "1.2.0",
|
| 163 |
+
"state": {
|
| 164 |
+
"_model_module": "@jupyter-widgets/base",
|
| 165 |
+
"_model_module_version": "1.2.0",
|
| 166 |
+
"_model_name": "LayoutModel",
|
| 167 |
+
"_view_count": null,
|
| 168 |
+
"_view_module": "@jupyter-widgets/base",
|
| 169 |
+
"_view_module_version": "1.2.0",
|
| 170 |
+
"_view_name": "LayoutView",
|
| 171 |
+
"align_content": null,
|
| 172 |
+
"align_items": null,
|
| 173 |
+
"align_self": null,
|
| 174 |
+
"border": null,
|
| 175 |
+
"bottom": null,
|
| 176 |
+
"display": null,
|
| 177 |
+
"flex": null,
|
| 178 |
+
"flex_flow": null,
|
| 179 |
+
"grid_area": null,
|
| 180 |
+
"grid_auto_columns": null,
|
| 181 |
+
"grid_auto_flow": null,
|
| 182 |
+
"grid_auto_rows": null,
|
| 183 |
+
"grid_column": null,
|
| 184 |
+
"grid_gap": null,
|
| 185 |
+
"grid_row": null,
|
| 186 |
+
"grid_template_areas": null,
|
| 187 |
+
"grid_template_columns": null,
|
| 188 |
+
"grid_template_rows": null,
|
| 189 |
+
"height": null,
|
| 190 |
+
"justify_content": null,
|
| 191 |
+
"justify_items": null,
|
| 192 |
+
"left": null,
|
| 193 |
+
"margin": null,
|
| 194 |
+
"max_height": null,
|
| 195 |
+
"max_width": null,
|
| 196 |
+
"min_height": null,
|
| 197 |
+
"min_width": null,
|
| 198 |
+
"object_fit": null,
|
| 199 |
+
"object_position": null,
|
| 200 |
+
"order": null,
|
| 201 |
+
"overflow": null,
|
| 202 |
+
"overflow_x": null,
|
| 203 |
+
"overflow_y": null,
|
| 204 |
+
"padding": null,
|
| 205 |
+
"right": null,
|
| 206 |
+
"top": null,
|
| 207 |
+
"visibility": null,
|
| 208 |
+
"width": null
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"0e9108eb5ada489a93719771ba9a8903": {
|
| 212 |
+
"model_module": "@jupyter-widgets/controls",
|
| 213 |
+
"model_name": "DescriptionStyleModel",
|
| 214 |
+
"model_module_version": "1.5.0",
|
| 215 |
+
"state": {
|
| 216 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 217 |
+
"_model_module_version": "1.5.0",
|
| 218 |
+
"_model_name": "DescriptionStyleModel",
|
| 219 |
+
"_view_count": null,
|
| 220 |
+
"_view_module": "@jupyter-widgets/base",
|
| 221 |
+
"_view_module_version": "1.2.0",
|
| 222 |
+
"_view_name": "StyleView",
|
| 223 |
+
"description_width": ""
|
| 224 |
+
}
|
| 225 |
+
},
|
| 226 |
+
"8fea9e36d8a948c4a93e9613df9f9f48": {
|
| 227 |
+
"model_module": "@jupyter-widgets/base",
|
| 228 |
+
"model_name": "LayoutModel",
|
| 229 |
+
"model_module_version": "1.2.0",
|
| 230 |
+
"state": {
|
| 231 |
+
"_model_module": "@jupyter-widgets/base",
|
| 232 |
+
"_model_module_version": "1.2.0",
|
| 233 |
+
"_model_name": "LayoutModel",
|
| 234 |
+
"_view_count": null,
|
| 235 |
+
"_view_module": "@jupyter-widgets/base",
|
| 236 |
+
"_view_module_version": "1.2.0",
|
| 237 |
+
"_view_name": "LayoutView",
|
| 238 |
+
"align_content": null,
|
| 239 |
+
"align_items": null,
|
| 240 |
+
"align_self": null,
|
| 241 |
+
"border": null,
|
| 242 |
+
"bottom": null,
|
| 243 |
+
"display": null,
|
| 244 |
+
"flex": null,
|
| 245 |
+
"flex_flow": null,
|
| 246 |
+
"grid_area": null,
|
| 247 |
+
"grid_auto_columns": null,
|
| 248 |
+
"grid_auto_flow": null,
|
| 249 |
+
"grid_auto_rows": null,
|
| 250 |
+
"grid_column": null,
|
| 251 |
+
"grid_gap": null,
|
| 252 |
+
"grid_row": null,
|
| 253 |
+
"grid_template_areas": null,
|
| 254 |
+
"grid_template_columns": null,
|
| 255 |
+
"grid_template_rows": null,
|
| 256 |
+
"height": null,
|
| 257 |
+
"justify_content": null,
|
| 258 |
+
"justify_items": null,
|
| 259 |
+
"left": null,
|
| 260 |
+
"margin": null,
|
| 261 |
+
"max_height": null,
|
| 262 |
+
"max_width": null,
|
| 263 |
+
"min_height": null,
|
| 264 |
+
"min_width": null,
|
| 265 |
+
"object_fit": null,
|
| 266 |
+
"object_position": null,
|
| 267 |
+
"order": null,
|
| 268 |
+
"overflow": null,
|
| 269 |
+
"overflow_x": null,
|
| 270 |
+
"overflow_y": null,
|
| 271 |
+
"padding": null,
|
| 272 |
+
"right": null,
|
| 273 |
+
"top": null,
|
| 274 |
+
"visibility": null,
|
| 275 |
+
"width": null
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
"51e33ef50f6f48e1b6c7d3da4ade7819": {
|
| 279 |
+
"model_module": "@jupyter-widgets/controls",
|
| 280 |
+
"model_name": "ProgressStyleModel",
|
| 281 |
+
"model_module_version": "1.5.0",
|
| 282 |
+
"state": {
|
| 283 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 284 |
+
"_model_module_version": "1.5.0",
|
| 285 |
+
"_model_name": "ProgressStyleModel",
|
| 286 |
+
"_view_count": null,
|
| 287 |
+
"_view_module": "@jupyter-widgets/base",
|
| 288 |
+
"_view_module_version": "1.2.0",
|
| 289 |
+
"_view_name": "StyleView",
|
| 290 |
+
"bar_color": null,
|
| 291 |
+
"description_width": ""
|
| 292 |
+
}
|
| 293 |
+
},
|
| 294 |
+
"16ba2159038e4dafac854a238854cc93": {
|
| 295 |
+
"model_module": "@jupyter-widgets/base",
|
| 296 |
+
"model_name": "LayoutModel",
|
| 297 |
+
"model_module_version": "1.2.0",
|
| 298 |
+
"state": {
|
| 299 |
+
"_model_module": "@jupyter-widgets/base",
|
| 300 |
+
"_model_module_version": "1.2.0",
|
| 301 |
+
"_model_name": "LayoutModel",
|
| 302 |
+
"_view_count": null,
|
| 303 |
+
"_view_module": "@jupyter-widgets/base",
|
| 304 |
+
"_view_module_version": "1.2.0",
|
| 305 |
+
"_view_name": "LayoutView",
|
| 306 |
+
"align_content": null,
|
| 307 |
+
"align_items": null,
|
| 308 |
+
"align_self": null,
|
| 309 |
+
"border": null,
|
| 310 |
+
"bottom": null,
|
| 311 |
+
"display": null,
|
| 312 |
+
"flex": null,
|
| 313 |
+
"flex_flow": null,
|
| 314 |
+
"grid_area": null,
|
| 315 |
+
"grid_auto_columns": null,
|
| 316 |
+
"grid_auto_flow": null,
|
| 317 |
+
"grid_auto_rows": null,
|
| 318 |
+
"grid_column": null,
|
| 319 |
+
"grid_gap": null,
|
| 320 |
+
"grid_row": null,
|
| 321 |
+
"grid_template_areas": null,
|
| 322 |
+
"grid_template_columns": null,
|
| 323 |
+
"grid_template_rows": null,
|
| 324 |
+
"height": null,
|
| 325 |
+
"justify_content": null,
|
| 326 |
+
"justify_items": null,
|
| 327 |
+
"left": null,
|
| 328 |
+
"margin": null,
|
| 329 |
+
"max_height": null,
|
| 330 |
+
"max_width": null,
|
| 331 |
+
"min_height": null,
|
| 332 |
+
"min_width": null,
|
| 333 |
+
"object_fit": null,
|
| 334 |
+
"object_position": null,
|
| 335 |
+
"order": null,
|
| 336 |
+
"overflow": null,
|
| 337 |
+
"overflow_x": null,
|
| 338 |
+
"overflow_y": null,
|
| 339 |
+
"padding": null,
|
| 340 |
+
"right": null,
|
| 341 |
+
"top": null,
|
| 342 |
+
"visibility": null,
|
| 343 |
+
"width": null
|
| 344 |
+
}
|
| 345 |
+
},
|
| 346 |
+
"b15a25c37e714190a8a3032ce16d8944": {
|
| 347 |
+
"model_module": "@jupyter-widgets/controls",
|
| 348 |
+
"model_name": "DescriptionStyleModel",
|
| 349 |
+
"model_module_version": "1.5.0",
|
| 350 |
+
"state": {
|
| 351 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 352 |
+
"_model_module_version": "1.5.0",
|
| 353 |
+
"_model_name": "DescriptionStyleModel",
|
| 354 |
+
"_view_count": null,
|
| 355 |
+
"_view_module": "@jupyter-widgets/base",
|
| 356 |
+
"_view_module_version": "1.2.0",
|
| 357 |
+
"_view_name": "StyleView",
|
| 358 |
+
"description_width": ""
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
},
|
| 364 |
+
"cells": [
|
| 365 |
+
{
|
| 366 |
+
"cell_type": "code",
|
| 367 |
+
"execution_count": 2,
|
| 368 |
+
"metadata": {
|
| 369 |
+
"id": "qNGi-NeEQKyh"
|
| 370 |
+
},
|
| 371 |
+
"outputs": [],
|
| 372 |
+
"source": [
|
| 373 |
+
"!pip install -q accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.0 transformers==4.31.0 trl==0.4.7\n"
|
| 374 |
+
]
|
| 375 |
+
},
|
| 376 |
+
{
|
| 377 |
+
"cell_type": "code",
|
| 378 |
+
"source": [
|
| 379 |
+
"# import Libraries"
|
| 380 |
+
],
|
| 381 |
+
"metadata": {
|
| 382 |
+
"id": "WauAa05-Qjvm"
|
| 383 |
+
},
|
| 384 |
+
"execution_count": null,
|
| 385 |
+
"outputs": []
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"cell_type": "code",
|
| 389 |
+
"source": [
|
| 390 |
+
"import os\n",
|
| 391 |
+
"import torch\n",
|
| 392 |
+
"from datasets import load_dataset\n",
|
| 393 |
+
"from transformers import (\n",
|
| 394 |
+
" AutoModelForCausalLM,\n",
|
| 395 |
+
" AutoTokenizer,\n",
|
| 396 |
+
" BitsAndBytesConfig,\n",
|
| 397 |
+
" TrainingArguments,\n",
|
| 398 |
+
" pipeline,\n",
|
| 399 |
+
" logging,\n",
|
| 400 |
+
")\n",
|
| 401 |
+
"from peft import LoraConfig\n",
|
| 402 |
+
"from trl import SFTTrainer"
|
| 403 |
+
],
|
| 404 |
+
"metadata": {
|
| 405 |
+
"colab": {
|
| 406 |
+
"base_uri": "https://localhost:8080/"
|
| 407 |
+
},
|
| 408 |
+
"id": "kHnoSTdZQchZ",
|
| 409 |
+
"outputId": "cb02da43-ae5a-4077-d4ae-73f3757a23f3"
|
| 410 |
+
},
|
| 411 |
+
"execution_count": 3,
|
| 412 |
+
"outputs": [
|
| 413 |
+
{
|
| 414 |
+
"output_type": "stream",
|
| 415 |
+
"name": "stdout",
|
| 416 |
+
"text": [
|
| 417 |
+
"\n",
|
| 418 |
+
"===================================BUG REPORT===================================\n",
|
| 419 |
+
"Welcome to bitsandbytes. For bug reports, please run\n",
|
| 420 |
+
"\n",
|
| 421 |
+
"python -m bitsandbytes\n",
|
| 422 |
+
"\n",
|
| 423 |
+
" and submit this information together with your error trace to: https://github.com/TimDettmers/bitsandbytes/issues\n",
|
| 424 |
+
"================================================================================\n",
|
| 425 |
+
"bin /usr/local/lib/python3.10/dist-packages/bitsandbytes/libbitsandbytes_cuda122.so\n",
|
| 426 |
+
"CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths...\n",
|
| 427 |
+
"CUDA SETUP: CUDA runtime path found: /usr/local/cuda/lib64/libcudart.so\n",
|
| 428 |
+
"CUDA SETUP: Highest compute capability among GPUs detected: 7.5\n",
|
| 429 |
+
"CUDA SETUP: Detected CUDA version 122\n",
|
| 430 |
+
"CUDA SETUP: Loading binary /usr/local/lib/python3.10/dist-packages/bitsandbytes/libbitsandbytes_cuda122.so...\n"
|
| 431 |
+
]
|
| 432 |
+
},
|
| 433 |
+
{
|
| 434 |
+
"output_type": "stream",
|
| 435 |
+
"name": "stderr",
|
| 436 |
+
"text": [
|
| 437 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: /usr/lib64-nvidia did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...\n",
|
| 438 |
+
" warn(msg)\n",
|
| 439 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('/sys/fs/cgroup/memory.events /var/colab/cgroup/jupyter-children/memory.events')}\n",
|
| 440 |
+
" warn(msg)\n",
|
| 441 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('8013'), PosixPath('//172.28.0.1'), PosixPath('http')}\n",
|
| 442 |
+
" warn(msg)\n",
|
| 443 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('//colab.research.google.com/tun/m/cc48301118ce562b961b3c22d803539adc1e0c19/gpu-t4-s-2m1xgbra9q2mp --tunnel_background_save_delay=10s --tunnel_periodic_background_save_frequency=30m0s --enable_output_coalescing=true --output_coalescing_required=true'), PosixPath('--logtostderr --listen_host=172.28.0.12 --target_host=172.28.0.12 --tunnel_background_save_url=https')}\n",
|
| 444 |
+
" warn(msg)\n",
|
| 445 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('/datalab/web/pyright/typeshed-fallback/stdlib,/usr/local/lib/python3.10/dist-packages')}\n",
|
| 446 |
+
" warn(msg)\n",
|
| 447 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('/env/python')}\n",
|
| 448 |
+
" warn(msg)\n",
|
| 449 |
+
"/usr/local/lib/python3.10/dist-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('module'), PosixPath('//ipykernel.pylab.backend_inline')}\n",
|
| 450 |
+
" warn(msg)\n"
|
| 451 |
+
]
|
| 452 |
+
}
|
| 453 |
+
]
|
| 454 |
+
},
|
| 455 |
+
{
|
| 456 |
+
"cell_type": "code",
|
| 457 |
+
"source": [
|
| 458 |
+
"# Model from Hugging Face hub\n",
|
| 459 |
+
"base_model = \"NousResearch/Llama-2-7b-chat-hf\"\n",
|
| 460 |
+
"\n",
|
| 461 |
+
"# New instruction dataset\n",
|
| 462 |
+
"data = \"mlabonne/guanaco-llama2-1k\"\n",
|
| 463 |
+
"\n",
|
| 464 |
+
"# Fine-tuned model\n",
|
| 465 |
+
"new_model = \"llama\""
|
| 466 |
+
],
|
| 467 |
+
"metadata": {
|
| 468 |
+
"id": "HK6v7rKIQc-N"
|
| 469 |
+
},
|
| 470 |
+
"execution_count": 5,
|
| 471 |
+
"outputs": []
|
| 472 |
+
},
|
| 473 |
+
{
|
| 474 |
+
"cell_type": "code",
|
| 475 |
+
"source": [
|
| 476 |
+
"#Loading dataset, model, and tokenizer"
|
| 477 |
+
],
|
| 478 |
+
"metadata": {
|
| 479 |
+
"id": "JwRCNdaCRCRg"
|
| 480 |
+
},
|
| 481 |
+
"execution_count": 6,
|
| 482 |
+
"outputs": []
|
| 483 |
+
},
|
| 484 |
+
{
|
| 485 |
+
"cell_type": "code",
|
| 486 |
+
"source": [
|
| 487 |
+
"dataset = load_dataset(data, split=\"train\")"
|
| 488 |
+
],
|
| 489 |
+
"metadata": {
|
| 490 |
+
"colab": {
|
| 491 |
+
"base_uri": "https://localhost:8080/"
|
| 492 |
+
},
|
| 493 |
+
"id": "RZxePacWQdAz",
|
| 494 |
+
"outputId": "8d4d4a5b-08f2-4ae2-b053-bf8fbf36d0a2"
|
| 495 |
+
},
|
| 496 |
+
"execution_count": 7,
|
| 497 |
+
"outputs": [
|
| 498 |
+
{
|
| 499 |
+
"output_type": "stream",
|
| 500 |
+
"name": "stderr",
|
| 501 |
+
"text": [
|
| 502 |
+
"/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:88: UserWarning: \n",
|
| 503 |
+
"The secret `HF_TOKEN` does not exist in your Colab secrets.\n",
|
| 504 |
+
"To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",
|
| 505 |
+
"You will be able to reuse this secret in all of your notebooks.\n",
|
| 506 |
+
"Please note that authentication is recommended but still optional to access public models or datasets.\n",
|
| 507 |
+
" warnings.warn(\n"
|
| 508 |
+
]
|
| 509 |
+
}
|
| 510 |
+
]
|
| 511 |
+
},
|
| 512 |
+
{
|
| 513 |
+
"cell_type": "code",
|
| 514 |
+
"source": [
|
| 515 |
+
"#4-bit quantization configuration"
|
| 516 |
+
],
|
| 517 |
+
"metadata": {
|
| 518 |
+
"id": "h1Jyci0XQ7fv"
|
| 519 |
+
},
|
| 520 |
+
"execution_count": null,
|
| 521 |
+
"outputs": []
|
| 522 |
+
},
|
| 523 |
+
{
|
| 524 |
+
"cell_type": "code",
|
| 525 |
+
"source": [
|
| 526 |
+
"compute_dtype = getattr(torch, \"float16\")\n",
|
| 527 |
+
"\n",
|
| 528 |
+
"quant_config = BitsAndBytesConfig(\n",
|
| 529 |
+
" load_in_4bit=True,\n",
|
| 530 |
+
" bnb_4bit_quant_type=\"nf4\",\n",
|
| 531 |
+
" bnb_4bit_compute_dtype=compute_dtype,\n",
|
| 532 |
+
" bnb_4bit_use_double_quant=False,\n",
|
| 533 |
+
")"
|
| 534 |
+
],
|
| 535 |
+
"metadata": {
|
| 536 |
+
"id": "CWdKioPXQdF2"
|
| 537 |
+
},
|
| 538 |
+
"execution_count": 8,
|
| 539 |
+
"outputs": []
|
| 540 |
+
},
|
| 541 |
+
{
|
| 542 |
+
"cell_type": "code",
|
| 543 |
+
"source": [
|
| 544 |
+
"#Loading Llama 2 model\n",
|
| 545 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
| 546 |
+
" base_model,\n",
|
| 547 |
+
" quantization_config=quant_config,\n",
|
| 548 |
+
" device_map={\"\": 0}\n",
|
| 549 |
+
")\n",
|
| 550 |
+
"model.config.use_cache = False\n",
|
| 551 |
+
"model.config.pretraining_tp = 1"
|
| 552 |
+
],
|
| 553 |
+
"metadata": {
|
| 554 |
+
"colab": {
|
| 555 |
+
"base_uri": "https://localhost:8080/",
|
| 556 |
+
"height": 49,
|
| 557 |
+
"referenced_widgets": [
|
| 558 |
+
"cb82c295aa304cbab2c037caffc8d8d1",
|
| 559 |
+
"67367bae31384088aa07fc80aa68a081",
|
| 560 |
+
"ed5621e9730641379c6b1c740c43ec1f",
|
| 561 |
+
"4c31c17d684d434b88481c42404d5582",
|
| 562 |
+
"9e300fa0cd094325ac4ce2f1aa5cca8b",
|
| 563 |
+
"2d58b05027644ae49d0d1c9b7a8c9f90",
|
| 564 |
+
"0e9108eb5ada489a93719771ba9a8903",
|
| 565 |
+
"8fea9e36d8a948c4a93e9613df9f9f48",
|
| 566 |
+
"51e33ef50f6f48e1b6c7d3da4ade7819",
|
| 567 |
+
"16ba2159038e4dafac854a238854cc93",
|
| 568 |
+
"b15a25c37e714190a8a3032ce16d8944"
|
| 569 |
+
]
|
| 570 |
+
},
|
| 571 |
+
"id": "yBKf8xyAQdIx",
|
| 572 |
+
"outputId": "90423d17-f99a-425f-9696-1309b370ce62"
|
| 573 |
+
},
|
| 574 |
+
"execution_count": 9,
|
| 575 |
+
"outputs": [
|
| 576 |
+
{
|
| 577 |
+
"output_type": "display_data",
|
| 578 |
+
"data": {
|
| 579 |
+
"text/plain": [
|
| 580 |
+
"Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s]"
|
| 581 |
+
],
|
| 582 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 583 |
+
"version_major": 2,
|
| 584 |
+
"version_minor": 0,
|
| 585 |
+
"model_id": "cb82c295aa304cbab2c037caffc8d8d1"
|
| 586 |
+
}
|
| 587 |
+
},
|
| 588 |
+
"metadata": {}
|
| 589 |
+
}
|
| 590 |
+
]
|
| 591 |
+
},
|
| 592 |
+
{
|
| 593 |
+
"cell_type": "code",
|
| 594 |
+
"source": [
|
| 595 |
+
"#Loading tokenizer"
|
| 596 |
+
],
|
| 597 |
+
"metadata": {
|
| 598 |
+
"id": "JVgUFEy2Rffs"
|
| 599 |
+
},
|
| 600 |
+
"execution_count": null,
|
| 601 |
+
"outputs": []
|
| 602 |
+
},
|
| 603 |
+
{
|
| 604 |
+
"cell_type": "code",
|
| 605 |
+
"source": [
|
| 606 |
+
"tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)\n",
|
| 607 |
+
"tokenizer.pad_token = tokenizer.eos_token\n",
|
| 608 |
+
"tokenizer.padding_side = \"right\""
|
| 609 |
+
],
|
| 610 |
+
"metadata": {
|
| 611 |
+
"id": "lPpE8LhQQdLd"
|
| 612 |
+
},
|
| 613 |
+
"execution_count": 10,
|
| 614 |
+
"outputs": []
|
| 615 |
+
},
|
| 616 |
+
{
|
| 617 |
+
"cell_type": "code",
|
| 618 |
+
"source": [
|
| 619 |
+
"#PEFT parameters"
|
| 620 |
+
],
|
| 621 |
+
"metadata": {
|
| 622 |
+
"id": "lUW2z345QdOI"
|
| 623 |
+
},
|
| 624 |
+
"execution_count": 11,
|
| 625 |
+
"outputs": []
|
| 626 |
+
},
|
| 627 |
+
{
|
| 628 |
+
"cell_type": "code",
|
| 629 |
+
"source": [
|
| 630 |
+
"peft_params = LoraConfig(\n",
|
| 631 |
+
" lora_alpha=16,\n",
|
| 632 |
+
" lora_dropout=0.1,\n",
|
| 633 |
+
" r=64,\n",
|
| 634 |
+
" bias=\"none\",\n",
|
| 635 |
+
" task_type=\"CAUSAL_LM\",\n",
|
| 636 |
+
")"
|
| 637 |
+
],
|
| 638 |
+
"metadata": {
|
| 639 |
+
"id": "jdspWkWcQdQq"
|
| 640 |
+
},
|
| 641 |
+
"execution_count": 12,
|
| 642 |
+
"outputs": []
|
| 643 |
+
},
|
| 644 |
+
{
|
| 645 |
+
"cell_type": "code",
|
| 646 |
+
"source": [
|
| 647 |
+
"#Training parameters"
|
| 648 |
+
],
|
| 649 |
+
"metadata": {
|
| 650 |
+
"id": "M-SkbgDRQdTq"
|
| 651 |
+
},
|
| 652 |
+
"execution_count": null,
|
| 653 |
+
"outputs": []
|
| 654 |
+
},
|
| 655 |
+
{
|
| 656 |
+
"cell_type": "code",
|
| 657 |
+
"source": [
|
| 658 |
+
"training_params = TrainingArguments(\n",
|
| 659 |
+
" output_dir=\"./results\",\n",
|
| 660 |
+
" num_train_epochs=1,\n",
|
| 661 |
+
" per_device_train_batch_size=4,\n",
|
| 662 |
+
" gradient_accumulation_steps=1,\n",
|
| 663 |
+
" optim=\"paged_adamw_32bit\",\n",
|
| 664 |
+
" save_steps=25,\n",
|
| 665 |
+
" logging_steps=25,\n",
|
| 666 |
+
" learning_rate=2e-4,\n",
|
| 667 |
+
" weight_decay=0.001,\n",
|
| 668 |
+
" fp16=False,\n",
|
| 669 |
+
" bf16=False,\n",
|
| 670 |
+
" max_grad_norm=0.3,\n",
|
| 671 |
+
" max_steps=-1,\n",
|
| 672 |
+
" warmup_ratio=0.03,\n",
|
| 673 |
+
" group_by_length=True,\n",
|
| 674 |
+
" lr_scheduler_type=\"constant\",\n",
|
| 675 |
+
" report_to=\"tensorboard\"\n",
|
| 676 |
+
")"
|
| 677 |
+
],
|
| 678 |
+
"metadata": {
|
| 679 |
+
"id": "ROCMS2d4QdW9"
|
| 680 |
+
},
|
| 681 |
+
"execution_count": 13,
|
| 682 |
+
"outputs": []
|
| 683 |
+
},
|
| 684 |
+
{
|
| 685 |
+
"cell_type": "code",
|
| 686 |
+
"source": [
|
| 687 |
+
"#Model fine-tuning"
|
| 688 |
+
],
|
| 689 |
+
"metadata": {
|
| 690 |
+
"id": "mZdeHuytQdZ5"
|
| 691 |
+
},
|
| 692 |
+
"execution_count": null,
|
| 693 |
+
"outputs": []
|
| 694 |
+
},
|
| 695 |
+
{
|
| 696 |
+
"cell_type": "code",
|
| 697 |
+
"source": [
|
| 698 |
+
"trainer = SFTTrainer(\n",
|
| 699 |
+
" model=model,\n",
|
| 700 |
+
" train_dataset=dataset,\n",
|
| 701 |
+
" peft_config=peft_params,\n",
|
| 702 |
+
" dataset_text_field=\"text\",\n",
|
| 703 |
+
" max_seq_length=None,\n",
|
| 704 |
+
" tokenizer=tokenizer,\n",
|
| 705 |
+
" args=training_params,\n",
|
| 706 |
+
" packing=False,\n",
|
| 707 |
+
")"
|
| 708 |
+
],
|
| 709 |
+
"metadata": {
|
| 710 |
+
"colab": {
|
| 711 |
+
"base_uri": "https://localhost:8080/"
|
| 712 |
+
},
|
| 713 |
+
"id": "o1vMJ7x_Qdb-",
|
| 714 |
+
"outputId": "aa0a32e3-c400-4c41-cb2f-9e91558cb339"
|
| 715 |
+
},
|
| 716 |
+
"execution_count": 14,
|
| 717 |
+
"outputs": [
|
| 718 |
+
{
|
| 719 |
+
"output_type": "stream",
|
| 720 |
+
"name": "stderr",
|
| 721 |
+
"text": [
|
| 722 |
+
"/usr/local/lib/python3.10/dist-packages/peft/utils/other.py:102: FutureWarning: prepare_model_for_int8_training is deprecated and will be removed in a future version. Use prepare_model_for_kbit_training instead.\n",
|
| 723 |
+
" warnings.warn(\n",
|
| 724 |
+
"/usr/local/lib/python3.10/dist-packages/trl/trainer/sft_trainer.py:159: UserWarning: You didn't pass a `max_seq_length` argument to the SFTTrainer, this will default to 1024\n",
|
| 725 |
+
" warnings.warn(\n"
|
| 726 |
+
]
|
| 727 |
+
}
|
| 728 |
+
]
|
| 729 |
+
},
|
| 730 |
+
{
|
| 731 |
+
"cell_type": "code",
|
| 732 |
+
"source": [
|
| 733 |
+
"trainer.model.save_pretrained(new_model)\n",
|
| 734 |
+
"trainer.tokenizer.save_pretrained(new_model)\n"
|
| 735 |
+
],
|
| 736 |
+
"metadata": {
|
| 737 |
+
"colab": {
|
| 738 |
+
"base_uri": "https://localhost:8080/"
|
| 739 |
+
},
|
| 740 |
+
"id": "Zmoa7iLFUez7",
|
| 741 |
+
"outputId": "48c41a64-ad0f-475a-f186-f82d9df5a719"
|
| 742 |
+
},
|
| 743 |
+
"execution_count": 15,
|
| 744 |
+
"outputs": [
|
| 745 |
+
{
|
| 746 |
+
"output_type": "execute_result",
|
| 747 |
+
"data": {
|
| 748 |
+
"text/plain": [
|
| 749 |
+
"('llama/tokenizer_config.json',\n",
|
| 750 |
+
" 'llama/special_tokens_map.json',\n",
|
| 751 |
+
" 'llama/tokenizer.model',\n",
|
| 752 |
+
" 'llama/added_tokens.json',\n",
|
| 753 |
+
" 'llama/tokenizer.json')"
|
| 754 |
+
]
|
| 755 |
+
},
|
| 756 |
+
"metadata": {},
|
| 757 |
+
"execution_count": 15
|
| 758 |
+
}
|
| 759 |
+
]
|
| 760 |
+
},
|
| 761 |
+
{
|
| 762 |
+
"cell_type": "code",
|
| 763 |
+
"source": [
|
| 764 |
+
"logging.set_verbosity(logging.CRITICAL)\n",
|
| 765 |
+
"\n",
|
| 766 |
+
"prompt = input(\"Enter prompt here:- \")\n",
|
| 767 |
+
"pipe = pipeline(task=\"text-generation\", model=model, tokenizer=tokenizer, max_length=200)\n",
|
| 768 |
+
"result = pipe(f\"<s>[INST] {prompt} [/INST]\")\n",
|
| 769 |
+
"print(result[0]['generated_text'])"
|
| 770 |
+
],
|
| 771 |
+
"metadata": {
|
| 772 |
+
"colab": {
|
| 773 |
+
"base_uri": "https://localhost:8080/"
|
| 774 |
+
},
|
| 775 |
+
"id": "UiSr45NDQdrx",
|
| 776 |
+
"outputId": "6c610f76-cd4f-4467-e1a3-a1a7cbe7de85"
|
| 777 |
+
},
|
| 778 |
+
"execution_count": 16,
|
| 779 |
+
"outputs": [
|
| 780 |
+
{
|
| 781 |
+
"name": "stdout",
|
| 782 |
+
"output_type": "stream",
|
| 783 |
+
"text": [
|
| 784 |
+
"Enter prompt here:- sharad pawar\n"
|
| 785 |
+
]
|
| 786 |
+
},
|
| 787 |
+
{
|
| 788 |
+
"output_type": "stream",
|
| 789 |
+
"name": "stderr",
|
| 790 |
+
"text": [
|
| 791 |
+
"/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py:1270: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation )\n",
|
| 792 |
+
" warnings.warn(\n"
|
| 793 |
+
]
|
| 794 |
+
},
|
| 795 |
+
{
|
| 796 |
+
"output_type": "stream",
|
| 797 |
+
"name": "stdout",
|
| 798 |
+
"text": [
|
| 799 |
+
"<s>[INST] sharad pawar [/INST] Sharad Pawar is a prominent Indian politician and the current President of the Nationalist Congress Party (NCP). Here are some key facts about him:\n",
|
| 800 |
+
" Unterscheidung:\n",
|
| 801 |
+
"\n",
|
| 802 |
+
"1. Early life and education: Sharad Pawar was born on December 12, 1940, in the village of Baramati in the state of Maharashtra, India. He completed his primary education in Baramati and later moved to Mumbai to pursue his higher education.\n",
|
| 803 |
+
"2. Political career: Pawar began his political career in the 1960s as a member of the Janata Party. He later joined the Indian National Congress and became a member of the Maharashtra Legislative Assembly in 1978. He served as the Chief Minister of Maharashtra from 1978 to \n"
|
| 804 |
+
]
|
| 805 |
+
}
|
| 806 |
+
]
|
| 807 |
+
}
|
| 808 |
+
]
|
| 809 |
+
}
|