def main(args): if args.do_eda: from theta.modeling import show_glue_datainfo show_glue_datainfo(glue_labels, train_data_generator, args.train_file, test_data_generator, args.test_file) else: trainer = AppTrainer(args, glue_labels) # --------------- Train --------------- if args.do_train: train_examples = load_train_examples(args.train_file) eval_examples = load_eval_examples(args.eval_file) trainer.train(args, train_examples, eval_examples) # --------------- Evaluate --------------- elif args.do_eval: eval_examples = load_eval_examples(args.eval_file) model = load_model(args) trainer.evaluate(args, model, eval_examples) # --------------- Predict --------------- elif args.do_predict: test_examples = load_test_examples(args) model = load_model(args) trainer.predict(args, model, test_examples) save_predict_results(args, trainer.pred_results, f"./{args.dataset_name}_predict.json", test_examples)
def do_predict(args): args.model_path = args.best_model_path test_examples = load_test_examples(args) model = load_model(args) trainer.predict(args, model, test_examples) reviews_file = save_glue_preds(args, trainer.pred_results, test_examples) return reviews_file
def do_eval(args): args.model_path = args.best_model_path _, eval_examples = load_train_val_examples(args) model = load_model(args) trainer.evaluate(args, model, eval_examples)