LongCat Flash Thinking · configuration
在 LongCat-Flash-Thinking-2601 chat template 中保留思维历史字段,执行一次检索研究问题,并把工具轨迹与结论分开验收。
任务:{{RESEARCH_QUESTION}}
工具 schema:{{REASONING_HISTORY}}
工具返回:{{RETRIEVAL_TOOL_SCHEMA}}
验收:{{TRACE_STOP_RULE}}运行前仍需替换: {{RESEARCH_QUESTION}}, {{REASONING_HISTORY}}, {{RETRIEVAL_TOOL_SCHEMA}}, {{TRACE_STOP_RULE}}
兼容模型 tokenizer 的推理服务;工具 schema、检索结果和 trace 日志均可保存。。
准备研究问题并固定其余输入。
按“LongCat-Flash-Thinking-2601:官方聊天模板、工具调用与思维历史配置”的公开格式发送一次真实请求,保存请求、事件和返回。
对照验收规则判断,不把模型自述当作工具已执行。
得到一条可复查记录,使输入、参数、工具返回和最终回答对齐。
检查响应状态、格式、关键字段与任务结果;保留原始错误。
缩小到单工具、单轮和最小 schema,再逐项恢复字段;服务错误检查 endpoint、权限、模型名和超时。
本指南是 Hugging Face 的公开说明,仅用于该任务试验,不保证其他后端行为。
在 Transformers 本地调用 LongCat-Flash-Thinking-2601 时,应使用仓库提供的 apply_chat_template,显式开启思考并按需传入工具,避免手写特殊 token。
适合的任务:本地 Transformers 推理、多轮深度思考、工具调用和工具结果回填。
不适合的任务:直接套用到未实现该模板的第三方 API;模型卡没有给出通用服务商的字段映射。
适用的模型版本:meituan-longcat/LongCat-Flash-Thinking-2601。
适用的客户端、Agent 或 API:Hugging Face Transformers;模型卡另提到 SGLang/vLLM,但本页代码是 tokenizer/model 本地调用示例。
推荐的推理档位和参数:官方示例使用 enable_thinking=True、add_generation_prompt=True、max_new_tokens=32768;温度未公开固定值,Heavy Thinking 的高温建议只适用于多轨迹探索。
下面保留模型卡的关键调用结构;将 model、tokenizer 替换为本地加载的对象即可。工具声明和消息字段必须保持 OpenAI 风格的 tools、tool_calls、reasoning_content 结构。
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "meituan-longcat/LongCat-Flash-Thinking-2601"
tokenizer = AutoTokenizer.from_pretrained(model_name)
# model = AutoModelForCausalLM.from_pretrained(model_name, ...)
tools = [{
"type": "function",
"function": {
"name": "func_add",
"description": "Calculate the sum of two numbers",
"parameters": {
"type": "object",
"properties": {
"x1": {"type": "number", "description": "The first addend"},
"x2": {"type": "number", "description": "The second addend"}
},
"required": ["x1", "x2"]
}
}
}]
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Please tell me what is 125679 + 234519?"},
{
"role": "assistant",
"reasoning_content": "This calculation requires precision; I will use the func_add tool.",
"tool_calls": [{
"type": "function",
"function": {
"name": "func_add",
"arguments": {"x1": 125679, "x2": 234519}
}
}]
},
{"role": "tool", "name": "func_add", "content": '{"ans": 360198}'}
]
text = tokenizer.apply_chat_template(
messages,
tools=tools,
tokenize=False,
enable_thinking=True,
add_generation_prompt=True,
save_history_reasoning_content=False
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
print(tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n"))注册工具 schema,并把工具列表传给 apply_chat_template。
发送用户任务;模型返回 reasoning_content 和 tool_calls 时,按调用参数执行真实工具。
将工具结果作为 role=tool 消息追加,再次调用模板和模型。
默认用 save_history_reasoning_content=False 丢弃历史思考以节省上下文;需要保留历史思考时改为 True,并单独监测上下文长度。
模型卡直接给出 tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, enable_thinking=True, add_generation_prompt=True, save_history_reasoning_content=False)。
官方工具示例使用 func_add,工具结果为 {"ans": 360198},模型生成上限示例为 max_new_tokens=32768。
模型卡说明:工具声明位于会话开头;默认交错思考模式保留最终回答和工具轨迹,丢弃此前思考内容。
这是 2601 权重的本地模板,不等于任何托管 API 的请求格式;API 网关可能改写 reasoning_content 或工具字段。
560B 总参数模型的显存、并行和量化要求很高;该页面的代码片段没有承诺消费级硬件可运行。
max_new_tokens=32768 是官方示例值,不是所有任务的最优值;长思考会显著增加成本和延迟。
模型卡未公开固定 temperature、top-p 或 Heavy Thinking 的轨迹数,不能从该示例推导一组通用参数。
页面明确把思考历史的保留设为可选:需要节省 token 时关闭 save_history_reasoning_content,需要完整复盘时再打开。
Hugging Face · 原文日期: 未公开 · 编辑日期: 2026-09-20
阅读原始来源LongCat Flash Thinking
请在上方所列环境中运行本指南。下载不会自动传入模板,也不代表账户已开放该模型。