From 8f8d82281c3e7d3b0e424e1c5d61c4fc8e43707c Mon Sep 17 00:00:00 2001 From: Debopam Chowdhury Param <116789128+DebopamParam@users.noreply.github.com> Date: Fri, 8 Nov 2024 00:15:18 +0530 Subject: [PATCH] Update RAGModel.py --- byaldi/RAGModel.py | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/byaldi/RAGModel.py b/byaldi/RAGModel.py index f025ec3..57e2f1f 100644 --- a/byaldi/RAGModel.py +++ b/byaldi/RAGModel.py @@ -180,34 +180,34 @@ def as_langchain_retriever(self, **kwargs: Any): return ByaldiLangChainRetriever(model=self, kwargs=kwargs) - def save_pretrained(self, directory_path: str) -> None: - """ - Save the model and processor to a specified directory. - - Parameters: - directory_path (str): The path to the directory where the model and processor should be saved. - - Returns: - None - - This function saves both the model and processor components of the current instance - to the specified directory, allowing the model to be reloaded later from this checkpoint. - However, for complete local setup follow this - https://github.com/illuin-tech/colpali/issues/129 - - Raises: - FileNotFoundError: If the specified directory does not exist. - PermissionError: If there are insufficient permissions to write to the directory. - Exception: For any other unexpected errors during the save process. - """ - try: - # Attempt to save the model and processor - self.model.model.save_pretrained(directory_path) - self.model.processor.save_pretrained(directory_path) + # def save_pretrained(self, directory_path: str) -> None: + # """ + # Save the model and processor to a specified directory. + + # Parameters: + # directory_path (str): The path to the directory where the model and processor should be saved. + + # Returns: + # None + + # This function saves both the model and processor components of the current instance + # to the specified directory, allowing the model to be reloaded later from this checkpoint. + # However, for complete local setup follow this - https://github.com/illuin-tech/colpali/issues/129 + + # Raises: + # FileNotFoundError: If the specified directory does not exist. + # PermissionError: If there are insufficient permissions to write to the directory. + # Exception: For any other unexpected errors during the save process. + # """ + # try: + # # Attempt to save the model and processor + # self.model.model.save_pretrained(directory_path) + # self.model.processor.save_pretrained(directory_path) - except FileNotFoundError as fnf_error: - raise FileNotFoundError(f"The specified directory '{directory_path}' does not exist.") from fnf_error - except PermissionError as perm_error: - raise PermissionError(f"Insufficient permissions to write to '{directory_path}'.") from perm_error - except Exception as e: - raise Exception(f"An unexpected error occurred while saving: {e}") from e + # except FileNotFoundError as fnf_error: + # raise FileNotFoundError(f"The specified directory '{directory_path}' does not exist.") from fnf_error + # except PermissionError as perm_error: + # raise PermissionError(f"Insufficient permissions to write to '{directory_path}'.") from perm_error + # except Exception as e: + # raise Exception(f"An unexpected error occurred while saving: {e}") from e