Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions 0_local_knowledge_search_walkthrough.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"from sochdb import Database, HnswIndex"
"from sochdb import Database, VectorIndex"
]
},
{
Expand Down Expand Up @@ -198,9 +198,9 @@
]
}
],
"source": [
"index = HnswIndex(dimension=DIMENSION, m=16, ef_construction=100, metric='cosine')\n",
"inserted = index.insert_batch_with_ids(ids, vectors)\n",
"source": [
"index = VectorIndex(dimension=DIMENSION, max_connections=16, ef_construction=100)\n",
"inserted = index.insert_batch(ids, vectors)\n",
"print(f'Indexed {inserted} document embeddings')"
]
},
Expand Down Expand Up @@ -247,13 +247,15 @@
"output_type": "execute_result"
}
],
"source": [
"query = 'How do I access internal tools securely from my laptop?'\n",
"query_vec = embed_text(query)\n",
"result_ids, distances = index.search(query_vec, k=3)\n",
"\n",
"results = []\n",
"for doc_id, distance in zip(result_ids.tolist(), distances.tolist()):\n",
"source": [
"query = 'How do I access internal tools securely from my laptop?'\n",
"query_vec = embed_text(query)\n",
"results = index.search(query_vec, k=3)\n",
"result_ids = [r[0] for r in results]\n",
"distances = [r[1] for r in results]\n",
"\n",
"results = []\n",
"for doc_id, distance in zip(result_ids, distances):\n",
" payload = db.get(f'docs/{doc_id}'.encode('utf-8'))\n",
" if payload is None:\n",
" continue\n",
Expand Down