Skip to content

Commit 1dab293

Browse files
authored
Avoid compatibility issues when loading models saved in Transformers v4.50 (#594)
1 parent 08b3a55 commit 1dab293

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/setfit/model_card.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ def register_model(self, model: "SetFitModel") -> None:
432432
def infer_st_id(self, setfit_model_id: str) -> None:
433433
config_dict, _ = PretrainedConfig.get_config_dict(setfit_model_id)
434434
st_id = config_dict.get("_name_or_path")
435+
if st_id is None:
436+
# If we can't access _name_or_path, we can't infer the base model ID
437+
return
435438
st_id_path = Path(st_id)
436439
# Sometimes the name_or_path ends exactly with the model_id, e.g.
437440
# "C:\\Users\\tom/.cache\\torch\\sentence_transformers\\BAAI_bge-small-en-v1.5\\"

0 commit comments

Comments
 (0)