Skip to content

DeepSeek模型多轮对话时reasoning_content字 段处理不当导致评测失败 #1392

Description

@JerryZ01

自查清单

问题描述

在使用 evalscope 对 DeepSeek
模型进行多轮对话评测时(如 bfcl_v3
multi_turn),遇到两种 API 报错:

错误 1:reasoning_content 字段问题
The reasoning_content in the thinking mode must
be passed back to the API.

错误 2:content 格式问题
Failed to deserialize the JSON body into the
target type: messages[x].content: missing field
text

根本原因是 evalscope 将 DeepSeek 模型返回的
reasoning_content 字段转换为 <think>
标签嵌入到 content
字符串中,而不是作为独立字段传递。这导致:

  1. 严格遵循 DeepSeek 官方 API 规范的服务商要求
    reasoning_content 作为独立字段传回
  2. 部分服务商对 content
    字段格式有严格要求,不接受嵌入标签的格式

EvalScope 版本(必填)

v0.x.x(最新版)

使用的工具

  • Native / 原生框架

执行的代码或指令

evalscope eval \
  --model DeepSeek-V4-Pro \
  --api-url <API_URL> \
  --api-key <API_KEY> \
  --datasets bfcl_v3 \
  --limit 10 \
  --dataset-args '{"bfcl_v3": {"subset_list":   
["multi_turn_base"]}}' \
  --eval-batch-size 3 \
  --stream \
  --generation-config '{"temperature": 0,       
"max_tokens": 4096}'

错误日志

错误 1:
openai.BadRequestError: Error code: 400 -       
{'error': {'message': 'The `reasoning_content`  
in the thinking mode must be passed back to the 
API.', 'type': 'invalid_request_error'}}        

错误 2:
openai.BadRequestError: Error code: 400 -       
{'error': {'message': 'Failed to deserialize the   JSON body into the target type:
messages[7].content: missing field `text`',     
'type': 'invalid_request_error'}}

根本原因分析

1. DeepSeek 模型返回 reasoning_content
字段(思考过程)
2. evalscope 将其转换为 <think> 标签嵌入      
content(位于 evalscope/models/utils/openai.py  
的 openai_assistant_content 函数)
3.
多轮对话时,ChatCompletionAssistantMessageParam 
只传递 content,没有 reasoning_content 字段     
4. 严格遵循规范的 API 要求:
  - reasoning_content 作为独立字段传回
  - content 字段必须包含 text
字段,不接受嵌入标签的格式

建议解决方案

方案 1(推荐):正确传递 reasoning_content 字段 

# 多轮请求应该包含:
{
    "role": "assistant",
    "content": "实际回复内容",
    "reasoning_content": "思考过程内容"  #      
独立字段
}

方案 2:支持关闭 thinking 模式

--generation-config '{"extra_body": {"thinking":   {"type": "disabled"}}}'

注:方案 2 可绕过错误 1,但仍可能遇到错误       
2(content 格式问题)

运行环境

- 操作系统:Linux
- Python版本:3.10

其他信息

临时解决方案:添加 --generation-config 
'{"extra_body": {"thinking": {"type": 
"disabled"}}}' 参数可禁用 thinking 模式,绕过   
reasoning_content 问题,但部分服务商仍有 content   格式兼容性问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions