kiwi.systems.encoders.xlmroberta
XLMRobertaTextEncoder
Encode a field, handling vocabulary, tokenization and embeddings.
XLMRobertaEncoder
XLM-RoBERTa model, using HuggingFace’s implementation.
kiwi.systems.encoders.xlmroberta.
logger
Bases: kiwi.data.encoders.field_encoders.TextEncoder
kiwi.data.encoders.field_encoders.TextEncoder
Heavily inspired in torchtext and torchnlp.
fit_vocab
Bases: kiwi.systems._meta_module.MetaModule
kiwi.systems._meta_module.MetaModule
Config
Bases: kiwi.utils.io.BaseConfig
kiwi.utils.io.BaseConfig
Base class for all pydantic configs. Used to configure base behaviour of configs.
model_name
Pre-trained XLMRoberta model to use.
interleave_input
Concatenate SOURCE and TARGET without internal padding (111222000 instead of 111002220)
use_mlp
Apply a linear layer on top of XLMRoberta.
hidden_size
Size of the linear layer on top of XLMRoberta.
pooling
Type of pooling used to extract features from the encoder. Options are: first_token: CLS_token is used for sentence representation mean: Use avg pooling for sentence representation using scalar mixed layers ll_mean: Mean pool of only last layer embeddings mixed: Concat CLS token with mean_pool
scalar_mix_dropout
scalar_mix_layer_norm
freeze
Freeze XLMRoberta during training.
freeze_for_number_of_steps
Freeze XLMR during training for this number of steps.
fix_relative_path
load_state_dict
Copies parameters and buffers from state_dict into this module and its descendants. If strict is True, then the keys of state_dict must exactly match the keys returned by this module’s state_dict() function.
state_dict
strict
True
state_dict()
state_dict (dict) – a dict containing parameters and persistent buffers.
strict (bool, optional) – whether to strictly enforce that the keys in state_dict match the keys returned by this module’s state_dict() function. Default: True
missing_keys is a list of str containing the missing keys
unexpected_keys is a list of str containing the unexpected keys
NamedTuple with missing_keys and unexpected_keys fields
NamedTuple
missing_keys
unexpected_keys
input_data_encoders
size
_check_freezing
forward
concat_input
Concatenate tensors of two batches into one tensor.
and concatenation of attention_mask.
split_outputs
Split contexts to get tag_side outputs.
features (tensor) – XLMRoberta output: <s> target </s> </s> source </s> Shape of (bs, 1 + target_len + 2 + source_len + 1, 2)
batch_inputs –
interleaved (bool) – whether the concat strategy was ‘interleaved’.
dict of tensors, one per tag side.
Interleave the source + target embeddings into one tensor.
This means making the input as [batch, target [SEP] source].
and concatenation of attention_mask
get_mismatch_features
kiwi.systems.encoders.xlm
kiwi.systems.outputs