这份详细的部署教程将指引您部署和使用 LongCat-2.0——一个由美团团队开发的大型混合专家(MoE)语言模型,拥有1.6万亿总参数(每次激活约480亿参数)。它在编程、代理任务等场景下表现出色。

LongCat-2.0 是一个模型权重仓库,其主要用途是为开发者提供高性能的AI模型核心,用于集成到自己的应用或工作流中。它不是开箱即用的独立产品,主要部署方式是通过 SGLang 等推理框架进行加载和服务化

📥 部署方式

LongCat-2.0 支持在 GPUNPU 两种硬件平台上部署。

GPU 平台部署

对于 GPU 部署,官方推荐使用 SGLang 推理框架。请参考 SGLang 官方提供的 LongCat-2.0 部署指南 (Cookbook) 获取详细的步骤、配置和脚本。

NPU 平台部署

对于 NPU 部署,请参考 SGLang-FluentLLM 项目,它提供了在 NPU 上运行 SGLang 的适配方案。

🚀 使用方式

部署完成后,你可以通过多种方式使用 LongCat-2.0。

1. 在线体验

最直接的方式是访问官方聊天网站 https://longcat.ai/,与 LongCat-2.0 进行对话,快速了解其能力。

2. 本地推理 (使用 Hugging Face Transformers)

你可以使用 Hugging Face 的 transformers 库加载模型并进行推理。首先,你需要从 Hugging Face 下载模型权重 (仓库名: meituan-longcat/LongCat-2.0)。

重要: 加载时需设置 trust_remote_code=True,因为模型使用了自定义代码。

聊天模板使用示例 (Python):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from transformers import AutoTokenizer

# 加载分词器 (注意 trust_remote_code)
tokenizer = AutoTokenizer.from_pretrained("meituan-longcat/LongCat-2.0", trust_remote_code=True)

# 定义消息和工具 (示例)
tools = [ ... ] # 见下方完整示例
messages = [ ... ] # 见下方完整示例

# 应用聊天模板,开启思考模式
prompt = tokenizer.apply_chat_template(
messages,
tools=tools,
tokenize=False,
enable_thinking=True,
add_generation_prompt=True
)
# 然后将 prompt 输入模型进行生成

详细的 apply_chat_template 示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("meituan-longcat/LongCat-2.0", trust_remote_code=True)

tools = [
{
"type": "function",
"function": {
"name": "func_add",
"description": "Calculate the sum of two numbers",
"parameters": {
"type": "object",
"properties": {
"x1": {"type": "number", "description": "The first number to add"},
"x2": {"type": "number", "description": "The second number to add"},
},
"required": ["x1", "x2"],
},
},
}
]

messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Calculate 1+1"},
{
"role": "assistant",
"reasoning_content": "Calling func_add to calculate 1+1",
"tool_calls": [
{"type": "function", "function": {"name": "func_add", "arguments": {"x1": 1, "x2": 1}}},
],
},
{"role": "tool", "name": "func_add", "content": '{"ans": 2}'},
{"role": "assistant", "reasoning_content": "The result is 2", "content": "2"},
]

# 开启思考模式
prompt_think = tokenizer.apply_chat_template(
messages,
tools=tools,
tokenize=False,
enable_thinking=True,
add_generation_prompt=True
)

🛠️ 集成与工作流

LongCat-2.0 与主流的 AI 代理框架(如 Claude Code, OpenClaw, Hermes)深度集成。你可以将部署好的模型配置为这些工具的后端模型,从而在代码理解、仓库级编辑和自动化任务执行中体验其强大性能。具体集成方法请参考对应工具的文档。

📚 更多资源

  • 技术博客:访问 LongCat Tech Blog 了解模型架构、训练细节和评估结果的深入解读。
  • 许可证:模型权重采用 MIT 许可证 发布,允许广泛使用。
  • 联系:如有疑问,可发送邮件至 longcat-team@meituan.com 或提交 GitHub Issue。

总结:LongCat-2.0 是一个高性能的 MoE 模型。你需要通过 SGLang(GPU)或 SGLang-FluentLLM(NPU)这样的推理框架来部署和提供服务,然后将其集成到你现有的 AI 应用或代理工具中。