-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathopenai.sh
executable file
·109 lines (98 loc) · 2.66 KB
/
openai.sh
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
#!/usr/bin/env bash
set -e
debug=false
source keys.sh
num_keys=${#keys[@]}
dataset=$1
config_file=$2
config_filename=$(basename -- "${config_file}")
config_filename="${config_filename%.*}"
debug_batch_size=1
batch_size=8
model=text-davinci-003
temperature=0
output=output/${dataset}/${model}/${config_filename}.jsonl
echo 'output to:' $output
prompt_type=""
if [[ ${dataset} == '2wikihop' ]]; then
input="--input data/2wikimultihopqa"
engine=elasticsearch
index_name=wikipedia_dpr
fewshot=8
max_num_examples=500
max_generation_len=256
elif [[ ${dataset} == 'strategyqa' ]]; then
input="--input data/strategyqa/dev_beir"
engine=elasticsearch
index_name=wikipedia_dpr
fewshot=6
max_num_examples=229
max_generation_len=256
elif [[ ${dataset} == 'asqa' ]]; then
prompt_type="--prompt_type general_hint_in_output"
input="--input data/asqa/ASQA.json"
engine=elasticsearch
index_name=wikipedia_dpr
fewshot=8
max_num_examples=500
max_generation_len=256
elif [[ ${dataset} == 'asqa_hint' ]]; then
prompt_type="--prompt_type general_hint_in_input"
dataset=asqa
input="--input data/asqa/ASQA.json"
engine=elasticsearch
index_name=wikipedia_dpr
fewshot=8
max_num_examples=500
max_generation_len=256
elif [[ ${dataset} == 'wikiasp' ]]; then
input="--input data/wikiasp"
engine=bing
index_name=wikiasp
fewshot=4
max_num_examples=500
max_generation_len=512
else
exit
fi
# query api
if [[ ${debug} == "true" ]]; then
python -m src.openai_api \
--model ${model} \
--dataset ${dataset} ${input} ${prompt_type} \
--config_file ${config_file} \
--fewshot ${fewshot} \
--search_engine ${engine} \
--index_name ${index_name} \
--max_num_examples 100 \
--max_generation_len ${max_generation_len} \
--batch_size ${debug_batch_size} \
--output test.jsonl \
--num_shards 1 \
--shard_id 0 \
--openai_keys ${test_key} \
--debug
exit
fi
function join_by {
local d=${1-} f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
joined_keys=$(join_by " " "${keys[@]:0:${num_keys}}")
python -m src.openai_api \
--model ${model} \
--dataset ${dataset} ${input} ${prompt_type} \
--config_file ${config_file} \
--fewshot ${fewshot} \
--search_engine ${engine} \
--index_name ${index_name} \
--max_num_examples ${max_num_examples} \
--max_generation_len ${max_generation_len} \
--temperature ${temperature} \
--batch_size ${batch_size} \
--output ${output} \
--num_shards 1 \
--shard_id 0 \
--openai_keys ${joined_keys} \