notice

This is unreleased documentation for Rasa Open Source Documentation Master/Unreleased version.
For the latest released documentation, see the latest version (2.0.x).

Version: Master/Unreleased

rasa.core.policies.policy

SupportedData Objects

class SupportedData(Enum)

Enumeration of a policy's supported training data type.

trackers_for_policy

| @staticmethod
| trackers_for_policy(policy: Union["Policy", Type["Policy"]], trackers: Union[List[DialogueStateTracker], List[TrackerWithCachedStates]]) -> Union[List[DialogueStateTracker], List[TrackerWithCachedStates]]

Return trackers for a given policy.

Arguments:

  • policy - Policy or policy type to return trackers for.
  • trackers - Trackers to split.

Returns:

Trackers from ML-based training data and/or rule-based data.

Policy Objects

class Policy()

supported_data

| @staticmethod
| supported_data() -> SupportedData

The type of data supported by this policy.

By default, this is only ML-based training data. If policies support rule data, or both ML-based data and rule data, they need to override this method.

Returns:

The data type supported by this policy (ML-based training data).

featurize_for_training

| featurize_for_training(training_trackers: List[DialogueStateTracker], domain: Domain, interpreter: NaturalLanguageInterpreter, **kwargs: Any, ,) -> Tuple[List[List[Dict[Text, List["Features"]]]], np.ndarray]

Transform training trackers into a vector representation.

The trackers, consisting of multiple turns, will be transformed into a float vector which can be used by a ML model.

Arguments:

training_trackers: the list of the :class:rasa.core.trackers.DialogueStateTracker

  • domain - the :class:rasa.shared.core.domain.Domain
  • interpreter - the :class:rasa.core.interpreter.NaturalLanguageInterpreter

Returns:

  • a dictionary of attribute (INTENT, TEXT, ACTION_NAME, ACTION_TEXT, ENTITIES, SLOTS, FORM) 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

train

| train(training_trackers: List[TrackerWithCachedStates], domain: Domain, interpreter: NaturalLanguageInterpreter, **kwargs: Any, ,) -> None

Trains the policy on given training trackers.

Arguments:

training_trackers: the list of the :class:rasa.core.trackers.DialogueStateTracker

  • domain - the :class:rasa.shared.core.domain.Domain
  • interpreter - Interpreter which can be used by the polices for featurization.

predict_action_probabilities

| predict_action_probabilities(tracker: DialogueStateTracker, domain: Domain, interpreter: NaturalLanguageInterpreter, **kwargs: Any, ,) -> List[float]

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 list of probabilities for the next actions

persist

| persist(path: Union[Text, Path]) -> None

Persists the policy to storage.

Arguments:

  • path - Path to persist policy to.

load

| @classmethod
| load(cls, path: Union[Text, Path]) -> "Policy"

Loads a policy from path.

Arguments:

  • path - Path to load policy from.

Returns:

An instance of Policy.

confidence_scores_for

confidence_scores_for(action_name: Text, value: float, domain: Domain) -> List[float]

Returns confidence scores if a single action is predicted.

Arguments:

  • action_name - the name of the action for which the score should be set
  • value - the confidence for action_name
  • domain - the :class:rasa.shared.core.domain.Domain

Returns:

the list of the length of the number of actions