Unverified Commit af436f59 authored by Zaida Zhou's avatar Zaida Zhou Committed by GitHub
Browse files

[Feature] Calculate max_out_len without hard code for OpenAI model (#158)



* calulate max_out_len without hard code

* set default value

* update configs

* Update configs/eval_gpt3.5.py
Co-authored-by: default avatarTong Gao <gaotongxiao@gmail.com>

---------
Co-authored-by: default avatarTong Gao <gaotongxiao@gmail.com>
parent 2f1949e7
......@@ -24,7 +24,7 @@ models = [
key='ENV', # The key will be obtained from $OPENAI_API_KEY, but you can write down your key here as well
meta_template=api_meta_template,
query_per_second=1,
max_out_len=2048, max_seq_len=2048, batch_size=8),
max_out_len=2048, max_seq_len=4096, batch_size=8),
]
infer = dict(
......
......@@ -50,8 +50,8 @@ class OpenAI(BaseAPIModel):
is_api: bool = True
def __init__(self,
path: str,
max_seq_len: int = 2048,
path: str = 'gpt-3.5-turbo',
max_seq_len: int = 4096,
query_per_second: int = 1,
retry: int = 2,
key: Union[str, List[str]] = 'ENV',
......@@ -146,7 +146,9 @@ class OpenAI(BaseAPIModel):
messages.append(msg)
# max num token for gpt-3.5-turbo is 4097
max_out_len = min(max_out_len, 4000 - self.get_token_len(str(input)))
max_out_len = min(
max_out_len,
self.max_seq_len - 50 - self.get_token_len(str(input)))
if max_out_len <= 0:
return ''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment