Skip to content

Commit

Permalink
πŸ‘©πŸ»β€πŸ’» fix(wip): notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchinegod committed Dec 23, 2023
1 parent 6facd00 commit 829718e
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions examples/distributed_embedding/1_callback_index.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[92m🌊 SUCCESS: connected successfully to 192.168.2.69\u001b[0m\n"
]
}
],
"source": [
"from magnet.ize import memory\n",
"config = {\n",
" \"MILVUS_URI\": \"192.168.2.69\"\n",
" , \"DIMENSION\": 1024\n",
" , \"MODEL\": \"BAAI/bge-large-en-v1.5\"\n",
" , \"INDEX\": \"bge_nlp_deduped\"\n",
" , \"INDEX_PARAMS\": {\n",
" 'metric_type': 'COSINE',\n",
" 'index_type':'HNSW',\n",
" 'params': {\n",
" \"efConstruction\": 40\n",
" , \"M\": 48\n",
" },\n",
" }\n",
"}\n",
"\n",
"index = memory.Embedder(config)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[96mβ˜•οΈ WAIT: connecting to my-user:[email protected]\u001b[0m\n",
"\u001b[92m🌊 SUCCESS: connected to my-user:[email protected]\u001b[0m\n",
"\u001b[94mℹ️ INFO: consuming delta from [nlp_chunks_deduped] on\n",
"πŸ›°οΈ stream: documents\n",
"🧲 session: \"bge_nlp_deduped_embedder\"\u001b[0m\n"
]
}
],
"source": [
"from magnet.ic import field\n",
"reso = field.Resonator(\"my-user:[email protected]\")\n",
"async def handle_payload(payload, msg):\n",
" await index.embed_and_store(payload)\n",
" await msg.ack()\n",
"await reso.on(cb=handle_payload, category=\"nlp_chunks_deduped\", session=\"bge_nlp_deduped_embedder\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 829718e

Please sign in to comment.