class hanlp.components.ner.biaffine_ner.biaffine_ner_model.BiaffineNamedEntityRecognitionDecoder(hidden_size, ffnn_size, label_space_size, loss_reduction='sum')[source]

An implementation of the biaffine decoder in “Named Entity Recognition as Dependency Parsing” (Yu et al. 2020).

  • hidden_size – Size of hidden states.

  • ffnn_size – Feedforward size for MLPs extracting the head/tail representations.

  • label_space_size – Size of tag set.

  • loss_reduction – The loss reduction used in aggregating losses.

forward(contextualized_embeddings: torch.FloatTensor, batch: Dict[str, torch.Tensor], mask=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.


Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.