-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathA3-B1_bench.py
65 lines (59 loc) · 1.92 KB
/
A3-B1_bench.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
import sys
import os
parent_path = os.path.dirname(sys.path[0])
if parent_path not in sys.path:
sys.path.append(parent_path)
from models.Openai import OpenaiAPI
# from ChatGLM import ChatGLMAPI
from bench_function import get_api_key, export_distribute_json, export_union_json
import json
from moss import MossAPI
import time
if __name__ == "__main__":
# Load the FBQ_prompt.json file
os.environ['HTTPS_PROXY'] = "your proxy"
with open("prompt/A3-4_prompt.json", "r", encoding="utf-8") as f:
data = json.load(f)['examples']
f.close()
# Iterate through the examples in the data
for i in range(len(data)):
directory = "data"
# get the api_key_list
openai_api_key = "your key"
# openai_api_key_list = get_api_key(, start_num=0, end_num=1)
# moss_api_key_list = [""]
model_type = "ChatGLM"
# get the model_name and instantiate model_api
if model_type == "OpenAI":
model_name = 'gpt-3.5-turbo'
# model_name = 'gpt-4'
model_api = OpenaiAPI(openai_api_key, model_name=model_name)
elif model_type == "ChatGLM":
model_name = 'chatglm'
model_api = ChatGLMAPI()
elif model_type == 'Moss':
model_name = 'moss'
# model_api = MossAPI(moss_api_key_list)
keyword = data[i]['keyword']
question_type = data[i]['type']
zero_shot_prompt_text = data[i]['prefix_prompt']
print(keyword)
print(model_name)
print(question_type)
export_distribute_json(
model_api,
model_name,
directory,
keyword,
zero_shot_prompt_text,
question_type,
[],
parallel_num=50,
)
export_union_json(
directory,
model_name,
keyword,
zero_shot_prompt_text,
question_type
)