Vector Store Retrieversο
Base vector store index query.
- class llama_index.indices.vector_store.retrievers.retriever.VectorIndexRetriever(index: VectorStoreIndex, similarity_top_k: int = 2, vector_store_query_mode: VectorStoreQueryMode = VectorStoreQueryMode.DEFAULT, filters: Optional[MetadataFilters] = None, alpha: Optional[float] = None, doc_ids: Optional[List[str]] = None, **kwargs: Any)ο
Vector index retriever.
- Parameters
index (VectorStoreIndex) β vector store index.
similarity_top_k (int) β number of top k results to return.
vector_store_query_mode (str) β vector store query mode See reference for VectorStoreQueryMode for full list of supported modes.
filters (Optional[MetadataFilters]) β metadata filters, defaults to None
alpha (float) β weight for sparse/dense retrieval, only used for hybrid query mode.
doc_ids (Optional[List[str]]) β list of documents to constrain search.
vector_store_kwargs (dict) β Additional vector store specific kwargs to pass through to the vector store at query time.
- retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore] ο
Retrieve nodes given query.
- Parameters
str_or_query_bundle (QueryType) β Either a query string or a QueryBundle object.
- class llama_index.indices.vector_store.retrievers.auto_retriever.auto_retriever.VectorIndexAutoRetriever(index: VectorStoreIndex, vector_store_info: VectorStoreInfo, prompt_template_str: Optional[str] = None, service_context: Optional[ServiceContext] = None, max_top_k: int = 10)ο
Vector store auto retriever.
A retriever for vector store index that uses an LLM to automatically set vector store query parameters.
- Parameters
index (VectorStoreIndex) β vector store index
vector_store_info (VectorStoreInfo) β additional information information about vector store content and supported metadata filters. The natural language description is used by an LLM to automatically set vector store query parameters.
prompt_template_str β custom prompt template string for LLM. Uses default template string if None.
service_context β service context containing reference to LLMPredictor. Uses service context from index be default if None.
max_top_k β the maximum top_k allowed. The top_k set by LLM will be clamped to this value.
- retrieve(str_or_query_bundle: Union[str, QueryBundle]) List[NodeWithScore] ο
Retrieve nodes given query.
- Parameters
str_or_query_bundle (QueryType) β Either a query string or a QueryBundle object.
Vector store index types.
- class llama_index.vector_stores.types.ExactMatchFilter(*, key: str, value: Union[str, int, float])ο
Exact match metadata filter for vector stores.
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model ο
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = βallowβ was set since it adds all passed values
- copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model ο
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters
include β fields to include in new model
exclude β fields to exclude from new model, as with values this takes precedence over include
update β values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep β set to True to make a deep copy of the model
- Returns
new model instance
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ο
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ο
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- classmethod update_forward_refs(**localns: Any) None ο
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- class llama_index.vector_stores.types.MetadataFilters(*, filters: List[ExactMatchFilter])ο
Metadata filters for vector stores.
Currently only supports exact match filters. TODO: support more advanced expressions.
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model ο
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = βallowβ was set since it adds all passed values
- copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model ο
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters
include β fields to include in new model
exclude β fields to exclude from new model, as with values this takes precedence over include
update β values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep β set to True to make a deep copy of the model
- Returns
new model instance
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ο
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ο
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- classmethod update_forward_refs(**localns: Any) None ο
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- class llama_index.vector_stores.types.MetadataInfo(*, name: str, type: str, description: str)ο
Information about a metadata filter supported by a vector store.
Currently only used by VectorIndexAutoRetriever.
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model ο
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = βallowβ was set since it adds all passed values
- copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model ο
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters
include β fields to include in new model
exclude β fields to exclude from new model, as with values this takes precedence over include
update β values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep β set to True to make a deep copy of the model
- Returns
new model instance
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ο
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ο
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- classmethod update_forward_refs(**localns: Any) None ο
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- class llama_index.vector_stores.types.VectorStoreInfo(*, metadata_info: List[MetadataInfo], content_info: str)ο
Information about a vector store (content and supported metadata filters).
Currently only used by VectorIndexAutoRetriever.
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model ο
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = βallowβ was set since it adds all passed values
- copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model ο
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters
include β fields to include in new model
exclude β fields to exclude from new model, as with values this takes precedence over include
update β values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep β set to True to make a deep copy of the model
- Returns
new model instance
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ο
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ο
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- classmethod update_forward_refs(**localns: Any) None ο
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- class llama_index.vector_stores.types.VectorStoreQueryMode(value)ο
Vector store query mode.