# biome.text.backbone Module

# ModelBackbone Class


class ModelBackbone (
    vocab: allennlp.data.vocabulary.Vocabulary,
    featurizer: InputFeaturizer,
    embedder: allennlp.modules.text_field_embedders.text_field_embedder.TextFieldEmbedder,
    encoder: Union[Seq2SeqEncoderConfiguration, NoneType] = None,
)

The backbone of the model.

It is composed of a tokenizer, featurizer and an encoder. This component of the model can be pretrained and used with different task heads.

Attributes

vocab
The vocabulary of the pipeline
featurizer
Defines the input features of the tokens and indexes
embedder
The embedding layer
encoder
Outputs an encoded sequence of the tokens

Initializes internal Module state, shared by both nn.Module and ScriptModule.

# Ancestors

  • torch.nn.modules.module.Module

# forward Method


def forward (
  self,
  text: Dict[str, Dict[str, torch.Tensor]],
  mask: torch.Tensor,
  num_wrapping_dims: int = 0,
)  -> torch.Tensor

Applies the embedding and encoding layer

Parameters

text
Output of the batch.as_tensor_dict() method, basically the indices of the indexed tokens
mask
A mask indicating which one of the tokens are padding tokens
num_wrapping_dims
0 if text is the output of a TextField, 1 if it is the output of a ListField

Returns

tensor
Encoded representation of the input

# on_vocab_update Method


def on_vocab_update(self)

This method is called when a base model updates the vocabulary

Maintained by