Kimi K2.7-Code:具有更高词元效率的开源编码模型
Kimi K2.7-Code: open-source coding model with better token efficiency

原始链接: https://huggingface.co/moonshotai/Kimi-K2.7-Code

**Kimi K2.7 Code** 是一款专为软件工程和复杂编码任务进行优化的先进智能体模型。该模型基于 K2.6 架构构建,采用 1 万亿参数的混合专家(MoE)设计,拥有 320 亿激活参数及 256K 上下文窗口。 主要改进包括: * **性能增强:** 与前代产品相比,在处理现实世界中长周期编码和智能体工作流方面表现更出色。 * **效率提升:** 思维令牌(thinking-token)的使用量减少了 30%。 * **进阶能力:** 原生支持多模态输入(图像和视频),通过强制开启 `preserve_thinking` 模式实现持久化推理,并与 Kimi Code CLI 实现无缝集成。 该模型在包括编码(Kimi Code Bench v2)和智能体工具使用任务(MCP-Atlas)在内的行业基准测试中表现极具竞争力。它支持原生 INT4 量化,并兼容 vLLM 和 SGLang 等标准推理引擎。对于熟悉以往 K2.x 版本的用户而言,部署流程十分简洁。该模型及其代码库基于修改后的 MIT 许可协议发布。用户可通过 Moonshot AI 平台使用兼容 OpenAI/Anthropic 的 API 进行访问。

Kimi K2.7-Code 的发布在 Hacker News 上引发了关于 AI 代码模型竞争格局的讨论。用户们正在争论,如果新模型不能显著超越 DeepSeek 目前所设定的高性价比标准,那么它们是否还有存在的必要。 争论的焦点在于顶级模型(如 Anthropic 的 Claude 3.5 Opus)与更便宜的替代品之间的性能差距。虽然一些用户质疑为何美国公司在成本高出许多的情况下仍能保持市场份额,但另一些人则认为,“护城河”不仅关乎数据隐私或企业级限制。经常使用编程智能体的用户表示,Opus 这类模型在处理复杂的工程研究时依然表现更佳;他们指出,更便宜的模型往往会引入错误,导致开发人员需要花费数小时进行修复。尽管开源或国际模型更具价格吸引力,但许多专业人士因其在生产环境中卓越的可靠性和代码质量,仍选择依赖 Anthropic 和 OpenAI。讨论最后,用户们开始寻求将企业业务迁移至开放权重模型的实用建议。
相关文章

原文

1. Model Introduction

Kimi K2.7 Code is a coding-focused agentic model built upon Kimi K2.6. With substantial improvements on real-world long-horizon coding tasks, it strengthens end-to-end task completion across complex software engineering workflows while improving token efficiency, reducing thinking-token usage by approximately 30% compared with Kimi K2.6.

2. Model Summary

Architecture Mixture-of-Experts (MoE)
Total Parameters 1T
Activated Parameters 32B
Number of Layers (Dense layer included) 61
Number of Dense Layers 1
Attention Hidden Dimension 7168
MoE Hidden Dimension (per Expert) 2048
Number of Attention Heads 64
Number of Experts 384
Selected Experts per Token 8
Number of Shared Experts 1
Vocabulary Size 160K
Context Length 256K
Attention Mechanism MLA
Activation Function SwiGLU
Vision Encoder MoonViT
Parameters of Vision Encoder 400M

3. Evaluation Results

