Tokenizer

×

Encode each prompt as a sequence of token IDs.

out
II [B batch, T positions]
Explanation

Chat prompts are wrapped in the checkpoint’s chat template before encoding; an image or a video in a message becomes a media placeholder. Token IDs index a vocabulary of 163,840 entries; TT counts the tokens.

Sources

In codechat_template.jinja

Open pinned code ↗

Direct 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 -%}

The language model’s configuration (text_config): the DeepSeek-V3 architecture, width, 61 layers of which 1 dense, 64 heads, 384 routed experts and one shared, routing (sigmoid scores, one expert group, top-8, route scale 2.827), MLA ranks and head widths, vocabulary, 262,144 positions and YaRN RoPE (factor 64 over 4,096 original positions, β_fast 32, β_slow 1).

config.json 17–167 ↗ · moonshotai/Kimi-K2.6 @ 7eb5002f6aad

Excerpt
  "text_config": {
    "_name_or_path": "",
    "add_cross_attention": false,
    "architectures": [
      "DeepseekV3ForCausalLM"
    ],
    "attention_bias": false,
    "attention_dropout": 0.0,
    "auto_map": {
      "AutoConfig": "configuration_deepseek.DeepseekV3Config",
      "AutoModel": "modeling_deepseek.DeepseekV3Model",
      "AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
    },
    "aux_loss_alpha": 0.001,
    "bad_words_ids": null,
    "begin_suppress_tokens": null,
    "bos_token_id": 163584,
    "chunk_size_feed_forward": 0,
    "cross_attention_hidden_size": null,
    "decoder_start_token_id": null,
    "diversity_penalty": 0.0,
    "do_sample": false,
    "dtype": "bfloat16",
    "early_stopping": false,
    "encoder_no_repeat_ngram_size": 0,
    "eos_token_id": 163586,
    "ep_size": 1,
    "exponential_decay_length_penalty": null,
    "finetuning_task": null,
    "first_k_dense_replace": 1,
    "forced_bos_token_id": null,
    "forced_eos_token_id": null,
    "hidden_act": "silu",
    "hidden_size": 7168,
    "id2label": {
      "0": "LABEL_0",
      "1": "LABEL_1"
    },
    "initializer_range": 0.02,
    "intermediate_size": 18432,
    "is_decoder": false,
    "is_encoder_decoder": false,
    "kv_lora_rank": 512,
    "label2id": {
      "LABEL_0": 0,
      "LABEL_1": 1
    },
    "length_penalty": 1.0,
    "max_length": 20,
    "max_position_embeddings": 262144,
    "min_length": 0,
    "model_type": "kimi_k2",
    "moe_intermediate_size": 2048,
    "moe_layer_freq": 1,
    "n_group": 1,
    "n_routed_experts": 384,
    "n_shared_experts": 1,
    "no_repeat_ngram_size": 0,
    "norm_topk_prob": true,
    "num_attention_heads": 64,
    "num_beam_groups": 1,
    "num_beams": 1,
    "num_experts_per_tok": 8,
    "num_hidden_layers": 61,
    "num_key_value_heads": 64,
    "num_nextn_predict_layers": 0,
    "num_return_sequences": 1,
    "output_attentions": false,
    "output_hidden_states": false,
    "output_scores": false,
    "pad_token_id": 163839,
    "prefix": null,
    "pretraining_tp": 1,
    "problem_type": null,
    "pruned_heads": {},
    "q_lora_rank": 1536,
    "qk_nope_head_dim": 128,
    "qk_rope_head_dim": 64,
    "quantization_config": {
      "config_groups": {
        "group_0": {
          "input_activations": null,
          "output_activations": null,
          "targets": [
            "Linear"
          ],
          "weights": {
            "actorder": null,
            "block_structure": null,
            "dynamic": false,
            "group_size": 32,
            "num_bits": 4,
            "observer": "minmax",
            "observer_kwargs": {},
            "strategy": "group",
            "symmetric": true,
            "type": "int"
          }
        }
      },
      "format": "pack-quantized",
      "ignore": [
        "re:.*self_attn.*",
        "re:.*shared_experts.*",
        "re:.*mlp\\.(gate|up|gate_up|down)_proj.*",
        "re:.*lm_head.*",
        "re:vision_tower.*",
        "re:mm_projector.*"
      ],
      "kv_cache_scheme": null,
      "quant_method": "compressed-tensors",
      "quantization_status": "compressed"
    },
    "remove_invalid_values": false,
    "repetition_penalty": 1.0,
    "return_dict": true,
    "return_dict_in_generate": false,
    "rms_norm_eps": 1e-05,
    "rope_scaling": {
      "beta_fast": 32.0,
      "beta_slow": 1.0,
      "factor": 64.0,
      "mscale": 1.0,
      "mscale_all_dim": 1.0,
      "original_max_position_embeddings": 4096,
      "type": "yarn"
    },
    "rope_theta": 50000.0,
    "routed_scaling_factor": 2.827,
    "scoring_func": "sigmoid",
    "sep_token_id": null,
    "seq_aux": true,
    "suppress_tokens": null,
    "task_specific_params": null,
    "temperature": 1.0,
    "tf_legacy_loss": false,
    "tie_encoder_decoder": false,
    "tie_word_embeddings": false,
    "tokenizer_class": null,
    "top_k": 50,
    "top_p": 1.0,
    "topk_group": 1,
    "topk_method": "noaux_tc",
    "torchscript": false,
    "transformers_version": "4.56.2",
    "typical_p": 1.0,
    "use_bfloat16": false,
    "use_cache": true,
    "v_head_dim": 128,
    "vocab_size": 163840
  },