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.featurizers.tracker_featurizers
InvalidStory Objects
Exception that can be raised if story cannot be featurized.
TrackerFeaturizer Objects
Base class for actual tracker featurizers.
__init__
Initializes the tracker featurizer.
Arguments:
state_featurizer
- The state featurizer used to encode tracker states.
training_states_actions_and_entities
Transforms trackers to states, actions, and entity data.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states, actions, and entity data.
training_states_and_actions
Transforms trackers to states and actions.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states and actions.
training_states_and_labels
Transforms trackers to states and labels.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states and labels.
training_states_labels_and_entities
Transforms trackers to states, labels, and entity data.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states, labels, and entity data.
prepare_for_featurization
Ensures that the featurizer is ready to be called during training.
State featurizer needs to build its vocabulary from the domain for it to be ready to be used during training.
Arguments:
domain
- Domain of the assistant.interpreter
- NLU Interpreter for featurizing states.bilou_tagging
- Whether to consider bilou tagging.
featurize_trackers
Featurizes the training trackers.
Arguments:
trackers
- list of training trackersdomain
- the domaininterpreter
- the interpreterbilou_tagging
- indicates whether BILOU tagging should be used or notignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training state features.
Returns:
- a dictionary of state types (INTENT, TEXT, ACTION_NAME, ACTION_TEXT, ENTITIES, SLOTS, ACTIVE_LOOP) to a list of features for all dialogue turns in all training trackers
- the label ids (e.g. action ids) for every dialogue turn in all training trackers
- A dictionary of entity type (ENTITY_TAGS) to a list of features containing entity tag ids for text user inputs otherwise empty dict for all dialogue turns in all training trackers
prediction_states
Transforms trackers to states for prediction.
Arguments:
trackers
- The trackers to transform.domain
- The domain.use_text_for_last_user_input
- Indicates whether to use text or intent label for featurizing last user input.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.ignore_action_unlikely_intent
- Whether to remove states containingaction_unlikely_intent
from prediction states.
Returns:
Trackers as states for prediction.
create_state_features
Creates state features for prediction.
Arguments:
trackers
- A list of state trackersdomain
- The domaininterpreter
- The interpreteruse_text_for_last_user_input
- Indicates whether to use text or intent label for featurizing last user input.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.ignore_action_unlikely_intent
- Whether to remove any states containingaction_unlikely_intent
from state features.
Returns:
Dictionaries of state type (INTENT, TEXT, ACTION_NAME, ACTION_TEXT, ENTITIES, SLOTS, ACTIVE_LOOP) to a list of features for all dialogue turns in all trackers.
persist
Persists the tracker featurizer to the given path.
Arguments:
path
- The path to persist the tracker featurizer to.
load
Loads the featurizer from file.
Arguments:
path
- The path to load the tracker featurizer from.
Returns:
The loaded tracker featurizer.
FullDialogueTrackerFeaturizer Objects
Creates full dialogue training data for time distributed architectures.
Creates training data that uses each time output for prediction.
training_states_labels_and_entities
Transforms trackers to states, action labels, and entity data.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states, action labels, and entity data.
prediction_states
Transforms trackers to states for prediction.
Arguments:
trackers
- The trackers to transform.domain
- The domain.use_text_for_last_user_input
- Indicates whether to use text or intent label for featurizing last user input.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.ignore_action_unlikely_intent
- Whether to remove any states containingaction_unlikely_intent
from prediction states.
Returns:
Trackers as states for prediction.
MaxHistoryTrackerFeaturizer Objects
Truncates the tracker history into max_history
long sequences.
Creates training data from trackers where actions are the output prediction
labels. Tracker state sequences which represent policy input are truncated
to not excede max_history
states.
__init__
Initializes the tracker featurizer.
Arguments:
state_featurizer
- The state featurizer used to encode the states.max_history
- The maximum length of an extracted state sequence.remove_duplicates
- Keep only unique training state sequence/label pairs.
slice_state_history
Slices states from the trackers history.
Arguments:
states
- The statesslice_length
- The slice length
Returns:
The sliced states.
training_states_labels_and_entities
Transforms trackers to states, action labels, and entity data.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states, labels, and entity data.
prediction_states
Transforms trackers to states for prediction.
Arguments:
trackers
- The trackers to transform.domain
- The domain.use_text_for_last_user_input
- Indicates whether to use text or intent label for featurizing last user input.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.ignore_action_unlikely_intent
- Whether to remove any states containingaction_unlikely_intent
from prediction states.
Returns:
Trackers as states for prediction.
IntentMaxHistoryTrackerFeaturizer Objects
Truncates the tracker history into max_history
long sequences.
Creates training data from trackers where intents are the output prediction
labels. Tracker state sequences which represent policy input are truncated
to not excede max_history
states.
training_states_labels_and_entities
Transforms trackers to states, intent labels, and entity data.
Arguments:
trackers
- The trackers to transform.domain
- The domain.omit_unset_slots
- IfTrue
do not include the initial values of slots.ignore_action_unlikely_intent
- Whether to removeaction_unlikely_intent
from training states.
Returns:
Trackers as states, labels, and entity data.
prediction_states
Transforms trackers to states for prediction.
Arguments:
trackers
- The trackers to transform.domain
- The domain.use_text_for_last_user_input
- Indicates whether to use text or intent label for featurizing last user input.ignore_rule_only_turns
- If True ignore dialogue turns that are present only in rules.rule_only_data
- Slots and loops, which only occur in rules but not in stories.ignore_action_unlikely_intent
- Whether to remove any states containingaction_unlikely_intent
from prediction states.
Returns:
Trackers as states for prediction.