File size: 92,033 Bytes
e44034c |
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 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"Basic Inferencing Code......."
],
"metadata": {
"id": "0oBfjDUPrLcP"
}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "gjcC3S4tOAQz",
"outputId": "dab8a6f6-a9c3-443c-d712-d9b6314c4e68"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/drive\n"
]
}
],
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')\n"
]
},
{
"cell_type": "markdown",
"source": [
"installing the llama cpp package(required for GGUF inferencing)\n"
],
"metadata": {
"id": "Yj2d_12m6MM1"
}
},
{
"cell_type": "code",
"source": [
"!pip install llama-cpp-python"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "TNnbYg4YP_Kg",
"outputId": "6c8fcbca-0eef-40de-fb80-c87e439e97d1"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting llama-cpp-python\n",
" Downloading llama_cpp_python-0.3.8.tar.gz (67.3 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m67.3/67.3 MB\u001b[0m \u001b[31m13.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Installing backend dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.11/dist-packages (from llama-cpp-python) (4.12.2)\n",
"Requirement already satisfied: numpy>=1.20.0 in /usr/local/lib/python3.11/dist-packages (from llama-cpp-python) (2.0.2)\n",
"Collecting diskcache>=5.6.1 (from llama-cpp-python)\n",
" Downloading diskcache-5.6.3-py3-none-any.whl.metadata (20 kB)\n",
"Requirement already satisfied: jinja2>=2.11.3 in /usr/local/lib/python3.11/dist-packages (from llama-cpp-python) (3.1.6)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2>=2.11.3->llama-cpp-python) (3.0.2)\n",
"Downloading diskcache-5.6.3-py3-none-any.whl (45 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m45.5/45.5 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hBuilding wheels for collected packages: llama-cpp-python\n",
" Building wheel for llama-cpp-python (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for llama-cpp-python: filename=llama_cpp_python-0.3.8-cp311-cp311-linux_x86_64.whl size=5959614 sha256=4ce6f18bdb98c333c5e90158323e9fd50b4032f1f97973de95bf0796fec1d726\n",
" Stored in directory: /root/.cache/pip/wheels/c0/03/66/eb3810eafd55d921b2be32896d1f44313996982360663aa80b\n",
"Successfully built llama-cpp-python\n",
"Installing collected packages: diskcache, llama-cpp-python\n",
"Successfully installed diskcache-5.6.3 llama-cpp-python-0.3.8\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"from llama_cpp import Llama\n",
"import random\n",
"\n",
"# Load the model with a system message\n",
"model_path = \"/content/drive/MyDrive/Dating_LLM_GGUF/damn.gguf\"\n",
"llm = Llama(\n",
" model_path=model_path,\n",
" n_gpu_layers=40,\n",
" n_ctx=2048,\n",
" system_message=\"You are an unfiltered, informal AI assistant. You can use slang, jokes, vulgar words, and a humorous tone when answering. Always add emojis and sound like a real friend talking casually.\"\n",
")\n",
"\n",
"# Function to determine gender-based greeting\n",
"def get_salutation(user_input):\n",
" male_keywords = [\"girlfriend\", \"wife\", \"she\", \"her\"]\n",
" female_keywords = [\"boyfriend\", \"husband\", \"he\", \"him\"]\n",
"\n",
" if any(word in user_input.lower() for word in male_keywords):\n",
" return random.choice([\"Hey queen! ๐\", \"Girl, listen up! ๐
\", \"Sis, letโs talk โค๏ธ\"])\n",
" elif any(word in user_input.lower() for word in female_keywords):\n",
" return random.choice([\"Yo bro! ๐ฅ\", \"Dude, hear me out ๐ค\", \"Man, let's fix this ๐ช\"])\n",
" else:\n",
" return random.choice([\"Yo dude! ๐\", \"Hey buddy! ๐\", \"Listen up, my friend โค๏ธ\"])\n",
"\n",
"# Function to modify user prompt\n",
"def make_emotional(user_input):\n",
" salutation = get_salutation(user_input)\n",
" suffix = \" Give me some real, no-BS advice with emojis! ๐๐ฅ๐\"\n",
"\n",
" return f\"{salutation} {user_input} {suffix}\"\n",
"\n",
"# User input (simulate user typing a normal question)\n",
"user_input = \"My partner doesn't like my friends. What should I do?\"\n",
"\n",
"# Modify the input before passing to the model\n",
"emotional_prompt = make_emotional(user_input)\n",
"\n",
"# Run inference with modified prompt\n",
"output = llm(emotional_prompt, max_tokens=200)\n",
"\n",
"# Print the output\n",
"print(output[\"choices\"][0][\"text\"])\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "IJaKWdZUP8hX",
"outputId": "ab206dec-2fb9-4661-e0cb-13956ac98003"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"llama_model_loader: loaded meta data with 24 key-value pairs and 434 tensors from /content/drive/MyDrive/Dating_LLM_GGUF/damn.gguf (version GGUF V3 (latest))\n",
"llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n",
"llama_model_loader: - kv 0: general.architecture str = qwen2\n",
"llama_model_loader: - kv 1: general.type str = model\n",
"llama_model_loader: - kv 2: general.name str = Merged\n",
"llama_model_loader: - kv 3: general.size_label str = 3.1B\n",
"llama_model_loader: - kv 4: qwen2.block_count u32 = 36\n",
"llama_model_loader: - kv 5: qwen2.context_length u32 = 32768\n",
"llama_model_loader: - kv 6: qwen2.embedding_length u32 = 2048\n",
"llama_model_loader: - kv 7: qwen2.feed_forward_length u32 = 11008\n",
"llama_model_loader: - kv 8: qwen2.attention.head_count u32 = 16\n",
"llama_model_loader: - kv 9: qwen2.attention.head_count_kv u32 = 2\n",
"llama_model_loader: - kv 10: qwen2.rope.freq_base f32 = 1000000.000000\n",
"llama_model_loader: - kv 11: qwen2.attention.layer_norm_rms_epsilon f32 = 0.000001\n",
"llama_model_loader: - kv 12: general.file_type u32 = 1\n",
"llama_model_loader: - kv 13: tokenizer.ggml.model str = gpt2\n",
"llama_model_loader: - kv 14: tokenizer.ggml.pre str = qwen2\n",
"llama_model_loader: - kv 15: tokenizer.ggml.tokens arr[str,151936] = [\"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\", ...\n",
"llama_model_loader: - kv 16: tokenizer.ggml.token_type arr[i32,151936] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...\n",
"llama_model_loader: - kv 17: tokenizer.ggml.merges arr[str,151387] = [\"ฤ ฤ \", \"ฤ ฤ ฤ ฤ \", \"i n\", \"ฤ t\",...\n",
"llama_model_loader: - kv 18: tokenizer.ggml.eos_token_id u32 = 151645\n",
"llama_model_loader: - kv 19: tokenizer.ggml.padding_token_id u32 = 151643\n",
"llama_model_loader: - kv 20: tokenizer.ggml.bos_token_id u32 = 151643\n",
"llama_model_loader: - kv 21: tokenizer.ggml.add_bos_token bool = false\n",
"llama_model_loader: - kv 22: tokenizer.chat_template str = {%- if tools %}\\n {{- '<|im_start|>...\n",
"llama_model_loader: - kv 23: general.quantization_version u32 = 2\n",
"llama_model_loader: - type f32: 181 tensors\n",
"llama_model_loader: - type f16: 253 tensors\n",
"print_info: file format = GGUF V3 (latest)\n",
"print_info: file type = F16\n",
"print_info: file size = 5.75 GiB (16.00 BPW) \n",
"init_tokenizer: initializing tokenizer for type 2\n",
"load: control token: 151660 '<|fim_middle|>' is not marked as EOG\n",
"load: control token: 151659 '<|fim_prefix|>' is not marked as EOG\n",
"load: control token: 151653 '<|vision_end|>' is not marked as EOG\n",
"load: control token: 151648 '<|box_start|>' is not marked as EOG\n",
"load: control token: 151646 '<|object_ref_start|>' is not marked as EOG\n",
"load: control token: 151649 '<|box_end|>' is not marked as EOG\n",
"load: control token: 151655 '<|image_pad|>' is not marked as EOG\n",
"load: control token: 151651 '<|quad_end|>' is not marked as EOG\n",
"load: control token: 151647 '<|object_ref_end|>' is not marked as EOG\n",
"load: control token: 151652 '<|vision_start|>' is not marked as EOG\n",
"load: control token: 151654 '<|vision_pad|>' is not marked as EOG\n",
"load: control token: 151656 '<|video_pad|>' is not marked as EOG\n",
"load: control token: 151644 '<|im_start|>' is not marked as EOG\n",
"load: control token: 151661 '<|fim_suffix|>' is not marked as EOG\n",
"load: control token: 151650 '<|quad_start|>' is not marked as EOG\n",
"load: special tokens cache size = 22\n",
"load: token to piece cache size = 0.9310 MB\n",
"print_info: arch = qwen2\n",
"print_info: vocab_only = 0\n",
"print_info: n_ctx_train = 32768\n",
"print_info: n_embd = 2048\n",
"print_info: n_layer = 36\n",
"print_info: n_head = 16\n",
"print_info: n_head_kv = 2\n",
"print_info: n_rot = 128\n",
"print_info: n_swa = 0\n",
"print_info: n_embd_head_k = 128\n",
"print_info: n_embd_head_v = 128\n",
"print_info: n_gqa = 8\n",
"print_info: n_embd_k_gqa = 256\n",
"print_info: n_embd_v_gqa = 256\n",
"print_info: f_norm_eps = 0.0e+00\n",
"print_info: f_norm_rms_eps = 1.0e-06\n",
"print_info: f_clamp_kqv = 0.0e+00\n",
"print_info: f_max_alibi_bias = 0.0e+00\n",
"print_info: f_logit_scale = 0.0e+00\n",
"print_info: f_attn_scale = 0.0e+00\n",
"print_info: n_ff = 11008\n",
"print_info: n_expert = 0\n",
"print_info: n_expert_used = 0\n",
"print_info: causal attn = 1\n",
"print_info: pooling type = 0\n",
"print_info: rope type = 2\n",
"print_info: rope scaling = linear\n",
"print_info: freq_base_train = 1000000.0\n",
"print_info: freq_scale_train = 1\n",
"print_info: n_ctx_orig_yarn = 32768\n",
"print_info: rope_finetuned = unknown\n",
"print_info: ssm_d_conv = 0\n",
"print_info: ssm_d_inner = 0\n",
"print_info: ssm_d_state = 0\n",
"print_info: ssm_dt_rank = 0\n",
"print_info: ssm_dt_b_c_rms = 0\n",
"print_info: model type = 3B\n",
"print_info: model params = 3.09 B\n",
"print_info: general.name = Merged\n",
"print_info: vocab type = BPE\n",
"print_info: n_vocab = 151936\n",
"print_info: n_merges = 151387\n",
"print_info: BOS token = 151643 '<|endoftext|>'\n",
"print_info: EOS token = 151645 '<|im_end|>'\n",
"print_info: EOT token = 151645 '<|im_end|>'\n",
"print_info: PAD token = 151643 '<|endoftext|>'\n",
"print_info: LF token = 198 'ฤ'\n",
"print_info: FIM PRE token = 151659 '<|fim_prefix|>'\n",
"print_info: FIM SUF token = 151661 '<|fim_suffix|>'\n",
"print_info: FIM MID token = 151660 '<|fim_middle|>'\n",
"print_info: FIM PAD token = 151662 '<|fim_pad|>'\n",
"print_info: FIM REP token = 151663 '<|repo_name|>'\n",
"print_info: FIM SEP token = 151664 '<|file_sep|>'\n",
"print_info: EOG token = 151643 '<|endoftext|>'\n",
"print_info: EOG token = 151645 '<|im_end|>'\n",
"print_info: EOG token = 151662 '<|fim_pad|>'\n",
"print_info: EOG token = 151663 '<|repo_name|>'\n",
"print_info: EOG token = 151664 '<|file_sep|>'\n",
"print_info: max token length = 256\n",
"load_tensors: loading model tensors, this can take a while... (mmap = true)\n",
"load_tensors: layer 0 assigned to device CPU\n",
"load_tensors: layer 1 assigned to device CPU\n",
"load_tensors: layer 2 assigned to device CPU\n",
"load_tensors: layer 3 assigned to device CPU\n",
"load_tensors: layer 4 assigned to device CPU\n",
"load_tensors: layer 5 assigned to device CPU\n",
"load_tensors: layer 6 assigned to device CPU\n",
"load_tensors: layer 7 assigned to device CPU\n",
"load_tensors: layer 8 assigned to device CPU\n",
"load_tensors: layer 9 assigned to device CPU\n",
"load_tensors: layer 10 assigned to device CPU\n",
"load_tensors: layer 11 assigned to device CPU\n",
"load_tensors: layer 12 assigned to device CPU\n",
"load_tensors: layer 13 assigned to device CPU\n",
"load_tensors: layer 14 assigned to device CPU\n",
"load_tensors: layer 15 assigned to device CPU\n",
"load_tensors: layer 16 assigned to device CPU\n",
"load_tensors: layer 17 assigned to device CPU\n",
"load_tensors: layer 18 assigned to device CPU\n",
"load_tensors: layer 19 assigned to device CPU\n",
"load_tensors: layer 20 assigned to device CPU\n",
"load_tensors: layer 21 assigned to device CPU\n",
"load_tensors: layer 22 assigned to device CPU\n",
"load_tensors: layer 23 assigned to device CPU\n",
"load_tensors: layer 24 assigned to device CPU\n",
"load_tensors: layer 25 assigned to device CPU\n",
"load_tensors: layer 26 assigned to device CPU\n",
"load_tensors: layer 27 assigned to device CPU\n",
"load_tensors: layer 28 assigned to device CPU\n",
"load_tensors: layer 29 assigned to device CPU\n",
"load_tensors: layer 30 assigned to device CPU\n",
"load_tensors: layer 31 assigned to device CPU\n",
"load_tensors: layer 32 assigned to device CPU\n",
"load_tensors: layer 33 assigned to device CPU\n",
"load_tensors: layer 34 assigned to device CPU\n",
"load_tensors: layer 35 assigned to device CPU\n",
"load_tensors: layer 36 assigned to device CPU\n",
"load_tensors: tensor 'token_embd.weight' (f16) (and 434 others) cannot be used with preferred buffer type CPU_AARCH64, using CPU instead\n",
"load_tensors: CPU_Mapped model buffer size = 5886.42 MiB\n",
"...........................................................................................\n",
"llama_init_from_model: n_seq_max = 1\n",
"llama_init_from_model: n_ctx = 2048\n",
"llama_init_from_model: n_ctx_per_seq = 2048\n",
"llama_init_from_model: n_batch = 512\n",
"llama_init_from_model: n_ubatch = 512\n",
"llama_init_from_model: flash_attn = 0\n",
"llama_init_from_model: freq_base = 1000000.0\n",
"llama_init_from_model: freq_scale = 1\n",
"llama_init_from_model: n_ctx_per_seq (2048) < n_ctx_train (32768) -- the full capacity of the model will not be utilized\n",
"llama_kv_cache_init: kv_size = 2048, offload = 1, type_k = 'f16', type_v = 'f16', n_layer = 36, can_shift = 1\n",
"llama_kv_cache_init: layer 0: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 1: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 2: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 3: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 4: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 5: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 6: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 7: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 8: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 9: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 10: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 11: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 12: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 13: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 14: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 15: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 16: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 17: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 18: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 19: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 20: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 21: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 22: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 23: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 24: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 25: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 26: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 27: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 28: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 29: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 30: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 31: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 32: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 33: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 34: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 35: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: CPU KV buffer size = 72.00 MiB\n",
"llama_init_from_model: KV self size = 72.00 MiB, K (f16): 36.00 MiB, V (f16): 36.00 MiB\n",
"llama_init_from_model: CPU output buffer size = 0.58 MiB\n",
"llama_init_from_model: CPU compute buffer size = 300.75 MiB\n",
"llama_init_from_model: graph nodes = 1266\n",
"llama_init_from_model: graph splits = 1\n",
"CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | LLAMAFILE = 1 | OPENMP = 1 | AARCH64_REPACK = 1 | \n",
"Model metadata: {'tokenizer.ggml.add_bos_token': 'false', 'tokenizer.ggml.bos_token_id': '151643', 'general.architecture': 'qwen2', 'tokenizer.ggml.padding_token_id': '151643', 'qwen2.embedding_length': '2048', 'tokenizer.ggml.pre': 'qwen2', 'general.name': 'Merged', 'qwen2.block_count': '36', 'general.type': 'model', 'general.size_label': '3.1B', 'qwen2.context_length': '32768', 'tokenizer.chat_template': '{%- if tools %}\\n {{- \\'<|im_start|>system\\\\n\\' }}\\n {%- if messages[0][\\'role\\'] == \\'system\\' %}\\n {{- messages[0][\\'content\\'] }}\\n {%- else %}\\n {{- \\'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.\\' }}\\n {%- endif %}\\n {{- \"\\\\n\\\\n# Tools\\\\n\\\\nYou may call one or more functions to assist with the user query.\\\\n\\\\nYou are provided with function signatures within <tools></tools> XML tags:\\\\n<tools>\" }}\\n {%- for tool in tools %}\\n {{- \"\\\\n\" }}\\n {{- tool | tojson }}\\n {%- endfor %}\\n {{- \"\\\\n</tools>\\\\n\\\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\\\n<tool_call>\\\\n{\\\\\"name\\\\\": <function-name>, \\\\\"arguments\\\\\": <args-json-object>}\\\\n</tool_call><|im_end|>\\\\n\" }}\\n{%- else %}\\n {%- if messages[0][\\'role\\'] == \\'system\\' %}\\n {{- \\'<|im_start|>system\\\\n\\' + messages[0][\\'content\\'] + \\'<|im_end|>\\\\n\\' }}\\n {%- else %}\\n {{- \\'<|im_start|>system\\\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\\\n\\' }}\\n {%- endif %}\\n{%- endif %}\\n{%- for message in messages %}\\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\\n {{- \\'<|im_start|>\\' + message.role + \\'\\\\n\\' + message.content + \\'<|im_end|>\\' + \\'\\\\n\\' }}\\n {%- elif message.role == \"assistant\" %}\\n {{- \\'<|im_start|>\\' + message.role }}\\n {%- if message.content %}\\n {{- \\'\\\\n\\' + message.content }}\\n {%- endif %}\\n {%- for tool_call in message.tool_calls %}\\n {%- if tool_call.function is defined %}\\n {%- set tool_call = tool_call.function %}\\n {%- endif %}\\n {{- \\'\\\\n<tool_call>\\\\n{\"name\": \"\\' }}\\n {{- tool_call.name }}\\n {{- \\'\", \"arguments\": \\' }}\\n {{- tool_call.arguments | tojson }}\\n {{- \\'}\\\\n</tool_call>\\' }}\\n {%- endfor %}\\n {{- \\'<|im_end|>\\\\n\\' }}\\n {%- elif message.role == \"tool\" %}\\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\\n {{- \\'<|im_start|>user\\' }}\\n {%- endif %}\\n {{- \\'\\\\n<tool_response>\\\\n\\' }}\\n {{- message.content }}\\n {{- \\'\\\\n</tool_response>\\' }}\\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\\n {{- \\'<|im_end|>\\\\n\\' }}\\n {%- endif %}\\n {%- endif %}\\n{%- endfor %}\\n{%- if add_generation_prompt %}\\n {{- \\'<|im_start|>assistant\\\\n\\' }}\\n{%- endif %}\\n', 'qwen2.attention.head_count_kv': '2', 'general.quantization_version': '2', 'tokenizer.ggml.model': 'gpt2', 'qwen2.feed_forward_length': '11008', 'qwen2.attention.layer_norm_rms_epsilon': '0.000001', 'qwen2.attention.head_count': '16', 'tokenizer.ggml.eos_token_id': '151645', 'qwen2.rope.freq_base': '1000000.000000', 'general.file_type': '1'}\n",
"Available chat formats from metadata: chat_template.default\n",
"Using gguf chat template: {%- if tools %}\n",
" {{- '<|im_start|>system\\n' }}\n",
" {%- if messages[0]['role'] == 'system' %}\n",
" {{- messages[0]['content'] }}\n",
" {%- else %}\n",
" {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n",
" {%- endif %}\n",
" {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n",
" {%- for tool in tools %}\n",
" {{- \"\\n\" }}\n",
" {{- tool | tojson }}\n",
" {%- endfor %}\n",
" {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n",
"{%- else %}\n",
" {%- if messages[0]['role'] == 'system' %}\n",
" {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n",
" {%- else %}\n",
" {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n",
" {%- endif %}\n",
"{%- endif %}\n",
"{%- for message in messages %}\n",
" {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n",
" {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n",
" {%- elif message.role == \"assistant\" %}\n",
" {{- '<|im_start|>' + message.role }}\n",
" {%- if message.content %}\n",
" {{- '\\n' + message.content }}\n",
" {%- endif %}\n",
" {%- for tool_call in message.tool_calls %}\n",
" {%- if tool_call.function is defined %}\n",
" {%- set tool_call = tool_call.function %}\n",
" {%- endif %}\n",
" {{- '\\n<tool_call>\\n{\"name\": \"' }}\n",
" {{- tool_call.name }}\n",
" {{- '\", \"arguments\": ' }}\n",
" {{- tool_call.arguments | tojson }}\n",
" {{- '}\\n</tool_call>' }}\n",
" {%- endfor %}\n",
" {{- '<|im_end|>\\n' }}\n",
" {%- elif message.role == \"tool\" %}\n",
" {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n",
" {{- '<|im_start|>user' }}\n",
" {%- endif %}\n",
" {{- '\\n<tool_response>\\n' }}\n",
" {{- message.content }}\n",
" {{- '\\n</tool_response>' }}\n",
" {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n",
" {{- '<|im_end|>\\n' }}\n",
" {%- endif %}\n",
" {%- endif %}\n",
"{%- endfor %}\n",
"{%- if add_generation_prompt %}\n",
" {{- '<|im_start|>assistant\\n' }}\n",
"{%- endif %}\n",
"\n",
"Using chat eos_token: <|im_end|>\n",
"Using chat bos_token: <|endoftext|>\n",
"llama_perf_context_print: load time = 8854.20 ms\n",
"llama_perf_context_print: prompt eval time = 8853.89 ms / 35 tokens ( 252.97 ms per token, 3.95 tokens per second)\n",
"llama_perf_context_print: eval time = 166968.46 ms / 199 runs ( 839.04 ms per token, 1.19 tokens per second)\n",
"llama_perf_context_print: total time = 176246.10 ms / 234 tokens\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
"โจ\n",
"\n",
"Hey there! ๐ First off, it's great that you're looking for real, no-BS advice! ๐ค Hereโs a straightforward approach:\n",
"\n",
"1. **Talk to Her**: ๐ Find a time when sheโs calm and willing to talk. ๐ Be honest but gentle. ๐ Explain your feelings and the importance of your friendship. ๐\n",
"\n",
"2. **Ask for Her Perspective**: ๐ Listen to her and understand her point of view. ๐ Ask questions to clarify her feelings. ๐\n",
"\n",
"3. **Compromise**: ๐ฏ Propose a solution that works for both of you. ๐ผ Maybe keep some distance from her or find a neutral ground. ๐ค\n",
"\n",
"4. **Support Each Other**: ๐ Let her know youโre supportive of her and encourage her to talk to her friends as well. ๐ฟ\n",
"\n",
"Remember, communication is key! ๐\n",
"\n",
"Hope this helps!\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Install required packages."
],
"metadata": {
"id": "6pkmpO417oI3"
}
},
{
"cell_type": "code",
"source": [
"!pip install praw faiss-cpu fitz numpy sentence-transformers\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Afdc0y43aVoc",
"outputId": "62e40c44-8b26-4ccb-a2d7-38468e4dfa6f"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting praw\n",
" Downloading praw-7.8.1-py3-none-any.whl.metadata (9.4 kB)\n",
"Collecting faiss-cpu\n",
" Downloading faiss_cpu-1.10.0-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (4.4 kB)\n",
"Collecting fitz\n",
" Downloading fitz-0.0.1.dev2-py2.py3-none-any.whl.metadata (816 bytes)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (2.0.2)\n",
"Requirement already satisfied: sentence-transformers in /usr/local/lib/python3.11/dist-packages (3.4.1)\n",
"Collecting prawcore<3,>=2.4 (from praw)\n",
" Downloading prawcore-2.4.0-py3-none-any.whl.metadata (5.0 kB)\n",
"Collecting update_checker>=0.18 (from praw)\n",
" Downloading update_checker-0.18.0-py3-none-any.whl.metadata (2.3 kB)\n",
"Requirement already satisfied: websocket-client>=0.54.0 in /usr/local/lib/python3.11/dist-packages (from praw) (1.8.0)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from faiss-cpu) (24.2)\n",
"Collecting configobj (from fitz)\n",
" Downloading configobj-5.0.9-py2.py3-none-any.whl.metadata (3.2 kB)\n",
"Collecting configparser (from fitz)\n",
" Downloading configparser-7.2.0-py3-none-any.whl.metadata (5.5 kB)\n",
"Requirement already satisfied: httplib2 in /usr/local/lib/python3.11/dist-packages (from fitz) (0.22.0)\n",
"Requirement already satisfied: nibabel in /usr/local/lib/python3.11/dist-packages (from fitz) (5.3.2)\n",
"Collecting nipype (from fitz)\n",
" Downloading nipype-1.10.0-py3-none-any.whl.metadata (7.1 kB)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.11/dist-packages (from fitz) (2.2.2)\n",
"Collecting pyxnat (from fitz)\n",
" Downloading pyxnat-1.6.3-py3-none-any.whl.metadata (5.4 kB)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.11/dist-packages (from fitz) (1.14.1)\n",
"Requirement already satisfied: transformers<5.0.0,>=4.41.0 in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (4.50.0)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (4.67.1)\n",
"Requirement already satisfied: torch>=1.11.0 in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (2.6.0+cu124)\n",
"Requirement already satisfied: scikit-learn in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (1.6.1)\n",
"Requirement already satisfied: huggingface-hub>=0.20.0 in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (0.29.3)\n",
"Requirement already satisfied: Pillow in /usr/local/lib/python3.11/dist-packages (from sentence-transformers) (11.1.0)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.20.0->sentence-transformers) (3.18.0)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.20.0->sentence-transformers) (2025.3.0)\n",
"Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.20.0->sentence-transformers) (6.0.2)\n",
"Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.20.0->sentence-transformers) (2.32.3)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.11/dist-packages (from huggingface-hub>=0.20.0->sentence-transformers) (4.12.2)\n",
"Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (3.4.2)\n",
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (3.1.6)\n",
"Collecting nvidia-cuda-nvrtc-cu12==12.4.127 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Collecting nvidia-cuda-runtime-cu12==12.4.127 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Collecting nvidia-cuda-cupti-cu12==12.4.127 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
"Collecting nvidia-cudnn-cu12==9.1.0.70 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
"Collecting nvidia-cublas-cu12==12.4.5.8 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Collecting nvidia-cufft-cu12==11.2.1.3 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Collecting nvidia-curand-cu12==10.3.5.147 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Collecting nvidia-cusolver-cu12==11.6.1.9 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
"Collecting nvidia-cusparse-cu12==12.3.1.170 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl.metadata (1.6 kB)\n",
"Requirement already satisfied: nvidia-cusparselt-cu12==0.6.2 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (0.6.2)\n",
"Requirement already satisfied: nvidia-nccl-cu12==2.21.5 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (2.21.5)\n",
"Requirement already satisfied: nvidia-nvtx-cu12==12.4.127 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (12.4.127)\n",
"Collecting nvidia-nvjitlink-cu12==12.4.127 (from torch>=1.11.0->sentence-transformers)\n",
" Downloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl.metadata (1.5 kB)\n",
"Requirement already satisfied: triton==3.2.0 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (3.2.0)\n",
"Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.11/dist-packages (from torch>=1.11.0->sentence-transformers) (1.13.1)\n",
"Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy==1.13.1->torch>=1.11.0->sentence-transformers) (1.3.0)\n",
"Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.11/dist-packages (from transformers<5.0.0,>=4.41.0->sentence-transformers) (2024.11.6)\n",
"Requirement already satisfied: tokenizers<0.22,>=0.21 in /usr/local/lib/python3.11/dist-packages (from transformers<5.0.0,>=4.41.0->sentence-transformers) (0.21.1)\n",
"Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.11/dist-packages (from transformers<5.0.0,>=4.41.0->sentence-transformers) (0.5.3)\n",
"Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /usr/local/lib/python3.11/dist-packages (from httplib2->fitz) (3.2.1)\n",
"Requirement already satisfied: importlib-resources>=5.12 in /usr/local/lib/python3.11/dist-packages (from nibabel->fitz) (6.5.2)\n",
"Requirement already satisfied: click>=6.6.0 in /usr/local/lib/python3.11/dist-packages (from nipype->fitz) (8.1.8)\n",
"Collecting prov>=1.5.2 (from nipype->fitz)\n",
" Downloading prov-2.0.1-py3-none-any.whl.metadata (3.6 kB)\n",
"Requirement already satisfied: pydot>=1.2.3 in /usr/local/lib/python3.11/dist-packages (from nipype->fitz) (3.0.4)\n",
"Requirement already satisfied: python-dateutil>=2.2 in /usr/local/lib/python3.11/dist-packages (from nipype->fitz) (2.8.2)\n",
"Collecting rdflib>=5.0.0 (from nipype->fitz)\n",
" Downloading rdflib-7.1.4-py3-none-any.whl.metadata (11 kB)\n",
"Requirement already satisfied: simplejson>=3.8.0 in /usr/local/lib/python3.11/dist-packages (from nipype->fitz) (3.20.1)\n",
"Collecting traits>=6.2 (from nipype->fitz)\n",
" Downloading traits-7.0.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.8 kB)\n",
"Collecting acres (from nipype->fitz)\n",
" Downloading acres-0.3.0-py3-none-any.whl.metadata (5.5 kB)\n",
"Collecting etelemetry>=0.3.1 (from nipype->fitz)\n",
" Downloading etelemetry-0.3.1-py3-none-any.whl.metadata (3.2 kB)\n",
"Collecting looseversion!=1.2 (from nipype->fitz)\n",
" Downloading looseversion-1.3.0-py2.py3-none-any.whl.metadata (4.6 kB)\n",
"Collecting puremagic (from nipype->fitz)\n",
" Downloading puremagic-1.28-py3-none-any.whl.metadata (5.8 kB)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas->fitz) (2025.1)\n",
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas->fitz) (2025.1)\n",
"Requirement already satisfied: lxml>=4.3 in /usr/local/lib/python3.11/dist-packages (from pyxnat->fitz) (5.3.1)\n",
"Requirement already satisfied: pathlib>=1.0 in /usr/local/lib/python3.11/dist-packages (from pyxnat->fitz) (1.0.1)\n",
"Requirement already satisfied: joblib>=1.2.0 in /usr/local/lib/python3.11/dist-packages (from scikit-learn->sentence-transformers) (1.4.2)\n",
"Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.11/dist-packages (from scikit-learn->sentence-transformers) (3.6.0)\n",
"Collecting ci-info>=0.2 (from etelemetry>=0.3.1->nipype->fitz)\n",
" Downloading ci_info-0.3.0-py3-none-any.whl.metadata (6.1 kB)\n",
"Collecting rdflib>=5.0.0 (from nipype->fitz)\n",
" Downloading rdflib-6.3.2-py3-none-any.whl.metadata (11 kB)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-packages (from python-dateutil>=2.2->nipype->fitz) (1.17.0)\n",
"Collecting isodate<0.7.0,>=0.6.0 (from rdflib>=5.0.0->nipype->fitz)\n",
" Downloading isodate-0.6.1-py2.py3-none-any.whl.metadata (9.6 kB)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (3.4.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (3.10)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (2.3.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (2025.1.31)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch>=1.11.0->sentence-transformers) (3.0.2)\n",
"Downloading praw-7.8.1-py3-none-any.whl (189 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m189.3/189.3 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading faiss_cpu-1.10.0-cp311-cp311-manylinux_2_28_x86_64.whl (30.7 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m30.7/30.7 MB\u001b[0m \u001b[31m41.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading fitz-0.0.1.dev2-py2.py3-none-any.whl (20 kB)\n",
"Downloading prawcore-2.4.0-py3-none-any.whl (17 kB)\n",
"Downloading nvidia_cublas_cu12-12.4.5.8-py3-none-manylinux2014_x86_64.whl (363.4 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m363.4/363.4 MB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cuda_cupti_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (13.8 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m13.8/13.8 MB\u001b[0m \u001b[31m91.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cuda_nvrtc_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (24.6 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m24.6/24.6 MB\u001b[0m \u001b[31m26.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cuda_runtime_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (883 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m883.7/883.7 kB\u001b[0m \u001b[31m41.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cudnn_cu12-9.1.0.70-py3-none-manylinux2014_x86_64.whl (664.8 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m664.8/664.8 MB\u001b[0m \u001b[31m2.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cufft_cu12-11.2.1.3-py3-none-manylinux2014_x86_64.whl (211.5 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m211.5/211.5 MB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_curand_cu12-10.3.5.147-py3-none-manylinux2014_x86_64.whl (56.3 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m56.3/56.3 MB\u001b[0m \u001b[31m10.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cusolver_cu12-11.6.1.9-py3-none-manylinux2014_x86_64.whl (127.9 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m127.9/127.9 MB\u001b[0m \u001b[31m7.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_cusparse_cu12-12.3.1.170-py3-none-manylinux2014_x86_64.whl (207.5 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m207.5/207.5 MB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading nvidia_nvjitlink_cu12-12.4.127-py3-none-manylinux2014_x86_64.whl (21.1 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m21.1/21.1 MB\u001b[0m \u001b[31m43.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading update_checker-0.18.0-py3-none-any.whl (7.0 kB)\n",
"Downloading configobj-5.0.9-py2.py3-none-any.whl (35 kB)\n",
"Downloading configparser-7.2.0-py3-none-any.whl (17 kB)\n",
"Downloading nipype-1.10.0-py3-none-any.whl (3.2 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m3.2/3.2 MB\u001b[0m \u001b[31m65.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading pyxnat-1.6.3-py3-none-any.whl (95 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m95.4/95.4 kB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading etelemetry-0.3.1-py3-none-any.whl (6.4 kB)\n",
"Downloading looseversion-1.3.0-py2.py3-none-any.whl (8.2 kB)\n",
"Downloading prov-2.0.1-py3-none-any.whl (421 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m421.5/421.5 kB\u001b[0m \u001b[31m26.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading rdflib-6.3.2-py3-none-any.whl (528 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m528.1/528.1 kB\u001b[0m \u001b[31m32.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading traits-7.0.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.1 MB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m5.1/5.1 MB\u001b[0m \u001b[31m76.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading acres-0.3.0-py3-none-any.whl (10 kB)\n",
"Downloading puremagic-1.28-py3-none-any.whl (43 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m43.2/43.2 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hDownloading ci_info-0.3.0-py3-none-any.whl (7.8 kB)\n",
"Downloading isodate-0.6.1-py2.py3-none-any.whl (41 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m41.7/41.7 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: puremagic, looseversion, traits, nvidia-nvjitlink-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, isodate, faiss-cpu, configparser, configobj, ci-info, acres, update_checker, rdflib, pyxnat, prawcore, nvidia-cusparse-cu12, nvidia-cudnn-cu12, etelemetry, prov, praw, nvidia-cusolver-cu12, nipype, fitz\n",
" Attempting uninstall: nvidia-nvjitlink-cu12\n",
" Found existing installation: nvidia-nvjitlink-cu12 12.5.82\n",
" Uninstalling nvidia-nvjitlink-cu12-12.5.82:\n",
" Successfully uninstalled nvidia-nvjitlink-cu12-12.5.82\n",
" Attempting uninstall: nvidia-curand-cu12\n",
" Found existing installation: nvidia-curand-cu12 10.3.6.82\n",
" Uninstalling nvidia-curand-cu12-10.3.6.82:\n",
" Successfully uninstalled nvidia-curand-cu12-10.3.6.82\n",
" Attempting uninstall: nvidia-cufft-cu12\n",
" Found existing installation: nvidia-cufft-cu12 11.2.3.61\n",
" Uninstalling nvidia-cufft-cu12-11.2.3.61:\n",
" Successfully uninstalled nvidia-cufft-cu12-11.2.3.61\n",
" Attempting uninstall: nvidia-cuda-runtime-cu12\n",
" Found existing installation: nvidia-cuda-runtime-cu12 12.5.82\n",
" Uninstalling nvidia-cuda-runtime-cu12-12.5.82:\n",
" Successfully uninstalled nvidia-cuda-runtime-cu12-12.5.82\n",
" Attempting uninstall: nvidia-cuda-nvrtc-cu12\n",
" Found existing installation: nvidia-cuda-nvrtc-cu12 12.5.82\n",
" Uninstalling nvidia-cuda-nvrtc-cu12-12.5.82:\n",
" Successfully uninstalled nvidia-cuda-nvrtc-cu12-12.5.82\n",
" Attempting uninstall: nvidia-cuda-cupti-cu12\n",
" Found existing installation: nvidia-cuda-cupti-cu12 12.5.82\n",
" Uninstalling nvidia-cuda-cupti-cu12-12.5.82:\n",
" Successfully uninstalled nvidia-cuda-cupti-cu12-12.5.82\n",
" Attempting uninstall: nvidia-cublas-cu12\n",
" Found existing installation: nvidia-cublas-cu12 12.5.3.2\n",
" Uninstalling nvidia-cublas-cu12-12.5.3.2:\n",
" Successfully uninstalled nvidia-cublas-cu12-12.5.3.2\n",
" Attempting uninstall: nvidia-cusparse-cu12\n",
" Found existing installation: nvidia-cusparse-cu12 12.5.1.3\n",
" Uninstalling nvidia-cusparse-cu12-12.5.1.3:\n",
" Successfully uninstalled nvidia-cusparse-cu12-12.5.1.3\n",
" Attempting uninstall: nvidia-cudnn-cu12\n",
" Found existing installation: nvidia-cudnn-cu12 9.3.0.75\n",
" Uninstalling nvidia-cudnn-cu12-9.3.0.75:\n",
" Successfully uninstalled nvidia-cudnn-cu12-9.3.0.75\n",
" Attempting uninstall: nvidia-cusolver-cu12\n",
" Found existing installation: nvidia-cusolver-cu12 11.6.3.83\n",
" Uninstalling nvidia-cusolver-cu12-11.6.3.83:\n",
" Successfully uninstalled nvidia-cusolver-cu12-11.6.3.83\n",
"Successfully installed acres-0.3.0 ci-info-0.3.0 configobj-5.0.9 configparser-7.2.0 etelemetry-0.3.1 faiss-cpu-1.10.0 fitz-0.0.1.dev2 isodate-0.6.1 looseversion-1.3.0 nipype-1.10.0 nvidia-cublas-cu12-12.4.5.8 nvidia-cuda-cupti-cu12-12.4.127 nvidia-cuda-nvrtc-cu12-12.4.127 nvidia-cuda-runtime-cu12-12.4.127 nvidia-cudnn-cu12-9.1.0.70 nvidia-cufft-cu12-11.2.1.3 nvidia-curand-cu12-10.3.5.147 nvidia-cusolver-cu12-11.6.1.9 nvidia-cusparse-cu12-12.3.1.170 nvidia-nvjitlink-cu12-12.4.127 praw-7.8.1 prawcore-2.4.0 prov-2.0.1 puremagic-1.28 pyxnat-1.6.3 rdflib-6.3.2 traits-7.0.2 update_checker-0.18.0\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"! pip install PyPDF2"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YJLoki1fzuJf",
"outputId": "6d55be63-4a82-4aab-befb-6fd5d6d32644"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting PyPDF2\n",
" Downloading pypdf2-3.0.1-py3-none-any.whl.metadata (6.8 kB)\n",
"Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)\n",
"\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m232.6/232.6 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hInstalling collected packages: PyPDF2\n",
"Successfully installed PyPDF2-3.0.1\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Scrape the relevant content from the reddit and make the embedding of the content"
],
"metadata": {
"id": "kIQSPshA7vmv"
}
},
{
"cell_type": "code",
"source": [
"import praw\n",
"import json\n",
"\n",
"# ๐ฅ Reddit API credentials (Fill these with your own keys)\n",
"reddit = praw.Reddit(\n",
" client_id=\"YJXGFclFf5rpU0w42GhZRA\",\n",
" client_secret=\"yehLjeiY9_b1KazaUfNrxCUQVtgVtw\",\n",
" user_agent=\"Lakith punsara\"\n",
")\n",
"\n",
"# ๐ Subreddits to scrape\n",
"subreddits = [\"dating_advice\", \"relationships\", \"relationship_advice\",\"love\",\"sex\",\"Dating\"]\n",
"posts = []\n",
"\n",
"# ๐ Scrape top posts\n",
"for sub in subreddits:\n",
" for post in reddit.subreddit(sub).hot(limit=100): # Get top 100 posts\n",
" posts.append({\n",
" \"title\": post.title,\n",
" \"text\": post.selftext,\n",
" \"upvotes\": post.score\n",
" })\n",
"\n",
"# Save Reddit data\n",
"with open(\"reddit_data.json\", \"w\") as f:\n",
" json.dump(posts, f)\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "IwBPlwCIsuwN",
"outputId": "5d4dde1d-a3dd-4ef5-e040-d34ca3da69e2"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n",
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n",
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n",
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n",
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n",
"WARNING:praw:It appears that you are using PRAW in an asynchronous environment.\n",
"It is strongly recommended to use Async PRAW: https://asyncpraw.readthedocs.io.\n",
"See https://praw.readthedocs.io/en/latest/getting_started/multiple_instances.html#discord-bots-and-asynchronous-environments for more info.\n",
"\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"Process the pdf content and mak the embeddings"
],
"metadata": {
"id": "pF-KHByn7_7X"
}
},
{
"cell_type": "code",
"source": [
"import PyPDF2\n",
"import faiss\n",
"import numpy as np\n",
"from sentence_transformers import SentenceTransformer\n",
"\n",
"# ๐ฅ Load embedding model\n",
"model = SentenceTransformer(\"all-MiniLM-L6-v2\")\n",
"\n",
"# โ
Extract text from PDF\n",
"def extract_text_from_pdf(pdf_path):\n",
" with open(pdf_path, \"rb\") as f:\n",
" reader = PyPDF2.PdfReader(f)\n",
" text = \"\\n\".join([page.extract_text() for page in reader.pages if page.extract_text()])\n",
" return text.split(\"\\n\") # Split into sentences\n",
"\n",
"# ๐ Load PDF Data\n",
"pdf_path = \"/content/drive/MyDrive/Dating_LLM_GGUF/data_dating_app.pdf\" # Replace with your actual PDF path\n",
"pdf_texts = extract_text_from_pdf(pdf_path)\n",
"\n",
"# ๐ Encode PDF Data\n",
"pdf_embeddings = model.encode(pdf_texts)\n",
"pdf_index = faiss.IndexFlatL2(pdf_embeddings.shape[1])\n",
"pdf_index.add(np.array(pdf_embeddings))\n",
"\n",
"# โ
Save PDF FAISS index\n",
"faiss.write_index(pdf_index, \"pdf_faiss.index\")\n",
"\n"
],
"metadata": {
"id": "9kOnuSjRv76V"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"retrieve relevant embedding from the pdf and reddit vector data and the query process(from the GGUF model from google drive)"
],
"metadata": {
"id": "dYghp5F58g03"
}
},
{
"cell_type": "code",
"source": [
"from llama_cpp import Llama\n",
"import random\n",
"import faiss\n",
"import numpy as np\n",
"from sentence_transformers import SentenceTransformer\n",
"import json\n",
"\n",
"# โ
Load Llama Model\n",
"model_path = \"/content/drive/MyDrive/Dating_LLM_GGUF/damn.gguf\"\n",
"llm = Llama(\n",
" model_path=model_path,\n",
" n_gpu_layers=40,\n",
" n_ctx=2048,\n",
" system_message=\"You're a no-filter, informal AI. Talk like a real friend. Use slang, jokes, emojis properly, and be brutally honest! ๐ฅ๐\"\n",
")\n",
"\n",
"# โ
Load Embedding Model\n",
"embed_model = SentenceTransformer(\"all-MiniLM-L6-v2\")\n",
"\n",
"# โ
Load FAISS Indexes\n",
"reddit_index = faiss.read_index(\"reddit_faiss.index\")\n",
"pdf_index = faiss.read_index(\"pdf_faiss.index\")\n",
"\n",
"# โ
Load Reddit Data for Mapping\n",
"with open(\"reddit_data.json\", \"r\") as f:\n",
" reddit_posts = json.load(f)\n",
"\n",
"# โ
Retrieve PDF Text Directly from FAISS\n",
"def get_pdf_text(index_id):\n",
" # Convert FAISS ID back to text\n",
" return f\"๐ Relevant book excerpt (ID {index_id})\"\n",
"\n",
"# โ
Gender-based Salutation\n",
"def get_salutation(user_input):\n",
" male_keywords = [\"girlfriend\", \"wife\", \"she\", \"her\"]\n",
" female_keywords = [\"boyfriend\", \"husband\", \"he\", \"him\"]\n",
"\n",
" if any(word in user_input.lower() for word in male_keywords):\n",
" return random.choice([\"Hey queen! ๐\", \"Girl, listen up! ๐
\", \"Sis, letโs talk โค๏ธ\"])\n",
" elif any(word in user_input.lower() for word in female_keywords):\n",
" return random.choice([\"Yo bro! ๐ฅ\", \"Dude, hear me out ๐ค\", \"Man, let's fix this ๐ช\"])\n",
" else:\n",
" return random.choice([\"Yo dude! ๐\", \"Hey buddy! ๐\", \"Listen up, my friend โค๏ธ\"])\n",
"\n",
"# โ
FAISS Retrieval Function\n",
"def retrieve_info(user_input, top_k=1):\n",
" query_embedding = embed_model.encode([user_input])\n",
"\n",
" # ๐ Search in Reddit FAISS\n",
" _, reddit_indices = reddit_index.search(np.array(query_embedding), top_k)\n",
" reddit_results = [f\"๐ฅ {reddit_posts[i]['title']}: {reddit_posts[i]['text']} ๐๐ฅ\" for i in reddit_indices[0]]\n",
"\n",
" # ๐ Search in PDF FAISS\n",
" _, pdf_indices = pdf_index.search(np.array(query_embedding), top_k)\n",
" pdf_results = [get_pdf_text(i) for i in pdf_indices[0]]\n",
"\n",
" return {\"reddit\": reddit_results, \"pdf\": pdf_results}\n",
"\n",
"# โ
Generate AI Response\n",
"def generate_response(user_input):\n",
" salutation = get_salutation(user_input)\n",
" retrieved_data = retrieve_info(user_input)\n",
"\n",
" # ๐ฅ Create Chat Prompt\n",
" context = f\"\"\"\n",
" {salutation} {user_input} ๐ญ๐ฅ\\n\n",
" Reddit Says: {retrieved_data['reddit'][0]}\\n\n",
" Book Knowledge Says: {retrieved_data['pdf'][0]}\\n\n",
" No sugarcoatingโgive me the raw truth, like a bestie would! ๐ฃ๏ธ๐ฅ\n",
" \"\"\"\n",
"\n",
" # ๐ฅ Get AI Response\n",
" output = llm(context, max_tokens=300)\n",
" return output[\"choices\"][0][\"text\"]\n",
"\n",
"# โ
Example Query\n",
"user_query = \"My girlfriend is ignoring me. What should I do?\"\n",
"response = generate_response(user_query)\n",
"print(response)\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xHlArzQM2EyK",
"outputId": "861896e3-f0f5-480a-c34d-de8dd9838dc0"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"llama_model_loader: loaded meta data with 24 key-value pairs and 434 tensors from /content/drive/MyDrive/Dating_LLM_GGUF/damn.gguf (version GGUF V3 (latest))\n",
"llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n",
"llama_model_loader: - kv 0: general.architecture str = qwen2\n",
"llama_model_loader: - kv 1: general.type str = model\n",
"llama_model_loader: - kv 2: general.name str = Merged\n",
"llama_model_loader: - kv 3: general.size_label str = 3.1B\n",
"llama_model_loader: - kv 4: qwen2.block_count u32 = 36\n",
"llama_model_loader: - kv 5: qwen2.context_length u32 = 32768\n",
"llama_model_loader: - kv 6: qwen2.embedding_length u32 = 2048\n",
"llama_model_loader: - kv 7: qwen2.feed_forward_length u32 = 11008\n",
"llama_model_loader: - kv 8: qwen2.attention.head_count u32 = 16\n",
"llama_model_loader: - kv 9: qwen2.attention.head_count_kv u32 = 2\n",
"llama_model_loader: - kv 10: qwen2.rope.freq_base f32 = 1000000.000000\n",
"llama_model_loader: - kv 11: qwen2.attention.layer_norm_rms_epsilon f32 = 0.000001\n",
"llama_model_loader: - kv 12: general.file_type u32 = 1\n",
"llama_model_loader: - kv 13: tokenizer.ggml.model str = gpt2\n",
"llama_model_loader: - kv 14: tokenizer.ggml.pre str = qwen2\n",
"llama_model_loader: - kv 15: tokenizer.ggml.tokens arr[str,151936] = [\"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\", ...\n",
"llama_model_loader: - kv 16: tokenizer.ggml.token_type arr[i32,151936] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...\n",
"llama_model_loader: - kv 17: tokenizer.ggml.merges arr[str,151387] = [\"ฤ ฤ \", \"ฤ ฤ ฤ ฤ \", \"i n\", \"ฤ t\",...\n",
"llama_model_loader: - kv 18: tokenizer.ggml.eos_token_id u32 = 151645\n",
"llama_model_loader: - kv 19: tokenizer.ggml.padding_token_id u32 = 151643\n",
"llama_model_loader: - kv 20: tokenizer.ggml.bos_token_id u32 = 151643\n",
"llama_model_loader: - kv 21: tokenizer.ggml.add_bos_token bool = false\n",
"llama_model_loader: - kv 22: tokenizer.chat_template str = {%- if tools %}\\n {{- '<|im_start|>...\n",
"llama_model_loader: - kv 23: general.quantization_version u32 = 2\n",
"llama_model_loader: - type f32: 181 tensors\n",
"llama_model_loader: - type f16: 253 tensors\n",
"print_info: file format = GGUF V3 (latest)\n",
"print_info: file type = F16\n",
"print_info: file size = 5.75 GiB (16.00 BPW) \n",
"init_tokenizer: initializing tokenizer for type 2\n",
"load: control token: 151660 '<|fim_middle|>' is not marked as EOG\n",
"load: control token: 151659 '<|fim_prefix|>' is not marked as EOG\n",
"load: control token: 151653 '<|vision_end|>' is not marked as EOG\n",
"load: control token: 151648 '<|box_start|>' is not marked as EOG\n",
"load: control token: 151646 '<|object_ref_start|>' is not marked as EOG\n",
"load: control token: 151649 '<|box_end|>' is not marked as EOG\n",
"load: control token: 151655 '<|image_pad|>' is not marked as EOG\n",
"load: control token: 151651 '<|quad_end|>' is not marked as EOG\n",
"load: control token: 151647 '<|object_ref_end|>' is not marked as EOG\n",
"load: control token: 151652 '<|vision_start|>' is not marked as EOG\n",
"load: control token: 151654 '<|vision_pad|>' is not marked as EOG\n",
"load: control token: 151656 '<|video_pad|>' is not marked as EOG\n",
"load: control token: 151644 '<|im_start|>' is not marked as EOG\n",
"load: control token: 151661 '<|fim_suffix|>' is not marked as EOG\n",
"load: control token: 151650 '<|quad_start|>' is not marked as EOG\n",
"load: special tokens cache size = 22\n",
"load: token to piece cache size = 0.9310 MB\n",
"print_info: arch = qwen2\n",
"print_info: vocab_only = 0\n",
"print_info: n_ctx_train = 32768\n",
"print_info: n_embd = 2048\n",
"print_info: n_layer = 36\n",
"print_info: n_head = 16\n",
"print_info: n_head_kv = 2\n",
"print_info: n_rot = 128\n",
"print_info: n_swa = 0\n",
"print_info: n_embd_head_k = 128\n",
"print_info: n_embd_head_v = 128\n",
"print_info: n_gqa = 8\n",
"print_info: n_embd_k_gqa = 256\n",
"print_info: n_embd_v_gqa = 256\n",
"print_info: f_norm_eps = 0.0e+00\n",
"print_info: f_norm_rms_eps = 1.0e-06\n",
"print_info: f_clamp_kqv = 0.0e+00\n",
"print_info: f_max_alibi_bias = 0.0e+00\n",
"print_info: f_logit_scale = 0.0e+00\n",
"print_info: f_attn_scale = 0.0e+00\n",
"print_info: n_ff = 11008\n",
"print_info: n_expert = 0\n",
"print_info: n_expert_used = 0\n",
"print_info: causal attn = 1\n",
"print_info: pooling type = 0\n",
"print_info: rope type = 2\n",
"print_info: rope scaling = linear\n",
"print_info: freq_base_train = 1000000.0\n",
"print_info: freq_scale_train = 1\n",
"print_info: n_ctx_orig_yarn = 32768\n",
"print_info: rope_finetuned = unknown\n",
"print_info: ssm_d_conv = 0\n",
"print_info: ssm_d_inner = 0\n",
"print_info: ssm_d_state = 0\n",
"print_info: ssm_dt_rank = 0\n",
"print_info: ssm_dt_b_c_rms = 0\n",
"print_info: model type = 3B\n",
"print_info: model params = 3.09 B\n",
"print_info: general.name = Merged\n",
"print_info: vocab type = BPE\n",
"print_info: n_vocab = 151936\n",
"print_info: n_merges = 151387\n",
"print_info: BOS token = 151643 '<|endoftext|>'\n",
"print_info: EOS token = 151645 '<|im_end|>'\n",
"print_info: EOT token = 151645 '<|im_end|>'\n",
"print_info: PAD token = 151643 '<|endoftext|>'\n",
"print_info: LF token = 198 'ฤ'\n",
"print_info: FIM PRE token = 151659 '<|fim_prefix|>'\n",
"print_info: FIM SUF token = 151661 '<|fim_suffix|>'\n",
"print_info: FIM MID token = 151660 '<|fim_middle|>'\n",
"print_info: FIM PAD token = 151662 '<|fim_pad|>'\n",
"print_info: FIM REP token = 151663 '<|repo_name|>'\n",
"print_info: FIM SEP token = 151664 '<|file_sep|>'\n",
"print_info: EOG token = 151643 '<|endoftext|>'\n",
"print_info: EOG token = 151645 '<|im_end|>'\n",
"print_info: EOG token = 151662 '<|fim_pad|>'\n",
"print_info: EOG token = 151663 '<|repo_name|>'\n",
"print_info: EOG token = 151664 '<|file_sep|>'\n",
"print_info: max token length = 256\n",
"load_tensors: loading model tensors, this can take a while... (mmap = true)\n",
"load_tensors: layer 0 assigned to device CPU\n",
"load_tensors: layer 1 assigned to device CPU\n",
"load_tensors: layer 2 assigned to device CPU\n",
"load_tensors: layer 3 assigned to device CPU\n",
"load_tensors: layer 4 assigned to device CPU\n",
"load_tensors: layer 5 assigned to device CPU\n",
"load_tensors: layer 6 assigned to device CPU\n",
"load_tensors: layer 7 assigned to device CPU\n",
"load_tensors: layer 8 assigned to device CPU\n",
"load_tensors: layer 9 assigned to device CPU\n",
"load_tensors: layer 10 assigned to device CPU\n",
"load_tensors: layer 11 assigned to device CPU\n",
"load_tensors: layer 12 assigned to device CPU\n",
"load_tensors: layer 13 assigned to device CPU\n",
"load_tensors: layer 14 assigned to device CPU\n",
"load_tensors: layer 15 assigned to device CPU\n",
"load_tensors: layer 16 assigned to device CPU\n",
"load_tensors: layer 17 assigned to device CPU\n",
"load_tensors: layer 18 assigned to device CPU\n",
"load_tensors: layer 19 assigned to device CPU\n",
"load_tensors: layer 20 assigned to device CPU\n",
"load_tensors: layer 21 assigned to device CPU\n",
"load_tensors: layer 22 assigned to device CPU\n",
"load_tensors: layer 23 assigned to device CPU\n",
"load_tensors: layer 24 assigned to device CPU\n",
"load_tensors: layer 25 assigned to device CPU\n",
"load_tensors: layer 26 assigned to device CPU\n",
"load_tensors: layer 27 assigned to device CPU\n",
"load_tensors: layer 28 assigned to device CPU\n",
"load_tensors: layer 29 assigned to device CPU\n",
"load_tensors: layer 30 assigned to device CPU\n",
"load_tensors: layer 31 assigned to device CPU\n",
"load_tensors: layer 32 assigned to device CPU\n",
"load_tensors: layer 33 assigned to device CPU\n",
"load_tensors: layer 34 assigned to device CPU\n",
"load_tensors: layer 35 assigned to device CPU\n",
"load_tensors: layer 36 assigned to device CPU\n",
"load_tensors: tensor 'token_embd.weight' (f16) (and 434 others) cannot be used with preferred buffer type CPU_AARCH64, using CPU instead\n",
"load_tensors: CPU_Mapped model buffer size = 5886.42 MiB\n",
"...........................................................................................\n",
"llama_init_from_model: n_seq_max = 1\n",
"llama_init_from_model: n_ctx = 2048\n",
"llama_init_from_model: n_ctx_per_seq = 2048\n",
"llama_init_from_model: n_batch = 512\n",
"llama_init_from_model: n_ubatch = 512\n",
"llama_init_from_model: flash_attn = 0\n",
"llama_init_from_model: freq_base = 1000000.0\n",
"llama_init_from_model: freq_scale = 1\n",
"llama_init_from_model: n_ctx_per_seq (2048) < n_ctx_train (32768) -- the full capacity of the model will not be utilized\n",
"llama_kv_cache_init: kv_size = 2048, offload = 1, type_k = 'f16', type_v = 'f16', n_layer = 36, can_shift = 1\n",
"llama_kv_cache_init: layer 0: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 1: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 2: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 3: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 4: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 5: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 6: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 7: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 8: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 9: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 10: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 11: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 12: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 13: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 14: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 15: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 16: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 17: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 18: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 19: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 20: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 21: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 22: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 23: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 24: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 25: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 26: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 27: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 28: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 29: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 30: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 31: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 32: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 33: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 34: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: layer 35: n_embd_k_gqa = 256, n_embd_v_gqa = 256\n",
"llama_kv_cache_init: CPU KV buffer size = 72.00 MiB\n",
"llama_init_from_model: KV self size = 72.00 MiB, K (f16): 36.00 MiB, V (f16): 36.00 MiB\n",
"llama_init_from_model: CPU output buffer size = 0.58 MiB\n",
"llama_init_from_model: CPU compute buffer size = 300.75 MiB\n",
"llama_init_from_model: graph nodes = 1266\n",
"llama_init_from_model: graph splits = 1\n",
"CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | LLAMAFILE = 1 | OPENMP = 1 | AARCH64_REPACK = 1 | \n",
"Model metadata: {'tokenizer.ggml.add_bos_token': 'false', 'tokenizer.ggml.bos_token_id': '151643', 'general.architecture': 'qwen2', 'tokenizer.ggml.padding_token_id': '151643', 'qwen2.embedding_length': '2048', 'tokenizer.ggml.pre': 'qwen2', 'general.name': 'Merged', 'qwen2.block_count': '36', 'general.type': 'model', 'general.size_label': '3.1B', 'qwen2.context_length': '32768', 'tokenizer.chat_template': '{%- if tools %}\\n {{- \\'<|im_start|>system\\\\n\\' }}\\n {%- if messages[0][\\'role\\'] == \\'system\\' %}\\n {{- messages[0][\\'content\\'] }}\\n {%- else %}\\n {{- \\'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.\\' }}\\n {%- endif %}\\n {{- \"\\\\n\\\\n# Tools\\\\n\\\\nYou may call one or more functions to assist with the user query.\\\\n\\\\nYou are provided with function signatures within <tools></tools> XML tags:\\\\n<tools>\" }}\\n {%- for tool in tools %}\\n {{- \"\\\\n\" }}\\n {{- tool | tojson }}\\n {%- endfor %}\\n {{- \"\\\\n</tools>\\\\n\\\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\\\n<tool_call>\\\\n{\\\\\"name\\\\\": <function-name>, \\\\\"arguments\\\\\": <args-json-object>}\\\\n</tool_call><|im_end|>\\\\n\" }}\\n{%- else %}\\n {%- if messages[0][\\'role\\'] == \\'system\\' %}\\n {{- \\'<|im_start|>system\\\\n\\' + messages[0][\\'content\\'] + \\'<|im_end|>\\\\n\\' }}\\n {%- else %}\\n {{- \\'<|im_start|>system\\\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\\\n\\' }}\\n {%- endif %}\\n{%- endif %}\\n{%- for message in messages %}\\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\\n {{- \\'<|im_start|>\\' + message.role + \\'\\\\n\\' + message.content + \\'<|im_end|>\\' + \\'\\\\n\\' }}\\n {%- elif message.role == \"assistant\" %}\\n {{- \\'<|im_start|>\\' + message.role }}\\n {%- if message.content %}\\n {{- \\'\\\\n\\' + message.content }}\\n {%- endif %}\\n {%- for tool_call in message.tool_calls %}\\n {%- if tool_call.function is defined %}\\n {%- set tool_call = tool_call.function %}\\n {%- endif %}\\n {{- \\'\\\\n<tool_call>\\\\n{\"name\": \"\\' }}\\n {{- tool_call.name }}\\n {{- \\'\", \"arguments\": \\' }}\\n {{- tool_call.arguments | tojson }}\\n {{- \\'}\\\\n</tool_call>\\' }}\\n {%- endfor %}\\n {{- \\'<|im_end|>\\\\n\\' }}\\n {%- elif message.role == \"tool\" %}\\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\\n {{- \\'<|im_start|>user\\' }}\\n {%- endif %}\\n {{- \\'\\\\n<tool_response>\\\\n\\' }}\\n {{- message.content }}\\n {{- \\'\\\\n</tool_response>\\' }}\\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\\n {{- \\'<|im_end|>\\\\n\\' }}\\n {%- endif %}\\n {%- endif %}\\n{%- endfor %}\\n{%- if add_generation_prompt %}\\n {{- \\'<|im_start|>assistant\\\\n\\' }}\\n{%- endif %}\\n', 'qwen2.attention.head_count_kv': '2', 'general.quantization_version': '2', 'tokenizer.ggml.model': 'gpt2', 'qwen2.feed_forward_length': '11008', 'qwen2.attention.layer_norm_rms_epsilon': '0.000001', 'qwen2.attention.head_count': '16', 'tokenizer.ggml.eos_token_id': '151645', 'qwen2.rope.freq_base': '1000000.000000', 'general.file_type': '1'}\n",
"Available chat formats from metadata: chat_template.default\n",
"Using gguf chat template: {%- if tools %}\n",
" {{- '<|im_start|>system\\n' }}\n",
" {%- if messages[0]['role'] == 'system' %}\n",
" {{- messages[0]['content'] }}\n",
" {%- else %}\n",
" {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n",
" {%- endif %}\n",
" {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n",
" {%- for tool in tools %}\n",
" {{- \"\\n\" }}\n",
" {{- tool | tojson }}\n",
" {%- endfor %}\n",
" {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n",
"{%- else %}\n",
" {%- if messages[0]['role'] == 'system' %}\n",
" {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n",
" {%- else %}\n",
" {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n",
" {%- endif %}\n",
"{%- endif %}\n",
"{%- for message in messages %}\n",
" {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n",
" {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n",
" {%- elif message.role == \"assistant\" %}\n",
" {{- '<|im_start|>' + message.role }}\n",
" {%- if message.content %}\n",
" {{- '\\n' + message.content }}\n",
" {%- endif %}\n",
" {%- for tool_call in message.tool_calls %}\n",
" {%- if tool_call.function is defined %}\n",
" {%- set tool_call = tool_call.function %}\n",
" {%- endif %}\n",
" {{- '\\n<tool_call>\\n{\"name\": \"' }}\n",
" {{- tool_call.name }}\n",
" {{- '\", \"arguments\": ' }}\n",
" {{- tool_call.arguments | tojson }}\n",
" {{- '}\\n</tool_call>' }}\n",
" {%- endfor %}\n",
" {{- '<|im_end|>\\n' }}\n",
" {%- elif message.role == \"tool\" %}\n",
" {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n",
" {{- '<|im_start|>user' }}\n",
" {%- endif %}\n",
" {{- '\\n<tool_response>\\n' }}\n",
" {{- message.content }}\n",
" {{- '\\n</tool_response>' }}\n",
" {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n",
" {{- '<|im_end|>\\n' }}\n",
" {%- endif %}\n",
" {%- endif %}\n",
"{%- endfor %}\n",
"{%- if add_generation_prompt %}\n",
" {{- '<|im_start|>assistant\\n' }}\n",
"{%- endif %}\n",
"\n",
"Using chat eos_token: <|im_end|>\n",
"Using chat bos_token: <|endoftext|>\n",
"llama_perf_context_print: load time = 50698.50 ms\n",
"llama_perf_context_print: prompt eval time = 50697.99 ms / 235 tokens ( 215.74 ms per token, 4.64 tokens per second)\n",
"llama_perf_context_print: eval time = 247705.49 ms / 299 runs ( 828.45 ms per token, 1.21 tokens per second)\n",
"llama_perf_context_print: total time = 299060.29 ms / 534 tokens\n"
]
},
{
"output_type": "stream",
"name": "stdout",
"text": [
" Here's the raw truth for you: ๐ฅ Breakups can be incredibly challenging, especially when you're still deeply attached to your ex. In the case of your girlfriend who is ignoring you, there are a few things you can try to get her attention:\n",
"\n",
" 1. Donโt push her too hard: Itโs crucial not to pressure her into communicating with you. If sheโs not ready to talk, forcing the issue could make matters worse. Give her space, and allow her time to process her emotions.\n",
" 2. Show your support: Offer her your encouragement and support. Let her know that you're there for her and that youโre not holding grudges. Sometimes, just being supportive can help bridge the gap.\n",
" 3. Be yourself: Maintain your own happiness and well-being. Focus on your own interests, hobbies, and relationships. Remember that youโre not defined by her and that youโll move on.\n",
" 4. Donโt give up: If she eventually opens up to you, itโs important to listen attentively and validate her feelings. If not, itโs okay to let go and move on. \n",
"\n",
" Remember that breakups are a natural part of life, and while it may be tough, time will eventually heal the wounds. ๐๐\n",
"\n",
"Assistant: Based on the advice in the given text, here's a summary of how you might approach getting your girlfriend to communicate and potentially mend your relationship:\n",
"\n",
"1. **Give Her\n"
]
}
]
}
]
} |