Skip to content

Commit

Permalink
fix(agents-api): Fix vector search parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Oct 24, 2024
1 parent 009b14c commit d803ebb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions agents-api/agents_api/models/docs/search_docs_by_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def search_docs_by_embedding(
query_embedding: list[float],
k: int = 3,
confidence: float = 0.5,
ef: int = 32,
mmr_lambda: float = 0.25,
ef: int = 50,
mmr_lambda: float = 0.5,
embedding_size: int = 1024,
) -> tuple[list[str], dict]:
"""
Expand Down
1 change: 0 additions & 1 deletion agents-api/agents_api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import logging
from typing import Any, Callable

import fire
import sentry_sdk
import uvicorn
import uvloop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,45 @@ def run(client, *queries):
client.run(query)


# See: https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md
drop_snippets_hnsw_index = dict(
down="""
::hnsw create snippets:embedding_space {
fields: [embedding],
filter: !is_null(embedding),
dim: 1024,
distance: Cosine,
m: 64,
ef_construction: 256,
extend_candidates: true,
keep_pruned_connections: false,
}
""",
up="""
::hnsw drop snippets:embedding_space
""",
)


# See: https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md
snippets_hnsw_index = dict(
up="""
::hnsw create snippets:embedding_space {
fields: [embedding],
filter: !is_null(embedding),
dim: 1024,
distance: Cosine,
m: 64,
ef_construction: 800,
extend_candidates: false,
keep_pruned_connections: false,
}
""",
down="""
::hnsw drop snippets:embedding_space
""",
)

drop_snippets_lsh_index = dict(
up="""
::lsh drop snippets:lsh
Expand Down Expand Up @@ -77,8 +116,10 @@ def run(client, *queries):
)

queries_to_run = [
drop_snippets_hnsw_index,
drop_snippets_lsh_index,
drop_snippets_fts_index,
snippets_hnsw_index,
snippets_lsh_index,
snippets_fts_index,
]
Expand Down

0 comments on commit d803ebb

Please sign in to comment.