Skip to content

Commit

Permalink
[serving] fix stop token
Browse files Browse the repository at this point in the history
  • Loading branch information
imoneoi committed Aug 3, 2023
1 parent 4f32ca9 commit edaa011
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ochat/serving/openai_api_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ChatCompletionRequest(BaseModel):
top_p: Optional[float] = 1.0
n: Optional[int] = 1
max_tokens: Optional[int] = 768
stop: Optional[Union[str, List[str]]] = Field(default_factory=list)
stop: Optional[Union[str, List[str]]] = None
stream: Optional[bool] = False
presence_penalty: Optional[float] = 0.0
frequency_penalty: Optional[float] = 0.0
Expand Down
2 changes: 1 addition & 1 deletion ochat/serving/openai_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def create_chat_completion(raw_request: Request):
frequency_penalty=request.frequency_penalty,
temperature=request.temperature,
top_p=request.top_p,
stop=[model.eot_token],
stop=request.stop,
max_tokens=request.max_tokens
)
except ValueError as e:
Expand Down

1 comment on commit edaa011

@skepsun
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动反而让网页端无法识别停止词了,比如不修改special_tokens_map.json,那么回复会重复很多次<|end_of_turn|>停不下来,修改了special_tokens_map.json,会在每个回复的末尾加上一个<|end_of_turn|>。
我手动改回去之后一切正常(用本框架训练的模型,未修改special_tokens_map.json)。

Please sign in to comment.