Open svenhendrikx opened 1 year ago
@svenhendrikx thanks for opening an issue! The issue is very clear; this is indeed a bug, and our warning message (and these regular expressions) were written for a prior version of transformers. Feel free to open a PR, it would be great to fix this, since it's an annoying warning message!
When running the code example shown in the Attack class' docstring, the following error occurs:
textattack: Unknown if model of class <class 'transformers.models.bert.modeling_bert.BertForSequenceClassification'> compatible with goal function <class 'textattack.goal_functions.classification.untargeted_classification.UntargetedClassification'>.
To Reproduce run the following code:This code is sourced from the documentation of the Attack class.
See error.
Expected behavior This code should run the attack and store the result in the attack_result variable.
System Information (please complete the following information):
Additional context In shared/validators.py, the following code defines the globs which are used to validate compatibility between models and goal_functions:
However, the following glob is incorrect:
r"^transformers.modeling_\w*\.\w*ForSequenceClassification$"
The correct module path for models in Transformers is as follows:
r"transformers.models.\w*.modeling_\w*.\w*ForSequenceClassification"
Suggested fix:
Add the correct module path to the list of globs like so:
This fixed the issue for me, let me know if I missed anything!
I have a branch with this fix already, so let me know if I can help/make a PR.