Open GTimothee opened 1 week ago
Here you go https://github.com/UKPLab/sentence-transformers/pull/3057
Edit: from what I understand, the issue is the following; there is a function in transformers that checks if the model is a PeftMixedModel
or not. If not, it is not considered a peft model and the trainer tries to load the model as usual. The problem is our model is a PeftAdapterMixin
so it is not recognized as a peft model.
Edit2: The fix is just a temporary fix to remove the error, as we probably need to update transformers directly. So the fix I did is just to check if the model has adapters on it (is a PeftAdapterMixin)
Edit3: I figured out it probably does not work then lol, I need to check if there are some adapters on it instead. Will do.
Edit4: Found a way to find if there is at least one adapter, so it should work now
Edit5: Tried it with and without adapter, it works
Edit6: I added a little warning so that the user can actually see the log: /usr/local/lib/python3.10/dist-packages/transformers/trainer.py:2601: UserWarning: Could not load best model, as the model has at least one adapter set. Please wait for an update of the transformers library to enable this feature. self._load_best_model()
opened a ticket in transformers to request the change https://github.com/huggingface/transformers/issues/34747
When I try to train a peft model with the
load_best_model_at_end=True
option enabled, it crashes, raising aFileNotFoundError
.Here is the example code as a gist: gist
Error I get:
FileNotFoundError: [Errno 2] No such file or directory: 'training_trial/checkpoint-250/pytorch_model.bin'