diff --git a/.gitignore b/.gitignore index 712b099b..d50d1667 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,31 @@ # Byte-compiled / optimized / DLL files __pycache__/ +models/__pycache__/ *.py[cod] *$py.class # added manually .data .embeddings -__pycache__/ -models/__pycache__/ -multiprocess/__pycache__/ results/ -tests/embeddings/* local_files local_scripts/* dataset/* generated/* +*events.out.tfevents* .DS_Store .idea/ .vscode/ models/.DS_Store -multiprocess/.DS_Store -text/.DS_Store src/ workdir/ *save*/ lightning_logs/ pytorch_model.bin +*.pth +tests/embeddings/* tests/dataset-* tests/dataset/* tests/database/* diff --git a/genienlp/arguments.py b/genienlp/arguments.py index 1562b6e5..94a1ba3d 100644 --- a/genienlp/arguments.py +++ b/genienlp/arguments.py @@ -77,21 +77,21 @@ def parse_argv(parser): 'If sentence_batching is used, this will be interpreted as number of examples.') parser.add_argument('--jump_start', default=0, type=int, help='number of iterations to give jump started tasks') parser.add_argument('--n_jump_start', default=0, type=int, help='how many tasks to jump start (presented in order)') - parser.add_argument('--num_print', default=15, type=int, + parser.add_argument('--num_print', default=10, type=int, help='how many validation examples with greedy output to print to std out') parser.add_argument('--no_tensorboard', action='store_false', dest='tensorboard', help='Turn off tensorboard logging') parser.add_argument('--tensorboard_dir', default=None, help='Directory where to save Tensorboard logs (defaults to --save)') - parser.add_argument('--max_to_keep', default=5, type=int, help='number of checkpoints to keep') - parser.add_argument('--log_every', default=int(1e2), type=int, help='how often to log results in # of iterations') - parser.add_argument('--save_every', default=int(1e3), type=int, + parser.add_argument('--max_to_keep', default=3, type=int, help='number of checkpoints to keep') + parser.add_argument('--log_every', default=100, type=int, help='how often to log results in # of iterations') + parser.add_argument('--save_every', default=1000, type=int, help='how often to save a checkpoint in # of iterations') parser.add_argument('--val_tasks', nargs='+', type=str, dest='val_task_names', help='tasks to collect evaluation metrics for') - parser.add_argument('--val_every', default=int(1e3), type=int, + parser.add_argument('--val_every', default=1000, type=int, help='how often to run validation in # of iterations') parser.add_argument('--val_batch_size', nargs='+', default=[3000], type=int, help='Number of tokens in each batch for validation, corresponding to tasks in --val_tasks') diff --git a/genienlp/data_utils/example.py b/genienlp/data_utils/example.py index 862a603a..16b0921d 100644 --- a/genienlp/data_utils/example.py +++ b/genienlp/data_utils/example.py @@ -49,8 +49,6 @@ class Example(NamedTuple): answer: str context_plus_question: List[str] - vocab_fields = ['context', 'question', 'answer'] - @staticmethod def from_raw(example_id: str, context: str, question: str, answer: str, preprocess = identity, lower=False): args = [example_id] diff --git a/genienlp/models/mqan_decoder.py b/genienlp/models/mqan_decoder.py index d7c50283..75c78571 100644 --- a/genienlp/models/mqan_decoder.py +++ b/genienlp/models/mqan_decoder.py @@ -68,8 +68,8 @@ class MQANDecoder(nn.Module): def forward(self, batch, final_context, context_rnn_state, encoder_loss, current_token_id=None, decoder_wrapper=None, expansion_factor=1, generation_dict=None): - context, context_lengths, context_limited = batch.context.value, batch.context.length, batch.context.limited - answer, answer_lengths, answer_limited = batch.answer.value, batch.answer.length, batch.answer.limited + context, context_limited = batch.context.value, batch.context.limited + answer, answer_limited = batch.answer.value, batch.answer.limited decoder_vocab = self.numericalizer.decoder_vocab self.map_to_full = decoder_vocab.decode context_padding = context.data == self.pad_idx diff --git a/genienlp/train.py b/genienlp/train.py index ef9a967a..fb1ec971 100644 --- a/genienlp/train.py +++ b/genienlp/train.py @@ -138,7 +138,6 @@ def train_step(model, batch, iteration, opt, devices, lr_scheduler=None, grad_cl for p in model.parameters(): if p.grad is None: continue - # print('p.grad = ', p.grad) p.grad /= accumulated_batch_lengths accumulated_batch_lengths = 0 if grad_clip > 0.0: @@ -367,8 +366,7 @@ def train(args, devices, model, opt, lr_scheduler, train_sets, train_iterations, grad_clip=args.grad_clip, gradient_accumulation_steps=args.gradient_accumulation_steps) if loss is None: - logger.info( - 'Encountered NAN loss during training... Continue training ignoring the current batch') + logger.info('Encountered NAN loss during training... Continue training ignoring the current batch') continue if loss < 1e-6: zero_loss += 1 diff --git a/genienlp/util.py b/genienlp/util.py index e64bb77d..540cfe70 100644 --- a/genienlp/util.py +++ b/genienlp/util.py @@ -435,19 +435,6 @@ def make_data_loader(dataset, numericalizer, batch_size, device=None, train=Fals return data_loader -def pad(x, new_channel, dim, val=None): - if x.size(dim) > new_channel: - x = x.narrow(dim, 0, new_channel) - channels = x.size() - assert (new_channel >= channels[dim]) - if new_channel == channels[dim]: - return x - size = list(channels) - size[dim] = new_channel - size[dim] - padding = x.new(*size).fill_(val) - return torch.cat([x, padding], dim) - - def have_multilingual(task_names): return any(['multilingual' in name for name in task_names])