Open EvilCalf opened 2 weeks ago
类似readme里的例子,加在llm cfg的generate_cfg字段:
# Step 2: Configure the LLM you are using.
llm_cfg = {
# Use the model service provided by DashScope:
'model': 'qwen-max',
'model_server': 'dashscope',
# 'api_key': 'YOUR_DASHSCOPE_API_KEY',
# It will use the `DASHSCOPE_API_KEY' environment variable if 'api_key' is not set here.
# Use a model service compatible with the OpenAI API, such as vLLM or Ollama:
# 'model': 'Qwen2-7B-Chat',
# 'model_server': 'http://localhost:8000/v1', # base_url, also known as api_base
# 'api_key': 'EMPTY',
# (Optional) LLM hyperparameters for generation:
'generate_cfg': {
'top_p': 0.8
}
}
比如上面的例子就加入了top_p这个额外生成参数。类似地加个 length_penalty 即可,会传递给openai api、dashscope api。
这样好像不行,我服务是VLLM起的,但是在到openai框架create函数的地方,就不行了,TypeError: Completions.create() got an unexpected keyword argument 'length_penalty',这个貌似是直接给的变量,没有给在额外参数里,openai的也没有这个参数
这样好像不行,我服务是VLLM起的,但是在到openai框架create函数的地方,就不行了,TypeError: Completions.create() got an unexpected keyword argument 'length_penalty',这个貌似是直接给的变量,没有给在额外参数里,openai的也没有这个参数
那可以类似这里的代码 https://github.com/QwenLM/Qwen-Agent/blob/main/qwen_agent/llm/oai.py#L55 将这个额外参数放在 extra_body 里传给vllm
好的,那我必须手动在这个参数list里面加入,对吧
例如length_penalty这些