|
223 | 223 | },
|
224 | 224 | {
|
225 | 225 | "cell_type": "code",
|
226 |
| - "execution_count": 78, |
| 226 | + "execution_count": null, |
227 | 227 | "id": "6739f55b-6983-4b48-9349-6e0111b313fe",
|
228 | 228 | "metadata": {
|
229 | 229 | "id": "6739f55b-6983-4b48-9349-6e0111b313fe"
|
230 | 230 | },
|
231 |
| - "outputs": [ |
232 |
| - { |
233 |
| - "name": "stdout", |
234 |
| - "output_type": "stream", |
235 |
| - "text": [ |
236 |
| - "ecommerce-pipeline created: True\n" |
237 |
| - ] |
238 |
| - } |
239 |
| - ], |
| 231 | + "outputs": [], |
240 | 232 | "source": [
|
241 | 233 | "index_pipeline = \"ecommerce-pipeline\"\n",
|
242 | 234 | "resp = client.ingest.put_pipeline(\n",
|
|
290 | 282 | },
|
291 | 283 | {
|
292 | 284 | "cell_type": "code",
|
293 |
| - "execution_count": 82, |
| 285 | + "execution_count": null, |
294 | 286 | "id": "9b53b39e-d74e-4fa8-a364-e2c3caf37418",
|
295 | 287 | "metadata": {
|
296 | 288 | "id": "9b53b39e-d74e-4fa8-a364-e2c3caf37418"
|
297 | 289 | },
|
298 |
| - "outputs": [ |
299 |
| - { |
300 |
| - "name": "stdout", |
301 |
| - "output_type": "stream", |
302 |
| - "text": [ |
303 |
| - "Index ecommerce-search created: True\n" |
304 |
| - ] |
305 |
| - } |
306 |
| - ], |
| 290 | + "outputs": [], |
307 | 291 | "source": [
|
308 | 292 | "# define the index name and mapping\n",
|
309 | 293 | "commerce_index = \"ecommerce-search\"\n",
|
|
329 | 313 | " \"type\": \"semantic_text\",\n",
|
330 | 314 | " \"inference_id\": e5_endpoint,\n",
|
331 | 315 | " },\n",
|
332 |
| - " \"elser_semantic_description_vector\": {\n", |
333 |
| - " \"type\": \"semantic_text\"\n", |
334 |
| - " # \"inference_id\": elser_endpoint\n", |
335 |
| - " },\n", |
| 316 | + " \"elser_semantic_description_vector\": {\"type\": \"semantic_text\"},\n", |
336 | 317 | " }\n",
|
337 | 318 | "}\n",
|
338 | 319 | "\n",
|
|
358 | 339 | },
|
359 | 340 | {
|
360 | 341 | "cell_type": "code",
|
361 |
| - "execution_count": 83, |
| 342 | + "execution_count": null, |
362 | 343 | "id": "c4830b74",
|
363 | 344 | "metadata": {},
|
364 |
| - "outputs": [ |
365 |
| - { |
366 |
| - "name": "stdout", |
367 |
| - "output_type": "stream", |
368 |
| - "text": [ |
369 |
| - "Pipeline set for ecommerce-search: True\n" |
370 |
| - ] |
371 |
| - } |
372 |
| - ], |
| 345 | + "outputs": [], |
373 | 346 | "source": [
|
374 | 347 | "resp = client.indices.put_settings(\n",
|
375 | 348 | " index=commerce_index,\n",
|
|
397 | 370 | "metadata": {
|
398 | 371 | "id": "3cfdc3b7-7e4f-4111-997b-c333ac8938ba"
|
399 | 372 | },
|
400 |
| - "outputs": [ |
401 |
| - { |
402 |
| - "name": "stdout", |
403 |
| - "output_type": "stream", |
404 |
| - "text": [ |
405 |
| - "Indexing documents...\n", |
406 |
| - "Documents indexed successfully: 2506\n" |
407 |
| - ] |
408 |
| - } |
409 |
| - ], |
| 373 | + "outputs": [], |
410 | 374 | "source": [
|
411 | 375 | "# Load the dataset\n",
|
412 | 376 | "with open(\"products-ecommerce.json\", \"r\") as f:\n",
|
|
531 | 495 | },
|
532 | 496 | {
|
533 | 497 | "cell_type": "code",
|
534 |
| - "execution_count": 64, |
| 498 | + "execution_count": null, |
535 | 499 | "id": "d44f3e2b",
|
536 | 500 | "metadata": {},
|
537 |
| - "outputs": [ |
538 |
| - { |
539 |
| - "name": "stdout", |
540 |
| - "output_type": "stream", |
541 |
| - "text": [ |
542 |
| - "Custom Tokens: ['comfortable', 'furniture', 'for', 'a', 'large', 'balcony']\n" |
543 |
| - ] |
544 |
| - }, |
545 |
| - { |
546 |
| - "data": { |
547 |
| - "text/plain": [ |
548 |
| - "ObjectApiResponse({'acknowledged': True})" |
549 |
| - ] |
550 |
| - }, |
551 |
| - "execution_count": 64, |
552 |
| - "metadata": {}, |
553 |
| - "output_type": "execute_result" |
554 |
| - } |
555 |
| - ], |
| 501 | + "outputs": [], |
556 | 502 | "source": [
|
557 | 503 | "index_settings = {\n",
|
558 | 504 | " \"settings\": {\n",
|
|
645 | 591 | },
|
646 | 592 | {
|
647 | 593 | "cell_type": "code",
|
648 |
| - "execution_count": 65, |
| 594 | + "execution_count": null, |
649 | 595 | "id": "f4984f6c-ceec-46a4-b64c-f749e6b1b04f",
|
650 | 596 | "metadata": {
|
651 | 597 | "id": "f4984f6c-ceec-46a4-b64c-f749e6b1b04f"
|
652 | 598 | },
|
653 |
| - "outputs": [ |
654 |
| - { |
655 |
| - "name": "stdout", |
656 |
| - "output_type": "stream", |
657 |
| - "text": [ |
658 |
| - "\n", |
659 |
| - "Score: 12.93728\n", |
660 |
| - "Product: Barbie Dreamhouse\n", |
661 |
| - "Category: Toys\n", |
662 |
| - "Description: is a classic Barbie playset with multiple rooms, furniture, a large balcony, a pool, and accessories. It allows kids to create their dream Barbie world.\n", |
663 |
| - "\n", |
664 |
| - "\n", |
665 |
| - "Score: 7.9097595\n", |
666 |
| - "Product: Rattan Patio Conversation Set\n", |
667 |
| - "Category: Outdoor Furniture\n", |
668 |
| - "Description: is a stylish and comfortable outdoor furniture set, including a sofa, two chairs, and a coffee table, all made of durable rattan material.\n", |
669 |
| - "\n" |
670 |
| - ] |
671 |
| - } |
672 |
| - ], |
| 599 | + "outputs": [], |
673 | 600 | "source": [
|
674 | 601 | "results_list = []\n",
|
675 | 602 | "\n",
|
|
720 | 647 | },
|
721 | 648 | {
|
722 | 649 | "cell_type": "code",
|
723 |
| - "execution_count": 66, |
| 650 | + "execution_count": null, |
724 | 651 | "id": "72187c9a-14c1-4084-a080-4e5c1e614f22",
|
725 | 652 | "metadata": {
|
726 | 653 | "id": "72187c9a-14c1-4084-a080-4e5c1e614f22"
|
727 | 654 | },
|
728 |
| - "outputs": [ |
729 |
| - { |
730 |
| - "name": "stdout", |
731 |
| - "output_type": "stream", |
732 |
| - "text": [ |
733 |
| - "\n", |
734 |
| - "Score: 0.93147576\n", |
735 |
| - "Product: Metal Garden Bench with Cushion\n", |
736 |
| - "Category: Garden Furniture\n", |
737 |
| - "Description: is a stylish and comfortable metal garden bench, complete with a cushion for added support.\n", |
738 |
| - "\n", |
739 |
| - "\n", |
740 |
| - "Score: 0.9304026\n", |
741 |
| - "Product: Garden Dining Set with Swivel Chairs\n", |
742 |
| - "Category: Garden Furniture\n", |
743 |
| - "Description: is a functional and comfortable garden dining set, including a table and chairs with swivel seats for convenience.\n", |
744 |
| - "\n" |
745 |
| - ] |
746 |
| - } |
747 |
| - ], |
| 655 | + "outputs": [], |
748 | 656 | "source": [
|
749 | 657 | "# KNN\n",
|
750 | 658 | "# TODO: Add Semantic_Text type?\n",
|
|
782 | 690 | },
|
783 | 691 | {
|
784 | 692 | "cell_type": "code",
|
785 |
| - "execution_count": 85, |
| 693 | + "execution_count": null, |
786 | 694 | "id": "c5475e21",
|
787 | 695 | "metadata": {},
|
788 |
| - "outputs": [ |
789 |
| - { |
790 |
| - "name": "stdout", |
791 |
| - "output_type": "stream", |
792 |
| - "text": [ |
793 |
| - "\n", |
794 |
| - "Score: 11.354144\n", |
795 |
| - "Product: Garden Lounge Set with Side Table\n", |
796 |
| - "Category: Garden Furniture\n", |
797 |
| - "Description: is a comfortable and stylish garden lounge set, including a sofa, chairs, and a side table for outdoor relaxation.\n", |
798 |
| - "\n", |
799 |
| - "\n", |
800 |
| - "Score: 11.200024\n", |
801 |
| - "Product: Garden Lounge Set with Ottoman\n", |
802 |
| - "Category: Garden Furniture\n", |
803 |
| - "Description: is a versatile and comfortable garden lounge set, including a sofa, chairs, and ottoman for outdoor relaxation.\n", |
804 |
| - "\n" |
805 |
| - ] |
806 |
| - } |
807 |
| - ], |
| 696 | + "outputs": [], |
808 | 697 | "source": [
|
809 | 698 | "# Elastic Learned Sparse Encoder - ELSER\n",
|
810 | 699 | "\n",
|
|
837 | 726 | },
|
838 | 727 | {
|
839 | 728 | "cell_type": "code",
|
840 |
| - "execution_count": 93, |
| 729 | + "execution_count": null, |
841 | 730 | "id": "4d2fb926",
|
842 | 731 | "metadata": {},
|
843 |
| - "outputs": [ |
844 |
| - { |
845 |
| - "name": "stdout", |
846 |
| - "output_type": "stream", |
847 |
| - "text": [ |
848 |
| - "\n", |
849 |
| - "Score: 11.354144\n", |
850 |
| - "Product: Garden Lounge Set with Side Table\n", |
851 |
| - "Category: Garden Furniture\n", |
852 |
| - "Description: is a comfortable and stylish garden lounge set, including a sofa, chairs, and a side table for outdoor relaxation.\n", |
853 |
| - "\n", |
854 |
| - "\n", |
855 |
| - "Score: 11.200024\n", |
856 |
| - "Product: Garden Lounge Set with Ottoman\n", |
857 |
| - "Category: Garden Furniture\n", |
858 |
| - "Description: is a versatile and comfortable garden lounge set, including a sofa, chairs, and ottoman for outdoor relaxation.\n", |
859 |
| - "\n" |
860 |
| - ] |
861 |
| - } |
862 |
| - ], |
| 732 | + "outputs": [], |
863 | 733 | "source": [
|
864 | 734 | "# Elastic Learned Sparse Encoder - ELSER\n",
|
865 | 735 | "\n",
|
|
890 | 760 | },
|
891 | 761 | {
|
892 | 762 | "cell_type": "code",
|
893 |
| - "execution_count": 94, |
| 763 | + "execution_count": null, |
894 | 764 | "id": "2c0bf5fc-ab32-4f33-8f26-904ff10635a5",
|
895 | 765 | "metadata": {
|
896 | 766 | "id": "2c0bf5fc-ab32-4f33-8f26-904ff10635a5"
|
897 | 767 | },
|
898 |
| - "outputs": [ |
899 |
| - { |
900 |
| - "name": "stdout", |
901 |
| - "output_type": "stream", |
902 |
| - "text": [ |
903 |
| - "\n", |
904 |
| - "Score: 0.93147576\n", |
905 |
| - "Product: Metal Garden Bench with Cushion\n", |
906 |
| - "Category: Garden Furniture\n", |
907 |
| - "Description: is a stylish and comfortable metal garden bench, complete with a cushion for added support.\n", |
908 |
| - "\n", |
909 |
| - "\n", |
910 |
| - "Score: 0.9304026\n", |
911 |
| - "Product: Garden Dining Set with Swivel Chairs\n", |
912 |
| - "Category: Garden Furniture\n", |
913 |
| - "Description: is a functional and comfortable garden dining set, including a table and chairs with swivel seats for convenience.\n", |
914 |
| - "\n" |
915 |
| - ] |
916 |
| - } |
917 |
| - ], |
| 768 | + "outputs": [], |
918 | 769 | "source": [
|
919 | 770 | "# Elastic Learned Sparse Encoder - ELSER\n",
|
920 | 771 | "\n",
|
|
0 commit comments