Skip to content

Commit

Permalink
notebook re runs
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerhutcherson committed Nov 21, 2023
1 parent 0684735 commit ab2f3ff
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 76 deletions.
16 changes: 11 additions & 5 deletions docs/user_guide/getting_started_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m16:03:01\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m16:03:01\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_index\n"
"\u001b[32m22:49:46\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m22:49:46\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_index\n"
]
}
],
Expand Down Expand Up @@ -587,7 +587,10 @@
{
"data": {
"text/plain": [
"{'index': {'name': 'user_index', 'prefix': 'user'},\n",
"{'index': {'name': 'user_index',\n",
" 'prefix': 'user',\n",
" 'storage_type': 'hash',\n",
" 'key_separator': ':'},\n",
" 'fields': {'tag': [{'name': 'credit_score'}],\n",
" 'text': [{'name': 'job'}],\n",
" 'numeric': [{'name': 'age'}],\n",
Expand Down Expand Up @@ -616,7 +619,10 @@
{
"data": {
"text/plain": [
"{'index': {'name': 'user_index', 'prefix': 'user'},\n",
"{'index': {'name': 'user_index',\n",
" 'prefix': 'user',\n",
" 'storage_type': 'hash',\n",
" 'key_separator': ':'},\n",
" 'fields': {'tag': [{'name': 'credit_score'}, {'name': 'job'}],\n",
" 'text': [],\n",
" 'numeric': [{'name': 'age'}],\n",
Expand Down Expand Up @@ -729,7 +735,7 @@
"│ offsets_per_term_avg │ 0 │\n",
"│ records_per_doc_avg │ 4 │\n",
"│ sortable_values_size_mb │ 0 │\n",
"│ total_indexing_time │ 0.59 \n",
"│ total_indexing_time │ 1.738\n",
"│ total_inverted_index_blocks │ 7 │\n",
"│ vector_index_sz_mb │ 0.235603 │\n",
"╰─────────────────────────────┴─────────────╯\n"
Expand Down
41 changes: 6 additions & 35 deletions docs/user_guide/hash_vs_json_05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"outputs": [],
"source": [
"# import necessary modules\n",
"import os\n",
"import pickle\n",
"from jupyterutils import table_print, result_print\n",
"from redisvl.index import SearchIndex\n",
Expand Down Expand Up @@ -203,21 +202,7 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OBJ {'user': 'john', 'age': 18, 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'derrick', 'age': 14, 'job': 'doctor', 'credit_score': 'low', 'office_location': '-122.4194,37.7749', 'user_embedding': b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'nancy', 'age': 94, 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': b'333?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'tyler', 'age': 100, 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': b'\\xcd\\xcc\\xcc=\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'tim', 'age': 12, 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': b'\\xcd\\xcc\\xcc>\\xcd\\xcc\\xcc>\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'taimur', 'age': 15, 'job': 'CEO', 'credit_score': 'low', 'office_location': '-122.0839,37.3861', 'user_embedding': b'\\x9a\\x99\\x19?\\xcd\\xcc\\xcc=\\x00\\x00\\x00?'}\n",
"OBJ {'user': 'joe', 'age': 35, 'job': 'dentist', 'credit_score': 'medium', 'office_location': '-122.0839,37.3861', 'user_embedding': b'fff?fff?\\xcd\\xcc\\xcc='}\n"
]
}
],
"outputs": [],
"source": [
"# load hash data\n",
"hindex.load(data)"
Expand Down Expand Up @@ -253,7 +238,7 @@
"│ offsets_per_term_avg │ 0.204545 │\n",
"│ records_per_doc_avg │ 6.28571 │\n",
"│ sortable_values_size_mb │ 0 │\n",
"│ total_indexing_time │ 0.265\n",
"│ total_indexing_time │ 0.335\n",
"│ total_inverted_index_blocks │ 18 │\n",
"│ vector_index_sz_mb │ 0.0202332 │\n",
"╰─────────────────────────────┴─────────────╯\n"
Expand Down Expand Up @@ -395,9 +380,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m17:52:28\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m17:52:28\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user-hashes\n",
"\u001b[32m17:52:28\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 2. user-json\n"
"\u001b[32m22:50:47\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m22:50:47\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user-hashes\n",
"\u001b[32m22:50:47\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 2. user-json\n"
]
}
],
Expand Down Expand Up @@ -458,21 +443,7 @@
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OBJ {'user': 'john', 'age': 18, 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': [0.10000000149011612, 0.10000000149011612, 0.5]}\n",
"OBJ {'user': 'derrick', 'age': 14, 'job': 'doctor', 'credit_score': 'low', 'office_location': '-122.4194,37.7749', 'user_embedding': [0.10000000149011612, 0.10000000149011612, 0.5]}\n",
"OBJ {'user': 'nancy', 'age': 94, 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': [0.699999988079071, 0.10000000149011612, 0.5]}\n",
"OBJ {'user': 'tyler', 'age': 100, 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': [0.10000000149011612, 0.4000000059604645, 0.5]}\n",
"OBJ {'user': 'tim', 'age': 12, 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': [0.4000000059604645, 0.4000000059604645, 0.5]}\n",
"OBJ {'user': 'taimur', 'age': 15, 'job': 'CEO', 'credit_score': 'low', 'office_location': '-122.0839,37.3861', 'user_embedding': [0.6000000238418579, 0.10000000149011612, 0.5]}\n",
"OBJ {'user': 'joe', 'age': 35, 'job': 'dentist', 'credit_score': 'medium', 'office_location': '-122.0839,37.3861', 'user_embedding': [0.8999999761581421, 0.8999999761581421, 0.10000000149011612]}\n"
]
}
],
"outputs": [],
"source": [
"jindex.load(json_data)"
]
Expand Down
12 changes: 6 additions & 6 deletions docs/user_guide/hybrid_queries_02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m16:03:26\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m16:03:26\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_index\n"
"\u001b[32m22:51:08\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
"\u001b[32m22:51:08\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_index\n"
]
}
],
Expand Down Expand Up @@ -1108,10 +1108,10 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'id': 'v1:54b273392e4d4fa2af424caca095d2d4', 'payload': None, 'user': 'john', 'age': '18', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '==\\x00\\x00\\x00?'}\n",
"{'id': 'v1:abdab0c48bed49bea9a79d9eb3f247fa', 'payload': None, 'user': 'nancy', 'age': '94', 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '333?=\\x00\\x00\\x00?'}\n",
"{'id': 'v1:81ea678467be4ca1bd8efaec27766d10', 'payload': None, 'user': 'tyler', 'age': '100', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '=>\\x00\\x00\\x00?'}\n",
"{'id': 'v1:44741013d4d5469dad4b95f70cedc0bb', 'payload': None, 'user': 'tim', 'age': '12', 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '>>\\x00\\x00\\x00?'}\n"
"{'id': 'v1:13dbcb6b63e6416187a8c9ee1ab6eae7', 'payload': None, 'user': 'john', 'age': '18', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '==\\x00\\x00\\x00?'}\n",
"{'id': 'v1:02d544f7543a40c780dee81116dd5610', 'payload': None, 'user': 'nancy', 'age': '94', 'job': 'doctor', 'credit_score': 'high', 'office_location': '-122.4194,37.7749', 'user_embedding': '333?=\\x00\\x00\\x00?'}\n",
"{'id': 'v1:d521d5c1778842e98d8ad50d837a60a4', 'payload': None, 'user': 'tyler', 'age': '100', 'job': 'engineer', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '=>\\x00\\x00\\x00?'}\n",
"{'id': 'v1:2efe1220f62a4f8fb94055de526ff8f6', 'payload': None, 'user': 'tim', 'age': '12', 'job': 'dermatologist', 'credit_score': 'high', 'office_location': '-122.0839,37.3861', 'user_embedding': '>>\\x00\\x00\\x00?'}\n"
]
}
],
Expand Down
60 changes: 30 additions & 30 deletions docs/user_guide/llmcache_03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import openai\n",
"import getpass\n",
"os.environ[\"TOKENIZERS_PARALLELISM\"] = \"False\"\n",
"\n",
"os.environ[\"TOKENIZERS_PARALLELISM\"] = \"False\"\n",
"\n",
"api_key = os.getenv(\"OPENAI_API_KEY\") or getpass.getpass(\"Enter your OpenAI API key: \")\n",
"\n",
Expand All @@ -45,14 +45,14 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Paris\n"
"Paris.\n"
]
}
],
Expand All @@ -72,20 +72,20 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from redisvl.llmcache.semantic import SemanticCache\n",
"cache = SemanticCache(\n",
" redis_url=\"redis://localhost:6379\",\n",
" threshold=0.9, # semantic similarity threshold\n",
" )"
")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -116,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -125,7 +125,7 @@
"[]"
]
},
"execution_count": 20,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -137,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -156,7 +156,7 @@
"['Paris']"
]
},
"execution_count": 22,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -168,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -177,7 +177,7 @@
"[]"
]
},
"execution_count": 23,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -189,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -198,7 +198,7 @@
"['Paris']"
]
},
"execution_count": 24,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -211,7 +211,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -220,7 +220,7 @@
"[]"
]
},
"execution_count": 25,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -232,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -250,7 +250,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -266,14 +266,14 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time taken without cache 0.8732700347900391\n"
"Time taken without cache 0.574105978012085\n"
]
}
],
Expand All @@ -287,15 +287,15 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time Taken with cache: 0.04746699333190918\n",
"Percentage of time saved: 94.56%\n"
"Time Taken with cache: 0.09868717193603516\n",
"Percentage of time saved: 82.81%\n"
]
}
],
Expand All @@ -309,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -337,9 +337,9 @@
"│ offsets_per_term_avg │ 0 │\n",
"│ records_per_doc_avg │ 2 │\n",
"│ sortable_values_size_mb │ 0 │\n",
"│ total_indexing_time │ 0.211\n",
"│ total_indexing_time │ 0.087\n",
"│ total_inverted_index_blocks │ 11 │\n",
"│ vector_index_sz_mb │ 3.00814\n",
"│ vector_index_sz_mb │ 3.0161 \n",
"╰─────────────────────────────┴─────────────╯\n"
]
}
Expand All @@ -351,7 +351,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -376,7 +376,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.9.12"
},
"orig_nbformat": 4
},
Expand Down

0 comments on commit ab2f3ff

Please sign in to comment.