Response selector using supervised embeddings.
The response selector embeds user inputs and candidate response into the same space. Supervised embeddings are trained by maximizing similarity between them. It also provides rankings of the response that did not "win".
The supervised response selector needs to be preceded by
a featurizer in the pipeline.
This featurizer creates the features used for the embeddings.
It is recommended to use
can be optionally preceded by
Based on the starspace idea from: https://arxiv.org/abs/1709.03856.
However, in this implementation the
mu parameter is treated differently
and additional hidden layers are added together with dropout.
Components that should be included in the pipeline before this component.
The component's default config (see parent class for full docstring).
Declare instance variables with default values.
config- Configuration for the component.
model_storage- Storage which graph components can use to persist and load themselves.
resource- Resource locator for this component which can be used to persist and load itself from the
execution_context- Information about the current graph run.
index_label_id_mapping- Mapping between label and index used for encoding.
entity_tag_specs- Format specification all entity tags.
model- Model architecture.
all_retrieval_intents- All retrieval intents defined in the data.
responses- All responses defined in the data.
model_storage0 - If
model_storage1 loads the model with pre-trained weights, otherwise initializes it with random weights.
model_storage2 - Sizes of the sparse features the model was trained on.
Returns label key.
Returns label sub_key.
Returns model class.
Prepares data for training.
Performs sanity checks on training data, extracts encodings for labels.
training_data- training data to preprocessed.
Selects most like response for message.
messages- List containing latest user message.
List containing the message augmented with the most likely response, the associated intent_response_key and its similarity to the input.
Persist this model into the passed directory.
Loads the trained model from the provided directory.
DIET2BOW transformer implementation.
Diet 2 Diet transformer implementation.
Calculates the loss for the given batch.
batch_in- The batch.
The loss of the given batch.
Predicts the output of the given batch.
batch_in- The batch.
The output to predict.