@@ -46,46 +46,6 @@ def get_sentence_transformer_and_scaling_fn(
4646
4747 return model , None
4848
49-
50- def extract_model_name_from_sentence_transformer (
51- model : SentenceTransformer ,
52- ) -> Optional [str ]:
53- """
54- Attempt to extract the model name from a SentenceTransformer instance.
55-
56- This is a best-effort function as SentenceTransformer doesn't directly store
57- the original model name. It tries to infer it from the model's configuration.
58-
59- Args:
60- model: A SentenceTransformer model instance
61-
62- Returns:
63- A string representing the best guess at the model name, or
64- None if it cannot be determined
65- """
66- # Try to get the name from the model's modules
67- if hasattr (model , "modules" ) and model .modules :
68- # Most SentenceTransformer models use a Transformer as the first module
69- if hasattr (model .modules [0 ], "auto_model" ) and hasattr (
70- model .modules [0 ].auto_model , "config"
71- ):
72- # Try to get the name from the config
73- if hasattr (model .modules [0 ].auto_model .config , "name_or_path" ):
74- return model .modules [0 ].auto_model .config .name_or_path
75-
76- # Try to get from the model's save directory name
77- if hasattr (model , "get_sentence_embedding_dimension" ) and hasattr (
78- model , "get_config_dict"
79- ):
80- config = model .get_config_dict ()
81- if "__path__" in config and config ["__path__" ]:
82- # Extract the final path component as the model name
83- return os .path .basename (os .path .normpath (config ["__path__" ]))
84-
85- # Return None if we can't determine the name
86- return None
87-
88-
8949def e5_scaling_function (score : float ) -> float :
9050 """
9151 Scale the similarity score for E5 embeddings.
0 commit comments