Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated recommended vector indexes #88

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
42 changes: 7 additions & 35 deletions notebooks/searching-all-of-wikipedia/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
"source": [
"## Part 3: Building the vector indexes\n",
"\n",
"Now, we have all the data in our table `vecs`. Let's go ahead and build our vector index. SingleStore gives us many options for our index with many tunable parameters. We will stick with the IVF indexes with default parameters."
"Now, we have all the data in our table `vecs`. Let's go ahead and build our vector index. SingleStore gives us many options for our index with many tunable parameters. We will stick with the `IVF_PQFS` and `HNSW_FLAT` indexes with default parameters."
]
},
{
Expand All @@ -319,7 +319,7 @@
"outputs": [],
"source": [
"%%sql\n",
"alter table vecs add vector index auto (v) INDEX_OPTIONS '{\"index_type\":\"AUTO\"}';"
"alter table vecs add vector index ivf_pqfs (v) INDEX_OPTIONS '{\"index_type\":\"IVF_PQFS\"}';"
]
},
{
Expand All @@ -330,18 +330,7 @@
"outputs": [],
"source": [
"%%sql\n",
"alter table vecs add vector index ivf_flat (v) INDEX_OPTIONS '{\"index_type\":\"IVF_FLAT\"}';"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "55de3a82-4e6f-4e8b-9fbd-8f5370fd4145",
"metadata": {},
"outputs": [],
"source": [
"%%sql\n",
"alter table vecs add vector index ivf_pq (v) INDEX_OPTIONS '{\"index_type\":\"IVF_PQ\"}';"
"alter table vecs add vector index hnsw_flat (v) INDEX_OPTIONS '{\"index_type\":\"HNSW_FLAT\"}';"
]
},
{
Expand Down Expand Up @@ -389,7 +378,7 @@
"-- AUTO index\n",
"select paragraph, v <*> @qv as sim\n",
"from vecs\n",
"order by sim use index (auto) desc\n",
"order by sim use index (ivf_pqfs) desc\n",
"limit 5;"
]
},
Expand All @@ -406,24 +395,7 @@
"-- IVF_FLAT\n",
"select paragraph, v <*> @qv as sim\n",
"from vecs\n",
"order by sim use index (ivf_flat) desc\n",
"limit 5;"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "40ea859c-c57a-4624-965f-94a18cd05c90",
"metadata": {},
"outputs": [],
"source": [
"%%sql\n",
"set @qv = (select v from vecs where id = 1125899906845489);\n",
"\n",
"-- IVF_PQ\n",
"select paragraph, v <*> @qv as sim\n",
"from vecs\n",
"order by sim use index (ivf_pq) desc\n",
"order by sim use index (hnsw_flat) desc\n",
"limit 5;"
]
},
Expand Down Expand Up @@ -464,7 +436,7 @@
"vs as (\n",
" select id, paragraph, v <*> @v_mario as score\n",
" from vecs\n",
" order by score use index (auto) desc\n",
" order by score use index (ivf_pqfs) desc\n",
" limit 200\n",
")\n",
"select vs.id,\n",
Expand Down Expand Up @@ -567,7 +539,7 @@
" statement = sa.text(\n",
" f'''select paragraph, v <*> :query_embedding :> vector(1536) AS similarity\n",
" from vecs\n",
" order by similarity use index (auto) desc\n",
" order by similarity use index (ivf_pqfs) desc\n",
" limit :limit;'''\n",
" )\n",
" print(\"Searching for matches...\")\n",
Expand Down
Loading