|
50 | 50 | }, |
51 | 51 | { |
52 | 52 | "cell_type": "code", |
53 | | - "execution_count": null, |
| 53 | + "execution_count": 3, |
54 | 54 | "id": "36881aa5-3a6f-4358-985b-b829aac42826", |
55 | 55 | "metadata": {}, |
56 | 56 | "outputs": [], |
|
94 | 94 | "output_type": "stream", |
95 | 95 | "text": [ |
96 | 96 | "Image 'qdrant/qdrant' already exists locally\n", |
97 | | - "Container started with ID: 33dec7bc01280a8b8343ff4da87e8822cbfdd3a242249d1935b581031ae48784\n", |
| 97 | + "Container started with ID: 7a505aaa0d10843ece53e55fdf42458a41723c6cc7ddcacd1534e36a515db551\n", |
98 | 98 | "Container status: running\n", |
99 | 99 | "Container logs:\n", |
100 | 100 | " _ _ \n", |
|
107 | 107 | "Version: 1.14.0, build: 3617a011\n", |
108 | 108 | "Access web UI at http://localhost:6333/dashboard\n", |
109 | 109 | "\n", |
110 | | - "2025-05-21T19:20:02.141355Z INFO storage::content_manager::consensus::persistent: Loading raft state from ./storage/raft_state.json \n", |
111 | | - "2025-05-21T19:20:02.145747Z INFO qdrant: Distributed mode disabled \n", |
112 | | - "2025-05-21T19:20:02.145819Z INFO qdrant: Telemetry reporting enabled, id: 92001ec9-eb22-4dbf-bcfd-5a800bac4ffb \n", |
113 | | - "2025-05-21T19:20:02.145906Z INFO qdrant: Inference service is not configured. \n", |
114 | | - "2025-05-21T19:20:02.147806Z INFO qdrant::actix: TLS disabled for REST API \n", |
115 | | - "2025-05-21T19:20:02.147861Z INFO qdrant::actix: Qdrant HTTP listening on 6333 \n", |
116 | | - "2025-05-21T19:20:02.147878Z INFO actix_server::builder: Starting 11 workers\n", |
117 | | - "2025-05-21T19:20:02.147884Z INFO actix_server::server: Actix runtime found; starting in Actix runtime\n", |
118 | | - "2025-05-21T19:20:02.151909Z INFO qdrant::tonic: Qdrant gRPC listening on 6334 \n", |
119 | | - "2025-05-21T19:20:02.151920Z INFO qdrant::tonic: TLS disabled for gRPC API \n", |
| 110 | + "2025-06-18T02:43:01.654204Z INFO storage::content_manager::consensus::persistent: Loading raft state from ./storage/raft_state.json \n", |
| 111 | + "2025-06-18T02:43:01.658166Z INFO qdrant: Distributed mode disabled \n", |
| 112 | + "2025-06-18T02:43:01.658223Z INFO qdrant: Telemetry reporting enabled, id: d8e363b9-1c51-4b9a-afaf-18e5a03cb920 \n", |
| 113 | + "2025-06-18T02:43:01.658285Z INFO qdrant: Inference service is not configured. \n", |
| 114 | + "2025-06-18T02:43:01.660085Z INFO qdrant::actix: TLS disabled for REST API \n", |
| 115 | + "2025-06-18T02:43:01.660146Z INFO qdrant::actix: Qdrant HTTP listening on 6333 \n", |
| 116 | + "2025-06-18T02:43:01.660163Z INFO actix_server::builder: Starting 11 workers\n", |
| 117 | + "2025-06-18T02:43:01.660175Z INFO actix_server::server: Actix runtime found; starting in Actix runtime\n", |
| 118 | + "2025-06-18T02:43:01.663848Z INFO qdrant::tonic: Qdrant gRPC listening on 6334 \n", |
| 119 | + "2025-06-18T02:43:01.663858Z INFO qdrant::tonic: TLS disabled for gRPC API \n", |
120 | 120 | "\n" |
121 | 121 | ] |
122 | 122 | } |
|
371 | 371 | "output_type": "stream", |
372 | 372 | "text": [ |
373 | 373 | "Similarity score: 0.49984106\n", |
374 | | - "KnowledgeNode: node_id='d641b713-62dd-46e7-86c2-4e3968ed5339' embedding=None node_type=<NodeType.TEXT: 'text'> text_content=\"title: History of marine biology\\nsection: James Cook\\ntext: James Cook is well known for his voyages of exploration for the British Navy in which he mapped out a significant amount of the world's uncharted waters. Cook's explorations took him around the world twice and led to countless descriptions of previously unknown plants and animals. Cook's explorations influenced many others and led to a number of scientists examining marine life more closely. Among those influenced was Charles Darwin who went on to make many contributions of his own. \" image_content=None metadata={'id': '140'}\n" |
| 374 | + "KnowledgeNode: node_id='3e7e2e62-51ef-4da6-94e7-a1caef85c76e' embedding=None node_type=<NodeType.TEXT: 'text'> text_content=\"title: History of marine biology\\nsection: James Cook\\ntext: James Cook is well known for his voyages of exploration for the British Navy in which he mapped out a significant amount of the world's uncharted waters. Cook's explorations took him around the world twice and led to countless descriptions of previously unknown plants and animals. Cook's explorations influenced many others and led to a number of scientists examining marine life more closely. Among those influenced was Charles Darwin who went on to make many contributions of his own. \" image_content=None metadata={'id': '140'}\n" |
375 | 375 | ] |
376 | 376 | } |
377 | 377 | ], |
|
380 | 380 | "print(\"KnowledgeNode: \", knowledge_node)" |
381 | 381 | ] |
382 | 382 | }, |
| 383 | + { |
| 384 | + "cell_type": "markdown", |
| 385 | + "id": "1e7532c7-bbb2-4351-8ce1-107556ec35f8", |
| 386 | + "metadata": {}, |
| 387 | + "source": [ |
| 388 | + "## Batch Retrieval" |
| 389 | + ] |
| 390 | + }, |
| 391 | + { |
| 392 | + "cell_type": "code", |
| 393 | + "execution_count": 13, |
| 394 | + "id": "ad598746-9b13-4684-bbc3-611a1da4d886", |
| 395 | + "metadata": {}, |
| 396 | + "outputs": [], |
| 397 | + "source": [ |
| 398 | + "another_query = \"Who is Charles Darwin?\"\n", |
| 399 | + "another_query_emb = retriever.encode_query(another_query).tolist()" |
| 400 | + ] |
| 401 | + }, |
| 402 | + { |
| 403 | + "cell_type": "code", |
| 404 | + "execution_count": 14, |
| 405 | + "id": "74ca44a0-799e-4aa2-90da-1eb11b835ce2", |
| 406 | + "metadata": {}, |
| 407 | + "outputs": [], |
| 408 | + "source": [ |
| 409 | + "batch_retrieval_result = knowledge_store.batch_retrieve(\n", |
| 410 | + " query_embs=[query_emb, another_query_emb], top_k=1\n", |
| 411 | + ")" |
| 412 | + ] |
| 413 | + }, |
| 414 | + { |
| 415 | + "cell_type": "code", |
| 416 | + "execution_count": 15, |
| 417 | + "id": "ee08ec6f-fe6c-40be-b93b-2b4a163b02ff", |
| 418 | + "metadata": {}, |
| 419 | + "outputs": [ |
| 420 | + { |
| 421 | + "data": { |
| 422 | + "text/plain": [ |
| 423 | + "[(0.49984106,\n", |
| 424 | + " KnowledgeNode(node_id='3e7e2e62-51ef-4da6-94e7-a1caef85c76e', embedding=None, node_type=<NodeType.TEXT: 'text'>, text_content=\"title: History of marine biology\\nsection: James Cook\\ntext: James Cook is well known for his voyages of exploration for the British Navy in which he mapped out a significant amount of the world's uncharted waters. Cook's explorations took him around the world twice and led to countless descriptions of previously unknown plants and animals. Cook's explorations influenced many others and led to a number of scientists examining marine life more closely. Among those influenced was Charles Darwin who went on to make many contributions of his own. \", image_content=None, metadata={'id': '140'}))]" |
| 425 | + ] |
| 426 | + }, |
| 427 | + "execution_count": 15, |
| 428 | + "metadata": {}, |
| 429 | + "output_type": "execute_result" |
| 430 | + } |
| 431 | + ], |
| 432 | + "source": [ |
| 433 | + "# Who is James Cook?\n", |
| 434 | + "batch_retrieval_result[0]" |
| 435 | + ] |
| 436 | + }, |
| 437 | + { |
| 438 | + "cell_type": "code", |
| 439 | + "execution_count": 16, |
| 440 | + "id": "6bbd04a8-040b-4db3-833e-73db83cfdf47", |
| 441 | + "metadata": {}, |
| 442 | + "outputs": [ |
| 443 | + { |
| 444 | + "data": { |
| 445 | + "text/plain": [ |
| 446 | + "[(0.50851303,\n", |
| 447 | + " KnowledgeNode(node_id='27462ceb-8f25-4d4b-99b2-0b821697b37e', embedding=None, node_type=<NodeType.TEXT: 'text'>, text_content='title: History of marine biology\\nsection: Charles Darwin\\ntext: Charles Darwin, best known for his theory of evolution, made many significant contributions to the early study of marine biology. He spent much of his time from 1831 to 1836 on the voyage of HMS Beagle collecting and studying specimens from a variety of marine organisms. It was also on this expedition where Darwin began to study coral reefs and their formation. He came up with the theory that the overall growth of corals is a balance between the growth of corals upward and the sinking of the sea floor. He then came up with the idea that wherever coral atolls would be found, the central island where the coral had started to grow would be gradually subsiding', image_content=None, metadata={'id': '141'}))]" |
| 448 | + ] |
| 449 | + }, |
| 450 | + "execution_count": 16, |
| 451 | + "metadata": {}, |
| 452 | + "output_type": "execute_result" |
| 453 | + } |
| 454 | + ], |
| 455 | + "source": [ |
| 456 | + "# Who is Charles Darwin?\n", |
| 457 | + "batch_retrieval_result[1]" |
| 458 | + ] |
| 459 | + }, |
383 | 460 | { |
384 | 461 | "cell_type": "markdown", |
385 | 462 | "id": "463bfac0-bf0d-453e-a47f-b136c069793a", |
|
390 | 467 | }, |
391 | 468 | { |
392 | 469 | "cell_type": "code", |
393 | | - "execution_count": 13, |
| 470 | + "execution_count": 17, |
| 471 | + "id": "4f0d1315-f9eb-4306-a340-4d060511a27f", |
| 472 | + "metadata": {}, |
| 473 | + "outputs": [], |
| 474 | + "source": [ |
| 475 | + "knowledge_store.clear()" |
| 476 | + ] |
| 477 | + }, |
| 478 | + { |
| 479 | + "cell_type": "code", |
| 480 | + "execution_count": 18, |
394 | 481 | "id": "b2cf76bc-c0b6-4934-9e8a-5374ea16d34e", |
395 | 482 | "metadata": {}, |
396 | 483 | "outputs": [], |
|
0 commit comments