lm-sys / lm-sys/FastChat

When using the FastChat OpenAI API to deploy the Qwen-7B-Chat model with stop configuration, if the custom stop_word is not triggered, the model will not stop promptly until it reaches the max_tokens limit.

Open
#2,282 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.5k
Forks
4.8k
PR merge metrics
No merged PRs in 30d

Description

Bug Description

When using the FastChat OpenAI API to deploy the Qwen-7B-Chat model with stop configuration, if the custom stop_word is not triggered, the model will not stop promptly until it reaches the max_tokens limit.

Steps to Reproduce
  1. python -m fastchat.serve.controller
  2. python -m fastchat.serve.model_worker --model-path Qwen-7B-Chat --model-name gpt-3.5-turbo,text-davinci-003,text-embedding-ada-002
  3. python -m fastchat.serve.openai_api_server
  4. POST /worker_generate_stream
Screenshots/Recordings

image

  • The yellow highlight represents the output I expected, but it didn't stop promptly as desired.

Additional Information

After investigation, I found that FastChat/blob/main/fastchat/serve/openai_api_server.py#L278 , When I add a stop, the default stop will not be configured_ Token_ Ids, this will only cause llm to stop_ Stop after Word appears. In theory, llm should also be stopped at the end of the answer, which is to say, stop_ Token_ Automatically stop when the token corresponding to ids appears.

At present, I have two ways to solve this situation, but I am not sure if it will have an impact on other LLMs

  1. https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/inference.py#L185 Set skip_special_tokens=False and add “<|im_end|>” to stop_word
  2. https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/openai_api_server.py#L278 When there is a stop, also update "stop_token_ids": conv.stop_token_ids

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the listed controller, model_worker, and openai_api_server commands, then inspect fastchat/serve/openai_api_server.py around line 278 and fastchat/serve/inference.py around line 185. Compare custom stop handling with conv.stop_token_ids and skip_special_tokens behavior for Qwen-7B-Chat and other LLMs. Done means generation stops at the model's answer-ending token when the custom stop word is absent without breaking other models.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.