"git@developer.sourcefind.cn:OpenDAS/fastmoe.git" did not exist on "c6b06f76bca1cda1cbce92d303c1855bd4224085"
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 = [ ...@@ -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 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, meta_template=api_meta_template,
query_per_second=1, 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( infer = dict(
......
...@@ -50,8 +50,8 @@ class OpenAI(BaseAPIModel): ...@@ -50,8 +50,8 @@ class OpenAI(BaseAPIModel):
is_api: bool = True is_api: bool = True
def __init__(self, def __init__(self,
path: str, path: str = 'gpt-3.5-turbo',
max_seq_len: int = 2048, max_seq_len: int = 4096,
query_per_second: int = 1, query_per_second: int = 1,
retry: int = 2, retry: int = 2,
key: Union[str, List[str]] = 'ENV', key: Union[str, List[str]] = 'ENV',
...@@ -146,7 +146,9 @@ class OpenAI(BaseAPIModel): ...@@ -146,7 +146,9 @@ class OpenAI(BaseAPIModel):
messages.append(msg) messages.append(msg)
# max num token for gpt-3.5-turbo is 4097 # 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: if max_out_len <= 0:
return '' 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