kiwi.systems.encoders.predictor
DualSequencesEncoder
Base class for all neural network modules.
PredictorEncoder
Bidirectional Conditional Language Model
kiwi.systems.encoders.predictor.
logger
Bases: torch.nn.Module
torch.nn.Module
Your models should also subclass this class.
Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.
to()
forward
contextualize_b
encode_b
Encode sequence B.
Build a feature vector for each position i using left context i-1 and right context i+1. In the original implementation, this resulted in a returned tensor with -2 timesteps (dim=1). We have now changed it to return the same number of timesteps as the input. The consequence is that callers now have to deal with BOS and EOS in a different way, but hopefully this new behaviour is more consistent and less surprising. The old behaviour can be forced by setting self._use_v0_buggy_strategy to True.
self._use_v0_buggy_strategy
_reverse_padded_seq
Reverse a batch of padded sequences of different length.
_split_hidden
Split hidden state into forward/backward parts.
Bases: kiwi.systems._meta_module.MetaModule
kiwi.systems._meta_module.MetaModule
Implemented after Kim et al 2017, see: http://www.statmt.org/wmt17/pdf/WMT63.pdf
Config
Bases: kiwi.utils.io.BaseConfig
kiwi.utils.io.BaseConfig
Base class for all pydantic configs. Used to configure base behaviour of configs.
hidden_size
Size of hidden layers in LSTM.
rnn_layers
Number of RNN layers in the Predictor.
dropout
share_embeddings
Tie input and output embeddings for target.
out_embeddings_dim
Word Embedding in Output layer.
use_mismatch_features
Whether to use Alibaba’s mismatch features.
embeddings
use_v0_buggy_strategy
The Predictor implementation in Kiwi<=0.3.4 had a bug in applying the LSTM to encode source (it used lengths too short by 2) and in reversing the target embeddings for applying the backward LSTM (also short by 2). This flag is set to true when loading a saved model from those versions.
v0_start_stop
Whether pre_qe_f_v is padded on both ends or post_qe_f_v is strip on both ends.
dropout_on_rnns
no_implementation
input_data_encoders
size
kiwi.systems.encoders.bert
kiwi.systems.encoders.quetch