Skip to content

Update deprecated packages & API calls #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api.py
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ def parse_arguments():

parser.add_argument("--max_num_worker", type=int, default=0, help="maximum number of workers for dataloader")
parser.add_argument(
"--model", type=str, default="gpt3-xl", help="model used for decoding. Note that 'gpt3' are the smallest models."
"--model", type=str, default="gpt-3.5-turbo-16k", help="model used for decoding. Note that 'gpt-3.5-turbo' are the smallest models."
)
parser.add_argument(
"--method", type=str, default="auto_cot", choices=["zero_shot", "zero_shot_cot", "few_shot", "few_shot_cot", "auto_cot"], help="method"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sklearn
scikit-learn
matplotlib
sentence-transformers
jupyter
53 changes: 14 additions & 39 deletions utils.py
Original file line number Diff line number Diff line change
@@ -58,47 +58,22 @@ def decoder_for_gpt3(args, input, max_length):
# https://beta.openai.com/account/api-keys
# openai.api_key = "[Your OpenAI API Key]"

# Specify engine ...
# Instruct GPT3
if args.model == "gpt3":
engine = "text-ada-001"
elif args.model == "gpt3-medium":
engine = "text-babbage-001"
elif args.model == "gpt3-large":
engine = "text-curie-001"
elif args.model == "gpt3-xl":
engine = "text-davinci-002"
elif args.model == "text-davinci-001":
engine = "text-davinci-001"
elif args.model == "code-davinci-002":
engine = "code-davinci-002"
else:
raise ValueError("model is not properly defined ...")

if ("few_shot" in args.method or "auto" in args.method) and engine == "code-davinci-002":
response = openai.Completion.create(
engine=engine,
prompt=input,
max_tokens=max_length,
temperature=args.temperature,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=["\n"]
)
else:
response = openai.Completion.create(
engine=engine,
prompt=input,
max_tokens=max_length,
temperature=args.temperature,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None
)
response = openai.chat.completions.create(
model=args.model,
messages=[{
"role": "user",
"content": input
}],
max_tokens=max_length,
temperature=args.temperature,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None
)

return response["choices"][0]["text"]
return response.choices[0].message.content

class Decoder():
def __init__(self):