-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 fix(docs): huggingface search callback notebok
- Loading branch information
1 parent
a08759f
commit 20d86b0
Showing
2 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ __pycache__/ | |
|
||
# Custom | ||
data/ | ||
*.ipynb | ||
/*.ipynb | ||
raw/ | ||
.DS_Store | ||
local_example.ipynb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[92m🌊 SUCCESS: connected successfully to 192.168.2.69\u001b[0m\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'\\n\\nAnswer: \\n\\nBioLargo, Inc. holds substantially all of its cash equivalents in short-term money market accounts at Bank of America. As of September 30, 2023, and December 31, 2022, BioLargo, Inc. and subsidiaries had cash balances of $2,280,000 and $2,280,000, respectively.'" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from magnet.ron import milvus, llm\n", | ||
"\n", | ||
"config = {\n", | ||
" \"MILVUS_URI\": \"192.168.2.69\"\n", | ||
" , \"DIMENSION\": 1024\n", | ||
" , \"MODEL\": \"BAAI/bge-large-en-v1.5\"\n", | ||
" , \"INDEX\": \"test_collection\"\n", | ||
" , \"INDEX_PARAMS\": {\n", | ||
" 'metric_type': 'COSINE',\n", | ||
" 'index_type':'HNSW',\n", | ||
" 'params': {\n", | ||
" \"efConstruction\": 40\n", | ||
" , \"M\": 48\n", | ||
" },\n", | ||
" }\n", | ||
"}\n", | ||
"\n", | ||
"async def handle_search(q, docs):\n", | ||
" gen = llm.Generate(hf_token='hf_yourTokenHere')\n", | ||
" return await gen.ask(\n", | ||
" q = q\n", | ||
" , docs = docs\n", | ||
" )\n", | ||
"\n", | ||
"index = milvus.Embedder(config)\n", | ||
"q = 'How is Bank of America doing?'\n", | ||
"\n", | ||
"results = index.search(q, limit=5, cb=handle_search)\n", | ||
"await results\n" | ||
] | ||
}, | ||
{ | ||
"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 | ||
} |