lavis-nlp / spert

PyTorch code for SpERT: Span-based Entity and Relation Transformer
MIT License
692 stars 147 forks source link

A little puzzle #16

Closed DragonAndSky closed 4 years ago

DragonAndSky commented 4 years ago

I have a question, where can I get the entity_mask if I predict the relationship between entities from an unmarked sentence

markus-eberts commented 4 years ago

Hi, the term 'entity_mask' in our code is a bit misleading. Better read it as 'entity candidate masks'. During training, this tensor contains masks for all annotated entities and a set of random spans not labelled as an entity as negative samples. During evaluation, where we don't know the entities, 'entity_masks' contains the masks for all spans up to a predefined length (10 in our paper). So when you want to predict entities/relations for an unmarked sentence, you can use the 'create_eval_sample' function in 'sampling.py' to get the necessary tensors for spans up to a specific size, including 'entity_masks'.

DragonAndSky commented 4 years ago

Thanks, i understanded.