Skip to content

Commit

Permalink
Pass token and trust_remote_code to tokenizer_args too (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaarsen authored Jan 15, 2024
1 parent 08a57b4 commit 3f9ec1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sentence_transformers/SentenceTransformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ def _load_auto_model(
model_name_or_path,
cache_dir=cache_folder,
model_args={"token": token, "trust_remote_code": trust_remote_code},
tokenizer_args={"token": token, "trust_remote_code": trust_remote_code},
)
pooling_model = Pooling(transformer_model.get_word_embedding_dimension(), "mean")
return [transformer_model, pooling_model]
Expand Down Expand Up @@ -1038,10 +1039,13 @@ def _load_sbert_model(
kwargs = json.load(fIn)
break
if "model_args" in kwargs:
kwargs["model_args"]["token"] = token
kwargs["model_args"]["trust_remote_code"] = trust_remote_code
kwargs["model_args"].update({"token": token, "trust_remote_code": trust_remote_code})
else:
kwargs["model_args"] = {"token": token, "trust_remote_code": trust_remote_code}
if "tokenizer_args" in kwargs:
kwargs["tokenizer_args"].update({"token": token, "trust_remote_code": trust_remote_code})
else:
kwargs["tokenizer_args"] = {"token": token, "trust_remote_code": trust_remote_code}
module = Transformer(model_name_or_path, cache_dir=cache_folder, **kwargs)
else:
module_path = load_dir_path(
Expand Down

0 comments on commit 3f9ec1e

Please sign in to comment.