-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add code to evaluate fine-tuned knowledge extraction model
- Loading branch information
Showing
6 changed files
with
139 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) Microsoft Corporation and Henry Lucco. | ||
# Licensed under the MIT License. | ||
|
||
from chaparral.util.datareader import DataReader | ||
from chaparral.train.hf_model import HFModel | ||
from chaparral.train.hf_params import HFParams | ||
import argparse | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser( | ||
description="Fine-tune a model with given dataset.") | ||
parser.add_argument("--dataset_file", help="Path to the dataset file.") | ||
parser.add_argument("--model_name", help="Name of the model to fine-tune.") | ||
parser.add_argument("--params", help="Path to params file") | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
dataset_file = args.dataset_file | ||
params_file = args.params | ||
|
||
# load params | ||
params = HFParams.from_file(params_file) | ||
|
||
# load dataset | ||
dataset = DataReader().load_text_file(dataset_file) | ||
|
||
# format data into train and eval sets | ||
train_set, eval_set = dataset.create_train_eval_sets() | ||
|
||
model = HFModel(params) | ||
|
||
print("Model loaded") | ||
|
||
model.load_local_model("./test_output") | ||
print(model.evaluate(eval_set)) | ||
print(model.generate(dataset.get_filled_prompt( | ||
"The quick brown fox jumps over the lazy dog"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters