def read_arguments(): args_ = argparse.ArgumentParser(description='Sovling GraphParser') args_.add_argument('--dataset', choices=['ontonotes', 'ud'], help='Dataset', required=True) args_.add_argument('--domain', help='domain/language', required=True) args_.add_argument('--rnn_mode', choices=['RNN', 'LSTM', 'GRU'], help='architecture of rnn', required=True) args_.add_argument('--gating', action='store_true', help='use gated mechanism') args_.add_argument('--num_gates', type=int, default=0, help='number of gates for gating mechanism') args_.add_argument('--num_epochs', type=int, default=200, help='Number of training epochs') args_.add_argument('--batch_size', type=int, default=64, help='Number of sentences in each batch') args_.add_argument('--hidden_size', type=int, default=256, help='Number of hidden units in RNN') args_.add_argument('--arc_space', type=int, default=128, help='Dimension of tag space') args_.add_argument('--arc_tag_space', type=int, default=128, help='Dimension of tag space') args_.add_argument('--num_layers', type=int, default=1, help='Number of layers of RNN') args_.add_argument('--num_filters', type=int, default=50, help='Number of filters in CNN') args_.add_argument('--kernel_size', type=int, default=3, help='Size of Kernel for CNN') args_.add_argument('--use_pos', action='store_true', help='use part-of-speech embedding.') args_.add_argument('--use_char', action='store_true', help='use character embedding and CNN.') args_.add_argument('--word_dim', type=int, default=300, help='Dimension of word embeddings') args_.add_argument('--pos_dim', type=int, default=50, help='Dimension of POS embeddings') args_.add_argument('--char_dim', type=int, default=50, help='Dimension of Character embeddings') args_.add_argument('--initializer', choices=['xavier'], help='initialize model parameters') args_.add_argument('--opt', choices=['adam', 'sgd'], help='optimization algorithm') args_.add_argument('--momentum', type=float, default=0.9, help='momentum of optimizer') args_.add_argument('--betas', nargs=2, type=float, default=[0.9, 0.9], help='betas of optimizer') args_.add_argument('--learning_rate', type=float, default=0.01, help='Learning rate') args_.add_argument('--decay_rate', type=float, default=0.05, help='Decay rate of learning rate') args_.add_argument('--schedule', type=int, help='schedule for learning rate decay') args_.add_argument('--clip', type=float, default=5.0, help='gradient clipping') args_.add_argument('--gamma', type=float, default=0.0, help='weight for regularization') args_.add_argument('--epsilon', type=float, default=1e-8, help='epsilon for adam') args_.add_argument('--p_rnn', nargs=2, type=float, required=True, help='dropout rate for RNN') args_.add_argument('--p_in', type=float, default=0.33, help='dropout rate for input embeddings') args_.add_argument('--p_out', type=float, default=0.33, help='dropout rate for output layer') args_.add_argument('--arc_decode', choices=['mst', 'greedy'], help='arc decoding algorithm', required=True) args_.add_argument('--unk_replace', type=float, default=0., help='The rate to replace a singleton word with UNK') args_.add_argument('--punct_set', nargs='+', type=str, help='List of punctuations') args_.add_argument('--word_embedding', choices=['random', 'glove', 'fasttext', 'word2vec'], help='Embedding for words') args_.add_argument( '--word_path', help= 'path for word embedding dict - in case word_embedding is not random') args_.add_argument('--freeze_word_embeddings', action='store_true', help='frozen the word embedding (disable fine-tuning).') args_.add_argument('--freeze_sequence_taggers', action='store_true', help='frozen the BiLSTMs of the pre-trained taggers.') args_.add_argument('--char_embedding', choices=['random'], help='Embedding for characters', required=True) args_.add_argument('--char_path', help='path for character embedding dict') args_.add_argument( '--set_num_training_samples', type=int, help='downsampling training set to a fixed number of samples') args_.add_argument('--model_path', help='path for saving model file.', required=True) args_.add_argument('--load_path', help='path for loading saved source model file.', default=None) args_.add_argument( '--load_sequence_taggers_paths', nargs='+', help='path for loading saved sequence_tagger saved_models files.', default=None) args_.add_argument('--strict', action='store_true', help='if True loaded model state should contin ' 'exactly the same keys as current model') args_.add_argument('--eval_mode', action='store_true', help='evaluating model without training it') args = args_.parse_args() args_dict = {} args_dict['dataset'] = args.dataset args_dict['domain'] = args.domain args_dict['rnn_mode'] = args.rnn_mode args_dict['gating'] = args.gating args_dict['num_gates'] = args.num_gates args_dict['arc_decode'] = args.arc_decode args_dict['splits'] = ['train', 'dev', 'test'] args_dict['model_path'] = args.model_path if not path.exists(args_dict['model_path']): makedirs(args_dict['model_path']) args_dict['data_paths'] = {} if args_dict['dataset'] == 'ontonotes': data_path = 'data/onto_pos_ner_dp' else: data_path = 'data/ud_pos_ner_dp' for split in args_dict['splits']: args_dict['data_paths'][ split] = data_path + '_' + split + '_' + args_dict['domain'] args_dict['alphabet_data_paths'] = {} for split in args_dict['splits']: if args_dict['dataset'] == 'ontonotes': args_dict['alphabet_data_paths'][ split] = data_path + '_' + split + '_' + 'all' else: if '_' in args_dict['domain']: args_dict['alphabet_data_paths'][ split] = data_path + '_' + split + '_' + args_dict[ 'domain'].split('_')[0] else: args_dict['alphabet_data_paths'][split] = args_dict[ 'data_paths'][split] args_dict['model_name'] = 'domain_' + args_dict['domain'] args_dict['full_model_name'] = path.join(args_dict['model_path'], args_dict['model_name']) args_dict['load_path'] = args.load_path args_dict['load_sequence_taggers_paths'] = args.load_sequence_taggers_paths if args_dict['load_sequence_taggers_paths'] is not None: args_dict['gating'] = True args_dict['num_gates'] = len( args_dict['load_sequence_taggers_paths']) + 1 else: if not args_dict['gating']: args_dict['num_gates'] = 0 args_dict['strict'] = args.strict args_dict['num_epochs'] = args.num_epochs args_dict['batch_size'] = args.batch_size args_dict['hidden_size'] = args.hidden_size args_dict['arc_space'] = args.arc_space args_dict['arc_tag_space'] = args.arc_tag_space args_dict['num_layers'] = args.num_layers args_dict['num_filters'] = args.num_filters args_dict['kernel_size'] = args.kernel_size args_dict['learning_rate'] = args.learning_rate args_dict[ 'initializer'] = nn.init.xavier_uniform_ if args.initializer == 'xavier' else None args_dict['opt'] = args.opt args_dict['momentum'] = args.momentum args_dict['betas'] = tuple(args.betas) args_dict['epsilon'] = args.epsilon args_dict['decay_rate'] = args.decay_rate args_dict['clip'] = args.clip args_dict['gamma'] = args.gamma args_dict['schedule'] = args.schedule args_dict['p_rnn'] = tuple(args.p_rnn) args_dict['p_in'] = args.p_in args_dict['p_out'] = args.p_out args_dict['unk_replace'] = args.unk_replace args_dict['set_num_training_samples'] = args.set_num_training_samples args_dict['punct_set'] = None if args.punct_set is not None: args_dict['punct_set'] = set(args.punct_set) logger.info( "punctuations(%d): %s" % (len(args_dict['punct_set']), ' '.join(args_dict['punct_set']))) args_dict['freeze_word_embeddings'] = args.freeze_word_embeddings args_dict['freeze_sequence_taggers'] = args.freeze_sequence_taggers args_dict['word_embedding'] = args.word_embedding args_dict['word_path'] = args.word_path args_dict['use_char'] = args.use_char args_dict['char_embedding'] = args.char_embedding args_dict['char_path'] = args.char_path args_dict['use_pos'] = args.use_pos args_dict['pos_dim'] = args.pos_dim args_dict['word_dict'] = None args_dict['word_dim'] = args.word_dim if args_dict['word_embedding'] != 'random' and args_dict['word_path']: args_dict['word_dict'], args_dict[ 'word_dim'] = load_word_embeddings.load_embedding_dict( args_dict['word_embedding'], args_dict['word_path']) args_dict['char_dict'] = None args_dict['char_dim'] = args.char_dim if args_dict['char_embedding'] != 'random': args_dict['char_dict'], args_dict[ 'char_dim'] = load_word_embeddings.load_embedding_dict( args_dict['char_embedding'], args_dict['char_path']) args_dict['pos_dict'] = None args_dict['alphabet_path'] = path.join( args_dict['model_path'], 'alphabets' + '_src_domain_' + args_dict['domain'] + '/') args_dict['model_name'] = path.join(args_dict['model_path'], args_dict['model_name']) args_dict['eval_mode'] = args.eval_mode args_dict['device'] = torch.device( 'cuda' if torch.cuda.is_available() else 'cpu') args_dict[ 'word_status'] = 'frozen' if args.freeze_word_embeddings else 'fine tune' args_dict['char_status'] = 'enabled' if args.use_char else 'disabled' args_dict['pos_status'] = 'enabled' if args.use_pos else 'disabled' logger.info("Saving arguments to file") save_args(args, args_dict['full_model_name']) logger.info("Creating Alphabets") alphabet_dict = creating_alphabets(args_dict['alphabet_path'], args_dict['alphabet_data_paths'], args_dict['word_dict']) args_dict = {**args_dict, **alphabet_dict} ARGS = namedtuple('ARGS', args_dict.keys()) my_args = ARGS(**args_dict) return my_args
def read_arguments(): args_ = argparse.ArgumentParser(description='Sovling SequenceTagger') args_.add_argument('--dataset', choices=['ontonotes', 'ud'], help='Dataset', required=True) args_.add_argument('--domain', help='domain', required=True) args_.add_argument('--rnn_mode', choices=['RNN', 'LSTM', 'GRU'], help='architecture of rnn', required=True) args_.add_argument('--task', default='distance_from_the_root', choices=['distance_from_the_root', 'number_of_children',\ 'relative_pos_based', 'language_model','add_label','add_head_coarse_pos','Multitask_POS_predict','Multitask_case_predict',\ 'Multitask_label_predict','Multitask_coarse_predict','MRL_Person','MRL_Gender','MRL_case','MRL_POS','MRL_no','MRL_label',\ 'predict_coarse_of_modifier','predict_ma_tag_of_modifier','add_head_ma','predict_case_of_modifier'], help='sequence_tagger task') args_.add_argument('--num_epochs', type=int, default=200, help='Number of training epochs') args_.add_argument('--batch_size', type=int, default=64, help='Number of sentences in each batch') args_.add_argument('--hidden_size', type=int, default=256, help='Number of hidden units in RNN') args_.add_argument('--tag_space', type=int, default=128, help='Dimension of tag space') args_.add_argument('--num_layers', type=int, default=1, help='Number of layers of RNN') args_.add_argument('--num_filters', type=int, default=50, help='Number of filters in CNN') args_.add_argument('--kernel_size', type=int, default=3, help='Size of Kernel for CNN') args_.add_argument('--use_pos', action='store_true', help='use part-of-speech embedding.') args_.add_argument('--use_char', action='store_true', help='use character embedding and CNN.') args_.add_argument('--word_dim', type=int, default=300, help='Dimension of word embeddings') args_.add_argument('--pos_dim', type=int, default=50, help='Dimension of POS embeddings') args_.add_argument('--char_dim', type=int, default=50, help='Dimension of Character embeddings') args_.add_argument('--initializer', choices=['xavier'], help='initialize model parameters') args_.add_argument('--opt', choices=['adam', 'sgd'], help='optimization algorithm') args_.add_argument('--momentum', type=float, default=0.9, help='momentum of optimizer') args_.add_argument('--betas', nargs=2, type=float, default=[0.9, 0.9], help='betas of optimizer') args_.add_argument('--learning_rate', type=float, default=0.01, help='Learning rate') args_.add_argument('--decay_rate', type=float, default=0.05, help='Decay rate of learning rate') args_.add_argument('--schedule', type=int, help='schedule for learning rate decay') args_.add_argument('--clip', type=float, default=5.0, help='gradient clipping') args_.add_argument('--gamma', type=float, default=0.0, help='weight for regularization') args_.add_argument('--epsilon', type=float, default=1e-8, help='epsilon for adam') args_.add_argument('--p_rnn', nargs=2, type=float, required=True, help='dropout rate for RNN') args_.add_argument('--p_in', type=float, default=0.33, help='dropout rate for input embeddings') args_.add_argument('--p_out', type=float, default=0.33, help='dropout rate for output layer') args_.add_argument('--unk_replace', type=float, default=0., help='The rate to replace a singleton word with UNK') args_.add_argument('--punct_set', nargs='+', type=str, help='List of punctuations') args_.add_argument('--word_embedding', choices=['random', 'glove', 'fasttext', 'word2vec'], help='Embedding for words') args_.add_argument( '--word_path', help= 'path for word embedding dict - in case word_embedding is not random') args_.add_argument('--freeze_word_embeddings', action='store_true', help='frozen the word embedding (disable fine-tuning).') args_.add_argument('--char_embedding', choices=['random', 'hellwig'], help='Embedding for characters', required=True) args_.add_argument('--pos_embedding', choices=['random', 'one_hot'], help='Embedding for pos', required=True) args_.add_argument('--char_path', help='path for character embedding dict') args_.add_argument('--pos_path', help='path for pos embedding dict') args_.add_argument('--use_unlabeled_data', action='store_true', help='flag to use unlabeled data.') args_.add_argument('--use_labeled_data', action='store_true', help='flag to use labeled data.') args_.add_argument('--model_path', help='path for saving model file.', required=True) args_.add_argument('--parser_path', help='path for loading parser files.', default=None) args_.add_argument('--load_path', help='path for loading saved source model file.', default=None) args_.add_argument('--strict', action='store_true', help='if True loaded model state should contain ' 'exactly the same keys as current model') args_.add_argument('--eval_mode', action='store_true', help='evaluating model without training it') args = args_.parse_args() args_dict = {} args_dict['dataset'] = args.dataset args_dict['domain'] = args.domain args_dict['task'] = args.task args_dict['rnn_mode'] = args.rnn_mode args_dict['load_path'] = args.load_path args_dict['strict'] = args.strict args_dict['model_path'] = args.model_path if not path.exists(args_dict['model_path']): makedirs(args_dict['model_path']) args_dict['parser_path'] = args.parser_path args_dict['model_name'] = 'domain_' + args_dict['domain'] args_dict['full_model_name'] = path.join(args_dict['model_path'], args_dict['model_name']) args_dict['use_unlabeled_data'] = args.use_unlabeled_data args_dict['use_labeled_data'] = args.use_labeled_data print(args_dict['parser_path']) if args_dict['task'] == 'number_of_children': args_dict['data_paths'] = write_extra_labels.add_number_of_children( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'distance_from_the_root': args_dict[ 'data_paths'] = write_extra_labels.add_distance_from_the_root( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'Multitask_label_predict': args_dict['data_paths'] = write_extra_labels.Multitask_label_predict( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'Multitask_coarse_predict': args_dict['data_paths'] = write_extra_labels.Multitask_coarse_predict( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'Multitask_POS_predict': args_dict['data_paths'] = write_extra_labels.Multitask_POS_predict( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'relative_pos_based': args_dict['data_paths'] = write_extra_labels.add_relative_pos_based( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'add_label': args_dict['data_paths'] = write_extra_labels.add_label( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'add_relative_TAG': args_dict['data_paths'] = write_extra_labels.add_relative_TAG( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'add_head_coarse_pos': args_dict['data_paths'] = write_extra_labels.add_head_coarse_pos( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'predict_ma_tag_of_modifier': args_dict[ 'data_paths'] = write_extra_labels.predict_ma_tag_of_modifier( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'Multitask_case_predict': args_dict['data_paths'] = write_extra_labels.Multitask_case_predict( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'predict_coarse_of_modifier': args_dict[ 'data_paths'] = write_extra_labels.predict_coarse_of_modifier( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'predict_case_of_modifier': args_dict['data_paths'] = write_extra_labels.predict_case_of_modifier( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'add_head_ma': args_dict['data_paths'] = write_extra_labels.add_head_ma( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_case': args_dict['data_paths'] = write_extra_labels.MRL_case( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_POS': args_dict['data_paths'] = write_extra_labels.MRL_POS( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_no': args_dict['data_paths'] = write_extra_labels.MRL_no( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_label': args_dict['data_paths'] = write_extra_labels.MRL_label( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_Person': args_dict['data_paths'] = write_extra_labels.MRL_Person( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) elif args_dict['task'] == 'MRL_Gender': args_dict['data_paths'] = write_extra_labels.MRL_Gender( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) else: #args_dict['task'] == 'language_model': args_dict['data_paths'] = write_extra_labels.add_language_model( args_dict['model_path'], args_dict['parser_path'], args_dict['domain'], args_dict['domain'], use_unlabeled_data=args_dict['use_unlabeled_data'], use_labeled_data=args_dict['use_labeled_data']) args_dict['splits'] = args_dict['data_paths'].keys() alphabet_data_paths = deepcopy(args_dict['data_paths']) if args_dict['dataset'] == 'ontonotes': data_path = 'data/onto_pos_ner_dp' else: data_path = 'data/ud_pos_ner_dp' # Adding more resources to make sure equal alphabet size for all domains for split in args_dict['splits']: if args_dict['dataset'] == 'ontonotes': alphabet_data_paths['additional_' + split] = data_path + '_' + split + '_' + 'all' else: if '_' in args_dict['domain']: alphabet_data_paths[ split] = data_path + '_' + split + '_' + args_dict[ 'domain'].split('_')[0] else: alphabet_data_paths[split] = args_dict['data_paths'][split] args_dict['alphabet_data_paths'] = alphabet_data_paths args_dict['num_epochs'] = args.num_epochs args_dict['batch_size'] = args.batch_size args_dict['hidden_size'] = args.hidden_size args_dict['tag_space'] = args.tag_space args_dict['num_layers'] = args.num_layers args_dict['num_filters'] = args.num_filters args_dict['kernel_size'] = args.kernel_size args_dict['learning_rate'] = args.learning_rate args_dict[ 'initializer'] = nn.init.xavier_uniform_ if args.initializer == 'xavier' else None args_dict['opt'] = args.opt args_dict['momentum'] = args.momentum args_dict['betas'] = tuple(args.betas) args_dict['epsilon'] = args.epsilon args_dict['decay_rate'] = args.decay_rate args_dict['clip'] = args.clip args_dict['gamma'] = args.gamma args_dict['schedule'] = args.schedule args_dict['p_rnn'] = tuple(args.p_rnn) args_dict['p_in'] = args.p_in args_dict['p_out'] = args.p_out args_dict['unk_replace'] = args.unk_replace args_dict['punct_set'] = None if args.punct_set is not None: args_dict['punct_set'] = set(args.punct_set) logger.info( "punctuations(%d): %s" % (len(args_dict['punct_set']), ' '.join(args_dict['punct_set']))) args_dict['freeze_word_embeddings'] = args.freeze_word_embeddings args_dict['word_embedding'] = args.word_embedding args_dict['word_path'] = args.word_path args_dict['use_char'] = args.use_char args_dict['char_embedding'] = args.char_embedding args_dict['pos_embedding'] = args.pos_embedding args_dict['char_path'] = args.char_path args_dict['pos_path'] = args.pos_path args_dict['use_pos'] = args.use_pos args_dict['pos_dim'] = args.pos_dim args_dict['word_dict'] = None args_dict['word_dim'] = args.word_dim if args_dict['word_embedding'] != 'random' and args_dict['word_path']: args_dict['word_dict'], args_dict[ 'word_dim'] = load_word_embeddings.load_embedding_dict( args_dict['word_embedding'], args_dict['word_path']) args_dict['char_dict'] = None args_dict['char_dim'] = args.char_dim if args_dict['char_embedding'] != 'random': args_dict['char_dict'], args_dict[ 'char_dim'] = load_word_embeddings.load_embedding_dict( args_dict['char_embedding'], args_dict['char_path']) args_dict['pos_dict'] = None if args_dict['pos_embedding'] != 'random': args_dict['pos_dict'], args_dict[ 'pos_dim'] = load_word_embeddings.load_embedding_dict( args_dict['pos_embedding'], args_dict['pos_path']) args_dict['alphabet_path'] = path.join( args_dict['model_path'], 'alphabets' + '_src_domain_' + args_dict['domain'] + '/') args_dict['alphabet_parser_path'] = path.join( args_dict['parser_path'], 'alphabets' + '_src_domain_' + args_dict['domain'] + '/') args_dict['model_name'] = path.join(args_dict['model_path'], args_dict['model_name']) args_dict['eval_mode'] = args.eval_mode args_dict['device'] = torch.device( 'cuda' if torch.cuda.is_available() else 'cpu') args_dict[ 'word_status'] = 'frozen' if args.freeze_word_embeddings else 'fine tune' args_dict['char_status'] = 'enabled' if args.use_char else 'disabled' args_dict['pos_status'] = 'enabled' if args.use_pos else 'disabled' logger.info("Saving arguments to file") save_args(args, args_dict['full_model_name']) logger.info("Creating Alphabets") alphabet_dict = creating_alphabets(args_dict['alphabet_path'], args_dict['alphabet_parser_path'], args_dict['alphabet_data_paths']) args_dict = {**args_dict, **alphabet_dict} ARGS = namedtuple('ARGS', args_dict.keys()) my_args = ARGS(**args_dict) return my_args