From df0daf44a7036278d612754af695653dc7135ff1 Mon Sep 17 00:00:00 2001 From: Nathan Voxland Date: Wed, 7 Feb 2024 15:37:58 -0600 Subject: [PATCH 1/3] Improved deeplake.py init documentation --- llama_index/vector_stores/deeplake.py | 63 +++++++++++---------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/llama_index/vector_stores/deeplake.py b/llama_index/vector_stores/deeplake.py index 5a589b05fbfd7..80e104f9d3a29 100644 --- a/llama_index/vector_stores/deeplake.py +++ b/llama_index/vector_stores/deeplake.py @@ -47,49 +47,38 @@ class DeepLakeVectorStore(BasePydanticVectorStore): _deeplake_db_collection: Any = PrivateAttr() def __init__( - self, - dataset_path: str = "llama_index", - token: Optional[str] = None, - read_only: Optional[bool] = False, - ingestion_batch_size: int = 1024, - ingestion_num_workers: int = 4, - overwrite: bool = False, - exec_option: Optional[str] = None, - verbose: bool = True, - **kwargs: Any, + self, + dataset_path: str = "llama_index", + token: Optional[str] = None, + read_only: Optional[bool] = False, + ingestion_batch_size: int = 1024, + ingestion_num_workers: int = 4, + overwrite: bool = False, + exec_option: Optional[str] = None, + verbose: bool = True, + **kwargs: Any, ) -> None: super().__init__() """ Args: - dataset_path (str): Path to the deeplake dataset, where data will be - stored. Defaults to "llama_index". - overwrite (bool, optional): Whether to overwrite existing dataset with same - name. Defaults to False. - token (str, optional): the deeplake token that allows you to access the - dataset with proper access. Defaults to None. - read_only (bool, optional): Whether to open the dataset with read only mode. - ingestion_batch_size (int): used for controlling batched data - ingestion to deeplake dataset. Defaults to 1024. + dataset_path (str): The full path for storing to the Deep Lake Vector Store. It can be: + - a Deep Lake cloud path of the form ``hub://org_id/dataset_name``. Requires registration with Deep Lake. + - an s3 path of the form ``s3://bucketname/path/to/dataset``. Credentials are required in either the environment or passed to the creds argument. + - a local file system path of the form ``./path/to/dataset`` or ``~/path/to/dataset`` or ``path/to/dataset``. + - a memory path of the form ``mem://path/to/dataset`` which doesn't save the dataset but keeps it in memory instead. Should be used only for testing as it does not persist. + Defaults to "llama_index". + overwrite (bool, optional): If set to True this overwrites the Vector Store if it already exists. Defaults to False. + token (str, optional): Activeloop token, used for fetching user credentials. This is Optional, tokens are normally autogenerated. Defaults to None. + read_only (bool, optional): Opens dataset in read-only mode if True. Defaults to False. + ingestion_batch_size (int): During data ingestion, data is divided + into batches. Batch size is the size of each batch. Defaults to 1024. ingestion_num_workers (int): number of workers to use during data ingestion. Defaults to 4. - overwrite (bool): Whether to overwrite existing dataset with the - new dataset with the same name. - exec_option (str): Default method for search execution. It could be either - It could be either ``"python"``, ``"compute_engine"`` or - ``"tensor_db"``. Defaults to ``"python"``. - - ``python`` - Pure-python implementation that runs on the client and - can be used for data stored anywhere. WARNING: using this option - with big datasets is discouraged because it can lead to memory - issues. - - ``compute_engine`` - Performant C++ implementation of the Deep Lake - Compute Engine that runs on the client and can be used for any data - stored in or connected to Deep Lake. It cannot be used with - in-memory or local datasets. - - ``tensor_db`` - Performant and fully-hosted Managed Tensor Database - that is responsible for storage and query execution. Only available - for data stored in the Deep Lake Managed Database. Store datasets in - this database by specifying runtime = {"tensor_db": True} during - dataset creation. + exec_option (str): Default method for search execution. It could be either ``"auto"``, ``"python"``, ``"compute_engine"`` or ``"tensor_db"``. Defaults to ``"auto"``. If None, it's set to "auto". + - ``auto``- Selects the best execution method based on the storage location of the Vector Store. It is the default option. + - ``python`` - Pure-python implementation that runs on the client and can be used for data stored anywhere. WARNING: using this option with big datasets is discouraged because it can lead to memory issues. + - ``compute_engine`` - Performant C++ implementation of the Deep Lake Compute Engine that runs on the client and can be used for any data stored in or connected to Deep Lake. It cannot be used with in-memory or local datasets. + - ``tensor_db`` - Performant and fully-hosted Managed Tensor Database that is responsible for storage and query execution. Only available for data stored in the Deep Lake Managed Database. Store datasets in this database by specifying runtime = {"tensor_db": True} during dataset creation. verbose (bool): Specify if verbose output is enabled. Default is True. **kwargs (Any): Additional keyword arguments. From c45a092ddce612a56f4ba2af7a18c297ba99a769 Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Wed, 14 Feb 2024 17:21:49 -0500 Subject: [PATCH 2/3] Add __del__ at Vllm for deleting model --- .../llama_index/llms/vllm/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llama-index-integrations/llms/llama-index-llms-vllm/llama_index/llms/vllm/base.py b/llama-index-integrations/llms/llama-index-llms-vllm/llama_index/llms/vllm/base.py index 5fdd577c7dedb..6c80052c177a9 100644 --- a/llama-index-integrations/llms/llama-index-llms-vllm/llama_index/llms/vllm/base.py +++ b/llama-index-integrations/llms/llama-index-llms-vllm/llama_index/llms/vllm/base.py @@ -212,6 +212,17 @@ def _model_kwargs(self) -> Dict[str, Any]: } return {**base_kwargs} + def __del__(self) -> None: + import torch + from vllm.model_executor.parallel_utils.parallel_state import ( + destroy_model_parallel, + ) + + destroy_model_parallel() + del self._client + if torch.cuda.is_available(): + torch.cuda.synchronize() + def _get_all_kwargs(self, **kwargs: Any) -> Dict[str, Any]: return { **self._model_kwargs, From 6e9702db48484946b69695ad59e815a0e0426c7d Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Wed, 14 Feb 2024 18:15:52 -0500 Subject: [PATCH 3/3] cr --- .../vector_stores/deeplake/base.py | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-deeplake/llama_index/vector_stores/deeplake/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-deeplake/llama_index/vector_stores/deeplake/base.py index 93f5aacd2fe26..734da12f31b61 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-deeplake/llama_index/vector_stores/deeplake/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-deeplake/llama_index/vector_stores/deeplake/base.py @@ -56,16 +56,16 @@ class DeepLakeVectorStore(BasePydanticVectorStore): _id_tensor_name: str = PrivateAttr() def __init__( - self, - dataset_path: str = "llama_index", - token: Optional[str] = None, - read_only: Optional[bool] = False, - ingestion_batch_size: int = 1024, - ingestion_num_workers: int = 4, - overwrite: bool = False, - exec_option: Optional[str] = None, - verbose: bool = True, - **kwargs: Any, + self, + dataset_path: str = "llama_index", + token: Optional[str] = None, + read_only: Optional[bool] = False, + ingestion_batch_size: int = 1024, + ingestion_num_workers: int = 4, + overwrite: bool = False, + exec_option: Optional[str] = None, + verbose: bool = True, + **kwargs: Any, ) -> None: """ Args: @@ -87,8 +87,6 @@ def __init__( - ``python`` - Pure-python implementation that runs on the client and can be used for data stored anywhere. WARNING: using this option with big datasets is discouraged because it can lead to memory issues. - ``compute_engine`` - Performant C++ implementation of the Deep Lake Compute Engine that runs on the client and can be used for any data stored in or connected to Deep Lake. It cannot be used with in-memory or local datasets. - ``tensor_db`` - Performant and fully-hosted Managed Tensor Database that is responsible for storage and query execution. Only available for data stored in the Deep Lake Managed Database. Store datasets in this database by specifying runtime = {"tensor_db": True} during dataset creation. - verbose (bool): Specify if verbose output is enabled. Default is True. - **kwargs (Any): Additional keyword arguments. Raises: ImportError: Unable to import `deeplake`.