Benchmark Kimi K2.6 Kimi K2.7 Code GPT-5.5 Claude Opus 4.8
Coding
Kimi Code Bench v2 50.9 62.0 69.0 67.4
Program Bench 48.3 53.6 69.1 63.8
MLS Bench Lite 26.7 35.1 35.5 42.8
Agentic
Kimi Claw 24/7 Bench 42.9 46.9 52.8 50.4
MCP Atlas 69.4 76.0 79.4 81.3
MCP Mark Verified 72.8 81.1 92.9 76.4
Footnotes
  1. General Testing Details
    • Unless stated otherwise, Kimi K2.7 Code and K2.6 were tested with thinking mode enabled via Kimi Code CLI at temperature = 1.0, top-p = 0.95, and a 262,144-token context length; GPT-5.5 ran in Codex with xhigh mode, and Opus 4.8 in Claude Code with xhigh mode. Aside from these differences, all benchmarks were evaluated under the same conditions.
  2. Coding Benchmarks
    • Kimi Code Bench V2 is our in-house benchmark designed to evaluate coding agents on realistic tasks. It has diversed software engineering tasks across 10+ mainstream programming languages and a full production tech stack covering tasks from internal engineering use cases, production incidents, and real-world open-source projects, with emphasis on backend services, infrastructure, performance engineering, systems programming, security, frontend development, and ML/data engineering.
    • Program Bench evaluates code-generation agents by asking them to recreate a program’s behavior from only a compiled binary and its documentation. It spans 200 tasks, from small CLI tools to large systems like FFmpeg and SQLite. Submissions are judged against over 248,000 fuzz-generated behavioral tests. In each task, the agent is given an executable and its documentation, but no source code, decompilation, or internet access. It must choose its own implementation language, build the full program from scratch, and pass a behavioral test suite comparing its output against the original binary.
    • MLS-Bench evaluates whether AI systems can invent generalizable and scalable ML methods. MLS-Bench-Lite is the official 30-task subset of MLS-Bench, covering LLM pretraining and post-training, robotics, world models, computer vision, reinforcement learning, optimization, ML systems, AI for Science, and more. Agents are given 5 hours to explore before submitting their solutions. Opus 4.8 is evaluated with the max effort setting in Claude Code.
  3. Agentic Benchmarks
    • Kimi Claw 24/7 Bench is our in-house benchmark for evaluating long-horizon agentic performance in persistent, multi-day coworking tasks. It spans 17 professional scenarios across 610 evaluation points, covering domains such as software engineering, ML research, recruiting, trading, marketing. All tasks are executed through the OpenClaw harness. The final score is the average pass rate across all evaluation points, and is averaged over 3 runs.
    • MCP-Atlas evaluates LLM performance on realistic tool-use tasks through the scalable MCPs. We followed the official MCP-Atlas evaluation configuration with a 100 tool-call budget, and with 32k max tokens per step. The final result is averaged over 3 runs.
    • MCPMark-Verified is a human-verified edition of MCPMark, a benchmark for evaluating MCP tool use across five real server environments — Notion, GitHub, Filesystem, Postgres, and Playwright. Each task has been re-checked by our team and the benchmark offical and will be open-sourced soon. We followed the official MCPMark evaluation configuration with a 100-step tool-call budget and 32k max tokens per step. The final result is averaged over 3 runs.

4. Native INT4 Quantization

Kimi-K2.7-Code adopts the same native int4 quantization method as Kimi-K2-Thinking.

5. Deployment

You can access Kimi-K2.7-Code's API on https://platform.moonshot.ai and we provide OpenAI/Anthropic-compatible API for you. Currently, Kimi-K2.7-Code is recommended to run on the following inference engines:

  • vLLM
  • SGLang
  • KTransformers

Kimi-K2.7-Code has the same architecture as Kimi-K2.5/Kimi-K2.6, and the deployment method can be directly reused.

The version requirement for transformers is >=4.57.1, <5.0.0.

Deployment examples can be found in the Model Deployment Guide.


6. Model Usage

The usage demos below demonstrate how to call our official API. Note that Kimi-K2.7-Code forces thinking and preserve_thinking as True.

For third-party APIs deployed with vLLM or SGLang, please note that:

  • Chat with video content is an experimental feature and is only supported in our official API for now.

  • The recommended temperature will be 1.0 for Thinking mode.

  • The recommended top_p is 0.95.

  • Instant mode is not supported.

Chat Completion

This is a simple chat completion script which shows how to call K2.7-Code API in Thinking mode.

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}')

Chat Completion with visual content

K2.7-Code supports Image and Video input.

The following example demonstrates how to call K2.7-Code API with image input:

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}')

The following example demonstrates how to call K2.7-Code API with video input:

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}')

Preserve Thinking

Kimi K2.7 Code forces preserve_thinking mode, which retains full reasoning content across multi-turn interactions and enhances performance in coding agent scenarios.

This feature is enabled by default and can't be disabled. The following example demonstrates how to call K2.7-Code API in preserve_thinking mode:

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.",
            
            "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,
    )
    
    print(f"response: {response.choices[0].message.reasoning}")
    return response.choices[0].message.content

Interleaved Thinking and Multi-Step Tool Call

K2.7-Code shares the same design of Interleaved Thinking and Multi-Step Tool Call as K2 Thinking. For usage example, please refer to the K2 Thinking documentation.

Coding Agent Framework

Kimi K2.7-Code works best with Kimi Code CLI as its agent framework — give it a try at https://www.kimi.com/code.


7. License

Both the code repository and the model weights are released under the Modified MIT License.


8. Third Party Notices

See THIRD PARTY NOTICES


9. Contact Us

If you have any questions, please reach out at [email protected].

联系我们 contact @ memedata.com