microsoft/TypeAgent

Public

mirrored from https://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
565a643e9d52b9dcf7934829d2a0f1b78046bd21

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

python/fineTuning/tune.py

38lines · modecode

1# Copyright (c) Microsoft Corporation and Henry Lucco.
2# Licensed under the MIT License.
3
4from chaparral.util.datareader import DataReader
5from chaparral.train.hf_model import HFModel
6from chaparral.train.hf_params import HFParams
7import argparse
8
9def parse_args():
10 parser = argparse.ArgumentParser(description="Fine-tune a model with given dataset.")
11 parser.add_argument("--dataset_file", help="Path to the dataset file.")
12 parser.add_argument("--model_name", help="Name of the model to fine-tune.")
13 parser.add_argument("--params", help="Path to params file")
14 return parser.parse_args()
15
16if __name__ == "__main__":
17 args = parse_args()
18 dataset_file = args.dataset_file
19 params_file = args.params
20
21 # load params
22 params = HFParams.from_file(params_file)
23
24 # load dataset
25 dataset = DataReader().load_text_file(dataset_file)
26
27 # format data into train and eval sets
28 train_set, eval_set = dataset.create_train_eval_sets()
29
30 model = HFModel(params)
31
32 print("Model loaded")
33
34 model.load_training_data(train_set)
35
36 model.load_model()
37
38 model.train()