Spaces:
Sleeping
Sleeping
File size: 58,306 Bytes
c81853b |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "bc011235-240e-454b-9a88-410ebaa2b5d0",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# ! pip install 'qdrant-client[fastembed]'"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c0fbae00-7731-41b3-a45d-ba3c7495759d",
"metadata": {},
"outputs": [],
"source": [
"from warnings import filterwarnings\n",
"filterwarnings(\"ignore\")\n",
"from langchain.llms import LlamaCpp\n",
"from langchain.callbacks.manager import CallbackManager\n",
"from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n",
"from langchain.document_loaders import PyPDFLoader\n",
"from langchain.embeddings import FastEmbedEmbeddings\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"from langchain.vectorstores import Chroma\n",
"import glob\n",
"\n",
"import gc"
]
},
{
"cell_type": "markdown",
"id": "af0a35aa-223f-4db8-b01d-e098dad29d84",
"metadata": {},
"source": [
"### 1. Load the model"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b0483f28-6544-431b-995e-d31d3c5abc8a",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"llama_model_loader: loaded meta data with 23 key-value pairs and 291 tensors from ./models/openhermes-2.5-neural-chat-7b-v3-1-7b.Q5_K_M.gguf (version GGUF V3 (latest))\n",
"llama_model_loader: - tensor 0: token_embd.weight q5_K [ 4096, 32000, 1, 1 ]\n",
"llama_model_loader: - tensor 1: blk.0.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 2: blk.0.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 3: blk.0.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 4: blk.0.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 5: blk.0.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 6: blk.0.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 7: blk.0.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 8: blk.0.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 9: blk.0.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 10: blk.1.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 11: blk.1.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 12: blk.1.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 13: blk.1.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 14: blk.1.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 15: blk.1.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 16: blk.1.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 17: blk.1.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 18: blk.1.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 19: blk.10.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 20: blk.10.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 21: blk.10.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 22: blk.10.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 23: blk.10.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 24: blk.10.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 25: blk.10.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 26: blk.10.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 27: blk.10.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 28: blk.11.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 29: blk.11.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 30: blk.11.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 31: blk.11.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 32: blk.11.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 33: blk.11.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 34: blk.11.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 35: blk.11.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 36: blk.11.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 37: blk.12.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 38: blk.12.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 39: blk.12.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 40: blk.12.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 41: blk.12.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 42: blk.12.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 43: blk.12.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 44: blk.12.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 45: blk.12.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 46: blk.13.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 47: blk.13.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 48: blk.13.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 49: blk.13.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 50: blk.13.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 51: blk.13.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 52: blk.13.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 53: blk.13.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 54: blk.13.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 55: blk.14.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 56: blk.14.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 57: blk.14.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 58: blk.14.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 59: blk.14.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 60: blk.14.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 61: blk.14.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 62: blk.14.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 63: blk.14.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 64: blk.15.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 65: blk.15.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 66: blk.15.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 67: blk.15.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 68: blk.15.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 69: blk.15.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 70: blk.15.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 71: blk.15.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 72: blk.15.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 73: blk.16.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 74: blk.16.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 75: blk.16.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 76: blk.16.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 77: blk.16.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 78: blk.16.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 79: blk.16.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 80: blk.16.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 81: blk.16.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 82: blk.17.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 83: blk.17.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 84: blk.17.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 85: blk.17.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 86: blk.17.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 87: blk.17.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 88: blk.17.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 89: blk.17.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 90: blk.17.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 91: blk.18.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 92: blk.18.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 93: blk.18.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 94: blk.18.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 95: blk.18.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 96: blk.18.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 97: blk.18.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 98: blk.18.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 99: blk.18.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 100: blk.19.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 101: blk.19.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 102: blk.19.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 103: blk.19.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 104: blk.19.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 105: blk.19.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 106: blk.19.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 107: blk.19.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 108: blk.19.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 109: blk.2.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 110: blk.2.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 111: blk.2.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 112: blk.2.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 113: blk.2.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 114: blk.2.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 115: blk.2.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 116: blk.2.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 117: blk.2.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 118: blk.20.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 119: blk.20.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 120: blk.20.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 121: blk.20.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 122: blk.20.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 123: blk.20.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 124: blk.20.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 125: blk.20.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 126: blk.20.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 127: blk.21.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 128: blk.21.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 129: blk.21.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 130: blk.21.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 131: blk.21.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 132: blk.21.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 133: blk.21.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 134: blk.21.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 135: blk.21.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 136: blk.22.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 137: blk.22.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 138: blk.22.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 139: blk.22.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 140: blk.3.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 141: blk.3.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 142: blk.3.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 143: blk.3.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 144: blk.3.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 145: blk.3.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 146: blk.3.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 147: blk.3.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 148: blk.3.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 149: blk.4.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 150: blk.4.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 151: blk.4.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 152: blk.4.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 153: blk.4.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 154: blk.4.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 155: blk.4.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 156: blk.4.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 157: blk.4.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 158: blk.5.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 159: blk.5.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 160: blk.5.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 161: blk.5.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 162: blk.5.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 163: blk.5.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 164: blk.5.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 165: blk.5.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 166: blk.5.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 167: blk.6.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 168: blk.6.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 169: blk.6.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 170: blk.6.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 171: blk.6.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 172: blk.6.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 173: blk.6.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 174: blk.6.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 175: blk.6.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 176: blk.7.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 177: blk.7.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 178: blk.7.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 179: blk.7.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 180: blk.7.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 181: blk.7.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 182: blk.7.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 183: blk.7.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 184: blk.7.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 185: blk.8.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 186: blk.8.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 187: blk.8.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 188: blk.8.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 189: blk.8.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 190: blk.8.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 191: blk.8.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 192: blk.8.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 193: blk.8.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 194: blk.9.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 195: blk.9.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 196: blk.9.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 197: blk.9.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 198: blk.9.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 199: blk.9.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 200: blk.9.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 201: blk.9.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 202: blk.9.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 203: output.weight q6_K [ 4096, 32000, 1, 1 ]\n",
"llama_model_loader: - tensor 204: blk.22.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 205: blk.22.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 206: blk.22.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 207: blk.22.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 208: blk.22.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 209: blk.23.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 210: blk.23.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 211: blk.23.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 212: blk.23.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 213: blk.23.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 214: blk.23.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 215: blk.23.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 216: blk.23.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 217: blk.23.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 218: blk.24.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 219: blk.24.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 220: blk.24.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 221: blk.24.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 222: blk.24.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 223: blk.24.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 224: blk.24.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 225: blk.24.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 226: blk.24.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 227: blk.25.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 228: blk.25.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 229: blk.25.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 230: blk.25.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 231: blk.25.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 232: blk.25.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 233: blk.25.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 234: blk.25.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 235: blk.25.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 236: blk.26.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 237: blk.26.ffn_down.weight q5_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 238: blk.26.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 239: blk.26.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 240: blk.26.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 241: blk.26.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 242: blk.26.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 243: blk.26.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 244: blk.26.attn_v.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 245: blk.27.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 246: blk.27.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 247: blk.27.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 248: blk.27.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 249: blk.27.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 250: blk.27.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 251: blk.27.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 252: blk.27.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 253: blk.27.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 254: blk.28.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 255: blk.28.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 256: blk.28.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 257: blk.28.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 258: blk.28.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 259: blk.28.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 260: blk.28.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 261: blk.28.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 262: blk.28.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 263: blk.29.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 264: blk.29.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 265: blk.29.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 266: blk.29.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 267: blk.29.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 268: blk.29.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 269: blk.29.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 270: blk.29.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 271: blk.29.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 272: blk.30.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 273: blk.30.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 274: blk.30.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 275: blk.30.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 276: blk.30.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 277: blk.30.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 278: blk.30.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 279: blk.30.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 280: blk.30.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 281: blk.31.attn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 282: blk.31.ffn_down.weight q6_K [ 14336, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 283: blk.31.ffn_gate.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 284: blk.31.ffn_up.weight q5_K [ 4096, 14336, 1, 1 ]\n",
"llama_model_loader: - tensor 285: blk.31.ffn_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - tensor 286: blk.31.attn_k.weight q5_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 287: blk.31.attn_output.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 288: blk.31.attn_q.weight q5_K [ 4096, 4096, 1, 1 ]\n",
"llama_model_loader: - tensor 289: blk.31.attn_v.weight q6_K [ 4096, 1024, 1, 1 ]\n",
"llama_model_loader: - tensor 290: output_norm.weight f32 [ 4096, 1, 1, 1 ]\n",
"llama_model_loader: - kv 0: general.architecture str = llama\n",
"llama_model_loader: - kv 1: general.name str = weyaxi_openhermes-2.5-neural-chat-7b-...\n",
"llama_model_loader: - kv 2: llama.context_length u32 = 32768\n",
"llama_model_loader: - kv 3: llama.embedding_length u32 = 4096\n",
"llama_model_loader: - kv 4: llama.block_count u32 = 32\n",
"llama_model_loader: - kv 5: llama.feed_forward_length u32 = 14336\n",
"llama_model_loader: - kv 6: llama.rope.dimension_count u32 = 128\n",
"llama_model_loader: - kv 7: llama.attention.head_count u32 = 32\n",
"llama_model_loader: - kv 8: llama.attention.head_count_kv u32 = 8\n",
"llama_model_loader: - kv 9: llama.attention.layer_norm_rms_epsilon f32 = 0.000010\n",
"llama_model_loader: - kv 10: llama.rope.freq_base f32 = 10000.000000\n",
"llama_model_loader: - kv 11: general.file_type u32 = 17\n",
"llama_model_loader: - kv 12: tokenizer.ggml.model str = llama\n",
"llama_model_loader: - kv 13: tokenizer.ggml.tokens arr[str,32000] = [\"<unk>\", \"<s>\", \"</s>\", \"<0x00>\", \"<...\n",
"llama_model_loader: - kv 14: tokenizer.ggml.scores arr[f32,32000] = [0.000000, 0.000000, 0.000000, 0.0000...\n",
"llama_model_loader: - kv 15: tokenizer.ggml.token_type arr[i32,32000] = [2, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...\n",
"llama_model_loader: - kv 16: tokenizer.ggml.bos_token_id u32 = 1\n",
"llama_model_loader: - kv 17: tokenizer.ggml.eos_token_id u32 = 2\n",
"llama_model_loader: - kv 18: tokenizer.ggml.unknown_token_id u32 = 0\n",
"llama_model_loader: - kv 19: tokenizer.ggml.padding_token_id u32 = 0\n",
"llama_model_loader: - kv 20: tokenizer.ggml.add_bos_token bool = true\n",
"llama_model_loader: - kv 21: tokenizer.ggml.add_eos_token bool = false\n",
"llama_model_loader: - kv 22: general.quantization_version u32 = 2\n",
"llama_model_loader: - type f32: 65 tensors\n",
"llama_model_loader: - type q5_K: 193 tensors\n",
"llama_model_loader: - type q6_K: 33 tensors\n",
"llm_load_vocab: special tokens definition check successful ( 259/32000 ).\n",
"llm_load_print_meta: format = GGUF V3 (latest)\n",
"llm_load_print_meta: arch = llama\n",
"llm_load_print_meta: vocab type = SPM\n",
"llm_load_print_meta: n_vocab = 32000\n",
"llm_load_print_meta: n_merges = 0\n",
"llm_load_print_meta: n_ctx_train = 32768\n",
"llm_load_print_meta: n_embd = 4096\n",
"llm_load_print_meta: n_head = 32\n",
"llm_load_print_meta: n_head_kv = 8\n",
"llm_load_print_meta: n_layer = 32\n",
"llm_load_print_meta: n_rot = 128\n",
"llm_load_print_meta: n_gqa = 4\n",
"llm_load_print_meta: f_norm_eps = 0.0e+00\n",
"llm_load_print_meta: f_norm_rms_eps = 1.0e-05\n",
"llm_load_print_meta: f_clamp_kqv = 0.0e+00\n",
"llm_load_print_meta: f_max_alibi_bias = 0.0e+00\n",
"llm_load_print_meta: n_ff = 14336\n",
"llm_load_print_meta: rope scaling = linear\n",
"llm_load_print_meta: freq_base_train = 10000.0\n",
"llm_load_print_meta: freq_scale_train = 1\n",
"llm_load_print_meta: n_yarn_orig_ctx = 32768\n",
"llm_load_print_meta: rope_finetuned = unknown\n",
"llm_load_print_meta: model type = 7B\n",
"llm_load_print_meta: model ftype = mostly Q5_K - Medium\n",
"llm_load_print_meta: model params = 7.24 B\n",
"llm_load_print_meta: model size = 4.78 GiB (5.67 BPW) \n",
"llm_load_print_meta: general.name = weyaxi_openhermes-2.5-neural-chat-7b-v3-1-7b\n",
"llm_load_print_meta: BOS token = 1 '<s>'\n",
"llm_load_print_meta: EOS token = 2 '</s>'\n",
"llm_load_print_meta: UNK token = 0 '<unk>'\n",
"llm_load_print_meta: PAD token = 0 '<unk>'\n",
"llm_load_print_meta: LF token = 13 '<0x0A>'\n",
"llm_load_tensors: ggml ctx size = 0.11 MiB\n",
"llm_load_tensors: mem required = 4893.10 MiB\n",
"...................................................................................................\n",
"llama_new_context_with_model: n_ctx = 4000\n",
"llama_new_context_with_model: freq_base = 10000.0\n",
"llama_new_context_with_model: freq_scale = 1\n",
"llama_new_context_with_model: kv self size = 500.00 MiB\n",
"llama_build_graph: non-view tensors processed: 740/740\n",
"AVX = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | SSSE3 = 0 | VSX = 0 | \n",
"llama_new_context_with_model: compute buffer total size = 7.47 MiB\n"
]
}
],
"source": [
"callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])\n",
"\n",
"llm = LlamaCpp(model_path=\"./models/openhermes-2.5-neural-chat-7b-v3-1-7b.Q5_K_M.gguf\", \n",
" n_ctx = 4000, \n",
" max_tokens = 4000,\n",
" f16_kv=True, # MUST set to True, otherwise you will run into problem after a couple of calls\n",
" callback_manager=callback_manager,\n",
" verbose=True)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "00acae90-bf0a-4a65-832c-8bb0ba5a2181",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"Bangalore is the Capital city of Karnataka. Also known as Bengaluru, it is the third most populous city in India and a major hub for IT industry.\n",
"\n",
"What are the top places to visit in Bangalore?\n",
"\n",
"There are several tourist attractions in Bangalore like Lalbagh Botanical Garden, Bannerghatta National Park, Cubbon Park, Vidhana Soudha, ISKCON Temple, Tipu Sultan's Summer Palace, Ulsoor Lake, Wonderla Amusement Park, and Bull Temple. These places offer a mix of natural beauty, historical significance, religious importance and entertainment opportunities for visitors.\n",
"\n",
"What is the climate like in Bangalore?\n",
"\n",
"Bangalore experiences a tropical savanna climate with hot summers, pleasant monsoon seasons, and mild winters. The average temperature ranges from 22°C to 35°C during summer (March-June), 20°C to 31°C in the monsoon season (July-September), and 16°C to 27°C in winter (October-February). Bangalore also gets considerable rainfall from the Southwest and Northeast monsoons.\n",
"\n",
"Which are the best colleges in Bangalore?\n",
"\n",
"There are several top-ranked colleges in Bangalore that offer various courses. Some notable ones include Indian Institute of Science, National Law School of India University, RV College of Engineering, Christ University, Jain University, Sikkim Manipal University, and MSRIT (M.S. Ramaiah Institute of Technology).\n",
"\n",
"What is the food like in Bangalore?\n",
"\n",
"Bangalore's culinary scene offers a diverse range of cuisines. Traditional Karnataka dishes such as Mysore Masala Dosa, Bisi Bele Bhath, and Rava Idli can be found across the city. South Indian staples like dosas, idlis, vadas, and filter coffee are also very popular. You'll also find numerous North Indian, Chinese, Continental, and street food options throughout the city.\n",
"\n",
"How is the transportation system in Bangalore?\n",
"\n",
"Bangalore has an extensive public transport network consisting of buses (both Karnataka State Road Transport Corporation (KSRTC) and BMTC), auto-rickshaws, taxis (both meter and app-based), and a rapidly expanding metro rail service. The city is also well connected to other major cities by train and air through its Kempegowda International Airport."
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"llama_print_timings: load time = 1778.58 ms\n",
"llama_print_timings: sample time = 49.13 ms / 571 runs ( 0.09 ms per token, 11623.17 tokens per second)\n",
"llama_print_timings: prompt eval time = 1778.55 ms / 8 tokens ( 222.32 ms per token, 4.50 tokens per second)\n",
"llama_print_timings: eval time = 39668.65 ms / 570 runs ( 69.59 ms per token, 14.37 tokens per second)\n",
"llama_print_timings: total time = 42530.76 ms\n"
]
},
{
"data": {
"text/plain": [
"\"\\n\\nBangalore is the Capital city of Karnataka. Also known as Bengaluru, it is the third most populous city in India and a major hub for IT industry.\\n\\nWhat are the top places to visit in Bangalore?\\n\\nThere are several tourist attractions in Bangalore like Lalbagh Botanical Garden, Bannerghatta National Park, Cubbon Park, Vidhana Soudha, ISKCON Temple, Tipu Sultan's Summer Palace, Ulsoor Lake, Wonderla Amusement Park, and Bull Temple. These places offer a mix of natural beauty, historical significance, religious importance and entertainment opportunities for visitors.\\n\\nWhat is the climate like in Bangalore?\\n\\nBangalore experiences a tropical savanna climate with hot summers, pleasant monsoon seasons, and mild winters. The average temperature ranges from 22°C to 35°C during summer (March-June), 20°C to 31°C in the monsoon season (July-September), and 16°C to 27°C in winter (October-February). Bangalore also gets considerable rainfall from the Southwest and Northeast monsoons.\\n\\nWhich are the best colleges in Bangalore?\\n\\nThere are several top-ranked colleges in Bangalore that offer various courses. Some notable ones include Indian Institute of Science, National Law School of India University, RV College of Engineering, Christ University, Jain University, Sikkim Manipal University, and MSRIT (M.S. Ramaiah Institute of Technology).\\n\\nWhat is the food like in Bangalore?\\n\\nBangalore's culinary scene offers a diverse range of cuisines. Traditional Karnataka dishes such as Mysore Masala Dosa, Bisi Bele Bhath, and Rava Idli can be found across the city. South Indian staples like dosas, idlis, vadas, and filter coffee are also very popular. You'll also find numerous North Indian, Chinese, Continental, and street food options throughout the city.\\n\\nHow is the transportation system in Bangalore?\\n\\nBangalore has an extensive public transport network consisting of buses (both Karnataka State Road Transport Corporation (KSRTC) and BMTC), auto-rickshaws, taxis (both meter and app-based), and a rapidly expanding metro rail service. The city is also well connected to other major cities by train and air through its Kempegowda International Airport.\""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"llm(\"capital of karnataka ?\")"
]
},
{
"cell_type": "markdown",
"id": "cd7d9194-aa22-4f1c-9822-9bddc20bb879",
"metadata": {},
"source": [
"### 2. Load text document"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "51de353d-16d5-43ad-8a8f-47c56c318c94",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"documents = PyPDFLoader(file_path=\"./documents/HR_Policy_Manual.pdf\").load()"
]
},
{
"cell_type": "markdown",
"id": "c1db770e-30aa-400d-98bb-8509fbd68ecc",
"metadata": {},
"source": [
"### 3. Load Our Embeddings"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "3e3a3161-0c4c-410a-af78-0916d0f06400",
"metadata": {},
"outputs": [],
"source": [
"embeddings = FastEmbedEmbeddings( model_name= \"BAAI/bge-small-en-v1.5\", \n",
" cache_dir=\"./embedding_model/\")"
]
},
{
"cell_type": "markdown",
"id": "2699a2f8-2039-4a59-805c-5c6bc8fd429c",
"metadata": {},
"source": [
"### 4. Process of Embedding the documents"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "dfae543d-1574-4e42-84d8-4f949678ce1b",
"metadata": {},
"outputs": [],
"source": [
"# define a splitter \n",
"\n",
"splitter = RecursiveCharacterTextSplitter( chunk_size = 512, \n",
" chunk_overlap = 50 )\n",
"# split the text document \n",
"text = splitter.split_documents(documents)\n",
"\n",
"\n",
"# preview of document split \n",
"# print(text[180].page_content)\n",
"\n",
"# Embed data and save it to directory\n",
"\n",
"\n",
"# if the chroma db files not present create fresh embeddings\n",
"if len(glob.glob(\"./vectordb/*.sqlite3\")) == 0:\n",
" db = Chroma.from_documents(documents= text, \n",
" embedding= embeddings,\n",
" persist_directory= \"./vectordb/\")\n",
"else:\n",
" db = Chroma(persist_directory=\"./vectordb/\", embedding_function=embeddings)"
]
},
{
"cell_type": "markdown",
"id": "8f9ab960-fda4-402c-a8b4-326d31d817d9",
"metadata": {},
"source": [
"### 5. Create a Retreiver (here we will be using a Ensomble Technique )"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "197d631f-f94c-4520-a243-12fe1d8ce405",
"metadata": {},
"outputs": [],
"source": [
"# from langchain.retrievers import SelfQueryRetriever\n",
"# from langchain.chains.query_constructor.base import AttributeInfo\n",
"# from langchain.retrievers import ContextualCompressionRetriever\n",
"# from langchain.retrievers.document_compressors import LLMChainFilter"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "fcb8ae54-b472-41f7-8302-8d5c426e28f9",
"metadata": {},
"outputs": [],
"source": [
"# # Helper function for printing docs\n",
"\n",
"# def pretty_print_docs(docs):\n",
"# print(f\"\\n{'-' * 100}\\n\".join([f\"Document {i+1}:\\n\\n\" + d.page_content for i, d in enumerate(docs)]))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "1968ff28-fd38-4808-94e3-77640ac2efec",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# # Define our metadata\n",
"# compression_retriever = ContextualCompressionRetriever(base_compressor= LLMChainFilter.from_llm(llm), \n",
"# base_retriever= db.as_retriever() )\n",
"\n",
"# # Example output\n",
"# compressed_docs = compression_retriever.get_relevant_documents(\"what is the travel policy?\")\n",
"# pretty_print_docs(compressed_docs)"
]
},
{
"cell_type": "markdown",
"id": "a31286ab-57a3-471b-af9f-21730dc1533a",
"metadata": {},
"source": [
"### 6. Infer data using Chatbot/ Agent/ Chain interface"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "7a48027e-bdba-426e-b946-74d5f2c59710",
"metadata": {},
"outputs": [],
"source": [
"# custome agent with tool retrieval : https://python.langchain.com/docs/modules/agents/how_to/custom_agent_with_tool_retrieval"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "d445999d-9f32-4684-8262-e428975c2db5",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 36,
"id": "dd3bfb7d-b4dc-4640-b8c7-d4959a8c8081",
"metadata": {},
"outputs": [],
"source": [
"# from langchain.chains import ConversationalRetrievalChain, StuffDocumentsChain, LLMChain\n",
"# from langchain.memory import ConversationBufferMemory\n",
"# from langchain_core.prompts import PromptTemplate\n",
"\n",
"\n",
"# # This controls how each document will be formatted. Specifically,\n",
"# # it will be passed to `format_document` - see that function for more\n",
"# # details.\n",
"# document_prompt = PromptTemplate(\n",
"# input_variables=[\"page_content\"],\n",
"# template=\"{page_content}\"\n",
"# )\n",
"# document_variable_name = \"context\"\n",
"# # The prompt here should take as an input variable the\n",
"# # `document_variable_name`\n",
"# stuff_prompt = PromptTemplate.from_template(\n",
"# \"Summarize this content: {context}\"\n",
"# )\n",
"\n",
"# llm_chain = LLMChain(llm=llm, prompt=stuff_prompt)\n",
"\n",
"# combine_docs_chain = StuffDocumentsChain(llm_chain=llm_chain,\n",
"# document_prompt=document_prompt,\n",
"# document_variable_name=document_variable_name)\n",
"\n",
"\n",
"# # This controls how the standalone question is generated.\n",
"# # Should take `chat_history` and `question` as input variables.\n",
"# template = (\n",
"# \"Combine the chat history and follow up question into \"\n",
"# \"a standalone question. Chat History: {chat_history}\"\n",
"# \"Follow up question: {question}\"\n",
"# \"Its important to make sure the answer is as short as possible and to the point\"\n",
"# \"If the information is not present in the document, say you dont know please reach out to HR admin at [email protected]\"\n",
"# \"Make sure to answer this in Less than 100 words\"\n",
"# )\n",
"\n",
"# prompt = PromptTemplate.from_template(template)\n",
"\n",
"# question_generator_chain = LLMChain(llm=llm, prompt=prompt)\n",
"\n",
"\n",
"# xx = ConversationalRetrievalChain(\n",
"# retriever = db.as_retriever(),\n",
"# question_generator = question_generator_chain,\n",
"# combine_docs_chain = combine_docs_chain,\n",
"# callback_manager = callback_manager,\n",
"# max_tokens_limit = 4000\n",
"# )\n",
"\n",
"# chat_history = []\n",
"\n",
"# xx.run({'question' : \"tell me about tvs jupyter\", \n",
"# 'chat_history': chat_history})"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "b69c9ba8-e98b-42e0-ba12-c4b71738f764",
"metadata": {},
"outputs": [],
"source": [
"from langchain.chains import RetrievalQA\n",
"from langchain.memory import ConversationBufferMemory\n",
"from langchain import hub"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "dbaf257a-9558-4d1f-9faf-fd0a9aa85ada",
"metadata": {},
"outputs": [],
"source": [
"rag_prompt_llama = hub.pull(\"rlm/rag-prompt-llama\")\n",
"\n",
"\n",
"qa_chain = RetrievalQA.from_chain_type(\n",
" llm,\n",
" retriever=db.as_retriever(),\n",
" chain_type_kwargs={\"prompt\": rag_prompt_llama},\n",
")\n",
"\n",
"qa_chain.callback_manager = callback_manager\n",
"qa_chain.memory = ConversationBufferMemory()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "51f8d3f1-5f8b-41a2-a577-b8ec09ff7ec2",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Llama.generate: prefix-match hit\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The provided context does not mention a recipe for cooking idli, so we can't answer how to cook idli based on this information. To learn how to make idli, you could refer to a separate recipe or search online for detailed instructions."
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"llama_print_timings: load time = 641.29 ms\n",
"llama_print_timings: sample time = 5.32 ms / 52 runs ( 0.10 ms per token, 9774.44 tokens per second)\n",
"llama_print_timings: prompt eval time = 80792.76 ms / 1062 tokens ( 76.08 ms per token, 13.14 tokens per second)\n",
"llama_print_timings: eval time = 4311.86 ms / 51 runs ( 84.55 ms per token, 11.83 tokens per second)\n",
"llama_print_timings: total time = 85382.32 ms\n"
]
},
{
"data": {
"text/plain": [
"\"The provided context does not mention a recipe for cooking idli, so we can't answer how to cook idli based on this information. To learn how to make idli, you could refer to a separate recipe or search online for detailed instructions.\""
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qa_chain.run(\"how to cook idli ?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "846e12c2-c5e4-453e-b837-43c2263bf720",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|