-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
37 lines (27 loc) · 914 Bytes
/
test.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
from utils import *
import argparse
import warnings
warnings.filterwarnings('ignore')
def test(paragraph, args):
try:
model, tokenizer = load_phi2(args, testing=True)
output = predict_phi2(paragraph=input_txt, model=model, tokenizer=tokenizer, args=args).split('Answer:')[
1].strip()
return output
except Exception as err:
print(f"An Error Occurred - {err}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--text', type=str, help='A required string argument')
user_args = parser.parse_args()
input_txt = user_args.text
if input_txt is None:
print("Invalid Input! Enter Again.")
config_path = "configs/config.json"
args = load_config(config_path)
output = test(input_txt, args)
print("\nText:")
print(input_txt)
print("\n")
print("Entities:")
print(output)