PlusLabNLP / EventPlus

[NAACL'21 Demo] EventPlus: a temporal event understanding pipeline that integrates various state-of-the-art event understanding components including event trigger and type detection, event argument detection, event duration and temporal relation extraction
https://kairos-event.isi.edu
Apache License 2.0
26 stars 13 forks source link

TempRel inference breaks if no relations returned from construct_relations() #4

Closed lashmore closed 1 year ago

lashmore commented 2 years ago

During inference, if a sentence does not produce probabilities > 0.5 for any candidate event, the TempRelAPI.pred() pipeline breaks.

Specifically if the below line in construct_relations() returns an empty list, the TempRel pipeline breaks at a downstream line

# select event based on prob > 0.5, but eliminate ent_pred > context length
        ent_locs = [[x for x in (ent_probs[b,:, 1] > 0.5).nonzero().view(-1).tolist()
                     if x < lengths[b]] for b in range(batch_size)]

If ent_locs is an empty list, TempRel EventEvaluator.evaluate() call breaks at:

predicted_rels = [self.model._id_to_label[ridx] for ridx in torch.argmax(preds, dim=1).tolist()]

Also, NNClassifier.predict() doesn't like when probs returns as an empty list, either, which it definitely does return as an empty list if the ent_locs in construct_relations is an empty list, as rel_idxs returns as an empty list, etc:

probs = torch.cat(probs,dim=0)
labels = torch.cat(labels,dim=0)