moonshotai/Kimi-K2.7-Code · Hugging Face

Reddit r/LocalLLaMA 模型

摘要

Moonshot AI 发布了 Kimi K2.7 Code,这是一个专注于编码和智能体任务的 1T 参数混合专家模型,具有改进的 token 效率,并在与 GPT-5.5 和 Claude Opus 4.8 的对比中取得了强劲的基准测试结果。

Kimi K2.7 Code 是一款基于 Kimi K2.6 构建的、专注于编码的智能体模型。在实际的长周期编码任务上取得了显著改进,它增强了跨复杂软件工程工作流的端到端任务完成能力,同时提高了 token 效率,与 Kimi K2.6 相比,思考 token 的使用量减少了约 30%。
查看原文
查看缓存全文

缓存时间: 2026/06/12 10:56

moonshotai/Kimi-K2.7-Code · Hugging Face

来源:https://huggingface.co/moonshotai/Kimi-K2.7-Code Kimi K2.7 Code


聊天 (https://www.kimi.com/code) 主页 (https://www.moonshot.ai/)

Hugging Face (https://huggingface.co/moonshotai) Twitter关注 (https://twitter.com/kimi_moonshot) Discord (https://discord.gg/TYU2fdJykW) ModelScope (https://modelscope.cn/organization/moonshotai)

许可证 (https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/LICENSE)

1. 模型介绍

Kimi K2.7 Code 是一个专注于编码的智能体模型,基于 Kimi K2.6 构建。它在真实的长期编码任务上进行了大幅改进,增强了跨复杂软件工程工作流的端到端任务完成能力,同时提升了 token 效率,与 Kimi K2.6 相比,思维 token 使用量减少了约 30%。

2. 模型摘要

架构 混合专家模型 (MoE)
总参数量 1T
激活参数量 32B
层数 (包含稠密层) 61
稠密层数 1
注意力隐藏维度 7168
MoE 隐藏维度 (每个专家) 2048
注意力头数 64
专家数量 384
每个 token 选择的专家数 8
共享专家数量 1
词表大小 160K
上下文长度 256K
注意力机制 MLA
激活函数 SwiGLU
视觉编码器 MoonViT
视觉编码器参数量 400M

3. 评估结果

基准测试Kimi K2.6Kimi K2.7 CodeGPT-5.5Claude Opus 4.8
编码
Kimi Code Bench v250.9662.0669.0667.4
Program Bench48.353.669.163.8
MLS Bench Lite26.735.135.542.8
智能体
Kimi Claw 24/7 Bench42.946.952.850.4
MCP Atlas69.476.079.481.3
MCP Mark Verified72.881.192.976.4

脚注

  1. 通用测试细节

    • 除非另有说明,Kimi K2.7 Code 和 K2.6 均通过 Kimi Code CLI 启用思维模式进行测试,温度为 1.0,top-p 为 0.95,上下文长度为 262,144 token;GPT-5.5 在 Codex 中以 xhigh 模式运行,Opus 4.8 在 Claude Code 中以 xhigh 模式运行。除这些差异外,所有基准测试均在相同条件下评估。
  2. 编码基准测试

    • Kimi Code Bench V2 是我们内部的基准测试,旨在评估编码智能体在现实任务中的表现。它包含 10 多种主流编程语言以及完整生产技术栈的多样化软件工程任务,涵盖内部工程用例、生产事故和真实世界开源项目,重点领域包括后端服务、基础设施、性能工程、系统编程、安全、前端开发以及机器学习/数据工程。
    • Program Bench (https://programbench.com/) 评估代码生成智能体,要求其仅根据编译后的二进制文件及其文档重现程序行为。它包含 200 个任务,从小的命令行工具到大型系统(如 FFmpeg 和 SQLite)。提交结果根据超过 248,000 个模糊生成的 behavioral tests 进行评判。在每个任务中,智能体会获得一个可执行文件及其文档,但没有源代码、反编译内容或网络访问权限。它必须自行选择实现语言,从头构建整个程序,并通过 behavioral test suite,将其输出与原始二进制文件进行比较。
    • MLS-Bench (https://mls-bench.com/) 评估 AI 系统能否发明可泛化、可扩展的机器学习方法。MLS-Bench-Lite 是 MLS-Bench 的官方 30 任务子集,涵盖 LLM 预训练和后训练、机器人学、世界模型、计算机视觉、强化学习、优化、机器学习系统、AI for Science 等。智能体有 5 小时探索时间,然后提交解决方案。Opus 4.8 在 Claude Code 中采用最大努力设置进行评估。
  3. 智能体基准测试

    • Kimi Claw 24/7 Bench 是我们内部的基准测试,用于评估在持久、多日协作任务中的长期智能体性能。它涵盖 17 个专业场景,共 610 个评估点,涉及软件工程、机器学习研究、招聘、交易、营销等领域。所有任务均通过 OpenClaw harness 执行。最终分数是所有评估点的平均通过率,并基于 3 次运行取平均。
    • MCP-Atlas (https://labs.scale.com/leaderboard/mcp_atlas) 通过可扩展的 MCP 评估 LLM 在现实工具使用任务中的表现。我们遵循官方 MCP-Atlas 评估配置,工具调用预算为 100 次,每步最大 token 数为 32k。最终结果是 3 次运行的平均值。
    • MCPMark-Verified 是 MCPMark (https://mcpmark.ai/) 的人工验证版本,这是一个评估 MCP 工具使用的基准测试,涵盖五个真实服务器环境:Notion、GitHub、Filesystem、Postgres 和 Playwright。每个任务已由我们团队和基准测试官方重新检查,并将在不久后开源。我们遵循官方 MCPMark 评估配置,工具调用预算为 100 步,每步最大 token 数为 32k。最终结果是 3 次运行的平均值。

4. 原生 INT4 量化

Kimi-K2.7-Code 采用与 Kimi-K2-Thinking (https://huggingface.co/moonshotai/Kimi-K2-Thinking#4-native-int4-quantization) 相同的原生 int4 量化方法。

5. 部署

您可以通过 https://platform.moonshot.ai/ 访问 Kimi-K2.7-Code 的 API,我们提供兼容 OpenAI/Anthropic 的 API。目前,推荐在以下推理引擎上运行 Kimi-K2.7-Code:

  • vLLM
  • SGLang
  • KTransformers

Kimi-K2.7-Code 与 Kimi-K2.5/Kimi-K2.6 架构相同,部署方法可直接复用。

transformers 的版本要求为 >=4.57.1, <5.0.0

部署示例可见于 模型部署指南 (https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/docs/deploy_guidance.md)。


6. 模型使用

以下使用示例演示如何调用我们的官方 API。请注意,Kimi-K2.7-Code 强制启用思考模式并将 preserve_thinking 设置为 True。

对于使用 vLLM 或 SGLang 部署的第三方 API,请注意:

  • 视频内容聊天是一项实验性功能,目前仅在我们的官方 API 中支持。
  • 思考模式推荐温度为 1.0
  • 推荐的 top_p0.95
  • 不支持即时模式。

聊天补全

这是一个简单的聊天补全脚本,演示如何在思考模式下调用 K2.7-Code API。

import openai
import base64
import requests

def simple_chat(client: openai.OpenAI, model_name: str):
    messages = [
        {'role': 'system', 'content': 'You are Kimi, an AI assistant created by Moonshot AI.'},
        {
            'role': 'user',
            'content': [
                {'type': 'text', 'text': 'which one is bigger, 9.11 or 9.9? think carefully.'}
            ],
        },
    ]
    response = client.chat.completions.create(
        model=model_name, messages=messages, stream=False, max_tokens=4096
    )
    print('====== Below is reasoning content in Thinking Mode ======')
    print(f'reasoning content: {response.choices[0].message.reasoning}')
    print('====== Below is response in Thinking Mode ======')
    print(f'response: {response.choices[0].message.content}')

带视觉内容的聊天补全

K2.7-Code 支持图片和视频输入。

以下示例演示如何使用图片输入调用 K2.7-Code API:

import openai
import base64
import requests

def chat_with_image(client: openai.OpenAI, model_name: str):
    url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/kimi-logo.png'
    image_base64 = base64.b64encode(requests.get(url).content).decode()
    messages = [
        {
            'role': 'user',
            'content': [
                {'type': 'text', 'text': 'Describe this image in detail.'},
                {
                    'type': 'image_url',
                    'image_url': {'url': f'data:image/png;base64,{image_base64}'},
                },
            ],
        }
    ]

    response = client.chat.completions.create(
        model=model_name, messages=messages, stream=False, max_tokens=8192
    )
    print('====== Below is reasoning content in Thinking Mode ======')
    print(f'reasoning content: {response.choices[0].message.reasoning}')
    print('====== Below is response in Thinking Mode ======')
    print(f'response: {response.choices[0].message.content}')

以下示例演示如何使用视频输入调用 K2.7-Code API:

import openai
import base64
import requests

def chat_with_video(client: openai.OpenAI, model_name:str):
    url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/demo_video.mp4'
    video_base64 = base64.b64encode(requests.get(url).content).decode()
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "text","text": "Describe the video in detail."},
                {
                    "type": "video_url",
                    "video_url": {"url": f"data:video/mp4;base64,{video_base64}"},
                },
            ],
        }
    ]

    response = client.chat.completions.create(model=model_name, messages=messages)
    print('====== Below is reasoning content in Thinking Mode ======')
    print(f'reasoning content: {response.choices[0].message.reasoning}')
    print('====== Below is response in Thinking Mode ======')
    print(f'response: {response.choices[0].message.content}')

保留思维

Kimi K2.7 Code 强制启用 preserve_thinking 模式,该模式在多轮交互中保留完整的推理内容,从而提升编码智能体场景的性能。

此功能默认启用且不可禁用。以下示例演示如何在 preserve_thinking 模式下调用 K2.7-Code API:

def chat_with_preserve_thinking(client: openai.OpenAI, model_name: str):
    messages = [
        {
            "role": "user",
            "content": "Tell me three random numbers."
        },
        {
            "role": "assistant",
            "reasoning_content": "I'll start by listing five numbers: 473, 921, 235, 215, 222, and I'll tell you the first three.",
            # Some API (e.g. vLLM) may not support reasoning_content, you can try reasoning instead
            "content": "473, 921, 235"
        },
        {
            "role": "user",
            "content": "What are the other two numbers you have in mind?"
        }
    ]

    response = client.chat.completions.create(
        model=model_name,
        messages=messages,
        stream=False,
        max_tokens=4096,
    )
    # the assistant should mention 215 and 222 that appear in the prior reasoning content
    print(f"response: {response.choices[0].message.reasoning}")
    return response.choices[0].message.content

交错思维与多步骤工具调用

K2.7-Code 与 K2 Thinking 采用相同的交错思维与多步骤工具调用设计。使用示例请参考 K2 Thinking 文档 (https://platform.moonshot.ai/docs/guide/use-kimi-k2-thinking-model#complete-example)。

编码智能体框架

Kimi K2.7-Code 与 Kimi Code CLI 作为其智能体框架配合使用效果最佳——欢迎在 https://www.kimi.com/code 试用。


7. 许可证

代码仓库和模型权重均以 修改版 MIT 许可证 (https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/LICENSE) 发布。


8. 第三方声明

参见 第三方声明 (https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/THIRD_PARTY_NOTICES.md)


9. 联系我们

如有任何问题,请发送邮件至 [email protected]

相似文章

Kimi K2.7 Code 务实胜过炫技

Reddit r/AI_Agents

Kimi 发布了 K2.7 Code,这是一款专注于编程的 AI 模型,其基准测试成绩提升,且思考令牌使用量降低 30%。它更强调在长代码循环和智能体工具集成中的实际性能,而非炫目的分数。

Kimi K2.6

Product Hunt

Kimi K2.6 作为开源模型发布,在长程编码与智能体集群基准测试中达到 SOTA 性能。