crslab.model.crs.redial package¶
Submodules¶
-
class
crslab.model.crs.redial.modules.HRNN(utterance_encoder_hidden_size, dialog_encoder_hidden_size, dialog_encoder_num_layers, pad_token_idx, embedding=None, use_dropout=False, dropout=0.3)[source]¶ Bases:
torch.nn.modules.module.ModuleInitializes internal Module state, shared by both nn.Module and ScriptModule.
-
class
crslab.model.crs.redial.modules.SwitchingDecoder(hidden_size, context_size, num_layers, vocab_size, embedding, pad_token_idx)[source]¶ Bases:
torch.nn.modules.module.ModuleInitializes internal Module state, shared by both nn.Module and ScriptModule.
ReDial_Conv¶
References
Li, Raymond, et al. “Towards deep conversational recommendations.” in NeurIPS.
-
class
crslab.model.crs.redial.redial_conv.ReDialConvModel(opt, device, vocab, side_data)[source]¶ Bases:
crslab.model.base.BaseModel-
vocab_size¶ A integer indicating the vocabulary size.
-
pad_token_idx¶ A integer indicating the id of padding token.
-
start_token_idx¶ A integer indicating the id of start token.
-
end_token_idx¶ A integer indicating the id of end token.
-
unk_token_idx¶ A integer indicating the id of unk token.
-
pretrained_embedding¶ A string indicating the path of pretrained embedding.
-
embedding_dim¶ A integer indicating the dimension of item embedding.
A integer indicating the size of hidden size in utterance encoder.
A integer indicating the size of hidden size in dialog encoder.
-
dialog_encoder_num_layers¶ A integer indicating the number of layers in dialog encoder.
-
use_dropout¶ A boolean indicating if we use the dropout.
-
dropout¶ A float indicating the dropout rate.
A integer indicating the size of hidden size in decoder.
-
decoder_num_layers¶ A integer indicating the number of layer in decoder.
-
decoder_embedding_dim¶ A integer indicating the dimension of embedding in decoder.
- Parameters
opt (dict) – A dictionary record the hyper parameters.
device (torch.device) – A variable indicating which device to place the data and model.
vocab (dict) – A dictionary record the vocabulary information.
side_data (dict) – A dictionary record the side data.
-
forward(batch, mode)[source]¶ - Parameters
batch –
{ 'context': (batch_size, max_context_length, max_utterance_length), 'context_lengths': (batch_size), 'utterance_lengths': (batch_size, max_context_length), 'request': (batch_size, max_utterance_length), 'request_lengths': (batch_size), 'response': (batch_size, max_utterance_length) }
-
ReDial_Rec¶
References
Li, Raymond, et al. “Towards deep conversational recommendations.” in NeurIPS.
-
class
crslab.model.crs.redial.redial_rec.ReDialRecModel(opt, device, vocab, side_data)[source]¶ Bases:
crslab.model.base.BaseModel-
n_entity¶ A integer indicating the number of entities.
-
layer_sizes¶ A integer indicating the size of layer in autorec.
-
pad_entity_idx¶ A integer indicating the id of entity padding.
- Parameters
opt (dict) – A dictionary record the hyper parameters.
device (torch.device) – A variable indicating which device to place the data and model.
vocab (dict) – A dictionary record the vocabulary information.
side_data (dict) – A dictionary record the side data.
-