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+
"language_info": {
|
| 15 |
+
"name": "python"
|
| 16 |
+
},
|
| 17 |
+
"kernelspec": {
|
| 18 |
+
"name": "python3",
|
| 19 |
+
"display_name": "Python 3"
|
| 20 |
+
},
|
| 21 |
+
"widgets": {
|
| 22 |
+
"application/vnd.jupyter.widget-state+json": {
|
| 23 |
+
"b486eefffb274a1d89c401ee56f0ea7b": {
|
| 24 |
+
"model_module": "@jupyter-widgets/controls",
|
| 25 |
+
"model_name": "HBoxModel",
|
| 26 |
+
"model_module_version": "1.5.0",
|
| 27 |
+
"state": {
|
| 28 |
+
"_dom_classes": [],
|
| 29 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 30 |
+
"_model_module_version": "1.5.0",
|
| 31 |
+
"_model_name": "HBoxModel",
|
| 32 |
+
"_view_count": null,
|
| 33 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 34 |
+
"_view_module_version": "1.5.0",
|
| 35 |
+
"_view_name": "HBoxView",
|
| 36 |
+
"box_style": "",
|
| 37 |
+
"children": [
|
| 38 |
+
"IPY_MODEL_2757c39f0c9a4fa599bd2a7b58c3ad4a",
|
| 39 |
+
"IPY_MODEL_696a9b10ead84306a3886b2a5853eb7c",
|
| 40 |
+
"IPY_MODEL_d7684e7d23764317acc7bcc512944758"
|
| 41 |
+
],
|
| 42 |
+
"layout": "IPY_MODEL_e44dbcae75684967ae5a797d20c2ec16"
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"2757c39f0c9a4fa599bd2a7b58c3ad4a": {
|
| 46 |
+
"model_module": "@jupyter-widgets/controls",
|
| 47 |
+
"model_name": "HTMLModel",
|
| 48 |
+
"model_module_version": "1.5.0",
|
| 49 |
+
"state": {
|
| 50 |
+
"_dom_classes": [],
|
| 51 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 52 |
+
"_model_module_version": "1.5.0",
|
| 53 |
+
"_model_name": "HTMLModel",
|
| 54 |
+
"_view_count": null,
|
| 55 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 56 |
+
"_view_module_version": "1.5.0",
|
| 57 |
+
"_view_name": "HTMLView",
|
| 58 |
+
"description": "",
|
| 59 |
+
"description_tooltip": null,
|
| 60 |
+
"layout": "IPY_MODEL_f318babe826841ab96db9716af5adc5e",
|
| 61 |
+
"placeholder": "",
|
| 62 |
+
"style": "IPY_MODEL_fa14e7cbb0d14d56b5276d77f97f4315",
|
| 63 |
+
"value": "Loading weights: 100%"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"696a9b10ead84306a3886b2a5853eb7c": {
|
| 67 |
+
"model_module": "@jupyter-widgets/controls",
|
| 68 |
+
"model_name": "FloatProgressModel",
|
| 69 |
+
"model_module_version": "1.5.0",
|
| 70 |
+
"state": {
|
| 71 |
+
"_dom_classes": [],
|
| 72 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 73 |
+
"_model_module_version": "1.5.0",
|
| 74 |
+
"_model_name": "FloatProgressModel",
|
| 75 |
+
"_view_count": null,
|
| 76 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 77 |
+
"_view_module_version": "1.5.0",
|
| 78 |
+
"_view_name": "ProgressView",
|
| 79 |
+
"bar_style": "success",
|
| 80 |
+
"description": "",
|
| 81 |
+
"description_tooltip": null,
|
| 82 |
+
"layout": "IPY_MODEL_fd3f39e32b514e1f949a98ebc2922be0",
|
| 83 |
+
"max": 453,
|
| 84 |
+
"min": 0,
|
| 85 |
+
"orientation": "horizontal",
|
| 86 |
+
"style": "IPY_MODEL_e94a0224955143e59fb03000dff11208",
|
| 87 |
+
"value": 453
|
| 88 |
+
}
|
| 89 |
+
},
|
| 90 |
+
"d7684e7d23764317acc7bcc512944758": {
|
| 91 |
+
"model_module": "@jupyter-widgets/controls",
|
| 92 |
+
"model_name": "HTMLModel",
|
| 93 |
+
"model_module_version": "1.5.0",
|
| 94 |
+
"state": {
|
| 95 |
+
"_dom_classes": [],
|
| 96 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 97 |
+
"_model_module_version": "1.5.0",
|
| 98 |
+
"_model_name": "HTMLModel",
|
| 99 |
+
"_view_count": null,
|
| 100 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 101 |
+
"_view_module_version": "1.5.0",
|
| 102 |
+
"_view_name": "HTMLView",
|
| 103 |
+
"description": "",
|
| 104 |
+
"description_tooltip": null,
|
| 105 |
+
"layout": "IPY_MODEL_51f5cb0a06e84813a224e51e8a11c128",
|
| 106 |
+
"placeholder": "",
|
| 107 |
+
"style": "IPY_MODEL_adc120af345247d6b3de0611e6d44490",
|
| 108 |
+
"value": " 453/453 [00:00<00:00, 611.00it/s, Materializing param=model.layers.31.self_attn.v_proj.weight]"
|
| 109 |
+
}
|
| 110 |
+
},
|
| 111 |
+
"e44dbcae75684967ae5a797d20c2ec16": {
|
| 112 |
+
"model_module": "@jupyter-widgets/base",
|
| 113 |
+
"model_name": "LayoutModel",
|
| 114 |
+
"model_module_version": "1.2.0",
|
| 115 |
+
"state": {
|
| 116 |
+
"_model_module": "@jupyter-widgets/base",
|
| 117 |
+
"_model_module_version": "1.2.0",
|
| 118 |
+
"_model_name": "LayoutModel",
|
| 119 |
+
"_view_count": null,
|
| 120 |
+
"_view_module": "@jupyter-widgets/base",
|
| 121 |
+
"_view_module_version": "1.2.0",
|
| 122 |
+
"_view_name": "LayoutView",
|
| 123 |
+
"align_content": null,
|
| 124 |
+
"align_items": null,
|
| 125 |
+
"align_self": null,
|
| 126 |
+
"border": null,
|
| 127 |
+
"bottom": null,
|
| 128 |
+
"display": null,
|
| 129 |
+
"flex": null,
|
| 130 |
+
"flex_flow": null,
|
| 131 |
+
"grid_area": null,
|
| 132 |
+
"grid_auto_columns": null,
|
| 133 |
+
"grid_auto_flow": null,
|
| 134 |
+
"grid_auto_rows": null,
|
| 135 |
+
"grid_column": null,
|
| 136 |
+
"grid_gap": null,
|
| 137 |
+
"grid_row": null,
|
| 138 |
+
"grid_template_areas": null,
|
| 139 |
+
"grid_template_columns": null,
|
| 140 |
+
"grid_template_rows": null,
|
| 141 |
+
"height": null,
|
| 142 |
+
"justify_content": null,
|
| 143 |
+
"justify_items": null,
|
| 144 |
+
"left": null,
|
| 145 |
+
"margin": null,
|
| 146 |
+
"max_height": null,
|
| 147 |
+
"max_width": null,
|
| 148 |
+
"min_height": null,
|
| 149 |
+
"min_width": null,
|
| 150 |
+
"object_fit": null,
|
| 151 |
+
"object_position": null,
|
| 152 |
+
"order": null,
|
| 153 |
+
"overflow": null,
|
| 154 |
+
"overflow_x": null,
|
| 155 |
+
"overflow_y": null,
|
| 156 |
+
"padding": null,
|
| 157 |
+
"right": null,
|
| 158 |
+
"top": null,
|
| 159 |
+
"visibility": null,
|
| 160 |
+
"width": null
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
"f318babe826841ab96db9716af5adc5e": {
|
| 164 |
+
"model_module": "@jupyter-widgets/base",
|
| 165 |
+
"model_name": "LayoutModel",
|
| 166 |
+
"model_module_version": "1.2.0",
|
| 167 |
+
"state": {
|
| 168 |
+
"_model_module": "@jupyter-widgets/base",
|
| 169 |
+
"_model_module_version": "1.2.0",
|
| 170 |
+
"_model_name": "LayoutModel",
|
| 171 |
+
"_view_count": null,
|
| 172 |
+
"_view_module": "@jupyter-widgets/base",
|
| 173 |
+
"_view_module_version": "1.2.0",
|
| 174 |
+
"_view_name": "LayoutView",
|
| 175 |
+
"align_content": null,
|
| 176 |
+
"align_items": null,
|
| 177 |
+
"align_self": null,
|
| 178 |
+
"border": null,
|
| 179 |
+
"bottom": null,
|
| 180 |
+
"display": null,
|
| 181 |
+
"flex": null,
|
| 182 |
+
"flex_flow": null,
|
| 183 |
+
"grid_area": null,
|
| 184 |
+
"grid_auto_columns": null,
|
| 185 |
+
"grid_auto_flow": null,
|
| 186 |
+
"grid_auto_rows": null,
|
| 187 |
+
"grid_column": null,
|
| 188 |
+
"grid_gap": null,
|
| 189 |
+
"grid_row": null,
|
| 190 |
+
"grid_template_areas": null,
|
| 191 |
+
"grid_template_columns": null,
|
| 192 |
+
"grid_template_rows": null,
|
| 193 |
+
"height": null,
|
| 194 |
+
"justify_content": null,
|
| 195 |
+
"justify_items": null,
|
| 196 |
+
"left": null,
|
| 197 |
+
"margin": null,
|
| 198 |
+
"max_height": null,
|
| 199 |
+
"max_width": null,
|
| 200 |
+
"min_height": null,
|
| 201 |
+
"min_width": null,
|
| 202 |
+
"object_fit": null,
|
| 203 |
+
"object_position": null,
|
| 204 |
+
"order": null,
|
| 205 |
+
"overflow": null,
|
| 206 |
+
"overflow_x": null,
|
| 207 |
+
"overflow_y": null,
|
| 208 |
+
"padding": null,
|
| 209 |
+
"right": null,
|
| 210 |
+
"top": null,
|
| 211 |
+
"visibility": null,
|
| 212 |
+
"width": null
|
| 213 |
+
}
|
| 214 |
+
},
|
| 215 |
+
"fa14e7cbb0d14d56b5276d77f97f4315": {
|
| 216 |
+
"model_module": "@jupyter-widgets/controls",
|
| 217 |
+
"model_name": "DescriptionStyleModel",
|
| 218 |
+
"model_module_version": "1.5.0",
|
| 219 |
+
"state": {
|
| 220 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 221 |
+
"_model_module_version": "1.5.0",
|
| 222 |
+
"_model_name": "DescriptionStyleModel",
|
| 223 |
+
"_view_count": null,
|
| 224 |
+
"_view_module": "@jupyter-widgets/base",
|
| 225 |
+
"_view_module_version": "1.2.0",
|
| 226 |
+
"_view_name": "StyleView",
|
| 227 |
+
"description_width": ""
|
| 228 |
+
}
|
| 229 |
+
},
|
| 230 |
+
"fd3f39e32b514e1f949a98ebc2922be0": {
|
| 231 |
+
"model_module": "@jupyter-widgets/base",
|
| 232 |
+
"model_name": "LayoutModel",
|
| 233 |
+
"model_module_version": "1.2.0",
|
| 234 |
+
"state": {
|
| 235 |
+
"_model_module": "@jupyter-widgets/base",
|
| 236 |
+
"_model_module_version": "1.2.0",
|
| 237 |
+
"_model_name": "LayoutModel",
|
| 238 |
+
"_view_count": null,
|
| 239 |
+
"_view_module": "@jupyter-widgets/base",
|
| 240 |
+
"_view_module_version": "1.2.0",
|
| 241 |
+
"_view_name": "LayoutView",
|
| 242 |
+
"align_content": null,
|
| 243 |
+
"align_items": null,
|
| 244 |
+
"align_self": null,
|
| 245 |
+
"border": null,
|
| 246 |
+
"bottom": null,
|
| 247 |
+
"display": null,
|
| 248 |
+
"flex": null,
|
| 249 |
+
"flex_flow": null,
|
| 250 |
+
"grid_area": null,
|
| 251 |
+
"grid_auto_columns": null,
|
| 252 |
+
"grid_auto_flow": null,
|
| 253 |
+
"grid_auto_rows": null,
|
| 254 |
+
"grid_column": null,
|
| 255 |
+
"grid_gap": null,
|
| 256 |
+
"grid_row": null,
|
| 257 |
+
"grid_template_areas": null,
|
| 258 |
+
"grid_template_columns": null,
|
| 259 |
+
"grid_template_rows": null,
|
| 260 |
+
"height": null,
|
| 261 |
+
"justify_content": null,
|
| 262 |
+
"justify_items": null,
|
| 263 |
+
"left": null,
|
| 264 |
+
"margin": null,
|
| 265 |
+
"max_height": null,
|
| 266 |
+
"max_width": null,
|
| 267 |
+
"min_height": null,
|
| 268 |
+
"min_width": null,
|
| 269 |
+
"object_fit": null,
|
| 270 |
+
"object_position": null,
|
| 271 |
+
"order": null,
|
| 272 |
+
"overflow": null,
|
| 273 |
+
"overflow_x": null,
|
| 274 |
+
"overflow_y": null,
|
| 275 |
+
"padding": null,
|
| 276 |
+
"right": null,
|
| 277 |
+
"top": null,
|
| 278 |
+
"visibility": null,
|
| 279 |
+
"width": null
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
"e94a0224955143e59fb03000dff11208": {
|
| 283 |
+
"model_module": "@jupyter-widgets/controls",
|
| 284 |
+
"model_name": "ProgressStyleModel",
|
| 285 |
+
"model_module_version": "1.5.0",
|
| 286 |
+
"state": {
|
| 287 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 288 |
+
"_model_module_version": "1.5.0",
|
| 289 |
+
"_model_name": "ProgressStyleModel",
|
| 290 |
+
"_view_count": null,
|
| 291 |
+
"_view_module": "@jupyter-widgets/base",
|
| 292 |
+
"_view_module_version": "1.2.0",
|
| 293 |
+
"_view_name": "StyleView",
|
| 294 |
+
"bar_color": null,
|
| 295 |
+
"description_width": ""
|
| 296 |
+
}
|
| 297 |
+
},
|
| 298 |
+
"51f5cb0a06e84813a224e51e8a11c128": {
|
| 299 |
+
"model_module": "@jupyter-widgets/base",
|
| 300 |
+
"model_name": "LayoutModel",
|
| 301 |
+
"model_module_version": "1.2.0",
|
| 302 |
+
"state": {
|
| 303 |
+
"_model_module": "@jupyter-widgets/base",
|
| 304 |
+
"_model_module_version": "1.2.0",
|
| 305 |
+
"_model_name": "LayoutModel",
|
| 306 |
+
"_view_count": null,
|
| 307 |
+
"_view_module": "@jupyter-widgets/base",
|
| 308 |
+
"_view_module_version": "1.2.0",
|
| 309 |
+
"_view_name": "LayoutView",
|
| 310 |
+
"align_content": null,
|
| 311 |
+
"align_items": null,
|
| 312 |
+
"align_self": null,
|
| 313 |
+
"border": null,
|
| 314 |
+
"bottom": null,
|
| 315 |
+
"display": null,
|
| 316 |
+
"flex": null,
|
| 317 |
+
"flex_flow": null,
|
| 318 |
+
"grid_area": null,
|
| 319 |
+
"grid_auto_columns": null,
|
| 320 |
+
"grid_auto_flow": null,
|
| 321 |
+
"grid_auto_rows": null,
|
| 322 |
+
"grid_column": null,
|
| 323 |
+
"grid_gap": null,
|
| 324 |
+
"grid_row": null,
|
| 325 |
+
"grid_template_areas": null,
|
| 326 |
+
"grid_template_columns": null,
|
| 327 |
+
"grid_template_rows": null,
|
| 328 |
+
"height": null,
|
| 329 |
+
"justify_content": null,
|
| 330 |
+
"justify_items": null,
|
| 331 |
+
"left": null,
|
| 332 |
+
"margin": null,
|
| 333 |
+
"max_height": null,
|
| 334 |
+
"max_width": null,
|
| 335 |
+
"min_height": null,
|
| 336 |
+
"min_width": null,
|
| 337 |
+
"object_fit": null,
|
| 338 |
+
"object_position": null,
|
| 339 |
+
"order": null,
|
| 340 |
+
"overflow": null,
|
| 341 |
+
"overflow_x": null,
|
| 342 |
+
"overflow_y": null,
|
| 343 |
+
"padding": null,
|
| 344 |
+
"right": null,
|
| 345 |
+
"top": null,
|
| 346 |
+
"visibility": null,
|
| 347 |
+
"width": null
|
| 348 |
+
}
|
| 349 |
+
},
|
| 350 |
+
"adc120af345247d6b3de0611e6d44490": {
|
| 351 |
+
"model_module": "@jupyter-widgets/controls",
|
| 352 |
+
"model_name": "DescriptionStyleModel",
|
| 353 |
+
"model_module_version": "1.5.0",
|
| 354 |
+
"state": {
|
| 355 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 356 |
+
"_model_module_version": "1.5.0",
|
| 357 |
+
"_model_name": "DescriptionStyleModel",
|
| 358 |
+
"_view_count": null,
|
| 359 |
+
"_view_module": "@jupyter-widgets/base",
|
| 360 |
+
"_view_module_version": "1.2.0",
|
| 361 |
+
"_view_name": "StyleView",
|
| 362 |
+
"description_width": ""
|
| 363 |
+
}
|
| 364 |
+
},
|
| 365 |
+
"1e548b10c6b44b5fb6ea8687d94486f7": {
|
| 366 |
+
"model_module": "@jupyter-widgets/controls",
|
| 367 |
+
"model_name": "HBoxModel",
|
| 368 |
+
"model_module_version": "1.5.0",
|
| 369 |
+
"state": {
|
| 370 |
+
"_dom_classes": [],
|
| 371 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 372 |
+
"_model_module_version": "1.5.0",
|
| 373 |
+
"_model_name": "HBoxModel",
|
| 374 |
+
"_view_count": null,
|
| 375 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 376 |
+
"_view_module_version": "1.5.0",
|
| 377 |
+
"_view_name": "HBoxView",
|
| 378 |
+
"box_style": "",
|
| 379 |
+
"children": [
|
| 380 |
+
"IPY_MODEL_603cb08fbfdf4aa5bb1072da1501116f",
|
| 381 |
+
"IPY_MODEL_b30d2933522342bb8df152670e068a61",
|
| 382 |
+
"IPY_MODEL_c04efaac2bd042618f7d4923ec2be8c0"
|
| 383 |
+
],
|
| 384 |
+
"layout": "IPY_MODEL_90559a506ecb4f46a345855a05cfc2d4"
|
| 385 |
+
}
|
| 386 |
+
},
|
| 387 |
+
"603cb08fbfdf4aa5bb1072da1501116f": {
|
| 388 |
+
"model_module": "@jupyter-widgets/controls",
|
| 389 |
+
"model_name": "HTMLModel",
|
| 390 |
+
"model_module_version": "1.5.0",
|
| 391 |
+
"state": {
|
| 392 |
+
"_dom_classes": [],
|
| 393 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 394 |
+
"_model_module_version": "1.5.0",
|
| 395 |
+
"_model_name": "HTMLModel",
|
| 396 |
+
"_view_count": null,
|
| 397 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 398 |
+
"_view_module_version": "1.5.0",
|
| 399 |
+
"_view_name": "HTMLView",
|
| 400 |
+
"description": "",
|
| 401 |
+
"description_tooltip": null,
|
| 402 |
+
"layout": "IPY_MODEL_e36f24e96c9a4941a071ad0a10e486af",
|
| 403 |
+
"placeholder": "",
|
| 404 |
+
"style": "IPY_MODEL_e2962aae45854cc39eb90fdbcef0f460",
|
| 405 |
+
"value": "Loading weights: 100%"
|
| 406 |
+
}
|
| 407 |
+
},
|
| 408 |
+
"b30d2933522342bb8df152670e068a61": {
|
| 409 |
+
"model_module": "@jupyter-widgets/controls",
|
| 410 |
+
"model_name": "FloatProgressModel",
|
| 411 |
+
"model_module_version": "1.5.0",
|
| 412 |
+
"state": {
|
| 413 |
+
"_dom_classes": [],
|
| 414 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 415 |
+
"_model_module_version": "1.5.0",
|
| 416 |
+
"_model_name": "FloatProgressModel",
|
| 417 |
+
"_view_count": null,
|
| 418 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 419 |
+
"_view_module_version": "1.5.0",
|
| 420 |
+
"_view_name": "ProgressView",
|
| 421 |
+
"bar_style": "success",
|
| 422 |
+
"description": "",
|
| 423 |
+
"description_tooltip": null,
|
| 424 |
+
"layout": "IPY_MODEL_b004dc925fb64e43ae97d73788648ef7",
|
| 425 |
+
"max": 453,
|
| 426 |
+
"min": 0,
|
| 427 |
+
"orientation": "horizontal",
|
| 428 |
+
"style": "IPY_MODEL_c76b9cb1d93b48829805003ed178a2fa",
|
| 429 |
+
"value": 453
|
| 430 |
+
}
|
| 431 |
+
},
|
| 432 |
+
"c04efaac2bd042618f7d4923ec2be8c0": {
|
| 433 |
+
"model_module": "@jupyter-widgets/controls",
|
| 434 |
+
"model_name": "HTMLModel",
|
| 435 |
+
"model_module_version": "1.5.0",
|
| 436 |
+
"state": {
|
| 437 |
+
"_dom_classes": [],
|
| 438 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 439 |
+
"_model_module_version": "1.5.0",
|
| 440 |
+
"_model_name": "HTMLModel",
|
| 441 |
+
"_view_count": null,
|
| 442 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 443 |
+
"_view_module_version": "1.5.0",
|
| 444 |
+
"_view_name": "HTMLView",
|
| 445 |
+
"description": "",
|
| 446 |
+
"description_tooltip": null,
|
| 447 |
+
"layout": "IPY_MODEL_19103b3d686c4da994dc68912fe162b6",
|
| 448 |
+
"placeholder": "",
|
| 449 |
+
"style": "IPY_MODEL_f3a46d6eebe04dd3894cb893ca8bc58a",
|
| 450 |
+
"value": " 453/453 [00:01<00:00, 404.11it/s, Materializing param=model.layers.31.self_attn.v_proj.weight]"
|
| 451 |
+
}
|
| 452 |
+
},
|
| 453 |
+
"90559a506ecb4f46a345855a05cfc2d4": {
|
| 454 |
+
"model_module": "@jupyter-widgets/base",
|
| 455 |
+
"model_name": "LayoutModel",
|
| 456 |
+
"model_module_version": "1.2.0",
|
| 457 |
+
"state": {
|
| 458 |
+
"_model_module": "@jupyter-widgets/base",
|
| 459 |
+
"_model_module_version": "1.2.0",
|
| 460 |
+
"_model_name": "LayoutModel",
|
| 461 |
+
"_view_count": null,
|
| 462 |
+
"_view_module": "@jupyter-widgets/base",
|
| 463 |
+
"_view_module_version": "1.2.0",
|
| 464 |
+
"_view_name": "LayoutView",
|
| 465 |
+
"align_content": null,
|
| 466 |
+
"align_items": null,
|
| 467 |
+
"align_self": null,
|
| 468 |
+
"border": null,
|
| 469 |
+
"bottom": null,
|
| 470 |
+
"display": null,
|
| 471 |
+
"flex": null,
|
| 472 |
+
"flex_flow": null,
|
| 473 |
+
"grid_area": null,
|
| 474 |
+
"grid_auto_columns": null,
|
| 475 |
+
"grid_auto_flow": null,
|
| 476 |
+
"grid_auto_rows": null,
|
| 477 |
+
"grid_column": null,
|
| 478 |
+
"grid_gap": null,
|
| 479 |
+
"grid_row": null,
|
| 480 |
+
"grid_template_areas": null,
|
| 481 |
+
"grid_template_columns": null,
|
| 482 |
+
"grid_template_rows": null,
|
| 483 |
+
"height": null,
|
| 484 |
+
"justify_content": null,
|
| 485 |
+
"justify_items": null,
|
| 486 |
+
"left": null,
|
| 487 |
+
"margin": null,
|
| 488 |
+
"max_height": null,
|
| 489 |
+
"max_width": null,
|
| 490 |
+
"min_height": null,
|
| 491 |
+
"min_width": null,
|
| 492 |
+
"object_fit": null,
|
| 493 |
+
"object_position": null,
|
| 494 |
+
"order": null,
|
| 495 |
+
"overflow": null,
|
| 496 |
+
"overflow_x": null,
|
| 497 |
+
"overflow_y": null,
|
| 498 |
+
"padding": null,
|
| 499 |
+
"right": null,
|
| 500 |
+
"top": null,
|
| 501 |
+
"visibility": null,
|
| 502 |
+
"width": null
|
| 503 |
+
}
|
| 504 |
+
},
|
| 505 |
+
"e36f24e96c9a4941a071ad0a10e486af": {
|
| 506 |
+
"model_module": "@jupyter-widgets/base",
|
| 507 |
+
"model_name": "LayoutModel",
|
| 508 |
+
"model_module_version": "1.2.0",
|
| 509 |
+
"state": {
|
| 510 |
+
"_model_module": "@jupyter-widgets/base",
|
| 511 |
+
"_model_module_version": "1.2.0",
|
| 512 |
+
"_model_name": "LayoutModel",
|
| 513 |
+
"_view_count": null,
|
| 514 |
+
"_view_module": "@jupyter-widgets/base",
|
| 515 |
+
"_view_module_version": "1.2.0",
|
| 516 |
+
"_view_name": "LayoutView",
|
| 517 |
+
"align_content": null,
|
| 518 |
+
"align_items": null,
|
| 519 |
+
"align_self": null,
|
| 520 |
+
"border": null,
|
| 521 |
+
"bottom": null,
|
| 522 |
+
"display": null,
|
| 523 |
+
"flex": null,
|
| 524 |
+
"flex_flow": null,
|
| 525 |
+
"grid_area": null,
|
| 526 |
+
"grid_auto_columns": null,
|
| 527 |
+
"grid_auto_flow": null,
|
| 528 |
+
"grid_auto_rows": null,
|
| 529 |
+
"grid_column": null,
|
| 530 |
+
"grid_gap": null,
|
| 531 |
+
"grid_row": null,
|
| 532 |
+
"grid_template_areas": null,
|
| 533 |
+
"grid_template_columns": null,
|
| 534 |
+
"grid_template_rows": null,
|
| 535 |
+
"height": null,
|
| 536 |
+
"justify_content": null,
|
| 537 |
+
"justify_items": null,
|
| 538 |
+
"left": null,
|
| 539 |
+
"margin": null,
|
| 540 |
+
"max_height": null,
|
| 541 |
+
"max_width": null,
|
| 542 |
+
"min_height": null,
|
| 543 |
+
"min_width": null,
|
| 544 |
+
"object_fit": null,
|
| 545 |
+
"object_position": null,
|
| 546 |
+
"order": null,
|
| 547 |
+
"overflow": null,
|
| 548 |
+
"overflow_x": null,
|
| 549 |
+
"overflow_y": null,
|
| 550 |
+
"padding": null,
|
| 551 |
+
"right": null,
|
| 552 |
+
"top": null,
|
| 553 |
+
"visibility": null,
|
| 554 |
+
"width": null
|
| 555 |
+
}
|
| 556 |
+
},
|
| 557 |
+
"e2962aae45854cc39eb90fdbcef0f460": {
|
| 558 |
+
"model_module": "@jupyter-widgets/controls",
|
| 559 |
+
"model_name": "DescriptionStyleModel",
|
| 560 |
+
"model_module_version": "1.5.0",
|
| 561 |
+
"state": {
|
| 562 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 563 |
+
"_model_module_version": "1.5.0",
|
| 564 |
+
"_model_name": "DescriptionStyleModel",
|
| 565 |
+
"_view_count": null,
|
| 566 |
+
"_view_module": "@jupyter-widgets/base",
|
| 567 |
+
"_view_module_version": "1.2.0",
|
| 568 |
+
"_view_name": "StyleView",
|
| 569 |
+
"description_width": ""
|
| 570 |
+
}
|
| 571 |
+
},
|
| 572 |
+
"b004dc925fb64e43ae97d73788648ef7": {
|
| 573 |
+
"model_module": "@jupyter-widgets/base",
|
| 574 |
+
"model_name": "LayoutModel",
|
| 575 |
+
"model_module_version": "1.2.0",
|
| 576 |
+
"state": {
|
| 577 |
+
"_model_module": "@jupyter-widgets/base",
|
| 578 |
+
"_model_module_version": "1.2.0",
|
| 579 |
+
"_model_name": "LayoutModel",
|
| 580 |
+
"_view_count": null,
|
| 581 |
+
"_view_module": "@jupyter-widgets/base",
|
| 582 |
+
"_view_module_version": "1.2.0",
|
| 583 |
+
"_view_name": "LayoutView",
|
| 584 |
+
"align_content": null,
|
| 585 |
+
"align_items": null,
|
| 586 |
+
"align_self": null,
|
| 587 |
+
"border": null,
|
| 588 |
+
"bottom": null,
|
| 589 |
+
"display": null,
|
| 590 |
+
"flex": null,
|
| 591 |
+
"flex_flow": null,
|
| 592 |
+
"grid_area": null,
|
| 593 |
+
"grid_auto_columns": null,
|
| 594 |
+
"grid_auto_flow": null,
|
| 595 |
+
"grid_auto_rows": null,
|
| 596 |
+
"grid_column": null,
|
| 597 |
+
"grid_gap": null,
|
| 598 |
+
"grid_row": null,
|
| 599 |
+
"grid_template_areas": null,
|
| 600 |
+
"grid_template_columns": null,
|
| 601 |
+
"grid_template_rows": null,
|
| 602 |
+
"height": null,
|
| 603 |
+
"justify_content": null,
|
| 604 |
+
"justify_items": null,
|
| 605 |
+
"left": null,
|
| 606 |
+
"margin": null,
|
| 607 |
+
"max_height": null,
|
| 608 |
+
"max_width": null,
|
| 609 |
+
"min_height": null,
|
| 610 |
+
"min_width": null,
|
| 611 |
+
"object_fit": null,
|
| 612 |
+
"object_position": null,
|
| 613 |
+
"order": null,
|
| 614 |
+
"overflow": null,
|
| 615 |
+
"overflow_x": null,
|
| 616 |
+
"overflow_y": null,
|
| 617 |
+
"padding": null,
|
| 618 |
+
"right": null,
|
| 619 |
+
"top": null,
|
| 620 |
+
"visibility": null,
|
| 621 |
+
"width": null
|
| 622 |
+
}
|
| 623 |
+
},
|
| 624 |
+
"c76b9cb1d93b48829805003ed178a2fa": {
|
| 625 |
+
"model_module": "@jupyter-widgets/controls",
|
| 626 |
+
"model_name": "ProgressStyleModel",
|
| 627 |
+
"model_module_version": "1.5.0",
|
| 628 |
+
"state": {
|
| 629 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 630 |
+
"_model_module_version": "1.5.0",
|
| 631 |
+
"_model_name": "ProgressStyleModel",
|
| 632 |
+
"_view_count": null,
|
| 633 |
+
"_view_module": "@jupyter-widgets/base",
|
| 634 |
+
"_view_module_version": "1.2.0",
|
| 635 |
+
"_view_name": "StyleView",
|
| 636 |
+
"bar_color": null,
|
| 637 |
+
"description_width": ""
|
| 638 |
+
}
|
| 639 |
+
},
|
| 640 |
+
"19103b3d686c4da994dc68912fe162b6": {
|
| 641 |
+
"model_module": "@jupyter-widgets/base",
|
| 642 |
+
"model_name": "LayoutModel",
|
| 643 |
+
"model_module_version": "1.2.0",
|
| 644 |
+
"state": {
|
| 645 |
+
"_model_module": "@jupyter-widgets/base",
|
| 646 |
+
"_model_module_version": "1.2.0",
|
| 647 |
+
"_model_name": "LayoutModel",
|
| 648 |
+
"_view_count": null,
|
| 649 |
+
"_view_module": "@jupyter-widgets/base",
|
| 650 |
+
"_view_module_version": "1.2.0",
|
| 651 |
+
"_view_name": "LayoutView",
|
| 652 |
+
"align_content": null,
|
| 653 |
+
"align_items": null,
|
| 654 |
+
"align_self": null,
|
| 655 |
+
"border": null,
|
| 656 |
+
"bottom": null,
|
| 657 |
+
"display": null,
|
| 658 |
+
"flex": null,
|
| 659 |
+
"flex_flow": null,
|
| 660 |
+
"grid_area": null,
|
| 661 |
+
"grid_auto_columns": null,
|
| 662 |
+
"grid_auto_flow": null,
|
| 663 |
+
"grid_auto_rows": null,
|
| 664 |
+
"grid_column": null,
|
| 665 |
+
"grid_gap": null,
|
| 666 |
+
"grid_row": null,
|
| 667 |
+
"grid_template_areas": null,
|
| 668 |
+
"grid_template_columns": null,
|
| 669 |
+
"grid_template_rows": null,
|
| 670 |
+
"height": null,
|
| 671 |
+
"justify_content": null,
|
| 672 |
+
"justify_items": null,
|
| 673 |
+
"left": null,
|
| 674 |
+
"margin": null,
|
| 675 |
+
"max_height": null,
|
| 676 |
+
"max_width": null,
|
| 677 |
+
"min_height": null,
|
| 678 |
+
"min_width": null,
|
| 679 |
+
"object_fit": null,
|
| 680 |
+
"object_position": null,
|
| 681 |
+
"order": null,
|
| 682 |
+
"overflow": null,
|
| 683 |
+
"overflow_x": null,
|
| 684 |
+
"overflow_y": null,
|
| 685 |
+
"padding": null,
|
| 686 |
+
"right": null,
|
| 687 |
+
"top": null,
|
| 688 |
+
"visibility": null,
|
| 689 |
+
"width": null
|
| 690 |
+
}
|
| 691 |
+
},
|
| 692 |
+
"f3a46d6eebe04dd3894cb893ca8bc58a": {
|
| 693 |
+
"model_module": "@jupyter-widgets/controls",
|
| 694 |
+
"model_name": "DescriptionStyleModel",
|
| 695 |
+
"model_module_version": "1.5.0",
|
| 696 |
+
"state": {
|
| 697 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 698 |
+
"_model_module_version": "1.5.0",
|
| 699 |
+
"_model_name": "DescriptionStyleModel",
|
| 700 |
+
"_view_count": null,
|
| 701 |
+
"_view_module": "@jupyter-widgets/base",
|
| 702 |
+
"_view_module_version": "1.2.0",
|
| 703 |
+
"_view_name": "StyleView",
|
| 704 |
+
"description_width": ""
|
| 705 |
+
}
|
| 706 |
+
},
|
| 707 |
+
"844da948344e4421b32fa41a679fbdb7": {
|
| 708 |
+
"model_module": "@jupyter-widgets/controls",
|
| 709 |
+
"model_name": "HBoxModel",
|
| 710 |
+
"model_module_version": "1.5.0",
|
| 711 |
+
"state": {
|
| 712 |
+
"_dom_classes": [],
|
| 713 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 714 |
+
"_model_module_version": "1.5.0",
|
| 715 |
+
"_model_name": "HBoxModel",
|
| 716 |
+
"_view_count": null,
|
| 717 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 718 |
+
"_view_module_version": "1.5.0",
|
| 719 |
+
"_view_name": "HBoxView",
|
| 720 |
+
"box_style": "",
|
| 721 |
+
"children": [
|
| 722 |
+
"IPY_MODEL_012adaa5fd314a589e7c67e381a26c2c",
|
| 723 |
+
"IPY_MODEL_dea346540d084b5c89d96b992c11c30e",
|
| 724 |
+
"IPY_MODEL_a82b849d29f64d878cd87cba3851b80b"
|
| 725 |
+
],
|
| 726 |
+
"layout": "IPY_MODEL_fe5a48f5cb2743319c5fcd38a494ff2c"
|
| 727 |
+
}
|
| 728 |
+
},
|
| 729 |
+
"012adaa5fd314a589e7c67e381a26c2c": {
|
| 730 |
+
"model_module": "@jupyter-widgets/controls",
|
| 731 |
+
"model_name": "HTMLModel",
|
| 732 |
+
"model_module_version": "1.5.0",
|
| 733 |
+
"state": {
|
| 734 |
+
"_dom_classes": [],
|
| 735 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 736 |
+
"_model_module_version": "1.5.0",
|
| 737 |
+
"_model_name": "HTMLModel",
|
| 738 |
+
"_view_count": null,
|
| 739 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 740 |
+
"_view_module_version": "1.5.0",
|
| 741 |
+
"_view_name": "HTMLView",
|
| 742 |
+
"description": "",
|
| 743 |
+
"description_tooltip": null,
|
| 744 |
+
"layout": "IPY_MODEL_098dee5390834dba9557964ccde15819",
|
| 745 |
+
"placeholder": "",
|
| 746 |
+
"style": "IPY_MODEL_8fda24ae999c4da29f2282b7b687d147",
|
| 747 |
+
"value": "Loading weights: 100%"
|
| 748 |
+
}
|
| 749 |
+
},
|
| 750 |
+
"dea346540d084b5c89d96b992c11c30e": {
|
| 751 |
+
"model_module": "@jupyter-widgets/controls",
|
| 752 |
+
"model_name": "FloatProgressModel",
|
| 753 |
+
"model_module_version": "1.5.0",
|
| 754 |
+
"state": {
|
| 755 |
+
"_dom_classes": [],
|
| 756 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 757 |
+
"_model_module_version": "1.5.0",
|
| 758 |
+
"_model_name": "FloatProgressModel",
|
| 759 |
+
"_view_count": null,
|
| 760 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 761 |
+
"_view_module_version": "1.5.0",
|
| 762 |
+
"_view_name": "ProgressView",
|
| 763 |
+
"bar_style": "success",
|
| 764 |
+
"description": "",
|
| 765 |
+
"description_tooltip": null,
|
| 766 |
+
"layout": "IPY_MODEL_4d9edf9c343d4fc4a6381bba2d25ac4b",
|
| 767 |
+
"max": 453,
|
| 768 |
+
"min": 0,
|
| 769 |
+
"orientation": "horizontal",
|
| 770 |
+
"style": "IPY_MODEL_4c77a8efb23a4a44ba22aedcee5e6f16",
|
| 771 |
+
"value": 453
|
| 772 |
+
}
|
| 773 |
+
},
|
| 774 |
+
"a82b849d29f64d878cd87cba3851b80b": {
|
| 775 |
+
"model_module": "@jupyter-widgets/controls",
|
| 776 |
+
"model_name": "HTMLModel",
|
| 777 |
+
"model_module_version": "1.5.0",
|
| 778 |
+
"state": {
|
| 779 |
+
"_dom_classes": [],
|
| 780 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 781 |
+
"_model_module_version": "1.5.0",
|
| 782 |
+
"_model_name": "HTMLModel",
|
| 783 |
+
"_view_count": null,
|
| 784 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 785 |
+
"_view_module_version": "1.5.0",
|
| 786 |
+
"_view_name": "HTMLView",
|
| 787 |
+
"description": "",
|
| 788 |
+
"description_tooltip": null,
|
| 789 |
+
"layout": "IPY_MODEL_7ce7515d20fb4c06a27da6f45e0210d3",
|
| 790 |
+
"placeholder": "",
|
| 791 |
+
"style": "IPY_MODEL_0daa08754c274d51ac35ef34e3a9457d",
|
| 792 |
+
"value": " 453/453 [00:03<00:00, 144.88it/s, Materializing param=model.layers.31.self_attn.v_proj.weight]"
|
| 793 |
+
}
|
| 794 |
+
},
|
| 795 |
+
"fe5a48f5cb2743319c5fcd38a494ff2c": {
|
| 796 |
+
"model_module": "@jupyter-widgets/base",
|
| 797 |
+
"model_name": "LayoutModel",
|
| 798 |
+
"model_module_version": "1.2.0",
|
| 799 |
+
"state": {
|
| 800 |
+
"_model_module": "@jupyter-widgets/base",
|
| 801 |
+
"_model_module_version": "1.2.0",
|
| 802 |
+
"_model_name": "LayoutModel",
|
| 803 |
+
"_view_count": null,
|
| 804 |
+
"_view_module": "@jupyter-widgets/base",
|
| 805 |
+
"_view_module_version": "1.2.0",
|
| 806 |
+
"_view_name": "LayoutView",
|
| 807 |
+
"align_content": null,
|
| 808 |
+
"align_items": null,
|
| 809 |
+
"align_self": null,
|
| 810 |
+
"border": null,
|
| 811 |
+
"bottom": null,
|
| 812 |
+
"display": null,
|
| 813 |
+
"flex": null,
|
| 814 |
+
"flex_flow": null,
|
| 815 |
+
"grid_area": null,
|
| 816 |
+
"grid_auto_columns": null,
|
| 817 |
+
"grid_auto_flow": null,
|
| 818 |
+
"grid_auto_rows": null,
|
| 819 |
+
"grid_column": null,
|
| 820 |
+
"grid_gap": null,
|
| 821 |
+
"grid_row": null,
|
| 822 |
+
"grid_template_areas": null,
|
| 823 |
+
"grid_template_columns": null,
|
| 824 |
+
"grid_template_rows": null,
|
| 825 |
+
"height": null,
|
| 826 |
+
"justify_content": null,
|
| 827 |
+
"justify_items": null,
|
| 828 |
+
"left": null,
|
| 829 |
+
"margin": null,
|
| 830 |
+
"max_height": null,
|
| 831 |
+
"max_width": null,
|
| 832 |
+
"min_height": null,
|
| 833 |
+
"min_width": null,
|
| 834 |
+
"object_fit": null,
|
| 835 |
+
"object_position": null,
|
| 836 |
+
"order": null,
|
| 837 |
+
"overflow": null,
|
| 838 |
+
"overflow_x": null,
|
| 839 |
+
"overflow_y": null,
|
| 840 |
+
"padding": null,
|
| 841 |
+
"right": null,
|
| 842 |
+
"top": null,
|
| 843 |
+
"visibility": null,
|
| 844 |
+
"width": null
|
| 845 |
+
}
|
| 846 |
+
},
|
| 847 |
+
"098dee5390834dba9557964ccde15819": {
|
| 848 |
+
"model_module": "@jupyter-widgets/base",
|
| 849 |
+
"model_name": "LayoutModel",
|
| 850 |
+
"model_module_version": "1.2.0",
|
| 851 |
+
"state": {
|
| 852 |
+
"_model_module": "@jupyter-widgets/base",
|
| 853 |
+
"_model_module_version": "1.2.0",
|
| 854 |
+
"_model_name": "LayoutModel",
|
| 855 |
+
"_view_count": null,
|
| 856 |
+
"_view_module": "@jupyter-widgets/base",
|
| 857 |
+
"_view_module_version": "1.2.0",
|
| 858 |
+
"_view_name": "LayoutView",
|
| 859 |
+
"align_content": null,
|
| 860 |
+
"align_items": null,
|
| 861 |
+
"align_self": null,
|
| 862 |
+
"border": null,
|
| 863 |
+
"bottom": null,
|
| 864 |
+
"display": null,
|
| 865 |
+
"flex": null,
|
| 866 |
+
"flex_flow": null,
|
| 867 |
+
"grid_area": null,
|
| 868 |
+
"grid_auto_columns": null,
|
| 869 |
+
"grid_auto_flow": null,
|
| 870 |
+
"grid_auto_rows": null,
|
| 871 |
+
"grid_column": null,
|
| 872 |
+
"grid_gap": null,
|
| 873 |
+
"grid_row": null,
|
| 874 |
+
"grid_template_areas": null,
|
| 875 |
+
"grid_template_columns": null,
|
| 876 |
+
"grid_template_rows": null,
|
| 877 |
+
"height": null,
|
| 878 |
+
"justify_content": null,
|
| 879 |
+
"justify_items": null,
|
| 880 |
+
"left": null,
|
| 881 |
+
"margin": null,
|
| 882 |
+
"max_height": null,
|
| 883 |
+
"max_width": null,
|
| 884 |
+
"min_height": null,
|
| 885 |
+
"min_width": null,
|
| 886 |
+
"object_fit": null,
|
| 887 |
+
"object_position": null,
|
| 888 |
+
"order": null,
|
| 889 |
+
"overflow": null,
|
| 890 |
+
"overflow_x": null,
|
| 891 |
+
"overflow_y": null,
|
| 892 |
+
"padding": null,
|
| 893 |
+
"right": null,
|
| 894 |
+
"top": null,
|
| 895 |
+
"visibility": null,
|
| 896 |
+
"width": null
|
| 897 |
+
}
|
| 898 |
+
},
|
| 899 |
+
"8fda24ae999c4da29f2282b7b687d147": {
|
| 900 |
+
"model_module": "@jupyter-widgets/controls",
|
| 901 |
+
"model_name": "DescriptionStyleModel",
|
| 902 |
+
"model_module_version": "1.5.0",
|
| 903 |
+
"state": {
|
| 904 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 905 |
+
"_model_module_version": "1.5.0",
|
| 906 |
+
"_model_name": "DescriptionStyleModel",
|
| 907 |
+
"_view_count": null,
|
| 908 |
+
"_view_module": "@jupyter-widgets/base",
|
| 909 |
+
"_view_module_version": "1.2.0",
|
| 910 |
+
"_view_name": "StyleView",
|
| 911 |
+
"description_width": ""
|
| 912 |
+
}
|
| 913 |
+
},
|
| 914 |
+
"4d9edf9c343d4fc4a6381bba2d25ac4b": {
|
| 915 |
+
"model_module": "@jupyter-widgets/base",
|
| 916 |
+
"model_name": "LayoutModel",
|
| 917 |
+
"model_module_version": "1.2.0",
|
| 918 |
+
"state": {
|
| 919 |
+
"_model_module": "@jupyter-widgets/base",
|
| 920 |
+
"_model_module_version": "1.2.0",
|
| 921 |
+
"_model_name": "LayoutModel",
|
| 922 |
+
"_view_count": null,
|
| 923 |
+
"_view_module": "@jupyter-widgets/base",
|
| 924 |
+
"_view_module_version": "1.2.0",
|
| 925 |
+
"_view_name": "LayoutView",
|
| 926 |
+
"align_content": null,
|
| 927 |
+
"align_items": null,
|
| 928 |
+
"align_self": null,
|
| 929 |
+
"border": null,
|
| 930 |
+
"bottom": null,
|
| 931 |
+
"display": null,
|
| 932 |
+
"flex": null,
|
| 933 |
+
"flex_flow": null,
|
| 934 |
+
"grid_area": null,
|
| 935 |
+
"grid_auto_columns": null,
|
| 936 |
+
"grid_auto_flow": null,
|
| 937 |
+
"grid_auto_rows": null,
|
| 938 |
+
"grid_column": null,
|
| 939 |
+
"grid_gap": null,
|
| 940 |
+
"grid_row": null,
|
| 941 |
+
"grid_template_areas": null,
|
| 942 |
+
"grid_template_columns": null,
|
| 943 |
+
"grid_template_rows": null,
|
| 944 |
+
"height": null,
|
| 945 |
+
"justify_content": null,
|
| 946 |
+
"justify_items": null,
|
| 947 |
+
"left": null,
|
| 948 |
+
"margin": null,
|
| 949 |
+
"max_height": null,
|
| 950 |
+
"max_width": null,
|
| 951 |
+
"min_height": null,
|
| 952 |
+
"min_width": null,
|
| 953 |
+
"object_fit": null,
|
| 954 |
+
"object_position": null,
|
| 955 |
+
"order": null,
|
| 956 |
+
"overflow": null,
|
| 957 |
+
"overflow_x": null,
|
| 958 |
+
"overflow_y": null,
|
| 959 |
+
"padding": null,
|
| 960 |
+
"right": null,
|
| 961 |
+
"top": null,
|
| 962 |
+
"visibility": null,
|
| 963 |
+
"width": null
|
| 964 |
+
}
|
| 965 |
+
},
|
| 966 |
+
"4c77a8efb23a4a44ba22aedcee5e6f16": {
|
| 967 |
+
"model_module": "@jupyter-widgets/controls",
|
| 968 |
+
"model_name": "ProgressStyleModel",
|
| 969 |
+
"model_module_version": "1.5.0",
|
| 970 |
+
"state": {
|
| 971 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 972 |
+
"_model_module_version": "1.5.0",
|
| 973 |
+
"_model_name": "ProgressStyleModel",
|
| 974 |
+
"_view_count": null,
|
| 975 |
+
"_view_module": "@jupyter-widgets/base",
|
| 976 |
+
"_view_module_version": "1.2.0",
|
| 977 |
+
"_view_name": "StyleView",
|
| 978 |
+
"bar_color": null,
|
| 979 |
+
"description_width": ""
|
| 980 |
+
}
|
| 981 |
+
},
|
| 982 |
+
"7ce7515d20fb4c06a27da6f45e0210d3": {
|
| 983 |
+
"model_module": "@jupyter-widgets/base",
|
| 984 |
+
"model_name": "LayoutModel",
|
| 985 |
+
"model_module_version": "1.2.0",
|
| 986 |
+
"state": {
|
| 987 |
+
"_model_module": "@jupyter-widgets/base",
|
| 988 |
+
"_model_module_version": "1.2.0",
|
| 989 |
+
"_model_name": "LayoutModel",
|
| 990 |
+
"_view_count": null,
|
| 991 |
+
"_view_module": "@jupyter-widgets/base",
|
| 992 |
+
"_view_module_version": "1.2.0",
|
| 993 |
+
"_view_name": "LayoutView",
|
| 994 |
+
"align_content": null,
|
| 995 |
+
"align_items": null,
|
| 996 |
+
"align_self": null,
|
| 997 |
+
"border": null,
|
| 998 |
+
"bottom": null,
|
| 999 |
+
"display": null,
|
| 1000 |
+
"flex": null,
|
| 1001 |
+
"flex_flow": null,
|
| 1002 |
+
"grid_area": null,
|
| 1003 |
+
"grid_auto_columns": null,
|
| 1004 |
+
"grid_auto_flow": null,
|
| 1005 |
+
"grid_auto_rows": null,
|
| 1006 |
+
"grid_column": null,
|
| 1007 |
+
"grid_gap": null,
|
| 1008 |
+
"grid_row": null,
|
| 1009 |
+
"grid_template_areas": null,
|
| 1010 |
+
"grid_template_columns": null,
|
| 1011 |
+
"grid_template_rows": null,
|
| 1012 |
+
"height": null,
|
| 1013 |
+
"justify_content": null,
|
| 1014 |
+
"justify_items": null,
|
| 1015 |
+
"left": null,
|
| 1016 |
+
"margin": null,
|
| 1017 |
+
"max_height": null,
|
| 1018 |
+
"max_width": null,
|
| 1019 |
+
"min_height": null,
|
| 1020 |
+
"min_width": null,
|
| 1021 |
+
"object_fit": null,
|
| 1022 |
+
"object_position": null,
|
| 1023 |
+
"order": null,
|
| 1024 |
+
"overflow": null,
|
| 1025 |
+
"overflow_x": null,
|
| 1026 |
+
"overflow_y": null,
|
| 1027 |
+
"padding": null,
|
| 1028 |
+
"right": null,
|
| 1029 |
+
"top": null,
|
| 1030 |
+
"visibility": null,
|
| 1031 |
+
"width": null
|
| 1032 |
+
}
|
| 1033 |
+
},
|
| 1034 |
+
"0daa08754c274d51ac35ef34e3a9457d": {
|
| 1035 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1036 |
+
"model_name": "DescriptionStyleModel",
|
| 1037 |
+
"model_module_version": "1.5.0",
|
| 1038 |
+
"state": {
|
| 1039 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1040 |
+
"_model_module_version": "1.5.0",
|
| 1041 |
+
"_model_name": "DescriptionStyleModel",
|
| 1042 |
+
"_view_count": null,
|
| 1043 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1044 |
+
"_view_module_version": "1.2.0",
|
| 1045 |
+
"_view_name": "StyleView",
|
| 1046 |
+
"description_width": ""
|
| 1047 |
+
}
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
}
|
| 1051 |
+
},
|
| 1052 |
+
"cells": [
|
| 1053 |
+
{
|
| 1054 |
+
"cell_type": "code",
|
| 1055 |
+
"source": [
|
| 1056 |
+
"!pip install -U transformers"
|
| 1057 |
+
],
|
| 1058 |
+
"metadata": {
|
| 1059 |
+
"colab": {
|
| 1060 |
+
"base_uri": "https://localhost:8080/",
|
| 1061 |
+
"height": 810
|
| 1062 |
+
},
|
| 1063 |
+
"id": "o0zcQycu-UEa",
|
| 1064 |
+
"outputId": "3d82776f-8531-4680-8f2a-5578e708c945"
|
| 1065 |
+
},
|
| 1066 |
+
"execution_count": 23,
|
| 1067 |
+
"outputs": [
|
| 1068 |
+
{
|
| 1069 |
+
"output_type": "stream",
|
| 1070 |
+
"name": "stdout",
|
| 1071 |
+
"text": [
|
| 1072 |
+
"Requirement already satisfied: transformers in /usr/local/lib/python3.12/dist-packages (5.0.0)\n",
|
| 1073 |
+
"Collecting transformers\n",
|
| 1074 |
+
" Downloading transformers-5.8.1-py3-none-any.whl.metadata (33 kB)\n",
|
| 1075 |
+
"Requirement already satisfied: huggingface-hub<2.0,>=1.5.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (1.11.0)\n",
|
| 1076 |
+
"Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.12/dist-packages (from transformers) (2.0.2)\n",
|
| 1077 |
+
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (26.1)\n",
|
| 1078 |
+
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from transformers) (6.0.3)\n",
|
| 1079 |
+
"Requirement already satisfied: regex>=2025.10.22 in /usr/local/lib/python3.12/dist-packages (from transformers) (2025.11.3)\n",
|
| 1080 |
+
"Requirement already satisfied: tokenizers<=0.23.0,>=0.22.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.22.2)\n",
|
| 1081 |
+
"Requirement already satisfied: typer in /usr/local/lib/python3.12/dist-packages (from transformers) (0.24.2)\n",
|
| 1082 |
+
"Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.7.0)\n",
|
| 1083 |
+
"Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.12/dist-packages (from transformers) (4.67.3)\n",
|
| 1084 |
+
"Requirement already satisfied: filelock>=3.10.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.5.0->transformers) (3.29.0)\n",
|
| 1085 |
+
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.5.0->transformers) (2025.3.0)\n",
|
| 1086 |
+
"Requirement already satisfied: hf-xet<2.0.0,>=1.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.5.0->transformers) (1.4.3)\n",
|
| 1087 |
+
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.5.0->transformers) (0.28.1)\n",
|
| 1088 |
+
"Requirement already satisfied: typing-extensions>=4.1.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.5.0->transformers) (4.15.0)\n",
|
| 1089 |
+
"Requirement already satisfied: click>=8.2.1 in /usr/local/lib/python3.12/dist-packages (from typer->transformers) (8.3.3)\n",
|
| 1090 |
+
"Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.12/dist-packages (from typer->transformers) (1.5.4)\n",
|
| 1091 |
+
"Requirement already satisfied: rich>=12.3.0 in /usr/local/lib/python3.12/dist-packages (from typer->transformers) (13.9.4)\n",
|
| 1092 |
+
"Requirement already satisfied: annotated-doc>=0.0.2 in /usr/local/lib/python3.12/dist-packages (from typer->transformers) (0.0.4)\n",
|
| 1093 |
+
"Requirement already satisfied: anyio in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.5.0->transformers) (4.13.0)\n",
|
| 1094 |
+
"Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.5.0->transformers) (2026.4.22)\n",
|
| 1095 |
+
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.5.0->transformers) (1.0.9)\n",
|
| 1096 |
+
"Requirement already satisfied: idna in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.5.0->transformers) (3.13)\n",
|
| 1097 |
+
"Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.12/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.5.0->transformers) (0.16.0)\n",
|
| 1098 |
+
"Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich>=12.3.0->typer->transformers) (4.0.0)\n",
|
| 1099 |
+
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich>=12.3.0->typer->transformers) (2.20.0)\n",
|
| 1100 |
+
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich>=12.3.0->typer->transformers) (0.1.2)\n",
|
| 1101 |
+
"Downloading transformers-5.8.1-py3-none-any.whl (10.6 MB)\n",
|
| 1102 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.6/10.6 MB\u001b[0m \u001b[31m61.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 1103 |
+
"\u001b[?25hInstalling collected packages: transformers\n",
|
| 1104 |
+
" Attempting uninstall: transformers\n",
|
| 1105 |
+
" Found existing installation: transformers 5.0.0\n",
|
| 1106 |
+
" Uninstalling transformers-5.0.0:\n",
|
| 1107 |
+
" Successfully uninstalled transformers-5.0.0\n",
|
| 1108 |
+
"Successfully installed transformers-5.8.1\n"
|
| 1109 |
+
]
|
| 1110 |
+
},
|
| 1111 |
+
{
|
| 1112 |
+
"output_type": "display_data",
|
| 1113 |
+
"data": {
|
| 1114 |
+
"application/vnd.colab-display-data+json": {
|
| 1115 |
+
"pip_warning": {
|
| 1116 |
+
"packages": [
|
| 1117 |
+
"transformers"
|
| 1118 |
+
]
|
| 1119 |
+
},
|
| 1120 |
+
"id": "338a67b765ed413081d22a770dd5b35c"
|
| 1121 |
+
}
|
| 1122 |
+
},
|
| 1123 |
+
"metadata": {}
|
| 1124 |
+
}
|
| 1125 |
+
]
|
| 1126 |
+
},
|
| 1127 |
+
{
|
| 1128 |
+
"cell_type": "markdown",
|
| 1129 |
+
"source": [
|
| 1130 |
+
"## Local Inference on GPU\n",
|
| 1131 |
+
"Model page: https://huggingface.co/microsoft/phi-2\n",
|
| 1132 |
+
"\n",
|
| 1133 |
+
"⚠️ If the generated code snippets do not work, please open an issue on either the [model repo](https://huggingface.co/microsoft/phi-2)\n",
|
| 1134 |
+
"\t\t\tand/or on [huggingface.js](https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries-snippets.ts) 🙏"
|
| 1135 |
+
],
|
| 1136 |
+
"metadata": {
|
| 1137 |
+
"id": "qhYDm6yk-UEj"
|
| 1138 |
+
}
|
| 1139 |
+
},
|
| 1140 |
+
{
|
| 1141 |
+
"cell_type": "code",
|
| 1142 |
+
"source": [
|
| 1143 |
+
"# Use a pipeline as a high-level helper\n",
|
| 1144 |
+
"from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM, AutoConfig\n",
|
| 1145 |
+
"import torch\n",
|
| 1146 |
+
"\n",
|
| 1147 |
+
"model_name = \"microsoft/phi-2\"\n",
|
| 1148 |
+
"\n",
|
| 1149 |
+
"# Load tokenizer and set pad_token\n",
|
| 1150 |
+
"tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)\n",
|
| 1151 |
+
"tokenizer.pad_token = tokenizer.eos_token\n",
|
| 1152 |
+
"\n",
|
| 1153 |
+
"# Load model configuration and set pad_token_id\n",
|
| 1154 |
+
"config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)\n",
|
| 1155 |
+
"config.pad_token_id = tokenizer.eos_token_id\n",
|
| 1156 |
+
"\n",
|
| 1157 |
+
"# Load model with the modified configuration\n",
|
| 1158 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
| 1159 |
+
" model_name,\n",
|
| 1160 |
+
" config=config,\n",
|
| 1161 |
+
" trust_remote_code=True,\n",
|
| 1162 |
+
" torch_dtype=torch.float16 # Use float16 for potentially better performance/memory usage\n",
|
| 1163 |
+
")\n",
|
| 1164 |
+
"\n",
|
| 1165 |
+
"# Create the pipeline with the correctly loaded model and tokenizer\n",
|
| 1166 |
+
"# Check for GPU and move model if available\n",
|
| 1167 |
+
"device = 0 if torch.cuda.is_available() else -1\n",
|
| 1168 |
+
"if torch.cuda.is_available():\n",
|
| 1169 |
+
" model.to('cuda')\n",
|
| 1170 |
+
" print(\"Model moved to GPU.\")\n",
|
| 1171 |
+
"else:\n",
|
| 1172 |
+
" print(\"GPU not available, model will run on CPU.\")\n",
|
| 1173 |
+
"\n",
|
| 1174 |
+
"pipe = pipeline(\"text-generation\", model=model, tokenizer=tokenizer, device=device)\n",
|
| 1175 |
+
"print(\"Pipeline initialized successfully.\")"
|
| 1176 |
+
],
|
| 1177 |
+
"metadata": {
|
| 1178 |
+
"colab": {
|
| 1179 |
+
"base_uri": "https://localhost:8080/",
|
| 1180 |
+
"height": 96,
|
| 1181 |
+
"referenced_widgets": [
|
| 1182 |
+
"b486eefffb274a1d89c401ee56f0ea7b",
|
| 1183 |
+
"2757c39f0c9a4fa599bd2a7b58c3ad4a",
|
| 1184 |
+
"696a9b10ead84306a3886b2a5853eb7c",
|
| 1185 |
+
"d7684e7d23764317acc7bcc512944758",
|
| 1186 |
+
"e44dbcae75684967ae5a797d20c2ec16",
|
| 1187 |
+
"f318babe826841ab96db9716af5adc5e",
|
| 1188 |
+
"fa14e7cbb0d14d56b5276d77f97f4315",
|
| 1189 |
+
"fd3f39e32b514e1f949a98ebc2922be0",
|
| 1190 |
+
"e94a0224955143e59fb03000dff11208",
|
| 1191 |
+
"51f5cb0a06e84813a224e51e8a11c128",
|
| 1192 |
+
"adc120af345247d6b3de0611e6d44490"
|
| 1193 |
+
]
|
| 1194 |
+
},
|
| 1195 |
+
"id": "b9Ly2RUM-UFe",
|
| 1196 |
+
"outputId": "f89768a7-caf1-4972-8c24-d088907a31ea"
|
| 1197 |
+
},
|
| 1198 |
+
"execution_count": 25,
|
| 1199 |
+
"outputs": [
|
| 1200 |
+
{
|
| 1201 |
+
"output_type": "display_data",
|
| 1202 |
+
"data": {
|
| 1203 |
+
"text/plain": [
|
| 1204 |
+
"Loading weights: 0%| | 0/453 [00:00<?, ?it/s]"
|
| 1205 |
+
],
|
| 1206 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 1207 |
+
"version_major": 2,
|
| 1208 |
+
"version_minor": 0,
|
| 1209 |
+
"model_id": "b486eefffb274a1d89c401ee56f0ea7b"
|
| 1210 |
+
}
|
| 1211 |
+
},
|
| 1212 |
+
"metadata": {}
|
| 1213 |
+
},
|
| 1214 |
+
{
|
| 1215 |
+
"output_type": "stream",
|
| 1216 |
+
"name": "stdout",
|
| 1217 |
+
"text": [
|
| 1218 |
+
"GPU not available, model will run on CPU.\n",
|
| 1219 |
+
"Pipeline initialized successfully.\n"
|
| 1220 |
+
]
|
| 1221 |
+
}
|
| 1222 |
+
]
|
| 1223 |
+
},
|
| 1224 |
+
{
|
| 1225 |
+
"cell_type": "code",
|
| 1226 |
+
"source": [
|
| 1227 |
+
"from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig\n",
|
| 1228 |
+
"import torch\n",
|
| 1229 |
+
"\n",
|
| 1230 |
+
"# Load tokenizer first\n",
|
| 1231 |
+
"tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-2\", trust_remote_code=True)\n",
|
| 1232 |
+
"\n",
|
| 1233 |
+
"# Set pad_token for tokenizer using eos_token\n",
|
| 1234 |
+
"tokenizer.pad_token = tokenizer.eos_token\n",
|
| 1235 |
+
"\n",
|
| 1236 |
+
"# Load model configuration separately to ensure pad_token_id is set before model initialization\n",
|
| 1237 |
+
"config = AutoConfig.from_pretrained(\"microsoft/phi-2\", trust_remote_code=True)\n",
|
| 1238 |
+
"\n",
|
| 1239 |
+
"# Explicitly set pad_token_id in the config\n",
|
| 1240 |
+
"config.pad_token_id = tokenizer.eos_token_id\n",
|
| 1241 |
+
"\n",
|
| 1242 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
| 1243 |
+
" \"microsoft/phi-2\",\n",
|
| 1244 |
+
" config=config, # Pass the modified config here\n",
|
| 1245 |
+
" trust_remote_code=True,\n",
|
| 1246 |
+
" torch_dtype=torch.float16 # Use float16 for potentially better performance/memory usage\n",
|
| 1247 |
+
")"
|
| 1248 |
+
],
|
| 1249 |
+
"metadata": {
|
| 1250 |
+
"colab": {
|
| 1251 |
+
"base_uri": "https://localhost:8080/",
|
| 1252 |
+
"height": 61,
|
| 1253 |
+
"referenced_widgets": [
|
| 1254 |
+
"1e548b10c6b44b5fb6ea8687d94486f7",
|
| 1255 |
+
"603cb08fbfdf4aa5bb1072da1501116f",
|
| 1256 |
+
"b30d2933522342bb8df152670e068a61",
|
| 1257 |
+
"c04efaac2bd042618f7d4923ec2be8c0",
|
| 1258 |
+
"90559a506ecb4f46a345855a05cfc2d4",
|
| 1259 |
+
"e36f24e96c9a4941a071ad0a10e486af",
|
| 1260 |
+
"e2962aae45854cc39eb90fdbcef0f460",
|
| 1261 |
+
"b004dc925fb64e43ae97d73788648ef7",
|
| 1262 |
+
"c76b9cb1d93b48829805003ed178a2fa",
|
| 1263 |
+
"19103b3d686c4da994dc68912fe162b6",
|
| 1264 |
+
"f3a46d6eebe04dd3894cb893ca8bc58a"
|
| 1265 |
+
]
|
| 1266 |
+
},
|
| 1267 |
+
"id": "q5AOq1_Z-UFu",
|
| 1268 |
+
"outputId": "e1c11712-860c-40f7-e8eb-f639471858d7"
|
| 1269 |
+
},
|
| 1270 |
+
"execution_count": 39,
|
| 1271 |
+
"outputs": [
|
| 1272 |
+
{
|
| 1273 |
+
"output_type": "display_data",
|
| 1274 |
+
"data": {
|
| 1275 |
+
"text/plain": [
|
| 1276 |
+
"Loading weights: 0%| | 0/453 [00:00<?, ?it/s]"
|
| 1277 |
+
],
|
| 1278 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 1279 |
+
"version_major": 2,
|
| 1280 |
+
"version_minor": 0,
|
| 1281 |
+
"model_id": "1e548b10c6b44b5fb6ea8687d94486f7"
|
| 1282 |
+
}
|
| 1283 |
+
},
|
| 1284 |
+
"metadata": {}
|
| 1285 |
+
}
|
| 1286 |
+
]
|
| 1287 |
+
},
|
| 1288 |
+
{
|
| 1289 |
+
"cell_type": "markdown",
|
| 1290 |
+
"source": [
|
| 1291 |
+
"## Remote Inference via Inference Providers\n",
|
| 1292 |
+
"Ensure you have a valid **HF_TOKEN** set in your environment. You can get your token from [your settings page](https://huggingface.co/settings/tokens). Note: running this may incur charges above the free tier.\n",
|
| 1293 |
+
"The following Python example shows how to run the model remotely on HF Inference Providers, automatically selecting an available inference provider for you.\n",
|
| 1294 |
+
"For more information on how to use the Inference Providers, please refer to our [documentation and guides](https://huggingface.co/docs/inference-providers/en/index)."
|
| 1295 |
+
],
|
| 1296 |
+
"metadata": {
|
| 1297 |
+
"id": "IRyu8RyM-UF-"
|
| 1298 |
+
}
|
| 1299 |
+
},
|
| 1300 |
+
{
|
| 1301 |
+
"cell_type": "markdown",
|
| 1302 |
+
"metadata": {
|
| 1303 |
+
"id": "029ed965"
|
| 1304 |
+
},
|
| 1305 |
+
"source": [
|
| 1306 |
+
"## Gradio Interface for Phi-2 Chat"
|
| 1307 |
+
]
|
| 1308 |
+
},
|
| 1309 |
+
{
|
| 1310 |
+
"cell_type": "code",
|
| 1311 |
+
"metadata": {
|
| 1312 |
+
"id": "b8b69d12"
|
| 1313 |
+
},
|
| 1314 |
+
"source": [
|
| 1315 |
+
"# Install Gradio library\n",
|
| 1316 |
+
"!pip install gradio -q"
|
| 1317 |
+
],
|
| 1318 |
+
"execution_count": 27,
|
| 1319 |
+
"outputs": []
|
| 1320 |
+
},
|
| 1321 |
+
{
|
| 1322 |
+
"cell_type": "code",
|
| 1323 |
+
"metadata": {
|
| 1324 |
+
"colab": {
|
| 1325 |
+
"base_uri": "https://localhost:8080/",
|
| 1326 |
+
"height": 113,
|
| 1327 |
+
"referenced_widgets": [
|
| 1328 |
+
"844da948344e4421b32fa41a679fbdb7",
|
| 1329 |
+
"012adaa5fd314a589e7c67e381a26c2c",
|
| 1330 |
+
"dea346540d084b5c89d96b992c11c30e",
|
| 1331 |
+
"a82b849d29f64d878cd87cba3851b80b",
|
| 1332 |
+
"fe5a48f5cb2743319c5fcd38a494ff2c",
|
| 1333 |
+
"098dee5390834dba9557964ccde15819",
|
| 1334 |
+
"8fda24ae999c4da29f2282b7b687d147",
|
| 1335 |
+
"4d9edf9c343d4fc4a6381bba2d25ac4b",
|
| 1336 |
+
"4c77a8efb23a4a44ba22aedcee5e6f16",
|
| 1337 |
+
"7ce7515d20fb4c06a27da6f45e0210d3",
|
| 1338 |
+
"0daa08754c274d51ac35ef34e3a9457d"
|
| 1339 |
+
]
|
| 1340 |
+
},
|
| 1341 |
+
"id": "b5a619ac",
|
| 1342 |
+
"outputId": "7c85a144-3652-4541-ded7-dce03c49b549"
|
| 1343 |
+
},
|
| 1344 |
+
"source": [
|
| 1345 |
+
"import gradio as gr\n",
|
| 1346 |
+
"from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM, AutoConfig\n",
|
| 1347 |
+
"import torch\n",
|
| 1348 |
+
"\n",
|
| 1349 |
+
"print(\"Loading Phi-2 model and tokenizer...\")\n",
|
| 1350 |
+
"\n",
|
| 1351 |
+
"# Load tokenizer first\n",
|
| 1352 |
+
"tokenizer = AutoTokenizer.from_pretrained(\"microsoft/phi-2\", trust_remote_code=True)\n",
|
| 1353 |
+
"\n",
|
| 1354 |
+
"# Set pad_token for tokenizer using eos_token\n",
|
| 1355 |
+
"tokenizer.pad_token = tokenizer.eos_token\n",
|
| 1356 |
+
"\n",
|
| 1357 |
+
"# Load model configuration separately to ensure pad_token_id is set before model initialization\n",
|
| 1358 |
+
"config = AutoConfig.from_pretrained(\"microsoft/phi-2\", trust_remote_code=True)\n",
|
| 1359 |
+
"\n",
|
| 1360 |
+
"# Explicitly set pad_token_id in the config, as Phi-2's config might not have it by default\n",
|
| 1361 |
+
"# The model's internal structure expects this attribute to be present.\n",
|
| 1362 |
+
"config.pad_token_id = tokenizer.eos_token_id\n",
|
| 1363 |
+
"\n",
|
| 1364 |
+
"model = AutoModelForCausalLM.from_pretrained(\n",
|
| 1365 |
+
" \"microsoft/phi-2\",\n",
|
| 1366 |
+
" config=config, # Pass the modified config here\n",
|
| 1367 |
+
" trust_remote_code=True,\n",
|
| 1368 |
+
" torch_dtype=torch.float16\n",
|
| 1369 |
+
")\n",
|
| 1370 |
+
"\n",
|
| 1371 |
+
"# Check for GPU and move model if available\n",
|
| 1372 |
+
"if torch.cuda.is_available():\n",
|
| 1373 |
+
" model.to('cuda')\n",
|
| 1374 |
+
" print(\"Model moved to GPU.\")\n",
|
| 1375 |
+
"else:\n",
|
| 1376 |
+
" print(\"GPU not available, model will run on CPU.\")\n",
|
| 1377 |
+
"\n",
|
| 1378 |
+
"# Create a text generation pipeline and rename it to avoid conflict\n",
|
| 1379 |
+
"text_generator_pipeline = pipeline(\"text-generation\", model=model, tokenizer=tokenizer, device=0 if torch.cuda.is_available() else -1)\n",
|
| 1380 |
+
"\n",
|
| 1381 |
+
"print(\"Phi-2 model loaded successfully.\")"
|
| 1382 |
+
],
|
| 1383 |
+
"execution_count": 28,
|
| 1384 |
+
"outputs": [
|
| 1385 |
+
{
|
| 1386 |
+
"output_type": "stream",
|
| 1387 |
+
"name": "stdout",
|
| 1388 |
+
"text": [
|
| 1389 |
+
"Loading Phi-2 model and tokenizer...\n"
|
| 1390 |
+
]
|
| 1391 |
+
},
|
| 1392 |
+
{
|
| 1393 |
+
"output_type": "display_data",
|
| 1394 |
+
"data": {
|
| 1395 |
+
"text/plain": [
|
| 1396 |
+
"Loading weights: 0%| | 0/453 [00:00<?, ?it/s]"
|
| 1397 |
+
],
|
| 1398 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 1399 |
+
"version_major": 2,
|
| 1400 |
+
"version_minor": 0,
|
| 1401 |
+
"model_id": "844da948344e4421b32fa41a679fbdb7"
|
| 1402 |
+
}
|
| 1403 |
+
},
|
| 1404 |
+
"metadata": {}
|
| 1405 |
+
},
|
| 1406 |
+
{
|
| 1407 |
+
"output_type": "stream",
|
| 1408 |
+
"name": "stdout",
|
| 1409 |
+
"text": [
|
| 1410 |
+
"GPU not available, model will run on CPU.\n",
|
| 1411 |
+
"Phi-2 model loaded successfully.\n"
|
| 1412 |
+
]
|
| 1413 |
+
}
|
| 1414 |
+
]
|
| 1415 |
+
},
|
| 1416 |
+
{
|
| 1417 |
+
"cell_type": "code",
|
| 1418 |
+
"metadata": {
|
| 1419 |
+
"id": "61f7b058"
|
| 1420 |
+
},
|
| 1421 |
+
"source": [
|
| 1422 |
+
"def predict(message, history):\n",
|
| 1423 |
+
" conversation_history = \"\"\n",
|
| 1424 |
+
" for human, assistant in history:\n",
|
| 1425 |
+
" conversation_history += f\"Human: {human}\\nAssistant: {assistant}\\n\"\n",
|
| 1426 |
+
" conversation_history += f\"Human: {message}\\nAssistant:\"\n",
|
| 1427 |
+
"\n",
|
| 1428 |
+
" outputs = text_generator_pipeline(\n",
|
| 1429 |
+
" conversation_history, # Pass conversation_history directly as a string to the renamed pipeline object\n",
|
| 1430 |
+
" max_new_tokens=200, # Generate up to 200 new tokens\n",
|
| 1431 |
+
" do_sample=True,\n",
|
| 1432 |
+
" temperature=0.7,\n",
|
| 1433 |
+
" top_k=50,\n",
|
| 1434 |
+
" top_p=0.95,\n",
|
| 1435 |
+
" eos_token_id=tokenizer.eos_token_id # Stop generation at end-of-sequence token\n",
|
| 1436 |
+
" )\n",
|
| 1437 |
+
" generated_text = outputs[0]['generated_text']\n",
|
| 1438 |
+
"\n",
|
| 1439 |
+
" # Extract only the assistant's response part\n",
|
| 1440 |
+
" assistant_response = generated_text.split(\"Assistant:\")[-1].strip()\n",
|
| 1441 |
+
" # Remove the last user input from the response if the model repeats it\n",
|
| 1442 |
+
" if assistant_response.startswith(message):\n",
|
| 1443 |
+
" assistant_response = assistant_response[len(message):].strip()\n",
|
| 1444 |
+
"\n",
|
| 1445 |
+
" return assistant_response"
|
| 1446 |
+
],
|
| 1447 |
+
"execution_count": 29,
|
| 1448 |
+
"outputs": []
|
| 1449 |
+
},
|
| 1450 |
+
{
|
| 1451 |
+
"cell_type": "markdown",
|
| 1452 |
+
"metadata": {
|
| 1453 |
+
"id": "cbdf81f5"
|
| 1454 |
+
},
|
| 1455 |
+
"source": [
|
| 1456 |
+
"Now, let's launch the Gradio chat interface. Click the public URL to interact with the model."
|
| 1457 |
+
]
|
| 1458 |
+
},
|
| 1459 |
+
{
|
| 1460 |
+
"cell_type": "code",
|
| 1461 |
+
"metadata": {
|
| 1462 |
+
"colab": {
|
| 1463 |
+
"base_uri": "https://localhost:8080/",
|
| 1464 |
+
"height": 1000
|
| 1465 |
+
},
|
| 1466 |
+
"id": "63e656fe",
|
| 1467 |
+
"outputId": "cc1a646b-cc0a-4f68-e309-2ea3660104b8"
|
| 1468 |
+
},
|
| 1469 |
+
"source": [
|
| 1470 |
+
"gr.ChatInterface(\n",
|
| 1471 |
+
" predict,\n",
|
| 1472 |
+
" chatbot=gr.Chatbot(height=500), # Make the chatbot window larger\n",
|
| 1473 |
+
" textbox=gr.Textbox(placeholder=\"Ask me a question\", container=False, scale=7),\n",
|
| 1474 |
+
" title=\"Chat with Phi-2\",\n",
|
| 1475 |
+
" description=\"Interact with the Microsoft Phi-2 model. Ask questions, have conversations, or experiment with its generative capabilities!\",\n",
|
| 1476 |
+
" theme=\"soft\", # A pleasant theme\n",
|
| 1477 |
+
" examples=[\"Tell me a short story.\", \"Explain quantum physics simply.\", \"What is the capital of France?\"],\n",
|
| 1478 |
+
" cache_examples=False\n",
|
| 1479 |
+
").launch(debug=True, share=True)"
|
| 1480 |
+
],
|
| 1481 |
+
"execution_count": 36,
|
| 1482 |
+
"outputs": [
|
| 1483 |
+
{
|
| 1484 |
+
"output_type": "stream",
|
| 1485 |
+
"name": "stderr",
|
| 1486 |
+
"text": [
|
| 1487 |
+
"/tmp/ipykernel_3691/638742562.py:3: UserWarning: You have not specified a value for the `type` parameter. Defaulting to the 'tuples' format for chatbot messages, but this is deprecated and will be removed in a future version of Gradio. Please set type='messages' instead, which uses openai-style dictionaries with 'role' and 'content' keys.\n",
|
| 1488 |
+
" chatbot=gr.Chatbot(height=500), # Make the chatbot window larger\n",
|
| 1489 |
+
"/tmp/ipykernel_3691/638742562.py:3: DeprecationWarning: The default value of 'allow_tags' in gr.Chatbot will be changed from False to True in Gradio 6.0. You will need to explicitly set allow_tags=False if you want to disable tags in your chatbot.\n",
|
| 1490 |
+
" chatbot=gr.Chatbot(height=500), # Make the chatbot window larger\n",
|
| 1491 |
+
"/usr/local/lib/python3.12/dist-packages/gradio/chat_interface.py:330: UserWarning: The gr.ChatInterface was not provided with a type, so the type of the gr.Chatbot, 'tuples', will be used.\n",
|
| 1492 |
+
" warnings.warn(\n"
|
| 1493 |
+
]
|
| 1494 |
+
},
|
| 1495 |
+
{
|
| 1496 |
+
"output_type": "stream",
|
| 1497 |
+
"name": "stdout",
|
| 1498 |
+
"text": [
|
| 1499 |
+
"Colab notebook detected. This cell will run indefinitely so that you can see errors and logs. To turn off, set debug=False in launch().\n",
|
| 1500 |
+
"* Running on public URL: https://65e2f7deee45e031ef.gradio.live\n",
|
| 1501 |
+
"\n",
|
| 1502 |
+
"This share link expires in 1 week. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
|
| 1503 |
+
]
|
| 1504 |
+
},
|
| 1505 |
+
{
|
| 1506 |
+
"output_type": "display_data",
|
| 1507 |
+
"data": {
|
| 1508 |
+
"text/plain": [
|
| 1509 |
+
"<IPython.core.display.HTML object>"
|
| 1510 |
+
],
|
| 1511 |
+
"text/html": [
|
| 1512 |
+
"<div><iframe src=\"https://65e2f7deee45e031ef.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 1513 |
+
]
|
| 1514 |
+
},
|
| 1515 |
+
"metadata": {}
|
| 1516 |
+
},
|
| 1517 |
+
{
|
| 1518 |
+
"output_type": "stream",
|
| 1519 |
+
"name": "stderr",
|
| 1520 |
+
"text": [
|
| 1521 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1522 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1523 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1524 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1525 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1526 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1527 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1528 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1529 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n",
|
| 1530 |
+
"Both `max_new_tokens` (=200) and `max_length`(=20) seem to have been set. `max_new_tokens` will take precedence. Please refer to the documentation for more information. (https://huggingface.co/docs/transformers/main/en/main_classes/text_generation)\n"
|
| 1531 |
+
]
|
| 1532 |
+
},
|
| 1533 |
+
{
|
| 1534 |
+
"output_type": "stream",
|
| 1535 |
+
"name": "stdout",
|
| 1536 |
+
"text": [
|
| 1537 |
+
"Keyboard interruption in main thread... closing server.\n"
|
| 1538 |
+
]
|
| 1539 |
+
},
|
| 1540 |
+
{
|
| 1541 |
+
"output_type": "error",
|
| 1542 |
+
"ename": "KeyboardInterrupt",
|
| 1543 |
+
"evalue": "",
|
| 1544 |
+
"traceback": [
|
| 1545 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 1546 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
| 1547 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/gradio/blocks.py\u001b[0m in \u001b[0;36mblock_thread\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 3042\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3043\u001b[0;31m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3044\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mOSError\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1548 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m: ",
|
| 1549 |
+
"\nDuring handling of the above exception, another exception occurred:\n",
|
| 1550 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
| 1551 |
+
"\u001b[0;32m/tmp/ipykernel_3691/638742562.py\u001b[0m in \u001b[0;36m<cell line: 0>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mexamples\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"Tell me a short story.\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"Explain quantum physics simply.\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"What is the capital of France?\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mcache_examples\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m ).launch(debug=True, share=True)\n\u001b[0m",
|
| 1552 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/gradio/blocks.py\u001b[0m in \u001b[0;36mlaunch\u001b[0;34m(self, inline, inbrowser, share, debug, max_threads, auth, auth_message, prevent_thread_lock, show_error, server_name, server_port, height, width, favicon_path, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_verify, quiet, show_api, allowed_paths, blocked_paths, root_path, app_kwargs, state_session_capacity, share_server_address, share_server_protocol, share_server_tls_certificate, auth_dependency, max_file_size, enable_monitoring, strict_cors, node_server_name, node_port, ssr_mode, pwa, mcp_server, _frontend, i18n)\u001b[0m\n\u001b[1;32m 2948\u001b[0m )\n\u001b[1;32m 2949\u001b[0m ):\n\u001b[0;32m-> 2950\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mblock_thread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2951\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2952\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mTupleNoPrint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserver_app\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlocal_url\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshare_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# type: ignore\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1553 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/gradio/blocks.py\u001b[0m in \u001b[0;36mblock_thread\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 3045\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Keyboard interruption in main thread... closing server.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3046\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserver\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3047\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserver\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3048\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mtunnel\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mCURRENT_TUNNELS\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3049\u001b[0m \u001b[0mtunnel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkill\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1554 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/gradio/http_server.py\u001b[0m in \u001b[0;36mclose\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 67\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreloader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 68\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwatch_thread\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 69\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mthread\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 70\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 71\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1555 |
+
"\u001b[0;32m/usr/lib/python3.12/threading.py\u001b[0m in \u001b[0;36mjoin\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 1151\u001b[0m \u001b[0;31m# the behavior of a negative timeout isn't documented, but\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1152\u001b[0m \u001b[0;31m# historically .join(timeout=x) for x<0 has acted as if timeout=0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1153\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_wait_for_tstate_lock\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1154\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1155\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_wait_for_tstate_lock\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mblock\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1556 |
+
"\u001b[0;32m/usr/lib/python3.12/threading.py\u001b[0m in \u001b[0;36m_wait_for_tstate_lock\u001b[0;34m(self, block, timeout)\u001b[0m\n\u001b[1;32m 1167\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1168\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1169\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mlock\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0macquire\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mblock\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1170\u001b[0m \u001b[0mlock\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrelease\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1171\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1557 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
|
| 1558 |
+
]
|
| 1559 |
+
}
|
| 1560 |
+
]
|
| 1561 |
+
},
|
| 1562 |
+
{
|
| 1563 |
+
"cell_type": "code",
|
| 1564 |
+
"metadata": {
|
| 1565 |
+
"id": "61f7b008"
|
| 1566 |
+
},
|
| 1567 |
+
"source": [
|
| 1568 |
+
"def predict(message, history):\n",
|
| 1569 |
+
" conversation_history = \"\"\n",
|
| 1570 |
+
" for human, assistant in history:\n",
|
| 1571 |
+
" conversation_history += f\"Human: {human}\\nAssistant: {assistant}\\n\"\n",
|
| 1572 |
+
" conversation_history += f\"Human: {message}\\nAssistant:\"\n",
|
| 1573 |
+
"\n",
|
| 1574 |
+
" outputs = pipe(\n",
|
| 1575 |
+
" conversation_history, # Pass conversation_history directly as a string\n",
|
| 1576 |
+
" max_new_tokens=200, # Generate up to 200 new tokens\n",
|
| 1577 |
+
" do_sample=True,\n",
|
| 1578 |
+
" temperature=0.7,\n",
|
| 1579 |
+
" top_k=50,\n",
|
| 1580 |
+
" top_p=0.95,\n",
|
| 1581 |
+
" eos_token_id=tokenizer.eos_token_id # Stop generation at end-of-sequence token\n",
|
| 1582 |
+
" )\n",
|
| 1583 |
+
" generated_text = outputs[0]['generated_text']\n",
|
| 1584 |
+
"\n",
|
| 1585 |
+
" # Extract only the assistant's response part\n",
|
| 1586 |
+
" assistant_response = generated_text.split(\"Assistant:\")[-1].strip()\n",
|
| 1587 |
+
" # Remove the last user input from the response if the model repeats it\n",
|
| 1588 |
+
" if assistant_response.startswith(message):\n",
|
| 1589 |
+
" assistant_response = assistant_response[len(message):].strip()\n",
|
| 1590 |
+
"\n",
|
| 1591 |
+
" return assistant_response"
|
| 1592 |
+
],
|
| 1593 |
+
"execution_count": 35,
|
| 1594 |
+
"outputs": []
|
| 1595 |
+
},
|
| 1596 |
+
{
|
| 1597 |
+
"cell_type": "code",
|
| 1598 |
+
"source": [
|
| 1599 |
+
"import os\n",
|
| 1600 |
+
"os.environ['HF_TOKEN'] = 'YOUR_TOKEN_HERE'"
|
| 1601 |
+
],
|
| 1602 |
+
"metadata": {
|
| 1603 |
+
"id": "leeUFqBD-UF-"
|
| 1604 |
+
},
|
| 1605 |
+
"execution_count": 32,
|
| 1606 |
+
"outputs": []
|
| 1607 |
+
},
|
| 1608 |
+
{
|
| 1609 |
+
"cell_type": "code",
|
| 1610 |
+
"source": [
|
| 1611 |
+
"import os\n",
|
| 1612 |
+
"from huggingface_hub import InferenceClient\n",
|
| 1613 |
+
"\n",
|
| 1614 |
+
"client = InferenceClient(\n",
|
| 1615 |
+
" provider=\"auto\",\n",
|
| 1616 |
+
" api_key=os.environ[\"HF_TOKEN\"],\n",
|
| 1617 |
+
")\n",
|
| 1618 |
+
"\n",
|
| 1619 |
+
"completion = client.chat.completions.create(\n",
|
| 1620 |
+
" model=\"microsoft/phi-2\",\n",
|
| 1621 |
+
" messages=\"\\\"Can you please let us know more details about your \\\"\",\n",
|
| 1622 |
+
")\n",
|
| 1623 |
+
"\n",
|
| 1624 |
+
"print(completion.choices[0].message)"
|
| 1625 |
+
],
|
| 1626 |
+
"metadata": {
|
| 1627 |
+
"colab": {
|
| 1628 |
+
"base_uri": "https://localhost:8080/",
|
| 1629 |
+
"height": 512
|
| 1630 |
+
},
|
| 1631 |
+
"id": "Zmof51oV-UGN",
|
| 1632 |
+
"outputId": "7cf7ce76-f57b-44ee-9f06-5f3191182924"
|
| 1633 |
+
},
|
| 1634 |
+
"execution_count": 37,
|
| 1635 |
+
"outputs": [
|
| 1636 |
+
{
|
| 1637 |
+
"output_type": "error",
|
| 1638 |
+
"ename": "ValueError",
|
| 1639 |
+
"evalue": "Cannot select auto-router when using non-Hugging Face API key.",
|
| 1640 |
+
"traceback": [
|
| 1641 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 1642 |
+
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
|
| 1643 |
+
"\u001b[0;32m/tmp/ipykernel_3691/2505081652.py\u001b[0m in \u001b[0;36m<cell line: 0>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 7\u001b[0m )\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m completion = client.chat.completions.create(\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"microsoft/phi-2\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0mmessages\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"\\\"Can you please let us know more details about your \\\"\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1644 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/huggingface_hub/inference/_client.py\u001b[0m in \u001b[0;36mchat_completion\u001b[0;34m(self, messages, model, stream, frequency_penalty, logit_bias, logprobs, max_tokens, n, presence_penalty, response_format, seed, stop, stream_options, temperature, tool_choice, tool_prompt, tools, top_logprobs, top_p, extra_body)\u001b[0m\n\u001b[1;32m 920\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mextra_body\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 921\u001b[0m }\n\u001b[0;32m--> 922\u001b[0;31m request_parameters = provider_helper.prepare_request(\n\u001b[0m\u001b[1;32m 923\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmessages\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 924\u001b[0m \u001b[0mparameters\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mparameters\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1645 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/huggingface_hub/inference/_providers/_common.py\u001b[0m in \u001b[0;36mprepare_request\u001b[0;34m(self, inputs, parameters, headers, model, api_key, extra_payload)\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 101\u001b[0m \u001b[0;31m# routed URL if HF token, or direct URL (to customize in '_prepare_route' in subclasses)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 102\u001b[0;31m \u001b[0murl\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_prepare_url\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprovider_mapping_info\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprovider_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 103\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 104\u001b[0m \u001b[0;31m# prepare payload (to customize in subclasses)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1646 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/huggingface_hub/inference/_providers/_common.py\u001b[0m in \u001b[0;36m_prepare_url\u001b[0;34m(self, api_key, mapped_model)\u001b[0m\n\u001b[1;32m 214\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 215\u001b[0m Usually not overwritten in subclasses.\"\"\"\n\u001b[0;32m--> 216\u001b[0;31m \u001b[0mbase_url\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_prepare_base_url\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 217\u001b[0m \u001b[0mroute\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_prepare_route\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmapped_model\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mapi_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 218\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;34mf\"{base_url.rstrip('/')}/{route.lstrip('/')}\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1647 |
+
"\u001b[0;32m/usr/local/lib/python3.12/dist-packages/huggingface_hub/inference/_providers/_common.py\u001b[0m in \u001b[0;36m_prepare_base_url\u001b[0;34m(self, api_key)\u001b[0m\n\u001b[1;32m 300\u001b[0m \u001b[0;31m# Route to the proxy if the api_key is a HF TOKEN\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 301\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mapi_key\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstartswith\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"hf_\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 302\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Cannot select auto-router when using non-Hugging Face API key.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 303\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 304\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase_url\u001b[0m \u001b[0;31m# No `/auto` suffix in the URL\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
| 1648 |
+
"\u001b[0;31mValueError\u001b[0m: Cannot select auto-router when using non-Hugging Face API key."
|
| 1649 |
+
]
|
| 1650 |
+
}
|
| 1651 |
+
]
|
| 1652 |
+
}
|
| 1653 |
+
]
|
| 1654 |
+
}
|