File size: 82,208 Bytes
0feb34f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "9837afb7",
"metadata": {},
"outputs": [],
"source": [
"def generate_prompt(instruction: str, input_ctxt: str = None) -> str:\n",
" if input_ctxt:\n",
" return f\"\"\"Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n",
"\n",
"### Instruction:\n",
"{instruction}\n",
"\n",
"### Input:\n",
"{input_ctxt}\n",
"\n",
"### Response:\"\"\"\n",
" else:\n",
" return f\"\"\"Below is an instruction that describes a task. Write a response that appropriately completes the request.\n",
"\n",
"### Instruction:\n",
"{instruction}\n",
"\n",
"### Response:\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1cb5103c",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bff8fb0a005e4635a07ecf6fe0fdba88",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading checkpoint shards: 0%| | 0/33 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000\">╭─────────────────────────────── </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Traceback </span><span style=\"color: #bf7f7f; text-decoration-color: #bf7f7f; font-weight: bold\">(most recent call last)</span><span style=\"color: #800000; text-decoration-color: #800000\"> ────────────────────────────────╮</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">modeling_utils.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">45</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">9</span> in <span style=\"color: #00ff00; text-decoration-color: #00ff00\">load_state_dict</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 456 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span>) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 457 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">return</span> safe_load_file(checkpoint_file) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 458 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">try</span>: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span> 459 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">return</span> torch.load(checkpoint_file, map_location=<span style=\"color: #808000; text-decoration-color: #808000\">\"cpu\"</span>) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 460 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">except</span> <span style=\"color: #00ffff; text-decoration-color: #00ffff\">Exception</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">as</span> e: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 461 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">try</span>: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 462 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">with</span> <span style=\"color: #00ffff; text-decoration-color: #00ffff\">open</span>(checkpoint_file) <span style=\"color: #0000ff; text-decoration-color: #0000ff\">as</span> f: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">serialization.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">791</span> in <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">load</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 788 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> <span style=\"color: #808000; text-decoration-color: #808000\">'encoding'</span> <span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">not</span> <span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">in</span> pickle_load_args.keys(): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 789 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span>pickle_load_args[<span style=\"color: #808000; text-decoration-color: #808000\">'encoding'</span>] = <span style=\"color: #808000; text-decoration-color: #808000\">'utf-8'</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 790 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span> 791 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">with</span> _open_file_like(f, <span style=\"color: #808000; text-decoration-color: #808000\">'rb'</span>) <span style=\"color: #0000ff; text-decoration-color: #0000ff\">as</span> opened_file: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 792 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> _is_zipfile(opened_file): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 793 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># The zipfile reader is going to advance the current file position.</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 794 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># If we want to actually tail call to torch.jit.load, we need to</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">serialization.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">271</span> in <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">_open_file_like</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 268 </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 269 </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">def</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">_open_file_like</span>(name_or_buffer, mode): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 270 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> _is_path(name_or_buffer): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span> 271 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">return</span> _open_file(name_or_buffer, mode) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 272 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">else</span>: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 273 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> <span style=\"color: #808000; text-decoration-color: #808000\">'w'</span> <span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">in</span> mode: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 274 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">return</span> _open_buffer_writer(name_or_buffer) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">serialization.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">252</span> in <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">__init__</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 249 </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 250 </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">class</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00; text-decoration: underline\">_open_file</span>(_opener): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 251 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">def</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">__init__</span>(<span style=\"color: #00ffff; text-decoration-color: #00ffff\">self</span>, name, mode): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span> 252 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #00ffff; text-decoration-color: #00ffff\">super</span>().<span style=\"color: #00ff00; text-decoration-color: #00ff00\">__init__</span>(<span style=\"color: #00ffff; text-decoration-color: #00ffff\">open</span>(name, mode)) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 253 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 254 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">def</span> <span style=\"color: #00ff00; text-decoration-color: #00ff00\">__exit__</span>(<span style=\"color: #00ffff; text-decoration-color: #00ffff\">self</span>, *args): <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 255 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #00ffff; text-decoration-color: #00ffff\">self</span>.file_like.close() <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">╰──────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
"<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-weight: bold\">FileNotFoundError: </span><span style=\"font-weight: bold\">[</span>Errno <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"font-weight: bold\">]</span> No such file or directory: \n",
"<span style=\"color: #008000; text-decoration-color: #008000\">'../decapoda-research/llama-7b-hf/pytorch_model-00001-of-00033.bin'</span>\n",
"\n",
"<span style=\"font-style: italic\">During handling of the above exception, another exception occurred:</span>\n",
"\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">╭─────────────────────────────── </span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Traceback </span><span style=\"color: #bf7f7f; text-decoration-color: #bf7f7f; font-weight: bold\">(most recent call last)</span><span style=\"color: #800000; text-decoration-color: #800000\"> ────────────────────────────────╮</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> in <span style=\"color: #00ff00; text-decoration-color: #00ff00\"><module></span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">16</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">13 </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">14 </span>tokenizer = LlamaTokenizer.from_pretrained(MODEL_NAME) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">15 </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span>16 model = LlamaForCausalLM.from_pretrained( <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">17 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span>BASE_MODEL, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">18 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span>load_in_8bit=<span style=\"color: #0000ff; text-decoration-color: #0000ff\">True</span>, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">19 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span>torch_dtype=torch.float16, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">modeling_utils.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">28</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">70</span> in <span style=\"color: #00ff00; text-decoration-color: #00ff00\">from_pretrained</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2867 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>mismatched_keys, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2868 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>offload_index, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2869 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>error_msgs, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span>2870 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span>) = <span style=\"color: #00ffff; text-decoration-color: #00ffff\">cls</span>._load_pretrained_model( <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2871 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>model, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2872 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>state_dict, <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">2873 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>loaded_state_dict_keys, <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># XXX: rename?</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">modeling_utils.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">32</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">02</span> in <span style=\"color: #00ff00; text-decoration-color: #00ff00\">_load_pretrained_model</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3199 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># Skip the load for shards that only contain disk-offloaded weights when</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3200 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> shard_file <span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">in</span> disk_only_shard_files: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3201 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">continue</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span>3202 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span>state_dict = load_state_dict(shard_file) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3203 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3204 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># Mistmatched keys contains tuples key/shape1/shape2 of weights in the c</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3205 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"># matching the weights in the model.</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/</span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">modeling_utils.py</span>:<span style=\"color: #0000ff; text-decoration-color: #0000ff\">46</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">2</span> in <span style=\"color: #00ff00; text-decoration-color: #00ff00\">load_state_dict</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 459 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">return</span> torch.load(checkpoint_file, map_location=<span style=\"color: #808000; text-decoration-color: #808000\">\"cpu\"</span>) <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 460 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">except</span> <span style=\"color: #00ffff; text-decoration-color: #00ffff\">Exception</span> <span style=\"color: #0000ff; text-decoration-color: #0000ff\">as</span> e: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 461 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">try</span>: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #800000; text-decoration-color: #800000\">❱ </span> 462 <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">with</span> <span style=\"color: #00ffff; text-decoration-color: #00ffff\">open</span>(checkpoint_file) <span style=\"color: #0000ff; text-decoration-color: #0000ff\">as</span> f: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 463 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">if</span> f.read(<span style=\"color: #0000ff; text-decoration-color: #0000ff\">7</span>) == <span style=\"color: #808000; text-decoration-color: #808000\">\"version\"</span>: <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 464 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ │ </span><span style=\"color: #0000ff; text-decoration-color: #0000ff\">raise</span> <span style=\"color: #00ffff; text-decoration-color: #00ffff\">OSError</span>( <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">│</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> 465 </span><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">│ │ │ │ │ │ </span><span style=\"color: #808000; text-decoration-color: #808000\">\"You seem to have cloned a repository without having git-lfs ins</span> <span style=\"color: #800000; text-decoration-color: #800000\">│</span>\n",
"<span style=\"color: #800000; text-decoration-color: #800000\">╰──────────────────────────────────────────────────────────────────────────────────────────────────╯</span>\n",
"<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-weight: bold\">FileNotFoundError: </span><span style=\"font-weight: bold\">[</span>Errno <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span><span style=\"font-weight: bold\">]</span> No such file or directory: \n",
"<span style=\"color: #008000; text-decoration-color: #008000\">'../decapoda-research/llama-7b-hf/pytorch_model-00001-of-00033.bin'</span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/\u001b[0m\u001b[1;33mmodeling_utils.py\u001b[0m:\u001b[94m45\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[94m9\u001b[0m in \u001b[92mload_state_dict\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 456 \u001b[0m\u001b[2m│ │ │ \u001b[0m) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 457 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mreturn\u001b[0m safe_load_file(checkpoint_file) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 458 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 459 \u001b[2m│ │ \u001b[0m\u001b[94mreturn\u001b[0m torch.load(checkpoint_file, map_location=\u001b[33m\"\u001b[0m\u001b[33mcpu\u001b[0m\u001b[33m\"\u001b[0m) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 460 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mexcept\u001b[0m \u001b[96mException\u001b[0m \u001b[94mas\u001b[0m e: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 461 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 462 \u001b[0m\u001b[2m│ │ │ \u001b[0m\u001b[94mwith\u001b[0m \u001b[96mopen\u001b[0m(checkpoint_file) \u001b[94mas\u001b[0m f: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/\u001b[0m\u001b[1;33mserialization.py\u001b[0m:\u001b[94m791\u001b[0m in \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[92mload\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 788 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mif\u001b[0m \u001b[33m'\u001b[0m\u001b[33mencoding\u001b[0m\u001b[33m'\u001b[0m \u001b[95mnot\u001b[0m \u001b[95min\u001b[0m pickle_load_args.keys(): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 789 \u001b[0m\u001b[2m│ │ \u001b[0mpickle_load_args[\u001b[33m'\u001b[0m\u001b[33mencoding\u001b[0m\u001b[33m'\u001b[0m] = \u001b[33m'\u001b[0m\u001b[33mutf-8\u001b[0m\u001b[33m'\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 790 \u001b[0m\u001b[2m│ \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 791 \u001b[2m│ \u001b[0m\u001b[94mwith\u001b[0m _open_file_like(f, \u001b[33m'\u001b[0m\u001b[33mrb\u001b[0m\u001b[33m'\u001b[0m) \u001b[94mas\u001b[0m opened_file: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 792 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mif\u001b[0m _is_zipfile(opened_file): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 793 \u001b[0m\u001b[2m│ │ │ \u001b[0m\u001b[2m# The zipfile reader is going to advance the current file position.\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 794 \u001b[0m\u001b[2m│ │ │ \u001b[0m\u001b[2m# If we want to actually tail call to torch.jit.load, we need to\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/\u001b[0m\u001b[1;33mserialization.py\u001b[0m:\u001b[94m271\u001b[0m in \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[92m_open_file_like\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 268 \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 269 \u001b[0m\u001b[94mdef\u001b[0m \u001b[92m_open_file_like\u001b[0m(name_or_buffer, mode): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 270 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mif\u001b[0m _is_path(name_or_buffer): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 271 \u001b[2m│ │ \u001b[0m\u001b[94mreturn\u001b[0m _open_file(name_or_buffer, mode) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 272 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94melse\u001b[0m: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 273 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mif\u001b[0m \u001b[33m'\u001b[0m\u001b[33mw\u001b[0m\u001b[33m'\u001b[0m \u001b[95min\u001b[0m mode: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 274 \u001b[0m\u001b[2m│ │ │ \u001b[0m\u001b[94mreturn\u001b[0m _open_buffer_writer(name_or_buffer) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/torch/\u001b[0m\u001b[1;33mserialization.py\u001b[0m:\u001b[94m252\u001b[0m in \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[92m__init__\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 249 \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 250 \u001b[0m\u001b[94mclass\u001b[0m \u001b[4;92m_open_file\u001b[0m(_opener): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 251 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mdef\u001b[0m \u001b[92m__init__\u001b[0m(\u001b[96mself\u001b[0m, name, mode): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 252 \u001b[2m│ │ \u001b[0m\u001b[96msuper\u001b[0m().\u001b[92m__init__\u001b[0m(\u001b[96mopen\u001b[0m(name, mode)) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 253 \u001b[0m\u001b[2m│ \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 254 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mdef\u001b[0m \u001b[92m__exit__\u001b[0m(\u001b[96mself\u001b[0m, *args): \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 255 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[96mself\u001b[0m.file_like.close() \u001b[31m│\u001b[0m\n",
"\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n",
"\u001b[1;91mFileNotFoundError: \u001b[0m\u001b[1m[\u001b[0mErrno \u001b[1;36m2\u001b[0m\u001b[1m]\u001b[0m No such file or directory: \n",
"\u001b[32m'../decapoda-research/llama-7b-hf/pytorch_model-00001-of-00033.bin'\u001b[0m\n",
"\n",
"\u001b[3mDuring handling of the above exception, another exception occurred:\u001b[0m\n",
"\n",
"\u001b[31m╭─\u001b[0m\u001b[31m──────────────────────────────\u001b[0m\u001b[31m \u001b[0m\u001b[1;31mTraceback \u001b[0m\u001b[1;2;31m(most recent call last)\u001b[0m\u001b[31m \u001b[0m\u001b[31m───────────────────────────────\u001b[0m\u001b[31m─╮\u001b[0m\n",
"\u001b[31m│\u001b[0m in \u001b[92m<module>\u001b[0m:\u001b[94m16\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m13 \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m14 \u001b[0mtokenizer = LlamaTokenizer.from_pretrained(MODEL_NAME) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m15 \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m16 model = LlamaForCausalLM.from_pretrained( \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m17 \u001b[0m\u001b[2m│ \u001b[0mBASE_MODEL, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m18 \u001b[0m\u001b[2m│ \u001b[0mload_in_8bit=\u001b[94mTrue\u001b[0m, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m19 \u001b[0m\u001b[2m│ \u001b[0mtorch_dtype=torch.float16, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/\u001b[0m\u001b[1;33mmodeling_utils.py\u001b[0m:\u001b[94m28\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[94m70\u001b[0m in \u001b[92mfrom_pretrained\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2867 \u001b[0m\u001b[2m│ │ │ │ \u001b[0mmismatched_keys, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2868 \u001b[0m\u001b[2m│ │ │ │ \u001b[0moffload_index, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2869 \u001b[0m\u001b[2m│ │ │ │ \u001b[0merror_msgs, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m2870 \u001b[2m│ │ │ \u001b[0m) = \u001b[96mcls\u001b[0m._load_pretrained_model( \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2871 \u001b[0m\u001b[2m│ │ │ │ \u001b[0mmodel, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2872 \u001b[0m\u001b[2m│ │ │ │ \u001b[0mstate_dict, \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m2873 \u001b[0m\u001b[2m│ │ │ │ \u001b[0mloaded_state_dict_keys, \u001b[2m# XXX: rename?\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/\u001b[0m\u001b[1;33mmodeling_utils.py\u001b[0m:\u001b[94m32\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[94m02\u001b[0m in \u001b[92m_load_pretrained_model\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3199 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[2m# Skip the load for shards that only contain disk-offloaded weights when\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3200 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[94mif\u001b[0m shard_file \u001b[95min\u001b[0m disk_only_shard_files: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3201 \u001b[0m\u001b[2m│ │ │ │ │ \u001b[0m\u001b[94mcontinue\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m3202 \u001b[2m│ │ │ │ \u001b[0mstate_dict = load_state_dict(shard_file) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3203 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3204 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[2m# Mistmatched keys contains tuples key/shape1/shape2 of weights in the c\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m3205 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[2m# matching the weights in the model.\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2;33m/opt/conda/envs/media-reco-env-3-8/lib/python3.8/site-packages/transformers/\u001b[0m\u001b[1;33mmodeling_utils.py\u001b[0m:\u001b[94m46\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[94m2\u001b[0m in \u001b[92mload_state_dict\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 459 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mreturn\u001b[0m torch.load(checkpoint_file, map_location=\u001b[33m\"\u001b[0m\u001b[33mcpu\u001b[0m\u001b[33m\"\u001b[0m) \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 460 \u001b[0m\u001b[2m│ \u001b[0m\u001b[94mexcept\u001b[0m \u001b[96mException\u001b[0m \u001b[94mas\u001b[0m e: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 461 \u001b[0m\u001b[2m│ │ \u001b[0m\u001b[94mtry\u001b[0m: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[31m❱ \u001b[0m 462 \u001b[2m│ │ │ \u001b[0m\u001b[94mwith\u001b[0m \u001b[96mopen\u001b[0m(checkpoint_file) \u001b[94mas\u001b[0m f: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 463 \u001b[0m\u001b[2m│ │ │ │ \u001b[0m\u001b[94mif\u001b[0m f.read(\u001b[94m7\u001b[0m) == \u001b[33m\"\u001b[0m\u001b[33mversion\u001b[0m\u001b[33m\"\u001b[0m: \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 464 \u001b[0m\u001b[2m│ │ │ │ │ \u001b[0m\u001b[94mraise\u001b[0m \u001b[96mOSError\u001b[0m( \u001b[31m│\u001b[0m\n",
"\u001b[31m│\u001b[0m \u001b[2m 465 \u001b[0m\u001b[2m│ │ │ │ │ │ \u001b[0m\u001b[33m\"\u001b[0m\u001b[33mYou seem to have cloned a repository without having git-lfs ins\u001b[0m \u001b[31m│\u001b[0m\n",
"\u001b[31m╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n",
"\u001b[1;91mFileNotFoundError: \u001b[0m\u001b[1m[\u001b[0mErrno \u001b[1;36m2\u001b[0m\u001b[1m]\u001b[0m No such file or directory: \n",
"\u001b[32m'../decapoda-research/llama-7b-hf/pytorch_model-00001-of-00033.bin'\u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import torch\n",
"from transformers import GenerationConfig, LlamaTokenizer, LlamaForCausalLM\n",
"from peft import PeftModel, PeftConfig\n",
"\n",
"\n",
"MODEL_NAME = \"../\"\n",
"BASE_MODEL = \"../decapoda-research/llama-7b-hf\"\n",
"# MODEL_NAME = f\"lora-alpaca/conversations/GPU/{MODEL_NAME}\"\n",
"# MODEL_NAME = \"chainyo/alpaca-lora-7b\"\n",
"# MODEL_NAME = \"decapoda-research/llama-7b-hf\"\n",
"\n",
"config = PeftConfig.from_pretrained(MODEL_NAME)\n",
"\n",
"tokenizer = LlamaTokenizer.from_pretrained(MODEL_NAME)\n",
"\n",
"model = LlamaForCausalLM.from_pretrained(\n",
" BASE_MODEL,\n",
" load_in_8bit=True,\n",
" torch_dtype=torch.float16,\n",
" device_map=\"auto\",\n",
")\n",
"\n",
"# model = PeftModel.from_pretrained(model, MODEL_NAME)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "71dfae0f",
"metadata": {},
"outputs": [],
"source": [
"model.eval()\n",
"if torch.__version__ >= \"2\":\n",
" model = torch.compile(model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10372ae3",
"metadata": {},
"outputs": [],
"source": [
"generation_config = GenerationConfig(\n",
" temperature=0.2,\n",
" top_p=0.75,\n",
" top_k=40,\n",
" num_beams=4,\n",
" max_new_tokens=32,\n",
" repetition_penalty=1.5,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a84a4f9e",
"metadata": {},
"outputs": [],
"source": [
"instruction = \"I have two pieces of apples and 3 pieces of oranges. How many pieces of fruits do I have?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65117ac7",
"metadata": {},
"outputs": [],
"source": [
"instruction = \"What is the capital city of Greece and with which countries does Greece border?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ff7a5e5",
"metadata": {},
"outputs": [],
"source": [
"instruction = \"How can I cook Adobo?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b2b504da",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "9cba7db1",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "af3a477a",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "44fdd7ee",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Which are the tags of the following article: 'A year ago, Russia invaded Ukraine in a major escalation of the Russo-Ukrainian War, which had begun in 2014. The invasion has resulted in thousands of deaths, and instigated Europe's largest refugee crisis since World War II.\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f3a96aa",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Translate the following text from English to Greek: 'My name is George. I am 22 years old and I live with my parents.'\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b87f4120",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Ποιά είναι η πρωτεύουσα της Ελλάδας?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "520edf24",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2fdfc6b",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Translate the following text from Italian to English: 'Alla vigilia della sfida contro l'Inter, Luciano Spalletti risponde alle recenti parole del presidente De Laurentiis che ha messo in dubbio il suo futuro sulla panchina del Napoli.'\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6b87cfde",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"What is the capital city of Greece and with which countries does Greece border?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "08f25326",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"I have two oranges and 3 apples. How many pieces of fruits I have in total?\"\n",
"input_ctxt = \"Question Answering\" # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "218815c4",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Which are the tags of the following article: 'Prozess in Winterthur: Handwerker (69) wegen uraltem Sex-Heftli vor Gericht. Ein 69-jähriger Handwerker stand in Winterthur vor Gericht, weil bei ihm ein 35 Jahre altes Heftchen mit explizitem Inhalt gefunden wurde. Die Anklage scheiterte. Die Polizei führte bei einem Winterthurer eine Hausdurchsuchung durch, nachdem US-Behörden den Schweizer Behörden einen Hinweis auf ein verbotenes pornografisches Bild gaben. Allerdings fand sich auf den elektronischen Geräten des Mannes nicht der kleinste Hinweis auf weitere Bilder oder Videos im Zusammenhang mit Kinderpornografie, Sex mit Tieren oder mit Gewaltdarstellungen. Das Strafverfahren wurde eingestellt. «Jung und froh mit nacktem Po». Aber: Bei der Hausdurchsuchung stellten die Beamten ein 35 Jahre altes Sexheftli des Orion-Verlags in den Lagerräumen des Handwerkers sicher, wie der «Tages-Anzeiger» berichtet. Das Heftchen «Jung und froh mit nacktem Po» enthielt auf mehr als zehn Seiten ganzseitige Fotos nackter Mädchen und Jungen im Alter von drei bis fünfzehn Jahren.'?\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4fdd7591",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Which are the tags of the following article: 'For those now grappling with Alzheimer’s, lecanemab holds out the promise of slowing the disease’s progress. Are the modest benefits worth the risks? (C1)\\nAfter many decades of little or no progress in treating the dementia associated with Alzheimer’s, a new drug now offers hope to patients and caregivers. Lecanemab, announced late last month, was found in clinical trials to slow cognitive decline in early-stage Alzheimer’s patients. “It’s an extremely encouraging result,” says Dr. David Wolk, co-director of the University of Pennsylvania’s Penn Memory Center'?\"\n",
"input_ctxt = \"Question Answering\" # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ff82833",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Which characteristic is least likely to be affected by an individual's environment? (A) height (B) weight (C) skin color (D) eye color\"\n",
"input_ctxt = \"Tags\" # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "840e70c5",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"A student mixed some yellow sulfur powder with some iron filings. She was able to take the iron out of the sulfur by using a magnet. She then remixed the iron and sulfur in a test tube and heated it. After it cooled, she removed the substance from the test tube but could not separate the iron from the sulfur using the magnet. Which type of change occurred in the material when it was heated? (A) a physical change because the iron reacted with the sulfur (B) a chemical change because a new substance was formed (C) a physical change because a compound was formed (D) a chemical change because a magnet had to be used\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "54139a84",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Translate the following from English to Greek: 'My name is George. I am 22 years old and I live with my parents.'\"\n",
"input_ctxt = \"Question Answering\" # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c88de39f",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Translate the following from English to Spanish: 'My name is George. I am 22 years old and I live with my parents.'\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fbccda31",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"instruction = \"Translate the following from English to Tagalog: 'I love you. How is your day? Have you eaten?'\"\n",
"input_ctxt = None # For some tasks, you can provide an input context to help the model generate a better response.\n",
"\n",
"prompt = generate_prompt(instruction, input_ctxt)\n",
"input_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\n",
"input_ids = input_ids.to(model.device)\n",
"\n",
"with torch.no_grad():\n",
" outputs = model.generate(\n",
" input_ids=input_ids,\n",
" generation_config=generation_config,\n",
" return_dict_in_generate=True,\n",
" output_scores=True,\n",
" )\n",
"\n",
"response = tokenizer.decode(outputs.sequences[0], skip_special_tokens=True)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa6e355b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6df3c6d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:media-reco-env-3-8]",
"language": "python",
"name": "conda-env-media-reco-env-3-8-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|