Tabbit
活动资源博客模型
Tabbit LogoTabbit

Tabbit — 为你工作的 AI 浏览器

主题资源

  • AI Browser Resources
  • Agentic Browser Resources
  • Browser Downloads and Install Guides
  • Browser Comparisons
  • AI Browser Alternatives
  • Browser Productivity Resources

热门指南

  • AI Browser
  • Agentic Browser Download
  • Best AI Browser 2026: Top 9 Tested & Ranked
  • AI Browser Download
  • Free AI Browser
  • Best AI Browser 2026
  • AI Browser Comparison 2026
  • AI Browser for Windows
  • AI Browser for Mac
  • Chrome Alternative 2026

活动

  • 别装了,你在《牛来》里早有原型
  • Tabbit 妙招大赛
  • KPOP SBTI 饭圈人格测试
  • Tabbit 校园共创者计划
  • fifi 的论文文献妙招精选
  • 用户问卷

关于

  • Tabbit 博客
  • 媒体报道
提示词
媒体LongCat Flash Thinking

LongCat-Flash-Thinking-2601:官方聊天模板、工具调用与思维历史配置

原始来源

Hugging Face

作者Meituan LongCat Team / 模型仓库维护者

Tabbit 整理2026-08-19

查看原文

一句话结论

在 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"))

测试/工作流步骤

  1. 注册工具 schema,并把工具列表传给 apply_chat_template。

  2. 发送用户任务;模型返回 reasoning_content 和 tool_calls 时,按调用参数执行真实工具。

  3. 将工具结果作为 role=tool 消息追加,再次调用模板和模型。

  4. 默认用 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,需要完整复盘时再打开。

Tabbit 小编提醒

提示词内容来自公开资料与 Tabbit 编辑整理。引用前请查看原文授权与适用范围。

LongCat Flash Thinking

在 Tabbit 中使用

LongCat Flash Thinking

相关提示词

社区GitHub

LongCat-Flash-Thinking-2601:官方 SGLang/vLLM 部署与 MTP 配置

LongCat Flash Thinking

相关测评

媒体arXiv

LongCat-Flash-Thinking-2601:Heavy Thinking、环境噪声与 Agent 基准

媒体LongCat API Platform2025-09-22

LongCat-Flash-Thinking:API 别名升级、自动路由与服务退役边界

社区Reddit / r/LocalLLaMA

LongCat-Flash-Thinking-2601:LocalLLaMA 社区的初步阅读与部署观察