lm-sys / lm-sys/FastChat

2048 context length limit about qwen-7b-chat

Open
#2,324 9 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

Integrated with langchain, Qwen-7B-Chat model is deployed under FastChat and vLLM, which OpenAI API is employed. When the number of input tokens is more than 2048, it raise

openai.error.APIError: Invalid response object from API: '{"object":"error","message":"This model\'s maximum context length is 2048 tokens. However, you requested 2167 tokens (1655 in the messages, 512 in the completion). Please reduce the length of the messages or completion.","code":40303}' (HTTP response code was 400)

However, it shouldn't happend when use_dynamic_ntk and use_logn_attn is set to true in config.json file of model.

Steps to Reproduce
  1. python3 -m fastchat.serve.controller
  2. python3 -m fastchat.serve.vllm_worker --model-path ** --trust-remote-code --model-names qwen-7b-chat
  3. python3 -m fastchat.serve.openai_api_server --host localhost --port 8000
Packages
  1. vllm==0.1.4
  2. fschat==0.2.24
  3. langchain==0.0.274
  4. openai==0.27.9
Code piece
    from langchain.prompts import PromptTemplate
    from langchain.chat_models import ChatOpenAI
    from langchain.schema import HumanMessage

    openai_api_key = "EMPTY"
    openai_api_base = "http://localhost:8000/v1"
    model_name = "qwen-7b-chat"

    prompt = PromptTemplate(template=template, input_variables=["html_text"])
    model = ChatOpenAI(
        model=model_name, openai_api_key=openai_api_key, openai_api_base=openai_api_base, verbose=True,
        # use_dynamc_ntk=True, use_logn_attn=True, #no effect
        # model_kwargs={'use_dynamc_ntk': True, 'use_logn_attn': True} #no effect
    )
    query = prompt.format_prompt(html_text=html_text).to_string()
    output = model([HumanMessage(content=query)]) # raise the Exception

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

Start with the vLLM worker and OpenAI API server entry points shown in the reproduction, then inspect the Qwen model's config.json handling for use_dynamic_ntk and use_logn_attn. Reproduce the request with more than 2048 input tokens and compare the configured context limit with the API error; done means the reported configuration is honored or its limitation is documented.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.