dialogue_manager.dialogue_policy.neural_dialogue_policy¶
Neural dialogue policy built on top of PyTorch.
Module Contents¶
Classes¶
- class dialogue_manager.dialogue_policy.neural_dialogue_policy.NeuralDialoguePolicy(input_size: int, hidden_size: int, output_size: int, possible_actions: List[Any])¶
Bases:
torch.nn.Module- user_label_encoder¶
- agent_label_encoder¶
- abstract forward(state: torch.Tensor) torch.Tensor¶
Forward pass of the policy.
- Parameters:
state – State or batch of states.
- Raises:
NotImplementedError – If the method is not implemented in the subclass.
- Returns:
Output of the policy.
- abstract select_action(state: torch.Tensor) Any¶
Selects an action based on the current state.
- Parameters:
state – The current state.
- Raises:
NotImplementedError – If the method is not implemented in the subclass.
- Returns:
Selected action and optionally other information.
- abstract save_policy(path: str) None¶
Saves the policy.
- Parameters:
path – Path to save the policy.
- Raises:
NotImplementedError – If the method is not implemented in the subclass.
- abstract classmethod load_policy(path: str) NeuralDialoguePolicy¶
Loads the policy.
- Parameters:
path – Path to load the policy from.
- Raises:
NotImplementedError – If the method is not implemented in the subclass.
- Returns:
The loaded policy.
- classmethod build_input_from_dialogue_state(dialogue_state: moviebot.dialogue_manager.dialogue_state.DialogueState, **kwargs) torch.Tensor¶
Builds the input vector from the dialogue state.
The markovian state representation is built from booleans in the dialogue state (e.g., a recommendation was made, the agent should make an offer, we are at the beginning of the conversation). It can be seen as a one-hot encoding of the state.
- Parameters:
dialogue_state – The dialogue state.
- Returns:
Input vector for the policy (i.e., markovian state representation).
- classmethod build_input_from_dialogue_state_and_intents(dialogue_state: moviebot.dialogue_manager.dialogue_state.DialogueState, user_intents: List[moviebot.core.intents.user_intents.UserIntents], agent_intents: List[moviebot.core.intents.agent_intents.AgentIntents], **kwargs) torch.Tensor¶
Builds the input vector from the dialogue state and previous intents.
- Parameters:
dialogue_state – The dialogue state.
user_intents – The user intents.
agent_intents – The agent intents.
- Returns:
The input vector.
- classmethod build_input(dialogue_state: moviebot.dialogue_manager.dialogue_state.DialogueState, **kwargs) torch.Tensor¶
Builds the input vector.
- Parameters:
dialogue_state – The dialogue state.
- Returns:
The input vector.