SwinliQ-AIs/Kimi-K2.7-Code
118
1---2tags:3- compressed-tensors4license: other5license_name: modified-mit6library_name: transformers7pipeline_tag: image-text-to-text8---9<div align="center">10 <picture>11 <img src="figures/kimi-logo.png" width="30%" alt="Kimi K2.7 Code">12 </picture>13</div>14<hr>15<div align="center" style="line-height:1">16 <a href="https://www.kimi.com/code" target="_blank"><img alt="Chat" src="https://img.shields.io/badge/🤖-Kimi--Code-ff6b6b?color=1783ff&logoColor=white"/></a>17 <a href="https://www.moonshot.ai" target="_blank"><img alt="Homepage" src="https://img.shields.io/badge/Homepage-Moonshot%20AI-white?logo=Kimi&logoColor=white"/></a>18</div>19 20<div align="center" style="line-height: 1;">21 <a href="https://huggingface.co/moonshotai" target="_blank"><img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Moonshot%20AI-ffc107?color=ffc107&logoColor=white"/></a>22 <a href="https://twitter.com/kimi_moonshot" target="_blank"><img alt="Twitter Follow" src="https://img.shields.io/badge/Twitter-Kimi.ai-white?logo=x&logoColor=white"/></a>23 <a href="https://discord.gg/TYU2fdJykW" target="_blank"><img alt="Discord" src="https://img.shields.io/badge/Discord-Kimi.ai-white?logo=discord&logoColor=white"/></a>24 <a href="https://modelscope.cn/organization/moonshotai" target="_blank"><img alt="ModelScope" src="https://img.shields.io/badge/ModelScope-Moonshot%20AI-white?labelColor=rgb(99%2C%2074%2C%20255)"/></a>25</div>26<div align="center" style="line-height: 1;">27 <a href="https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-Modified_MIT-f5de53?&color=f5de53"/></a>28</div>29 30 31 32 33## 1. Model Introduction34 35Kimi 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.36 37## 2. Model Summary38 39<div align="center">40 41 42| | |43|:---:|:---:|44| **Architecture** | Mixture-of-Experts (MoE) |45| **Total Parameters** | 1T |46| **Activated Parameters** | 32B |47| **Number of Layers** (Dense layer included) | 61 |48| **Number of Dense Layers** | 1 |49| **Attention Hidden Dimension** | 7168 |50| **MoE Hidden Dimension** (per Expert) | 2048 |51| **Number of Attention Heads** | 64 |52| **Number of Experts** | 384 |53| **Selected Experts per Token** | 8 |54| **Number of Shared Experts** | 1 |55| **Vocabulary Size** | 160K |56| **Context Length** | 256K |57| **Attention Mechanism** | MLA |58| **Activation Function** | SwiGLU |59| **Vision Encoder** | MoonViT |60| **Parameters of Vision Encoder** | 400M |61</div>62 63## 3. Evaluation Results64 65<div align="center">66<table>67<thead>68<tr>69<th align="center">Benchmark</th>70<th align="center">Kimi K2.6</th>71<th align="center">Kimi K2.7 Code</th>72<th align="center">GPT-5.5</th>73<th align="center">Claude Opus 4.8</th>74</tr>75</thead>76<tbody>77<tr>78<td align="center" colspan=5><strong>Coding</strong></td>79</tr>80<tr>81<td align="center" style="vertical-align: middle">Kimi Code Bench v2</td>82<td align="center" style="vertical-align: middle">50.9</td>83<td align="center" style="vertical-align: middle">62.0</td>84<td align="center" style="vertical-align: middle">69.0</td>85<td align="center" style="vertical-align: middle">67.4</td>86</tr>87<tr>88<td align="center" style="vertical-align: middle">Program Bench</td>89<td align="center" style="vertical-align: middle">48.3</td>90<td align="center" style="vertical-align: middle">53.6</td>91<td align="center" style="vertical-align: middle">69.1</td>92<td align="center" style="vertical-align: middle">63.8</td>93</tr>94<tr>95<td align="center" style="vertical-align: middle">MLS Bench Lite</td>96<td align="center" style="vertical-align: middle">26.7</td>97<td align="center" style="vertical-align: middle">35.1</td>98<td align="center" style="vertical-align: middle">35.5</td>99<td align="center" style="vertical-align: middle">42.8</td>100</tr>101<tr>102<td align="center" colspan=5><strong>Agentic</strong></td>103</tr>104<tr>105<td align="center" style="vertical-align: middle">Kimi Claw 24/7 Bench</td>106<td align="center" style="vertical-align: middle">42.9</td>107<td align="center" style="vertical-align: middle">46.9</td>108<td align="center" style="vertical-align: middle">52.8</td>109<td align="center" style="vertical-align: middle">50.4</td>110</tr>111<tr>112<td align="center" style="vertical-align: middle">MCP Atlas</td>113<td align="center" style="vertical-align: middle">69.4</td>114<td align="center" style="vertical-align: middle">76.0</td>115<td align="center" style="vertical-align: middle">79.4</td>116<td align="center" style="vertical-align: middle">81.3</td>117</tr>118<tr>119<td align="center" style="vertical-align: middle">MCP Mark Verified</td>120<td align="center" style="vertical-align: middle">72.8</td>121<td align="center" style="vertical-align: middle">81.1</td>122<td align="center" style="vertical-align: middle">92.9</td>123<td align="center" style="vertical-align: middle">76.4</td>124</tr>125</tbody>126</table>127</div>128 129<details>130<summary><b>Footnotes</b></summary>131 1321. **General Testing Details**133 - 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.1342. **Coding Benchmarks**135 - 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.136 - [Program Bench](https://programbench.com/) 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.137 - [MLS-Bench](https://mls-bench.com) 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.1383. **Agentic Benchmarks**139 - 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.140 - [MCP-Atlas](https://labs.scale.com/leaderboard/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.141 - MCPMark-Verified is a human-verified edition of [MCPMark](https://mcpmark.ai/), 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.142 143</details>144 145 146## 4. Native INT4 Quantization147Kimi-K2.7-Code adopts the same native int4 quantization method as [Kimi-K2-Thinking](https://huggingface.co/moonshotai/Kimi-K2-Thinking#4-native-int4-quantization).148 149## 5. Deployment150 151> [!Note]152> You can access Kimi-K2.7-Code's API on https://platform.moonshot.ai and we provide OpenAI/Anthropic-compatible API for you.153Currently, Kimi-K2.7-Code is recommended to run on the following inference engines:154* vLLM155* SGLang156* KTransformers157 158Kimi-K2.7-Code has the same architecture as Kimi-K2.5/Kimi-K2.6, and the deployment method can be directly reused.159 160The version requirement for `transformers` is `>=4.57.1, <5.0.0`.161 162Deployment examples can be found in the [Model Deployment Guide](docs/deploy_guidance.md).163 164 165---166## 6. Model Usage167 168The usage demos below demonstrate how to call our official API. Note that Kimi-K2.7-Code forces thinking and preserve_thinking as True.169 170For third-party APIs deployed with vLLM or SGLang, please note that:171> [!Note]172> - Chat with video content is an experimental feature and is only supported in our official API for now.173> 174> - The recommended `temperature` will be `1.0` for Thinking mode.175> 176> - The recommended `top_p` is `0.95`.177> 178> - Instant mode is not supported.179 180### Chat Completion181 182This is a simple chat completion script which shows how to call K2.7-Code API in Thinking mode.183 184```python185import openai186import base64187import requests188def simple_chat(client: openai.OpenAI, model_name: str):189 messages = [190 {'role': 'system', 'content': 'You are Kimi, an AI assistant created by Moonshot AI.'},191 {192 'role': 'user',193 'content': [194 {'type': 'text', 'text': 'which one is bigger, 9.11 or 9.9? think carefully.'}195 ],196 },197 ]198 response = client.chat.completions.create(199 model=model_name, messages=messages, stream=False, max_tokens=4096200 )201 print('====== Below is reasoning content in Thinking Mode ======')202 print(f'reasoning content: {response.choices[0].message.reasoning}')203 print('====== Below is response in Thinking Mode ======')204 print(f'response: {response.choices[0].message.content}')205```206 207 208### Chat Completion with visual content209 210K2.7-Code supports Image and Video input.211 212The following example demonstrates how to call K2.7-Code API with image input:213 214```python215import openai216import base64217import requests218 219def chat_with_image(client: openai.OpenAI, model_name: str):220 url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/kimi-logo.png'221 image_base64 = base64.b64encode(requests.get(url).content).decode()222 messages = [223 {224 'role': 'user',225 'content': [226 {'type': 'text', 'text': 'Describe this image in detail.'},227 {228 'type': 'image_url',229 'image_url': {'url': f'data:image/png;base64,{image_base64}'},230 },231 ],232 }233 ]234 235 response = client.chat.completions.create(236 model=model_name, messages=messages, stream=False, max_tokens=8192237 )238 print('====== Below is reasoning content in Thinking Mode ======')239 print(f'reasoning content: {response.choices[0].message.reasoning}')240 print('====== Below is response in Thinking Mode ======')241 print(f'response: {response.choices[0].message.content}')242```243 244The following example demonstrates how to call K2.7-Code API with video input:245 246```python247import openai248import base64249import requests250 251def chat_with_video(client: openai.OpenAI, model_name:str):252 url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/demo_video.mp4'253 video_base64 = base64.b64encode(requests.get(url).content).decode()254 messages = [255 {256 "role": "user",257 "content": [258 {"type": "text","text": "Describe the video in detail."},259 {260 "type": "video_url",261 "video_url": {"url": f"data:video/mp4;base64,{video_base64}"},262 },263 ],264 }265 ]266 267 response = client.chat.completions.create(model=model_name, messages=messages)268 print('====== Below is reasoning content in Thinking Mode ======')269 print(f'reasoning content: {response.choices[0].message.reasoning}')270 print('====== Below is response in Thinking Mode ======')271 print(f'response: {response.choices[0].message.content}')272```273 274### Preserve Thinking275Kimi K2.7 Code forces `preserve_thinking` mode, which retains full reasoning content across multi-turn interactions and enhances performance in coding agent scenarios.276 277This 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:278 279```python280def chat_with_preserve_thinking(client: openai.OpenAI, model_name: str):281 messages = [282 {283 "role": "user",284 "content": "Tell me three random numbers."285 },286 {287 "role": "assistant",288 "reasoning_content": "I'll start by listing five numbers: 473, 921, 235, 215, 222, and I'll tell you the first three.",289 # Some API (e.g. vLLM) may not support reasoning_content, you can try reasoning instead290 "content": "473, 921, 235"291 },292 {293 "role": "user",294 "content": "What are the other two numbers you have in mind?"295 }296 ]297 298 response = client.chat.completions.create(299 model=model_name,300 messages=messages,301 stream=False,302 max_tokens=4096,303 )304 # the assistant should mention 215 and 222 that appear in the prior reasoning content305 print(f"response: {response.choices[0].message.reasoning}")306 return response.choices[0].message.content307 308```309 310### Interleaved Thinking and Multi-Step Tool Call311 312K2.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](https://platform.moonshot.ai/docs/guide/use-kimi-k2-thinking-model#complete-example).313 314### Coding Agent Framework315 316Kimi K2.7-Code works best with Kimi Code CLI as its agent framework — give it a try at https://www.kimi.com/code.317 318 319---320 321## 7. License322 323Both the code repository and the model weights are released under the [Modified MIT License](LICENSE).324 325---326 327## 8. Third Party Notices328 329See [THIRD PARTY NOTICES](THIRD_PARTY_NOTICES.md)330 331---332 333## 9. Contact Us334 335If you have any questions, please reach out at [support@moonshot.ai](mailto:support@moonshot.ai).336 