QData / TextAttack

TextAttack 🐙 is a Python framework for adversarial attacks, data augmentation, and model training in NLP https://textattack.readthedocs.io/en/master/
https://textattack.readthedocs.io/en/master/
MIT License
2.87k stars 383 forks source link

running CLARE recipe causes TypeError: 'NoneType' object is not callable #459

Closed ryanachi closed 2 years ago

ryanachi commented 3 years ago

Describe the bug When running textattack's CLARE recipe, it fails to generate more than one result, exiting due to the following error: TypeError: 'NoneType' object is not callable (please see the paste2 for full details)

To Reproduce Steps to reproduce the behavior:

  1. Run following command textattack attack --recipe clare --model bert-base-uncased-ag-news --num-examples 20

Expected behavior Given an example dataset, the CLARE recipe should (drawing on a RoBERTa model) create adversarial examples through infilling, merging, and replacing tokens.

Screenshots or Traceback https://paste2.org/gtc0V94W

System Information (please complete the following information):

Thank you for your help!

jxmorris12 commented 3 years ago

Looks like there was another error in the stack trace that was hard to spot:

  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/flair/models/sequence_tagger_model.py", line 232, in __init__
    self.to(flair.device)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/module.py", line 673, in to
    return self._apply(convert)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/flair/models/language_model.py", line 428, in _apply
    child_module._apply(fn)
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 186, in _apply
    self.flatten_parameters()
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/rnn.py", line 170, in flatten_parameters
    if self.proj_size > 0:
  File "/home/ryanchi/miniconda3/envs/glare/lib/python3.7/site-packages/torch/nn/modules/module.py", line 948, in __getattr__
    type(self).__name__, name))

AttributeError: 'LSTM' object has no attribute 'proj_size'

This actually might be a problem with the flair version. @ryanachi can you run the following command and paste the output? pip show flair (the most recent FLAIR version is 0.8: https://github.com/flairNLP/flair)