Skip to content

Commit

Permalink
support local model with safetensors format
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Nov 29, 2023
1 parent 4d3000e commit e3b0506
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion delft/utilities/Transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ def instantiate_layer(self, load_pretrained_weights=True) -> Union[object, TFAut

elif self.loading_method == LOADING_METHOD_LOCAL_MODEL_DIR:
if load_pretrained_weights:
transformer_model = TFAutoModel.from_pretrained(self.local_dir_path, from_pt=True)
try:
transformer_model = TFAutoModel.from_pretrained(self.local_dir_path, from_pt=True)
except:
# failure might be due to safetensors format for the weights, we can try an alternative loading
# for this case
transformer_model = TFAutoModel.from_pretrained(self.local_dir_path)
self.transformer_config = transformer_model.config
return transformer_model
else:
Expand Down

0 comments on commit e3b0506

Please sign in to comment.