-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_evaluation.py
139 lines (132 loc) · 4.23 KB
/
run_evaluation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2024 NVIDIA CORPORATION & AFFILIATES
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
from datetime import datetime
import pathlib
from fv_eval import evaluation, utils
ROOT = pathlib.Path(__file__).parent
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Run JG-based Evaluation of FVEval-SVAGen Results"
)
parser.add_argument(
"--llm_output_dir",
"-i",
type=str,
help="path to LLM results dir",
)
parser.add_argument(
"--model_name",
"-m",
type=str,
help="specific model name to evaluate for",
default="",
)
parser.add_argument(
"--save_dir",
"-o",
type=str,
help="path to save JG eval results",
)
parser.add_argument(
"--temp_dir",
"-t",
type=str,
help="path to temp dir",
)
parser.add_argument(
"--cleanup_temp",
type=bool,
help="Whether to clean up the temp dir afterwards",
default=True,
)
parser.add_argument(
"--task",
type=str,
help="task you are evaluating for",
default="nl2sva_human",
)
parser.add_argument(
"--nparallel",
"-n",
type=int,
help="parallel JG jobs",
default=8,
)
parser.add_argument(
"--debug",
action="store_true",
help="debug ",
)
args = parser.parse_args()
if not args.llm_output_dir:
utils.print_error(
"Argument Error",
"empty path to llm_output_dir. Provide correct args to --llm_output_dir",
)
raise ValueError("empty path to llm_output_dir")
if not args.save_dir:
save_dir = pathlib.Path(args.llm_output_dir) / "eval"
else:
save_dir = args.save_dir
save_dir = save_dir.as_posix()
if not args.temp_dir:
datetime_str = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
tmp_dir = ROOT.as_posix() + f"/tmp_{args.task}/{args.model_name}_{datetime_str}"
else:
tmp_dir = args.temp_dir
if "nl2sva" in args.task:
if "human" in args.task:
evaluator = evaluation.NL2SVAHumanEvaluator(
llm_output_dir=args.llm_output_dir,
model_name=args.model_name,
temp_dir=tmp_dir,
save_dir=save_dir,
cleanup_temp_files=args.cleanup_temp,
parallel_jobs=args.nparallel,
debug=args.debug,
)
evaluator.run_evaluation()
elif "machine" in args.task:
evaluator = evaluation.NL2SVAMachineEvaluator(
llm_output_dir=args.llm_output_dir,
model_name=args.model_name,
temp_dir=tmp_dir,
save_dir=save_dir,
cleanup_temp_files=args.cleanup_temp,
parallel_jobs=args.nparallel,
debug=args.debug,
)
evaluator.run_evaluation()
elif "design2sva" in args.task:
evaluator = evaluation.Design2SVAEvaluator(
llm_output_dir=args.llm_output_dir,
model_name=args.model_name,
temp_dir=tmp_dir,
save_dir=save_dir,
cleanup_temp_files=args.cleanup_temp,
parallel_jobs=args.nparallel,
debug=args.debug,
)
evaluator.run_evaluation()
# elif "helpergen" in args.task:
# evaluator = evaluation.HelperGenEvaluator(
# llm_output_dir=args.llm_output_dir,
# temp_dir=tmp_dir,
# save_dir=save_dir,
# cleanup_temp_files=args.cleanup_temp,
# parallel_jobs=args.nparallel,
# debug=args.debug,
# )
# evaluator.run_evaluation()