Skip to content

Commit

Permalink
🚧 fix(docs): huggingface search callback notebok
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchinegod committed Dec 20, 2023
1 parent a08759f commit 20d86b0
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __pycache__/

# Custom
data/
*.ipynb
/*.ipynb
raw/
.DS_Store
local_example.ipynb
Expand Down
87 changes: 87 additions & 0 deletions examples/search_qa/1_huggingface.ipynb
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
}

0 comments on commit 20d86b0

Please sign in to comment.