Skip to main content

Create Vector Search Model

item = {indexing_key: '<var:query>'}
from superduper.components.model import QueryModel

vector_search_model = QueryModel(
identifier="VectorSearch",
select=query_table_or_collection.like(item, vector_index=vector_index_name, n=5).select(),
# The _source is the identifier of the upstream data, which can be used to locate the data from upstream sources using `_source`.
postprocess=lambda docs: [{"text": doc[indexing_key], "_source": doc["_source"]} for doc in docs],
db=db
)
vector_search_model.predict(query=query)