Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Semantic role labelling model returns all 'O' tags #4146

Closed

Description

@RanganThaya

Describe the bug
Semantic role labelling model tags are all 'O'. No arguments are detected.

To Reproduce

from allennlp.predictors.predictor import Predictor
import allennlp_models.syntax.srl
predictor = Predictor.from_path("https://s3-us-west-2.amazonaws.com/allennlp/models/bert-base-srl-2019.06.17.tar.gz")
predictor.predict(
  sentence="Did Uriah honestly think he could beat the game in under three hours?"
)

Output:

 {'verb': 'beat',
   'description': 'Did Uriah honestly think he could beat the game in under three hours ?',
   'tags': ['O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O',
    'O']}],
 'words': ['Did',
  'Uriah',
  'honestly',
  'think',
  'he',
  'could',
  'beat',
  'the',
  'game',
  'in',
  'under',
  'three',
  'hours',
  '?']}

Expected Output

{
   "verbs":[
      {
         "description":"Did [ARG0: Uriah] [ARGM-MNR: honestly] [V: think] [ARG1: he could beat the game in under three hours] ?",
         "tags":[
            "O",
            "B-ARG0",
            "B-ARGM-MNR",
            "B-V",
            "B-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "I-ARG1",
            "O"
         ],
         "verb":"think"
      },
      {
         "description":"Did Uriah honestly think he [V: could] beat the game in under three hours ?",
         "tags":[
            "O",
            "O",
            "O",
            "O",
            "O",
            "B-V",
            "O",
            "O",
            "O",
            "O",
            "O",
            "O",
            "O",
            "O"
         ],
         "verb":"could"
      },
      {
         "description":"Did Uriah honestly think [ARG0: he] [ARGM-MOD: could] [V: beat] [ARG1: the game] in [ARGM-TMP: under three hours] ?",
         "tags":[
            "O",
            "O",
            "O",
            "O",
            "B-ARG0",
            "B-ARGM-MOD",
            "B-V",
            "B-ARG1",
            "I-ARG1",
            "O",
            "B-ARGM-TMP",
            "I-ARGM-TMP",
            "I-ARGM-TMP",
            "O"
         ],
         "verb":"beat"
      }
   ],
   "words":[
      "Did",
      "Uriah",
      "honestly",
      "think",
      "he",
      "could",
      "beat",
      "the",
      "game",
      "in",
      "under",
      "three",
      "hours",
      "?"
   ]
}

System:

  • OS: Ubuntu 16.04
  • Python version: Python 3.7.5
  • AllenNLP version: allennlp==1.0.0rc1 allennlp-models==1.0.0rc1
  • PyTorch version: 1.4.0

Activity

  1. iamsusiep commented on Apr 28, 2020

    @iamsusiep

    i'm encountering the same issue as well.

  2. added this to the 1.0.0 milestone on May 1, 2020
  3. epwalsh commented on May 1, 2020

    @epwalsh
    Contributor

    Hi @RanganThaya, sorry for the late response. We're looking into this now.

  4. epwalsh commented on May 1, 2020

    @epwalsh
    Contributor
  5. schmmd commented on May 1, 2020

    @schmmd
    Member

    @iamsusiep apologies but we had the wrong model in the usage on the demo. It should work with the model that @epwalsh posted and we're fixing this in the demo. allenai/allennlp-demo#390

  6. schmmd commented on May 1, 2020

    @schmmd
    Member

    Let us know if you have more problems, but closing this for now!

  7. krasi0 commented on Jun 10, 2020

    @krasi0

    @schmmd
    The last two working versions were AllenNLP version: allennlp==1.0.0rc1 allennlp-models==1.0.0rc1
    Any later versions, e.g. those mentioned in Installing AllenNLP, i.e. allennlp==1.0.0rc5 allennlp-models==1.0.0rc5 lead to the following error:

    >>> import allennlp_models.syntax.srl
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'allennlp_models.syntax'
    
  8. schmmd commented on Jun 10, 2020

    @schmmd
    Member

    @krasi0 I think we reorganized some of those packages. Sorry for the churn. I think you want https://github.com/allenai/allennlp-models/tree/master/allennlp_models/structured_prediction (e.g. import allennlp_models.structured_prediction).

  9. krasi0 commented on Jun 10, 2020

    @krasi0

    @schmmd your suggestion seems to have helped. Thanks!

    I have another question. When I run predictor = Predictor.from_path() for the first time, it downloads Spacy's en_core_web_sm model. How can I make it use en_core_web_md instead? Is there a parameter that I could specify somewhere?

  10. schmmd commented on Jun 10, 2020

    @schmmd
    Member

    @krasi0 in the future please open new issues instead of following up on a closed issue.

    I'm not sure, but my guess is that you would need to write a custom predictor. It looks like it's configurable on SpacyTokenizer.

    > git grep en_core_web_sm                                                   (base) 
    allennlp/data/tokenizers/sentence_splitter.py:    def __init__(self, language: str = "en_core_web_sm", rule_based: bool = False) -> None:
    allennlp/data/tokenizers/spacy_tokenizer.py:    language : `str`, optional, (default=`"en_core_web_sm"`)
    allennlp/data/tokenizers/spacy_tokenizer.py:        language: str = "en_core_web_sm",
    allennlp/predictors/sentence_tagger.py:        self, model: Model, dataset_reader: DatasetReader, language: str = "en_core_web_sm"
    tests/data/dataset_readers/text_classification_json_test.py:        spacy_tokenizer = get_spacy_model("en_core_web_sm", False, False, False)
    tests/data/token_indexers/spacy_indexer_test.py:        nlp = get_spacy_model("en_core_web_sm", pos_tags=True, parse=False, ner=False)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions