Checkpoint tokenizer

×

The tiktoken vocabulary, tokenizer class and chat template shipped with the checkpoint.

Unverified: the tiktoken vocabulary file and its token-to-ID mapping. The atlas records tiktoken.model by its checksum and keeps no copy.

Explanation

The checkpoint’s own TikTokenTokenizer class loads the vocabulary; tokenizer_config.json names it (208–215).

Sources

In codeTikTokenTokenizer

Open pinned code ↗

Contextual evidence

The checkpoint’s tokenizer is the repository’s own TikTokenTokenizer class, loaded through AutoTokenizer.

tokenizer_config.json 206–216 ↗ · moonshotai/Kimi-K2.6 @ 7eb5002f6aad

Excerpt
  "model_max_length": 1000000000000000019884624838656,
  "pad_token": "[PAD]",
  "tokenizer_class": "TikTokenTokenizer",
  "unk_token": "[UNK]",
  "auto_map": {
    "AutoTokenizer": [
      "tokenization_kimi.TikTokenTokenizer",
      null
    ]
  }
}

The chat template marks each message with its role (<|im_user|>, <|im_assistant|>, <|im_system|>) ending in <|im_end|>, puts a media placeholder where a message holds an image or a video, and opens the assistant’s turn with <think>.

chat_template.jinja 1–112 ↗ · moonshotai/Kimi-K2.6 @ 7eb5002f6aad

Excerpt
{%- macro render_content(msg) -%}
    {%- set c = msg.get('content') -%}
    {%- if c is string -%}
      {{ c }}
    {%- elif c is not none -%}
      {% for content in c -%}
        {% if content['type'] == 'image' or content['type'] == 'image_url' -%}
          <|media_begin|>image<|media_content|><|media_pad|><|media_end|>
        {% elif content['type'] == 'video' or content['type']== 'video_url'-%}
          <|kimi_k25_video_placeholder|>
        {% else -%}
          {{ content['text'] }}
        {%- endif -%}
      {%- endfor -%}
    {%- endif -%}
{%- endmacro -%}

{% macro set_roles(message) -%}
  {%- set role_name =  message.get('name') or  message['role'] -%}
  {%- if message['role'] == 'user' -%}
    <|im_user|>{{role_name}}<|im_middle|>
  {%- elif message['role'] == 'assistant' -%}
    <|im_assistant|>{{role_name}}<|im_middle|>
  {%- else -%}
    <|im_system|>{{role_name}}<|im_middle|>
  {%- endif -%}
{%- endmacro -%}

… lines 28–64 omitted …

{%- for message in hist_msgs -%}
  {{set_roles(message)}}
  {%- if message['role'] == 'assistant' -%}
    <think></think>{{render_content(message)}}
    {%- if message.get('tool_calls') -%}
      {{render_toolcalls(message)}}
    {%- endif -%}
  {%- elif message['role'] == 'tool' -%}
    {%- set tool_call_id = message.tool_call_id -%}
    ## Return of {{ tool_call_id }}
{{render_content(message)}}
  {%- elif message['content'] is not none -%}
    {{render_content(message)}}
  {%- endif -%}
  <|im_end|>
{%- endfor -%}

… lines 81–104 omitted …

{%- if add_generation_prompt -%}
  <|im_assistant|>assistant<|im_middle|>
  {%- if thinking is defined and thinking is false -%}
  <think></think>
  {%- else -%}
  <think>
  {%- endif -%}
{%- endif -%}