allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.77k stars 2.25k forks source link

The demo coreference resolution code doesn't seem to work #3275

Closed StrangeTcy closed 5 years ago

StrangeTcy commented 5 years ago

Describe the bug Creating a file coref.py with the exact contents of a python library usage examples from the coreference resolution demo page (https://demo.allennlp.org/coreference-resolution/MTA1ODA3NQ==) and running it with python3 coref.py results in the following errors:

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/rnn.py:51: UserWarning: dropout option adds dropout after all but last recurrent layer, so non-zero dropout expects num_layers greater than 1, but got dropout=0.2 and num_layers=1 "num_layers={}".format(dropout, num_layers)) /usr/local/lib/python3.6/dist-packages/allennlp/data/token_indexers/token_characters_indexer.py:56: UserWarning: You are using the default value (0) of min_padding_length, which can cause some subtle bugs (more info see https://github.com/allenai/allennlp/issues/1954). Strongly recommend to set a value, usually the maximum size of the convolutional layer size when using CnnEncoder. UserWarning) /pytorch/aten/src/ATen/native/LegacyDefinitions.cpp:14: UserWarning: maskedfill received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead. WARNING:allennlp.models.model:Encountered the antecedent_indices key in the model's return dictionary which couldn't be split by the batch size. Key will be ignored.

To Reproduce Steps to reproduce the behavior

  1. Go to https://demo.allennlp.org/coreference-resolution/MTA1ODA3NQ==
  2. Copy the usage example
  3. Run it
  4. See error

Expected behavior A sentence with numbered coref cluster similar to the output of a demo

System (please complete the following information):

matt-gardner commented 5 years ago

I see the same warning, but it's not an error. I still get output containing a 'clusters' key, with value [[[0, 4], [10, 10]]], indicating that the model thinks that "The woman reading a newspaper" is coreferent with "her".