From 420319ce020c8dc3f4c89bc4a16b46cf3ea66483 Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Fri, 14 Mar 2025 13:39:10 -0400 Subject: [PATCH 1/2] make a WA in case Bert model do not have `safetensor` file Signed-off-by: Liu, Kaixuan --- .../python/server/text_embeddings_server/models/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/python/server/text_embeddings_server/models/__init__.py b/backends/python/server/text_embeddings_server/models/__init__.py index 72ec500d..c1ee39f8 100644 --- a/backends/python/server/text_embeddings_server/models/__init__.py +++ b/backends/python/server/text_embeddings_server/models/__init__.py @@ -65,7 +65,10 @@ def get_model(model_path: Path, dtype: Optional[str], pool: str): return DefaultModel( model_path, device, datatype, pool, trust_remote=TRUST_REMOTE_CODE ) - return FlashBert(model_path, device, datatype) + try: + return FlashBert(model_path, device, datatype) + except: + return DefaultModel(model_path, device, datatype, pool, trust_remote=TRUST_REMOTE_CODE) if config.architectures[0].endswith("Classification"): return ClassificationModel( model_path, device, datatype, trust_remote=TRUST_REMOTE_CODE From c27350ed7c2decb915006c9e45ba270a378fd61d Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Mon, 17 Mar 2025 16:31:06 -0400 Subject: [PATCH 2/2] catch specific exception Signed-off-by: Liu, Kaixuan --- .../server/text_embeddings_server/models/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backends/python/server/text_embeddings_server/models/__init__.py b/backends/python/server/text_embeddings_server/models/__init__.py index c1ee39f8..a2258be0 100644 --- a/backends/python/server/text_embeddings_server/models/__init__.py +++ b/backends/python/server/text_embeddings_server/models/__init__.py @@ -67,8 +67,13 @@ def get_model(model_path: Path, dtype: Optional[str], pool: str): ) try: return FlashBert(model_path, device, datatype) - except: - return DefaultModel(model_path, device, datatype, pool, trust_remote=TRUST_REMOTE_CODE) + except FileNotFoundError as e: + logger.info( + "Do not have safetensors file for this model, use default transformers model path instead" + ) + return DefaultModel( + model_path, device, datatype, pool, trust_remote=TRUST_REMOTE_CODE + ) if config.architectures[0].endswith("Classification"): return ClassificationModel( model_path, device, datatype, trust_remote=TRUST_REMOTE_CODE