relevanceai.operations.vector.base
#
Module Contents#
- relevanceai.operations.vector.base.BASE_2VEC_DEFINITON#
- class relevanceai.operations.vector.base.Base2Vec#
Base class for vector
- classmethod validate_model_url(cls, model_url: str, list_of_urls: List[str])#
Validate the model url belongs in the list of urls. This is to help users to avoid mis-spelling the name of the model.
# TODO: Improve model URL validation to not include final number in URl string.
- Parameters
model_url – The URl of the the model in question
list_of_urls – The list of URLS for the model in question
- static is_url_working(url)#
- classmethod chunk(self, lst: List, chunksize: int)#
Chunk an iterable object in Python but not a pandas DataFrame. :param lst: Python List :param chunksize: The chunk size of an object.
Example
>>> documents = [{...}] >>> ViClient.chunk(documents)
- property zero_vector(self)#
- is_empty_vector(self, vector)#
- get_default_vector_field_name(self, field, field_type='vector')#
- encode_documents(self, fields: list, documents: list, vector_error_treatment='zero_vector', field_type='vector')#
Encode documents and their specific fields. Note that this runs off the default encode method. If there is a specific function that you want run, ensure that it is set to the encode function.
- Parameters
missing_treatment – Missing treatment can be one of [“do_not_include”, “zero_vector”, value].
documents – The documents that are being used
fields – The list of fields to be used
field_type – Accepts “vector” or “chunkvector”
- encode_chunk_documents(self, chunk_field, fields: list, documents: list, vector_error_treatment: str = 'zero_vector')#
Encode chunk documents. Loops through every field and then every document.
- Parameters
chunk_field – The field for chunking
fields – A list of fields for chunk documents
documents – a list of documents
vector_error_treatment – Vector Error Treatment
Example
>>> chunk_docs = enc.encode_chunk_documents(chunk_field="value", fields=["text"], documents=chunk_docs)
- bulk_encode_documents(self, fields: list, documents: list, vector_error_treatment='zero_vector', field_type='vector')#
Encode documents and their specific fields. Note that this runs off the default encode method. If there is a specific function that you want run, ensure that it is set to the encode function.
- Parameters
missing_treatment – Missing treatment can be one of [“do_not_include”, “zero_vector”, value].
documents – The documents that are being used
fields – The list of fields to be used
- get_combinations(self, lst, maximum_span=5)#
- get_cosine_similarity(self, vector_1, vector_2)#
- get_word_combinations(self, sentence, maximum_span=5)#
- get_result(self, result_text, query_vector)#
- explain(self, query_text, result_texts, highlight_threshold=0.5, max_highlights=None, return_cos_similarity_docs: bool = True, ignore_warnings: bool = True)#