Add files using upload-large-folder tool
Browse files- .gitattributes +2 -0
- chat_template.jinja +159 -0
- config.json +117 -0
- docs/function_call_guide.md +482 -0
- docs/vllm_deploy_guide.md +88 -0
- figures/Bench.png +3 -0
- model-00001-of-00041.safetensors +3 -0
- model-00002-of-00041.safetensors +3 -0
- model-00003-of-00041.safetensors +3 -0
- model-00004-of-00041.safetensors +3 -0
- model-00005-of-00041.safetensors +3 -0
- model-00006-of-00041.safetensors +3 -0
- model-00007-of-00041.safetensors +3 -0
- model-00008-of-00041.safetensors +3 -0
- model-00009-of-00041.safetensors +3 -0
- model-00010-of-00041.safetensors +3 -0
- model-00015-of-00041.safetensors +3 -0
- model-00040-of-00041.safetensors +3 -0
- model-00041-of-00041.safetensors +3 -0
- model.safetensors.index.json +3 -0
- tokenizer_config.json +495 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
figures/Bench.png filter=lfs diff=lfs merge=lfs -text
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{# ----------‑‑‑ special token variables ‑‑‑---------- #}
|
| 2 |
+
{%- set toolcall_begin_token = '<minimax:tool_call>' -%}
|
| 3 |
+
{%- set toolcall_end_token = '</minimax:tool_call>' -%}
|
| 4 |
+
{#- Tool Rendering Functions ============================================== -#}
|
| 5 |
+
{%- macro render_tool_namespace(namespace_name, tool_list) -%}
|
| 6 |
+
{%- for tool in tool_list -%}
|
| 7 |
+
<tool>{{ tool.function | tojson(ensure_ascii=False) }}</tool>
|
| 8 |
+
{% endfor -%}
|
| 9 |
+
{%- endmacro -%}
|
| 10 |
+
{%- macro visible_text(content) -%}
|
| 11 |
+
{%- if content is string -%}
|
| 12 |
+
{{ content }}
|
| 13 |
+
{%- elif content is iterable and content is not mapping -%}
|
| 14 |
+
{%- for item in content -%}
|
| 15 |
+
{%- if item is mapping and item.type == 'text' -%}
|
| 16 |
+
{{- item.text }}
|
| 17 |
+
{%- elif item is string -%}
|
| 18 |
+
{{- item }}
|
| 19 |
+
{%- endif -%}
|
| 20 |
+
{%- endfor -%}
|
| 21 |
+
{%- else -%}
|
| 22 |
+
{{- content }}
|
| 23 |
+
{%- endif -%}
|
| 24 |
+
{%- endmacro -%}
|
| 25 |
+
{#- System Message Construction ============================================ -#}
|
| 26 |
+
{%- macro build_system_message(system_message) -%}
|
| 27 |
+
{%- if system_message and system_message.content -%}
|
| 28 |
+
{{- visible_text(system_message.content) }}
|
| 29 |
+
{%- else -%}
|
| 30 |
+
{%- if model_identity is not defined -%}
|
| 31 |
+
{%- set model_identity = "You are a helpful assistant." -%}
|
| 32 |
+
{%- endif -%}
|
| 33 |
+
{{- model_identity }}
|
| 34 |
+
{%- endif -%}
|
| 35 |
+
|
| 36 |
+
{#- Handle current_date -#}
|
| 37 |
+
{%- if system_message and system_message.current_date -%}
|
| 38 |
+
{{- '\n' ~ 'Current date: ' + system_message.current_date }}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{#- Handle current_location -#}
|
| 41 |
+
{%- if system_message and system_message.current_location -%}
|
| 42 |
+
{{- '\n' ~ 'Current location: ' + system_message.current_location }}
|
| 43 |
+
{%- endif -%}
|
| 44 |
+
{%- endmacro -%}
|
| 45 |
+
{#- Main Template Logic ================================================= -#}
|
| 46 |
+
{#- Extract system message (only first message if it's system) -#}
|
| 47 |
+
{%- set system_message = none -%}
|
| 48 |
+
{%- set conversation_messages = messages -%}
|
| 49 |
+
{%- if messages and messages[0].role == "system" -%}
|
| 50 |
+
{%- set system_message = messages[0] -%}
|
| 51 |
+
{%- set conversation_messages = messages[1:] -%}
|
| 52 |
+
{%- endif -%}
|
| 53 |
+
{#- Get the last user message turn, for interleved thinking -#}
|
| 54 |
+
{%- set ns = namespace(last_user_index=-1) %}
|
| 55 |
+
{% for m in conversation_messages %}
|
| 56 |
+
{%- if m.role == 'user' %}
|
| 57 |
+
{% set ns.last_user_index = loop.index0 -%}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endfor %}
|
| 60 |
+
{#- Render system message -#}
|
| 61 |
+
{{- ']~!b[' ~ ']~b]system' ~ '\n' }}
|
| 62 |
+
{{- build_system_message(system_message) }}
|
| 63 |
+
{#- Render tools if available -#}
|
| 64 |
+
{%- if tools -%}
|
| 65 |
+
{{- '\n\n' ~ '# Tools' ~ '\n' ~ 'You may call one or more tools to assist with the user query.\nHere are the tools available in JSONSchema format:' ~ '\n' }}
|
| 66 |
+
{{- '\n' ~ '<tools>' ~ '\n' }}
|
| 67 |
+
{{- render_tool_namespace("functions", tools) }}
|
| 68 |
+
{{- '</tools>' ~ '\n\n' }}
|
| 69 |
+
{{- 'When making tool calls, use XML format to invoke tools and pass parameters:' ~ '\n' }}
|
| 70 |
+
{{- '\n' ~ toolcall_begin_token }}
|
| 71 |
+
<invoke name="tool-name-1">
|
| 72 |
+
<parameter name="param-key-1">param-value-1</parameter>
|
| 73 |
+
<parameter name="param-key-2">param-value-2</parameter>
|
| 74 |
+
...
|
| 75 |
+
</invoke>
|
| 76 |
+
{{- '\n' ~ toolcall_end_token }}
|
| 77 |
+
{%- endif -%}
|
| 78 |
+
{{- '[e~[\n' }}
|
| 79 |
+
|
| 80 |
+
{#- Render messages -#}
|
| 81 |
+
{%- set last_tool_call = namespace(name=none) -%}
|
| 82 |
+
{%- for message in conversation_messages -%}
|
| 83 |
+
{%- if message.role == 'assistant' -%}
|
| 84 |
+
{#- Only render reasoning_content if no user message follows -#}
|
| 85 |
+
{{- ']~b]ai' ~ '\n' }}
|
| 86 |
+
|
| 87 |
+
{%- set reasoning_content = '' %}
|
| 88 |
+
{%- set content = visible_text(message.content) %}
|
| 89 |
+
{%- if message.reasoning_content is string %}
|
| 90 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 91 |
+
{%- else %}
|
| 92 |
+
{%- if '</think>' in content %}
|
| 93 |
+
{%- set reasoning_content = content.split('</think>')[0].strip('\n').split('<think>')[-1].strip('\n') %}
|
| 94 |
+
{%- set content = content.split('</think>')[-1].strip('\n') %}
|
| 95 |
+
{%- endif %}
|
| 96 |
+
{%- endif %}
|
| 97 |
+
{%- if reasoning_content and loop.index0 > ns.last_user_index -%}
|
| 98 |
+
{{- '<think>' ~ '\n' ~ reasoning_content ~ '\n' ~ '</think>' ~ '\n\n' }}
|
| 99 |
+
{%- endif -%}
|
| 100 |
+
{%- if content -%}
|
| 101 |
+
{{- content }}
|
| 102 |
+
{%- endif -%}
|
| 103 |
+
{%- if message.tool_calls -%}
|
| 104 |
+
{{- '\n' ~ toolcall_begin_token ~ '\n' }}
|
| 105 |
+
|
| 106 |
+
{%- for tool_call in message.tool_calls -%}
|
| 107 |
+
{%- if tool_call.function %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{{- '<invoke name="' + tool_call.name + '">' }}
|
| 111 |
+
{% set _args = tool_call.arguments %}
|
| 112 |
+
{%- for k, v in _args.items() %}
|
| 113 |
+
{{- '<parameter name="' + k + '">' }}
|
| 114 |
+
{{- v | tojson(ensure_ascii=False) if v is not string else v }}
|
| 115 |
+
{{- '</parameter>' }}
|
| 116 |
+
{% endfor %}
|
| 117 |
+
{{- '</invoke>' ~ '\n' }}
|
| 118 |
+
{%- endfor -%}
|
| 119 |
+
|
| 120 |
+
{{- toolcall_end_token}}
|
| 121 |
+
{%- set last_tool_call.name = message.tool_calls[-1].name -%}
|
| 122 |
+
{%- else -%}
|
| 123 |
+
{%- set last_tool_call.name = none -%}
|
| 124 |
+
{%- endif -%}
|
| 125 |
+
{{- '[e~[' ~ '\n' }}
|
| 126 |
+
|
| 127 |
+
{%- elif message.role == 'tool' -%}
|
| 128 |
+
{%- if last_tool_call.name is none -%}
|
| 129 |
+
{{- raise_exception("Message has tool role, but there was no previous assistant message with a tool call!") }}
|
| 130 |
+
{%- endif -%}
|
| 131 |
+
{%- if loop.first or (conversation_messages[loop.index0 - 1].role != 'tool') -%}
|
| 132 |
+
{{- ']~b]tool' }}
|
| 133 |
+
{%- endif -%}
|
| 134 |
+
{%- if message.content is string -%}
|
| 135 |
+
{{- '\n<response>' }}
|
| 136 |
+
{{- message.content }}
|
| 137 |
+
{{- '</response>' }}
|
| 138 |
+
{%- else -%}
|
| 139 |
+
{%- for tr in message.content -%}
|
| 140 |
+
{{- '\n<response>' }}
|
| 141 |
+
{{- tr.output if tr.output is defined else (tr.text if tr.type == 'text' and tr.text is defined else tr) }}
|
| 142 |
+
{{- '\n</response>' }}
|
| 143 |
+
{%- endfor -%}
|
| 144 |
+
{%- endif -%}
|
| 145 |
+
{%- if loop.last or (conversation_messages[loop.index0 + 1].role != 'tool') -%}
|
| 146 |
+
{{- '[e~[\n' -}}
|
| 147 |
+
{%- endif -%}
|
| 148 |
+
|
| 149 |
+
{%- elif message.role == 'user' -%}
|
| 150 |
+
{{- ']~b]user' ~ '\n' }}
|
| 151 |
+
{{- visible_text(message.content) }}
|
| 152 |
+
{{- '[e~[' ~ '\n' }}
|
| 153 |
+
{%- endif -%}
|
| 154 |
+
{%- endfor -%}
|
| 155 |
+
|
| 156 |
+
{#- Generation prompt -#}
|
| 157 |
+
{%- if add_generation_prompt -%}
|
| 158 |
+
{{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
|
| 159 |
+
{%- endif -%}
|
config.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 31 |
+
1,
|
| 32 |
+
1,
|
| 33 |
+
1,
|
| 34 |
+
1,
|
| 35 |
+
1,
|
| 36 |
+
1,
|
| 37 |
+
1,
|
| 38 |
+
1,
|
| 39 |
+
1,
|
| 40 |
+
1,
|
| 41 |
+
1,
|
| 42 |
+
1,
|
| 43 |
+
1,
|
| 44 |
+
1,
|
| 45 |
+
1,
|
| 46 |
+
1,
|
| 47 |
+
1,
|
| 48 |
+
1,
|
| 49 |
+
1,
|
| 50 |
+
1,
|
| 51 |
+
1,
|
| 52 |
+
1,
|
| 53 |
+
1,
|
| 54 |
+
1,
|
| 55 |
+
1,
|
| 56 |
+
1,
|
| 57 |
+
1,
|
| 58 |
+
1,
|
| 59 |
+
1,
|
| 60 |
+
1,
|
| 61 |
+
1,
|
| 62 |
+
1,
|
| 63 |
+
1,
|
| 64 |
+
1,
|
| 65 |
+
1,
|
| 66 |
+
1,
|
| 67 |
+
1,
|
| 68 |
+
1,
|
| 69 |
+
1
|
| 70 |
+
],
|
| 71 |
+
"bos_token_id": null,
|
| 72 |
+
"eos_token_id": null,
|
| 73 |
+
"head_dim": 128,
|
| 74 |
+
"hidden_act": "silu",
|
| 75 |
+
"hidden_size": 3072,
|
| 76 |
+
"initializer_range": 0.02,
|
| 77 |
+
"intermediate_size": 1536,
|
| 78 |
+
"layernorm_full_attention_beta": 1.0,
|
| 79 |
+
"layernorm_linear_attention_beta": 1.0,
|
| 80 |
+
"layernorm_mlp_beta": 1.0,
|
| 81 |
+
"max_position_embeddings": 196608,
|
| 82 |
+
"mlp_intermediate_size": 8192,
|
| 83 |
+
"model_type": "mixtral",
|
| 84 |
+
"mtp_transformer_layers": 1,
|
| 85 |
+
"num_attention_heads": 48,
|
| 86 |
+
"num_experts_per_tok": 8,
|
| 87 |
+
"num_hidden_layers": 62,
|
| 88 |
+
"num_key_value_heads": 8,
|
| 89 |
+
"num_local_experts": 256,
|
| 90 |
+
"num_mtp_modules": 3,
|
| 91 |
+
"output_router_logits": false,
|
| 92 |
+
"qk_norm_type": "per_layer",
|
| 93 |
+
"quantization_config": {
|
| 94 |
+
"quant_method": "awq",
|
| 95 |
+
"bits": 4,
|
| 96 |
+
"group_size": 128,
|
| 97 |
+
"version": "gemm",
|
| 98 |
+
"zero_point": true
|
| 99 |
+
},
|
| 100 |
+
"rms_norm_eps": 1e-06,
|
| 101 |
+
"rope_theta": 5000000,
|
| 102 |
+
"rotary_dim": 64,
|
| 103 |
+
"router_aux_loss_coef": 0.001,
|
| 104 |
+
"router_jitter_noise": 0.0,
|
| 105 |
+
"scoring_func": "sigmoid",
|
| 106 |
+
"shared_intermediate_size": 0,
|
| 107 |
+
"shared_moe_mode": "sigmoid",
|
| 108 |
+
"sliding_window": null,
|
| 109 |
+
"tie_word_embeddings": false,
|
| 110 |
+
"transformers_version": "4.46.1",
|
| 111 |
+
"use_cache": true,
|
| 112 |
+
"use_mtp": true,
|
| 113 |
+
"use_qk_norm": true,
|
| 114 |
+
"use_routing_bias": true,
|
| 115 |
+
"vocab_size": 200064,
|
| 116 |
+
"torch_dtype": "float16"
|
| 117 |
+
}
|
docs/function_call_guide.md
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MiniMax-M2 Function Call Guide
|
| 2 |
+
|
| 3 |
+
## Introduction
|
| 4 |
+
|
| 5 |
+
The MiniMax-M2 model supports function calling capabilities, enabling the model to identify when external functions need to be called and output function call parameters in a structured format. This document provides detailed instructions on how to use the function calling features of MiniMax-M2.
|
| 6 |
+
|
| 7 |
+
## Basic Example
|
| 8 |
+
|
| 9 |
+
The following Python script implements a weather query function call example based on the OpenAI SDK:
|
| 10 |
+
|
| 11 |
+
```python
|
| 12 |
+
from openai import OpenAI
|
| 13 |
+
import json
|
| 14 |
+
|
| 15 |
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
|
| 16 |
+
|
| 17 |
+
def get_weather(location: str, unit: str):
|
| 18 |
+
return f"Getting the weather for {location} in {unit}..."
|
| 19 |
+
|
| 20 |
+
tool_functions = {"get_weather": get_weather}
|
| 21 |
+
|
| 22 |
+
tools = [{
|
| 23 |
+
"type": "function",
|
| 24 |
+
"function": {
|
| 25 |
+
"name": "get_weather",
|
| 26 |
+
"description": "Get the current weather in a given location",
|
| 27 |
+
"parameters": {
|
| 28 |
+
"type": "object",
|
| 29 |
+
"properties": {
|
| 30 |
+
"location": {"type": "string", "description": "City and state, e.g., 'San Francisco, CA'"},
|
| 31 |
+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
|
| 32 |
+
},
|
| 33 |
+
"required": ["location", "unit"]
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}]
|
| 37 |
+
|
| 38 |
+
response = client.chat.completions.create(
|
| 39 |
+
model=client.models.list().data[0].id,
|
| 40 |
+
messages=[{"role": "user", "content": "What's the weather like in San Francisco? use celsius."}],
|
| 41 |
+
tools=tools,
|
| 42 |
+
tool_choice="auto"
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
print(response)
|
| 46 |
+
|
| 47 |
+
tool_call = response.choices[0].message.tool_calls[0].function
|
| 48 |
+
print(f"Function called: {tool_call.name}")
|
| 49 |
+
print(f"Arguments: {tool_call.arguments}")
|
| 50 |
+
print(f"Result: {get_weather(**json.loads(tool_call.arguments))}")
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
**Output Example:**
|
| 54 |
+
```
|
| 55 |
+
Function called: get_weather
|
| 56 |
+
Arguments: {"location": "San Francisco, CA", "unit": "celsius"}
|
| 57 |
+
Result: Getting the weather for San Francisco, CA in celsius...
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Manually Parsing Model Output
|
| 61 |
+
|
| 62 |
+
If you cannot use the built-in parser of inference engines that support MiniMax-M2, or need to use other inference frameworks (such as transformers, TGI, etc.), you can manually parse the model's raw output using the following method. This approach requires you to parse the XML tag format of the model output yourself.
|
| 63 |
+
|
| 64 |
+
### Example Using Transformers
|
| 65 |
+
|
| 66 |
+
Here is a complete example using the transformers library:
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from transformers import AutoTokenizer
|
| 70 |
+
|
| 71 |
+
def get_default_tools():
|
| 72 |
+
return [
|
| 73 |
+
{
|
| 74 |
+
"name": "get_current_weather",
|
| 75 |
+
"description": "Get the latest weather for a location",
|
| 76 |
+
"parameters": {
|
| 77 |
+
"type": "object",
|
| 78 |
+
"properties": {
|
| 79 |
+
"location": {
|
| 80 |
+
"type": "string",
|
| 81 |
+
"description": "A certain city, such as Beijing, Shanghai"
|
| 82 |
+
}
|
| 83 |
+
},
|
| 84 |
+
}
|
| 85 |
+
"required": ["location"],
|
| 86 |
+
"type": "object"
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
# Load model and tokenizer
|
| 91 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 92 |
+
prompt = "What's the weather like in Shanghai today?"
|
| 93 |
+
messages = [
|
| 94 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 95 |
+
{"role": "user", "content": prompt},
|
| 96 |
+
]
|
| 97 |
+
|
| 98 |
+
# Enable function calling tools
|
| 99 |
+
tools = get_default_tools()
|
| 100 |
+
|
| 101 |
+
# Apply chat template and include tool definitions
|
| 102 |
+
text = tokenizer.apply_chat_template(
|
| 103 |
+
messages,
|
| 104 |
+
tokenize=False,
|
| 105 |
+
add_generation_prompt=True,
|
| 106 |
+
tools=tools
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# Send request (using any inference service)
|
| 110 |
+
import requests
|
| 111 |
+
payload = {
|
| 112 |
+
"model": "MiniMaxAI/MiniMax-M2",
|
| 113 |
+
"prompt": text,
|
| 114 |
+
"max_tokens": 4096
|
| 115 |
+
}
|
| 116 |
+
response = requests.post(
|
| 117 |
+
"http://localhost:8000/v1/completions",
|
| 118 |
+
headers={"Content-Type": "application/json"},
|
| 119 |
+
json=payload,
|
| 120 |
+
stream=False,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
# Model output needs manual parsing
|
| 124 |
+
raw_output = response.json()["choices"][0]["text"]
|
| 125 |
+
print("Raw output:", raw_output)
|
| 126 |
+
|
| 127 |
+
# Use the parsing function below to process the output
|
| 128 |
+
function_calls = parse_tool_calls(raw_output, tools)
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
## 🛠️ Function Call Definition
|
| 132 |
+
|
| 133 |
+
### Function Structure
|
| 134 |
+
|
| 135 |
+
Function calls need to define the `tools` field in the request body. Each function consists of the following parts:
|
| 136 |
+
|
| 137 |
+
```json
|
| 138 |
+
{
|
| 139 |
+
"tools": [
|
| 140 |
+
{
|
| 141 |
+
"name": "search_web",
|
| 142 |
+
"description": "Search function.",
|
| 143 |
+
"parameters": {
|
| 144 |
+
"properties": {
|
| 145 |
+
"query_list": {
|
| 146 |
+
"description": "Keywords for search, list should contain 1 element.",
|
| 147 |
+
"items": { "type": "string" },
|
| 148 |
+
"type": "array"
|
| 149 |
+
},
|
| 150 |
+
"query_tag": {
|
| 151 |
+
"description": "Category of query",
|
| 152 |
+
"items": { "type": "string" },
|
| 153 |
+
"type": "array"
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
"required": [ "query_list", "query_tag" ],
|
| 157 |
+
"type": "object"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
]
|
| 161 |
+
}
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
**Field Descriptions:**
|
| 165 |
+
- `name`: Function name
|
| 166 |
+
- `description`: Function description
|
| 167 |
+
- `parameters`: Function parameter definition
|
| 168 |
+
- `properties`: Parameter property definition, where key is the parameter name and value contains detailed parameter description
|
| 169 |
+
- `required`: List of required parameters
|
| 170 |
+
- `type`: Parameter type (usually "object")
|
| 171 |
+
|
| 172 |
+
### Internal Processing Format
|
| 173 |
+
|
| 174 |
+
When processing within the MiniMax-M2 model, function definitions are converted to a special format and concatenated to the input text. Here is a complete example:
|
| 175 |
+
|
| 176 |
+
```
|
| 177 |
+
]~!b[]~b]system
|
| 178 |
+
You are a helpful assistant.
|
| 179 |
+
|
| 180 |
+
# Tools
|
| 181 |
+
You may call one or more tools to assist with the user query.
|
| 182 |
+
Here are the tools available in JSONSchema format:
|
| 183 |
+
|
| 184 |
+
<tools>
|
| 185 |
+
<tool>{"name": "search_web", "description": "Search function.", "parameters": {"type": "object", "properties": {"query_list": {"type": "array", "items": {"type": "string"}, "description": "Keywords for search, list should contain 1 element."}, "query_tag": {"type": "array", "items": {"type": "string"}, "description": "Category of query"}}, "required": ["query_list", "query_tag"]}}</tool>
|
| 186 |
+
</tools>
|
| 187 |
+
|
| 188 |
+
When making tool calls, use XML format to invoke tools and pass parameters:
|
| 189 |
+
|
| 190 |
+
<minimax:tool_call>
|
| 191 |
+
<invoke name="tool-name-1">
|
| 192 |
+
<parameter name="param-key-1">param-value-1</parameter>
|
| 193 |
+
<parameter name="param-key-2">param-value-2</parameter>
|
| 194 |
+
...
|
| 195 |
+
</invoke>
|
| 196 |
+
[e~[
|
| 197 |
+
]~b]user
|
| 198 |
+
When were the latest announcements from OpenAI and Gemini?[e~[
|
| 199 |
+
]~b]ai
|
| 200 |
+
<think>
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
**Format Description:**
|
| 204 |
+
|
| 205 |
+
- `]~!b[]~b]system`: System message start marker
|
| 206 |
+
- `[e~[`: Message end marker
|
| 207 |
+
- `]~b]user`: User message start marker
|
| 208 |
+
- `]~b]ai`: Assistant message start marker
|
| 209 |
+
- `]~b]tool`: Tool result message start marker
|
| 210 |
+
- `<tools>...</tools>`: Tool definition area, each tool is wrapped with `<tool>` tag, content is JSON Schema
|
| 211 |
+
- `<minimax:tool_call>...</minimax:tool_call>`: Tool call area
|
| 212 |
+
- `<think>`: Thinking process marker during generation (optional)
|
| 213 |
+
|
| 214 |
+
### Model Output Format
|
| 215 |
+
|
| 216 |
+
MiniMax-M2 uses structured XML tag format:
|
| 217 |
+
|
| 218 |
+
```xml
|
| 219 |
+
<minimax:tool_call>
|
| 220 |
+
<invoke name="search_web">
|
| 221 |
+
<parameter name="query_tag">["technology", "events"]</parameter>
|
| 222 |
+
<parameter name="query_list">["\"OpenAI\" \"latest\" \"release\""]</parameter>
|
| 223 |
+
</invoke>
|
| 224 |
+
<invoke name="search_web">
|
| 225 |
+
<parameter name="query_tag">["technology", "events"]</parameter>
|
| 226 |
+
<parameter name="query_list">["\"Gemini\" \"latest\" \"release\""]</parameter>
|
| 227 |
+
</invoke>
|
| 228 |
+
</minimax:tool_call>
|
| 229 |
+
```
|
| 230 |
+
|
| 231 |
+
Each function call uses the `<invoke name="function_name">` tag, and parameters use the `<parameter name="parameter_name">` tag wrapper.
|
| 232 |
+
|
| 233 |
+
## Manually Parsing Function Call Results
|
| 234 |
+
|
| 235 |
+
### Parsing Function Calls
|
| 236 |
+
|
| 237 |
+
MiniMax-M2 uses structured XML tags, which require a different parsing approach. The core function is as follows:
|
| 238 |
+
|
| 239 |
+
```python
|
| 240 |
+
import re
|
| 241 |
+
import json
|
| 242 |
+
from typing import Any, Optional, List, Dict
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def extract_name(name_str: str) -> str:
|
| 246 |
+
"""Extract name from quoted string"""
|
| 247 |
+
name_str = name_str.strip()
|
| 248 |
+
if name_str.startswith('"') and name_str.endswith('"'):
|
| 249 |
+
return name_str[1:-1]
|
| 250 |
+
elif name_str.startswith("'") and name_str.endswith("'"):
|
| 251 |
+
return name_str[1:-1]
|
| 252 |
+
return name_str
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def convert_param_value(value: str, param_type: str) -> Any:
|
| 256 |
+
"""Convert parameter value based on parameter type"""
|
| 257 |
+
if value.lower() == "null":
|
| 258 |
+
return None
|
| 259 |
+
|
| 260 |
+
param_type = param_type.lower()
|
| 261 |
+
|
| 262 |
+
if param_type in ["string", "str", "text"]:
|
| 263 |
+
return value
|
| 264 |
+
elif param_type in ["integer", "int"]:
|
| 265 |
+
try:
|
| 266 |
+
return int(value)
|
| 267 |
+
except (ValueError, TypeError):
|
| 268 |
+
return value
|
| 269 |
+
elif param_type in ["number", "float"]:
|
| 270 |
+
try:
|
| 271 |
+
val = float(value)
|
| 272 |
+
return val if val != int(val) else int(val)
|
| 273 |
+
except (ValueError, TypeError):
|
| 274 |
+
return value
|
| 275 |
+
elif param_type in ["boolean", "bool"]:
|
| 276 |
+
return value.lower() in ["true", "1"]
|
| 277 |
+
elif param_type in ["object", "array"]:
|
| 278 |
+
try:
|
| 279 |
+
return json.loads(value)
|
| 280 |
+
except json.JSONDecodeError:
|
| 281 |
+
return value
|
| 282 |
+
else:
|
| 283 |
+
# Try JSON parsing, return string if failed
|
| 284 |
+
try:
|
| 285 |
+
return json.loads(value)
|
| 286 |
+
except json.JSONDecodeError:
|
| 287 |
+
return value
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def parse_tool_calls(model_output: str, tools: Optional[List[Dict]] = None) -> List[Dict]:
|
| 291 |
+
"""
|
| 292 |
+
Extract all tool calls from model output
|
| 293 |
+
|
| 294 |
+
Args:
|
| 295 |
+
model_output: Complete output text from the model
|
| 296 |
+
tools: Tool definition list for getting parameter type information, format can be:
|
| 297 |
+
- [{"name": "...", "parameters": {...}}]
|
| 298 |
+
- [{"type": "function", "function": {"name": "...", "parameters": {...}}}]
|
| 299 |
+
|
| 300 |
+
Returns:
|
| 301 |
+
Parsed tool call list, each element contains name and arguments fields
|
| 302 |
+
|
| 303 |
+
Example:
|
| 304 |
+
>>> tools = [{
|
| 305 |
+
... "name": "get_weather",
|
| 306 |
+
... "parameters": {
|
| 307 |
+
... "type": "object",
|
| 308 |
+
... "properties": {
|
| 309 |
+
... "location": {"type": "string"},
|
| 310 |
+
... "unit": {"type": "string"}
|
| 311 |
+
... }
|
| 312 |
+
... }
|
| 313 |
+
... }]
|
| 314 |
+
>>> output = '''<minimax:tool_call>
|
| 315 |
+
... <invoke name="get_weather">
|
| 316 |
+
... <parameter name="location">San Francisco</parameter>
|
| 317 |
+
... <parameter name="unit">celsius</parameter>
|
| 318 |
+
... </invoke>
|
| 319 |
+
... </minimax:tool_call>'''
|
| 320 |
+
>>> result = parse_tool_calls(output, tools)
|
| 321 |
+
>>> print(result)
|
| 322 |
+
[{'name': 'get_weather', 'arguments': {'location': 'San Francisco', 'unit': 'celsius'}}]
|
| 323 |
+
"""
|
| 324 |
+
# Quick check if tool call marker is present
|
| 325 |
+
if "<minimax:tool_call>" not in model_output:
|
| 326 |
+
return []
|
| 327 |
+
|
| 328 |
+
tool_calls = []
|
| 329 |
+
|
| 330 |
+
try:
|
| 331 |
+
# Match all <minimax:tool_call> blocks
|
| 332 |
+
tool_call_regex = re.compile(r"<minimax:tool_call>(.*?)</minimax:tool_call>", re.DOTALL)
|
| 333 |
+
invoke_regex = re.compile(r"<invoke name=(.*?)</invoke>", re.DOTALL)
|
| 334 |
+
parameter_regex = re.compile(r"<parameter name=(.*?)</parameter>", re.DOTALL)
|
| 335 |
+
|
| 336 |
+
# Iterate through all tool_call blocks
|
| 337 |
+
for tool_call_match in tool_call_regex.findall(model_output):
|
| 338 |
+
# Iterate through all invokes in this block
|
| 339 |
+
for invoke_match in invoke_regex.findall(tool_call_match):
|
| 340 |
+
# Extract function name
|
| 341 |
+
name_match = re.search(r'^([^>]+)', invoke_match)
|
| 342 |
+
if not name_match:
|
| 343 |
+
continue
|
| 344 |
+
|
| 345 |
+
function_name = extract_name(name_match.group(1))
|
| 346 |
+
|
| 347 |
+
# Get parameter configuration
|
| 348 |
+
param_config = {}
|
| 349 |
+
if tools:
|
| 350 |
+
for tool in tools:
|
| 351 |
+
tool_name = tool.get("name") or tool.get("function", {}).get("name")
|
| 352 |
+
if tool_name == function_name:
|
| 353 |
+
params = tool.get("parameters") or tool.get("function", {}).get("parameters")
|
| 354 |
+
if isinstance(params, dict) and "properties" in params:
|
| 355 |
+
param_config = params["properties"]
|
| 356 |
+
break
|
| 357 |
+
|
| 358 |
+
# Extract parameters
|
| 359 |
+
param_dict = {}
|
| 360 |
+
for match in parameter_regex.findall(invoke_match):
|
| 361 |
+
param_match = re.search(r'^([^>]+)>(.*)', match, re.DOTALL)
|
| 362 |
+
if param_match:
|
| 363 |
+
param_name = extract_name(param_match.group(1))
|
| 364 |
+
param_value = param_match.group(2).strip()
|
| 365 |
+
|
| 366 |
+
# Remove leading and trailing newlines
|
| 367 |
+
if param_value.startswith('\n'):
|
| 368 |
+
param_value = param_value[1:]
|
| 369 |
+
if param_value.endswith('\n'):
|
| 370 |
+
param_value = param_value[:-1]
|
| 371 |
+
|
| 372 |
+
# Get parameter type and convert
|
| 373 |
+
param_type = "string"
|
| 374 |
+
if param_name in param_config:
|
| 375 |
+
if isinstance(param_config[param_name], dict) and "type" in param_config[param_name]:
|
| 376 |
+
param_type = param_config[param_name]["type"]
|
| 377 |
+
|
| 378 |
+
param_dict[param_name] = convert_param_value(param_value, param_type)
|
| 379 |
+
|
| 380 |
+
tool_calls.append({
|
| 381 |
+
"name": function_name,
|
| 382 |
+
"arguments": param_dict
|
| 383 |
+
})
|
| 384 |
+
|
| 385 |
+
except Exception as e:
|
| 386 |
+
print(f"Failed to parse tool calls: {e}")
|
| 387 |
+
return []
|
| 388 |
+
|
| 389 |
+
return tool_calls
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
**Usage Example:**
|
| 393 |
+
|
| 394 |
+
```python
|
| 395 |
+
# Define tools
|
| 396 |
+
tools = [
|
| 397 |
+
{
|
| 398 |
+
"name": "get_weather",
|
| 399 |
+
"parameters": {
|
| 400 |
+
"type": "object",
|
| 401 |
+
"properties": {
|
| 402 |
+
"location": {"type": "string"},
|
| 403 |
+
"unit": {"type": "string"}
|
| 404 |
+
},
|
| 405 |
+
"required": ["location", "unit"]
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
]
|
| 409 |
+
|
| 410 |
+
# Model output
|
| 411 |
+
model_output = """Let me help you query the weather.
|
| 412 |
+
<minimax:tool_call>
|
| 413 |
+
<invoke name="get_weather">
|
| 414 |
+
<parameter name="location">San Francisco</parameter>
|
| 415 |
+
<parameter name="unit">celsius</parameter>
|
| 416 |
+
</invoke>
|
| 417 |
+
</minimax:tool_call>"""
|
| 418 |
+
|
| 419 |
+
# Parse tool calls
|
| 420 |
+
tool_calls = parse_tool_calls(model_output, tools)
|
| 421 |
+
|
| 422 |
+
# Output results
|
| 423 |
+
for call in tool_calls:
|
| 424 |
+
print(f"Function called: {call['name']}")
|
| 425 |
+
print(f"Arguments: {call['arguments']}")
|
| 426 |
+
# Output: Function called: get_weather
|
| 427 |
+
# Arguments: {'location': 'San Francisco', 'unit': 'celsius'}
|
| 428 |
+
```
|
| 429 |
+
|
| 430 |
+
### Executing Function Calls
|
| 431 |
+
|
| 432 |
+
After parsing is complete, you can execute the corresponding function and construct the return result:
|
| 433 |
+
|
| 434 |
+
```python
|
| 435 |
+
def execute_function_call(function_name: str, arguments: dict):
|
| 436 |
+
"""Execute function call and return result"""
|
| 437 |
+
if function_name == "get_weather":
|
| 438 |
+
location = arguments.get("location", "Unknown location")
|
| 439 |
+
unit = arguments.get("unit", "celsius")
|
| 440 |
+
# Build function execution result
|
| 441 |
+
return {
|
| 442 |
+
"role": "tool",
|
| 443 |
+
"content": [
|
| 444 |
+
{
|
| 445 |
+
"name": function_name,
|
| 446 |
+
"type": "text",
|
| 447 |
+
"text": json.dumps({
|
| 448 |
+
"location": location,
|
| 449 |
+
"temperature": "25",
|
| 450 |
+
"unit": unit,
|
| 451 |
+
"weather": "Sunny"
|
| 452 |
+
}, ensure_ascii=False)
|
| 453 |
+
}
|
| 454 |
+
]
|
| 455 |
+
}
|
| 456 |
+
elif function_name == "search_web":
|
| 457 |
+
query_list = arguments.get("query_list", [])
|
| 458 |
+
query_tag = arguments.get("query_tag", [])
|
| 459 |
+
# Simulate search results
|
| 460 |
+
return {
|
| 461 |
+
"role": "tool",
|
| 462 |
+
"content": [
|
| 463 |
+
{
|
| 464 |
+
"name": function_name,
|
| 465 |
+
"type": "text",
|
| 466 |
+
"text": f"Search keywords: {query_list}, Category: {query_tag}\nSearch results: Relevant information found"
|
| 467 |
+
}
|
| 468 |
+
]
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
return None
|
| 472 |
+
```
|
| 473 |
+
|
| 474 |
+
### Returning Function Execution Results to the Model
|
| 475 |
+
|
| 476 |
+
After successfully parsing function calls, you should add the function execution results to the conversation history so that the model can access and utilize this information in subsequent interactions. Refer to chat_template.jinja for concatenation format.
|
| 477 |
+
|
| 478 |
+
## References
|
| 479 |
+
|
| 480 |
+
- [MiniMax-M2 Model Repository](https://github.com/MiniMax-AI/MiniMax-M2)
|
| 481 |
+
- [vLLM Project Homepage](https://github.com/vllm-project/vllm)
|
| 482 |
+
- [OpenAI Python SDK](https://github.com/openai/openai-python)
|
docs/vllm_deploy_guide.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MiniMax M2 Model vLLM Deployment Guide
|
| 2 |
+
|
| 3 |
+
We recommend using [vLLM](https://docs.vllm.ai/en/stable/) to deploy the [MiniMax-M2](https://huggingface.co/MiniMaxAI/MiniMax-M2) model. vLLM is a high-performance inference engine with excellent serving throughput, efficient and intelligent memory management, powerful batch request processing capabilities, and deeply optimized underlying performance. We recommend reviewing vLLM's official documentation to check hardware compatibility before deployment.
|
| 4 |
+
|
| 5 |
+
## System Requirements
|
| 6 |
+
|
| 7 |
+
- OS: Linux
|
| 8 |
+
|
| 9 |
+
- Python: 3.9 - 3.12
|
| 10 |
+
|
| 11 |
+
- GPU:
|
| 12 |
+
|
| 13 |
+
- compute capability 7.0 or higher
|
| 14 |
+
|
| 15 |
+
- Memory requirements: 220 GB for weights, 60 GB per 1M context tokens
|
| 16 |
+
|
| 17 |
+
The following are recommended configurations; actual requirements should be adjusted based on your use case:
|
| 18 |
+
|
| 19 |
+
- 4x 96GB GPUs: Supports context input of up to 400K tokens.
|
| 20 |
+
|
| 21 |
+
- 8x 144GB GPUs: Supports context input of up to 3M tokens.
|
| 22 |
+
|
| 23 |
+
## Deployment with Python
|
| 24 |
+
|
| 25 |
+
It is recommended to use a virtual environment (such as venv, conda, or uv) to avoid dependency conflicts. We recommend installing vLLM in a fresh Python environment:
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
# Not yet released, please install nightly build
|
| 29 |
+
uv pip install -U vllm \
|
| 30 |
+
--torch-backend=auto \
|
| 31 |
+
--extra-index-url https://wheels.vllm.ai/nightly
|
| 32 |
+
# If released, install using uv
|
| 33 |
+
uv pip install "vllm" --torch-backend=auto
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
Run the following command to start the vLLM server. vLLM will automatically download and cache the MiniMax-M2 model from Hugging Face.
|
| 37 |
+
|
| 38 |
+
4-GPU deployment command:
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
SAFETENSORS_FAST_GPU=1 VLLM_USE_V1=0 vllm serve \
|
| 42 |
+
--model MiniMaxAI/MiniMax-M2 \
|
| 43 |
+
--trust-remote-code \
|
| 44 |
+
--enable-expert-parallel --tensor-parallel-size 4 \
|
| 45 |
+
--enable-auto-tool-choice --tool-call-parser minimax_m2 \
|
| 46 |
+
--reasoning-parser minimax_m2
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
## Testing Deployment
|
| 50 |
+
|
| 51 |
+
After startup, you can test the vLLM OpenAI-compatible API with the following command:
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
curl http://localhost:8000/v1/chat/completions \
|
| 55 |
+
-H "Content-Type: application/json" \
|
| 56 |
+
-d '{
|
| 57 |
+
"model": "MiniMaxAI/MiniMax-M2",
|
| 58 |
+
"messages": [
|
| 59 |
+
{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}]},
|
| 60 |
+
{"role": "user", "content": [{"type": "text", "text": "Who won the world series in 2020?"}]}
|
| 61 |
+
]
|
| 62 |
+
}'
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Common Issues
|
| 66 |
+
|
| 67 |
+
### Hugging Face Network Issues
|
| 68 |
+
|
| 69 |
+
If you encounter network issues, you can set up a proxy before pulling the model.
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
export HF_ENDPOINT=https://hf-mirror.com
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### MiniMax-M2 model is not currently supported
|
| 76 |
+
|
| 77 |
+
This vLLM version is outdated. Please upgrade to the latest version.
|
| 78 |
+
|
| 79 |
+
## Getting Support
|
| 80 |
+
|
| 81 |
+
If you encounter any issues while deploying the MiniMax model:
|
| 82 |
+
|
| 83 |
+
- Contact our technical support team through official channels such as email at api@minimaxi.com
|
| 84 |
+
|
| 85 |
+
- Submit an issue on our [GitHub](https://github.com/MiniMax-AI) repository
|
| 86 |
+
|
| 87 |
+
We continuously optimize the deployment experience for our models. Feedback is welcome!
|
| 88 |
+
|
figures/Bench.png
ADDED
|
Git LFS Details
|
model-00001-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1bb5393a7818d3160927d830676cbfb166032ec18fd92d13b3f27c4fead0987
|
| 3 |
+
size 2998507472
|
model-00002-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0548c74136e47f31d99f1ec36e2f7ba26af4607dba634f0d53aad4d2542d26e
|
| 3 |
+
size 3000140360
|
model-00003-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:501907424df6366c8347ab5563c87be221fc943425f9b63beda480e5cefcd6e2
|
| 3 |
+
size 2999224328
|
model-00004-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ad6ba2e48b9f3694285125fc8f775477aa5d9f8c6f2fb722622d0b77483efbd
|
| 3 |
+
size 3000139080
|
model-00005-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbad54e6e5b5e458182b0ae33394a7bff87f02be2709913d7d0e3bd6f9464338
|
| 3 |
+
size 2999224664
|
model-00006-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:559f18c233a7a3b23270cb5078cdb2a0d459a4096006bc86bcdaca31a611476c
|
| 3 |
+
size 2999223312
|
model-00007-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bff913bf65ab332dfb0ea6eaf76cc4c7b57389c6df7beb80e631cca298d3e1cd
|
| 3 |
+
size 3000141216
|
model-00008-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:353643fc6a9a90c7e2b098d3f272e7f312fc5a3d367a5255bd9fd2b0bea52a8c
|
| 3 |
+
size 2999226896
|
model-00009-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b8c84b2ee3746464971bf11e3ef07ba26ae0b8845882602c5ca2cbad2e09ca1
|
| 3 |
+
size 3000144016
|
model-00010-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a2a546c16ae0aefe42d03d3812473b1baf3286d7b7a8b12082731a9c083ea0c
|
| 3 |
+
size 2999227968
|
model-00015-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:24fba6f5010a7d2aff61906259532594faddf86cce972a90af6971f7fd96232b
|
| 3 |
+
size 2999226896
|
model-00040-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c2bddb39d77fe9b52719bd5e4404da0709846b34c941cb012544fde683d453a
|
| 3 |
+
size 2606931696
|
model-00041-of-00041.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9a14e18c736c0fadff1985dd1826447c2e593564d68ab10b844177325c854e5
|
| 3 |
+
size 1229199576
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid s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|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"200000": {
|
| 4 |
+
"content": "]!p~[",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"200001": {
|
| 12 |
+
"content": "<fim_prefix>",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"200002": {
|
| 20 |
+
"content": "<fim_middle>",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"200003": {
|
| 28 |
+
"content": "<fim_suffix>",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"200004": {
|
| 36 |
+
"content": "<fim_pad>",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"200005": {
|
| 44 |
+
"content": "<reponame>",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"200006": {
|
| 52 |
+
"content": "<filename>",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
},
|
| 59 |
+
"200007": {
|
| 60 |
+
"content": "<gh_stars>",
|
| 61 |
+
"lstrip": false,
|
| 62 |
+
"normalized": false,
|
| 63 |
+
"rstrip": false,
|
| 64 |
+
"single_word": false,
|
| 65 |
+
"special": true
|
| 66 |
+
},
|
| 67 |
+
"200008": {
|
| 68 |
+
"content": "<issue_start>",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false,
|
| 73 |
+
"special": true
|
| 74 |
+
},
|
| 75 |
+
"200009": {
|
| 76 |
+
"content": "<issue_comment>",
|
| 77 |
+
"lstrip": false,
|
| 78 |
+
"normalized": false,
|
| 79 |
+
"rstrip": false,
|
| 80 |
+
"single_word": false,
|
| 81 |
+
"special": true
|
| 82 |
+
},
|
| 83 |
+
"200010": {
|
| 84 |
+
"content": "<issue_closed>",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"200011": {
|
| 92 |
+
"content": "<jupyter_start>",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"200012": {
|
| 100 |
+
"content": "<jupyter_text>",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"200013": {
|
| 108 |
+
"content": "<jupyter_code>",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"200014": {
|
| 116 |
+
"content": "<jupyter_output>",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"200015": {
|
| 124 |
+
"content": "<empty_output>",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"200016": {
|
| 132 |
+
"content": "<commit_before>",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"200017": {
|
| 140 |
+
"content": "<commit_msg>",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"200018": {
|
| 148 |
+
"content": "<commit_after>",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"200019": {
|
| 156 |
+
"content": "]~b]",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"200020": {
|
| 164 |
+
"content": "[e~[",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"200021": {
|
| 172 |
+
"content": "]!d~[",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"200022": {
|
| 180 |
+
"content": "<function_call>",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"200023": {
|
| 188 |
+
"content": "<code_interpreter>",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"200024": {
|
| 196 |
+
"content": "]<]speech[>[",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"200025": {
|
| 204 |
+
"content": "]<]image[>[",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"200026": {
|
| 212 |
+
"content": "]<]video[>[",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"200027": {
|
| 220 |
+
"content": "]<]start of speech[>[",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"200028": {
|
| 228 |
+
"content": "]<]end of speech[>[",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"200029": {
|
| 236 |
+
"content": "]<]start of image[>[",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"200030": {
|
| 244 |
+
"content": "]<]end of image[>[",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"200031": {
|
| 252 |
+
"content": "]<]start of video[>[",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"200032": {
|
| 260 |
+
"content": "]<]end of video[>[",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"200033": {
|
| 268 |
+
"content": "]<]vision pad[>[",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"200034": {
|
| 276 |
+
"content": "]~!b[",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"200035": {
|
| 284 |
+
"content": "<jupyter_error>",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"200036": {
|
| 292 |
+
"content": "<add_file>",
|
| 293 |
+
"single_word": false,
|
| 294 |
+
"lstrip": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"normalized": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"200037": {
|
| 300 |
+
"content": "<delete_file>",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"200038": {
|
| 308 |
+
"content": "<rename_file>",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"200039": {
|
| 316 |
+
"content": "<edit_file>",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"200040": {
|
| 324 |
+
"content": "<commit_message>",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"200041": {
|
| 332 |
+
"content": "<empty_source_file>",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"200042": {
|
| 340 |
+
"content": "<repo_struct>",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"200043": {
|
| 348 |
+
"content": "<code_context>",
|
| 349 |
+
"single_word": false,
|
| 350 |
+
"lstrip": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"normalized": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"200044": {
|
| 356 |
+
"content": "<file_content>",
|
| 357 |
+
"single_word": false,
|
| 358 |
+
"lstrip": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"normalized": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"200045": {
|
| 364 |
+
"content": "<source_files>",
|
| 365 |
+
"single_word": false,
|
| 366 |
+
"lstrip": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"normalized": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"200046": {
|
| 372 |
+
"content": "<pr_start>",
|
| 373 |
+
"single_word": false,
|
| 374 |
+
"lstrip": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"normalized": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"200047": {
|
| 380 |
+
"content": "<review_comment>",
|
| 381 |
+
"single_word": false,
|
| 382 |
+
"lstrip": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"normalized": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"200048": {
|
| 388 |
+
"content": "<filepath>",
|
| 389 |
+
"single_word": false,
|
| 390 |
+
"lstrip": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"normalized": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"200049": {
|
| 396 |
+
"content": "<file_sep>",
|
| 397 |
+
"single_word": false,
|
| 398 |
+
"lstrip": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"normalized": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"200050": {
|
| 404 |
+
"content": "<think>",
|
| 405 |
+
"single_word": false,
|
| 406 |
+
"lstrip": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"normalized": false,
|
| 409 |
+
"special": false
|
| 410 |
+
},
|
| 411 |
+
"200051": {
|
| 412 |
+
"content": "</think>",
|
| 413 |
+
"single_word": false,
|
| 414 |
+
"lstrip": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"normalized": false,
|
| 417 |
+
"special": false
|
| 418 |
+
},
|
| 419 |
+
"200052": {
|
| 420 |
+
"content": "<minimax:tool_call>",
|
| 421 |
+
"single_word": false,
|
| 422 |
+
"lstrip": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"normalized": false,
|
| 425 |
+
"special": false
|
| 426 |
+
},
|
| 427 |
+
"200053": {
|
| 428 |
+
"content": "</minimax:tool_call>",
|
| 429 |
+
"single_word": false,
|
| 430 |
+
"lstrip": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"normalized": false,
|
| 433 |
+
"special": false
|
| 434 |
+
}
|
| 435 |
+
},
|
| 436 |
+
"additional_special_tokens": [
|
| 437 |
+
"<code_interpreter>",
|
| 438 |
+
"<commit_after>",
|
| 439 |
+
"<commit_before>",
|
| 440 |
+
"<commit_msg>",
|
| 441 |
+
"<empty_output>",
|
| 442 |
+
"<filename>",
|
| 443 |
+
"<fim_middle>",
|
| 444 |
+
"<fim_pad>",
|
| 445 |
+
"<fim_prefix>",
|
| 446 |
+
"<fim_suffix>",
|
| 447 |
+
"<function_call>",
|
| 448 |
+
"<gh_stars>",
|
| 449 |
+
"]<]speech[>[",
|
| 450 |
+
"]<]image[>[",
|
| 451 |
+
"]<]video[>[",
|
| 452 |
+
"]<]start of speech[>[",
|
| 453 |
+
"]<]end of speech[>[",
|
| 454 |
+
"]<]start of image[>[",
|
| 455 |
+
"]<]end of image[>[",
|
| 456 |
+
"]<]start of video[>[",
|
| 457 |
+
"]<]end of video[>[",
|
| 458 |
+
"]<]vision pad[>[",
|
| 459 |
+
"]~!b[",
|
| 460 |
+
"<issue_closed>",
|
| 461 |
+
"<issue_comment>",
|
| 462 |
+
"<issue_start>",
|
| 463 |
+
"<jupyter_code>",
|
| 464 |
+
"<jupyter_output>",
|
| 465 |
+
"<jupyter_start>",
|
| 466 |
+
"<jupyter_text>",
|
| 467 |
+
"<reponame>",
|
| 468 |
+
"[e~[",
|
| 469 |
+
"]!d~[",
|
| 470 |
+
"]!p~[",
|
| 471 |
+
"]~b]",
|
| 472 |
+
"<jupyter_error>",
|
| 473 |
+
"<add_file>",
|
| 474 |
+
"<delete_file>",
|
| 475 |
+
"<rename_file>",
|
| 476 |
+
"<edit_file>",
|
| 477 |
+
"<commit_message>",
|
| 478 |
+
"<empty_source_file>",
|
| 479 |
+
"<repo_struct>",
|
| 480 |
+
"<code_context>",
|
| 481 |
+
"<file_content>",
|
| 482 |
+
"<source_files>",
|
| 483 |
+
"<pr_start>",
|
| 484 |
+
"<review_comment>",
|
| 485 |
+
"<filepath>",
|
| 486 |
+
"<file_sep>"
|
| 487 |
+
],
|
| 488 |
+
"add_prefix_space": false,
|
| 489 |
+
"bos_token": "]~!b[",
|
| 490 |
+
"clean_up_tokenization_spaces": false,
|
| 491 |
+
"eos_token": "[e~[",
|
| 492 |
+
"model_max_length": 40960000,
|
| 493 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 494 |
+
"unk_token": "]!d~["
|
| 495 |
+
}
|