microsoft/TypeAgent

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a0006c580f8c0a1ca0f18ea15db6e02ce3152e46

Branches

Tags

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

Clone

HTTPS

Download ZIP

python/fineTuning/eval.py

40lines · 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
9
10def parse_args():
11 parser = argparse.ArgumentParser(
12 description="Fine-tune a model with given dataset.")
13 parser.add_argument("--dataset_file", help="Path to the dataset file.")
14 parser.add_argument("--model_name", help="Name of the model to fine-tune.")
15 parser.add_argument("--params", help="Path to params file")
16 return parser.parse_args()
17
18
19if __name__ == "__main__":
20 args = parse_args()
21 dataset_file = args.dataset_file
22 params_file = args.params
23
24 # load params
25 params = HFParams.from_file(params_file)
26
27 # load dataset
28 dataset = DataReader().load_text_file(dataset_file)
29
30 # format data into train and eval sets
31 train_set, eval_set = dataset.create_train_eval_sets()
32
33 model = HFModel(params)
34
35 print("Model loaded")
36
37 model.load_local_model("./test_output")
38 print(model.evaluate(eval_set))
39 print(model.generate(dataset.get_filled_prompt(
40 "The quick brown fox jumps over the lazy dog")))
41