deeppavlov.models.go_bot¶
-
class
deeppavlov.models.go_bot.bot.
GoalOrientedBot
(tokenizer: deeppavlov.core.models.component.Component, tracker: deeppavlov.models.go_bot.tracker.Tracker, network_parameters: Dict[str, Any], template_path: str, template_type: str = 'DefaultTemplate', word_vocab: deeppavlov.core.models.component.Component = None, bow_embedder: deeppavlov.core.models.component.Component = None, embedder: deeppavlov.core.models.component.Component = None, slot_filler: deeppavlov.core.models.component.Component = None, intent_classifier: deeppavlov.core.models.component.Component = None, database: deeppavlov.core.models.component.Component = None, api_call_action: str = None, use_action_mask: bool = False, debug: bool = False, load_path: str = None, save_path: str = None, **kwargs)[source]¶ The dialogue bot is based on https://arxiv.org/abs/1702.03274, which introduces Hybrid Code Networks that combine an RNN with domain-specific knowledge and system action templates.
Parameters: - tokenizer – one of tokenizers from deeppavlov.models.tokenizers module.
- tracker – dialogue state tracker from deeppavlov.models.go_bot.tracker.
- network_parameters – initialization parameters for policy network (see
GoalOrientedBotNetwork
). - template_path – file with mapping between actions and text templates for response generation.
- template_type – type of used response templates in string format.
- word_vocab – vocabulary of input word tokens
(
DefaultVocabulary
recommended). - bow_embedder – instance of one-hot word encoder
BoWEmbedder
. - embedder – one of embedders from deeppavlov.models.embedders module.
- slot_filler – component that outputs slot values for a given utterance
(
DstcSlotFillingNetwork
recommended). - intent_classifier – component that outputs intents probability distribution
for a given utterance (
KerasClassificationModel
recommended). - database – database that will be used during inference to perform
api_call_action
actions and get'db_result'
result (Sqlite3Database
recommended). - api_call_action – label of the action that corresponds to database api call
(it must be present in your
template_path
file), during interaction it will be used to get'db_result'
fromdatabase
. - use_action_mask – if
True
, network output will be applied with a mask over allowed actions. - debug – whether to display debug output.
-
class
deeppavlov.models.go_bot.network.
GoalOrientedBotNetwork
(hidden_size: int, action_size: int, obs_size: int, learning_rate: float, end_learning_rate: float = None, decay_steps: int = 1000, decay_power: float = 1.0, dropout_rate: float = 0.0, l2_reg_coef: float = 0.0, dense_size: int = None, optimizer: str = 'AdamOptimizer', attention_mechanism: Dict = None, **kwargs)[source]¶ The
GoalOrientedBotNetwork
is a recurrent network that handles dialogue policy management. Inputs features of an utterance and predicts label of a bot action (classification task).An LSTM with a dense layer for input features and a dense layer for it’s output. Softmax is used as an output activation function.
Parameters: - hidden_size – size of rnn hidden layer.
- action_size – size of rnn output (equals to number of bot actions).
- obs_size – input features’ size (must be equal to sum of output sizes of
bow_embedder
,embedder
,intent_classifier
,tracker.num_features
plus size of context features(=6) andaction_size
). - learning_rate – learning rate during training.
- end_learning_rate – if set, learning rate starts from
learning rate
value and decays polynomially to the value ofend_learning_rate
. - decay_steps – number of steps for learning rate to decay.
- decay_power – power used to calculate learning rate decay for polynomial strategy.
- dropout_rate – probability of weights dropping out.
- l2_reg_coef – l2 regularization weight (applied to input and output layer).
- dense_size – rnn input size.
- optimizer – one of tf.train.Optimizer subclasses as a string.
- attention_mechanism –
describes attention applied to embeddings of input tokens.
- type – type of attention mechanism, possible values are
'general'
,'bahdanau'
,'light_general'
,'light_bahdanau'
,'cs_general'
and'cs_bahdanau'
. - hidden_size – attention hidden state size.
- max_num_tokens – maximum number of input tokens.
- depth – number of averages used in constrained attentions
(
'cs_bahdanau'
or'cs_general'
). - action_as_key – whether to use action from previous timestep as key to attention.
- intent_as_key – use utterance intents as attention key or not.
- projected_align – whether to use output projection.
- type – type of attention mechanism, possible values are
-
class
deeppavlov.models.go_bot.tracker.
Tracker
[source]¶ An abstract class for trackers: a model that holds a dialogue state and generates state features.
-
class
deeppavlov.models.go_bot.tracker.
DefaultTracker
(slot_names: List[str])[source]¶ Tracker that overwrites slots with new values. Features are binary indicators: slot is present/absent.
Parameters: slot_names – list of slots that should be tracked.
-
class
deeppavlov.models.go_bot.tracker.
FeaturizedTracker
(slot_names: List[str])[source]¶ Tracker that overwrites slots with new values. Features are binary features (slot is present/absent) plus difference features (slot value is (the same)/(not the same) as before last update) and count features (sum of present slots and sum of changed during last update slots).
Parameters: slot_names – list of slots that should be tracked.