Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails with: unexpected keyword argument 'output_attentions' #2

Open
drscotthawley opened this issue Feb 17, 2020 · 1 comment
Open

Comments

@drscotthawley
Copy link

drscotthawley commented Feb 17, 2020

Thanks for creating this tool! Installation went fine, and when I run it, all goes well until I click the "send" button on the browser. (Chrome or Brave, on MacOS 10.15), then it fails.

I just ran with the defaults, GPT-2 and the default sentence.

Here's a log from running the server:

$ python server.py
Namespace(host=None, nodebug=False, port='8888')

  • Serving Flask app "server" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  • Restarting with stat
    Namespace(host=None, nodebug=False, port='8888')
  • Debugger is active!
  • Debugger PIN: 138-828-520
    127.0.0.1 - - [16/Feb/2020 22:48:31] "GET / HTTP/1.1" 302 -
    127.0.0.1 - - [16/Feb/2020 22:48:31] "GET /client/index.html HTTP/1.1" 200 -
    127.0.0.1 - - [16/Feb/2020 22:48:31] "GET /client/styles.css HTTP/1.1" 200 -
    127.0.0.1 - - [16/Feb/2020 22:48:32] "GET /client/tools..js HTTP/1.1" 200 -
    127.0.0.1 - - [16/Feb/2020 22:48:32] "GET /favicon.ico HTTP/1.1" 404 -
    Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 224/224 [00:00<00:00, 63.0kB/s]
    Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████| 548M/548M [00:27<00:00, 19.8MB/s]
    127.0.0.1 - - [16/Feb/2020 22:49:07] "POST /api/attn HTTP/1.1" 500 -
    Traceback (most recent call last):
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 2463, in call
    return self.wsgi_app(environ, start_response)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functionsrule.endpoint
    File "/Users/shawley/Downloads/attnvis/server.py", line 38, in attn
    loaded_models[model_name] = AttentionGetter(model_name)
    File "/Users/shawley/Downloads/attnvis/api.py", line 19, in init
    self.model = AutoModel.from_pretrained(model_name, output_attentions=True).to(
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/transformers/modeling_auto.py", line 377, in from_pretrained
    return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
    File "/Users/shawley/anaconda/envs/attnvis/lib/python3.6/site-packages/transformers/modeling_utils.py", line 463, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
    TypeError: init() got an unexpected keyword argument 'output_attentions'
@erickrf
Copy link

erickrf commented Jul 5, 2020

A quick fix is to move the output_attentions keyword from the loading method to the forward call. See my pull request #3 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants