notice
This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
rasa.core.policies.ted_policy
TEDPolicy Objects
Transformer Embedding Dialogue (TED) Policy.
The model architecture is described in detail in https://arxiv.org/abs/1910.00486. In summary, the architecture comprises of the following steps:
__init__
Declares instance variables with default values.
model_class
Gets the class of the model architecture to be used by the policy.
Returns:
Required class.
run_training
Feeds the featurized training data to the model.
Arguments:
model_data
- Featurized training data.label_ids
- Label ids corresponding to the data points inmodel_data
. These may or may not be used by the function depending on how the policy is trained.
train
Trains the policy on given training trackers.
Arguments:
training_trackers
- List of training trackers to be used for training the model.domain
- Domain of the assistant.interpreter
- NLU Interpreter to be used for featurizing the states.**kwargs
- Any other argument.
predict_action_probabilities
Predicts the next action the bot should take after seeing the tracker.
Arguments:
tracker
- the :class:rasa.core.trackers.DialogueStateTracker
domain
- the :class:rasa.shared.core.domain.Domain
interpreter
- Interpreter which may be used by the policies to create additional features.
Returns:
The policy's prediction (e.g. the probabilities for the actions).
persist
Persists the policy to a storage.
persist_model_utilities
Persists model's utility attributes like model weights, etc.
Arguments:
model_path
- Path where model is to be persisted
load
Loads a policy from the storage.
Arguments:
path
- Path on disk where policy is persisted.should_finetune
- Whether to load the policy for finetuning.epoch_override
- Override the number of epochs in persisted configuration for further finetuning.**kwargs
- Any other arguments
Returns:
Loaded policy
Raises:
PolicyModelNotFound
if the model is not found in the supplied path
.
TED Objects
TED model architecture from https://arxiv.org/abs/1910.00486.
__init__
Intializes the TED model.
Arguments:
data_signature
- the data signature of the input dataconfig
- the model configurationmax_history_featurizer_is_used
- if 'True' only the last dialogue turn will be usedlabel_data
- the label dataentity_tag_specs
- the entity tag specifications
batch_loss
Calculates the loss for the given batch.
Arguments:
batch_in
- The batch.
Returns:
The loss of the given batch.
prepare_for_predict
Prepares the model for prediction.
batch_predict
Predicts the output of the given batch.
Arguments:
batch_in
- The batch.
Returns:
The output to predict.