Retriever#
Vecworks implements various retrievers for interfacing with vector stores.
- class vecworks.retrievers.generic.Retriever#
Pypeworks Node providing access to a single vector index for similarity search.
Interface#
- __init__(index: Index | list[Index], **kwargs)#
Initializes the retriever. This must be invoked by an sub-class as part of initialization.
Parameters#
- index
Index to query for similarity.
- kwargs
Any additional arguments to pass to the underlying Pypeworks Node.
- exec(input: Any | Iterable, **kwargs)#
Search the index for content similar to the given input.
Parameters#
- input
Input(s) to compare the index with for similarity.
- kwargs
Any other arguments passed as part of the invocation of the method.
- query(input: Iterable[ndarray | sparray | spmatrix], **kwargs) dict[str, list[Any]] #
Search the index for a vector similar to the given vector(s). If the input is not yet vectorised, call
exec()
instead.Note
Any sub-class must re-implement this method to provide a fully functional retriever.
Parameters#
- input
Vectorized input(s).
- kwargs
Any other arguments passed.
- class vecworks.retrievers.generic.MultiIndexRetriever#
Interface implemented by all retrievers allowing to query multiple indices at the same time.
Interface#
- __init__(index: Index | list[Index], return_rank_as: str | None = None, ensemble_by: ENSEMBLERS | None = None, top_k: int = 10, **kwargs)#
Initializes the retriever. This must be invoked by an sub-class as part of initialization.
Parameters#
- index
Index or indices to query for similarity.
- return_rank_as
Name to assign to the variable holding the rank.
- ensemble_by
Ensembler to use to combine results from similarity queries. Refer to
vecworks.functions.ENSEMBLERS
for the available options.- top_k
Maximum number of results to retrieve per vector.
- kwargs
Any additional arguments to pass to the underlying Pypeworks Node.
- exec(*args, **kwargs)#
Search the index for content similar to the given input.
Parameters#
- args
Input(s) to compare the index with for similarity, passed without a name.
- kwargs
Input(s) to compare the index with for similarity, passed with a name. Any arguments with a name that may not be mapped to an index, are passed as key-value arguments for use at the discretion of the retriever.
- query(input: dict[str, Iterable[ndarray | sparray | spmatrix]], **kwargs) dict[str, list[list[Any]]] #
Search the index for a vector similar to the given vector(s). If the input is not yet vectorised, call
exec()
instead.Note
Any sub-class must re-implement this method to provide a fully functional retriever.
Parameters#
- input
Vectorized input(s) indexed by name.
- kwargs
Any other arguments passed.