tatk.nlu.jointBERT package¶
Subpackages¶
Submodules¶
tatk.nlu.jointBERT.dataloader module¶
-
class
tatk.nlu.jointBERT.dataloader.
Dataloader
(intent_vocab, tag_vocab, pretrained_weights)¶ Bases:
object
-
__init__
(intent_vocab, tag_vocab, pretrained_weights)¶ - Parameters
intent_vocab – list of all intents
tag_vocab – list of all tags
pretrained_weights – which bert, e.g. ‘bert-base-uncased’
-
bert_tokenize
(word_seq, tag_seq)¶
-
get_train_batch
(batch_size)¶
-
load_data
(data, data_key, cut_sen_len, use_bert_tokenizer=True)¶ sample representation: [list of words, list of tags, list of intents, original dialog act] :param data_key: train/val/test :param data: :return:
-
pad_batch
(batch_data)¶
-
seq_id2intent
(ids)¶
-
seq_id2tag
(ids)¶
-
seq_intent2id
(intents)¶
-
seq_tag2id
(tags)¶
-
yield_batches
(batch_size, data_key)¶
-
tatk.nlu.jointBERT.jointBERT module¶
-
class
tatk.nlu.jointBERT.jointBERT.
JointBERT
(model_config, device, slot_dim, intent_dim, intent_weight=None)¶ Bases:
torch.nn.modules.module.Module
-
__init__
(model_config, device, slot_dim, intent_dim, intent_weight=None)¶ Initializes internal Module state, shared by both nn.Module and ScriptModule.
-
forward
(word_seq_tensor, word_mask_tensor, tag_seq_tensor=None, tag_mask_tensor=None, intent_tensor=None, context_seq_tensor=None, context_mask_tensor=None)¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-