Skip to content

KeyError in Predicting End-to-End relations file #17

@Laxmaan

Description

@Laxmaan

I'm running the prediction script and I'm getting a "metadata" KeyError as shown below

Traceback (most recent call last):  
  File "scirex/predictors/predict_n_ary_relations.py", line 109, in <module>
    predict(argv[1], argv[2], argv[3], argv[4], int(argv[5]))
  File "scirex/predictors/predict_n_ary_relations.py", line 77, in predict  
    output_res = model.decode_relations(batch)   
  File ".../SciREX/scirex/models/scirex_model.py", line 385, in decode_relations   
    res["n_ary_relation"] = self._cluster_n_ary_relation.decode(output_n_ary_relation)  
  File ".../SciREX/scirex/models/relations/entity_relation.py", line 211, in decode  
    "metadata" : output_dict['metadata']  
KeyError: 'metadata'

I went up to the decode function in entity_relation.py, where I replaced output_dict['metadata'] with output_dict.get('metadata',[]) For the batches that do not have any spans.

That led to this error occuring:

Traceback (most recent call last):
  File "scirex/predictors/predict_n_ary_relations.py", line 109, in <module>
    predict(argv[1], argv[2], argv[3], argv[4], int(argv[5]))
  File "scirex/predictors/predict_n_ary_relations.py", line 82, in predict
    metadata = output_res['n_ary_relation']['metadata'][0]
IndexError: list index out of range

Returning a default value of [] did not seem to do the trick. How can I fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions