jingyaogong commited on
Commit
813c332
·
1 Parent(s): 10197e9

[update] minimind-3

Browse files
app.py CHANGED
@@ -1,36 +1,56 @@
1
  import random
2
  import re
 
 
3
  from threading import Thread
4
 
5
  import torch
6
  import numpy as np
7
  import streamlit as st
 
8
 
9
  st.set_page_config(page_title="MiniMind", initial_sidebar_state="collapsed")
10
 
11
  st.markdown("""
12
  <style>
13
- /* 调整主容器边距,避免溢出 */
14
- .stMainBlockContainer {
15
- padding-top: 3rem !important;
16
- padding-bottom: 0rem !important;
 
 
 
 
 
 
 
 
 
 
17
  }
18
-
19
- /* 调整应用容器,避免顶部内容被遮挡 */
20
- .stApp {
21
- overflow-y: auto !important;
 
 
 
 
 
 
22
  }
23
 
24
- /* 操作按钮样式 */
25
  .stButton > button {
 
26
  box-sizing: border-box !important;
27
  border-radius: 50% !important;
28
- width: 24px !important;
29
- height: 24px !important;
30
- min-width: 24px !important;
31
- min-height: 24px !important;
32
- max-width: 24px !important;
33
- max-height: 24px !important;
34
  padding: 0 !important;
35
  background-color: transparent !important;
36
  border: 1px solid #ddd !important;
@@ -41,54 +61,136 @@ st.markdown("""
41
  color: #888 !important;
42
  cursor: pointer !important;
43
  transition: all 0.2s ease !important;
44
- margin: 2px !important;
45
- }
46
-
47
- .stButton > button:hover {
48
- border-color: #999 !important;
49
- color: #333 !important;
50
- background-color: #f5f5f5 !important;
51
- }
52
-
53
- /* 确保聊天容器不溢出 */
54
- .stChatMessage {
55
- max-width: 100% !important;
56
- }
57
-
58
- /* 侧边栏样式优化 */
59
- section[data-testid="stSidebar"] {
60
- overflow-y: auto !important;
61
  }
 
62
  </style>
63
  """, unsafe_allow_html=True)
64
 
65
- system_prompt = []
66
  device = "cuda" if torch.cuda.is_available() else "cpu"
67
 
68
-
69
- def process_assistant_content(content):
70
- if model_source == "API" and 'R1' not in api_model_name:
71
- return content
72
- if model_source != "API" and 'R1' not in MODEL_PATHS[selected_model][1]:
73
- return content
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  if '<think>' in content and '</think>' in content:
76
- content = re.sub(r'(<think>)(.*?)(</think>)',
77
- r'<details style="font-style: italic; background: rgba(222, 222, 222, 0.5); padding: 10px; border-radius: 10px;"><summary style="font-weight:bold;">推理内容(展开)</summary>\2</details>',
78
- content,
79
- flags=re.DOTALL)
 
 
80
 
81
  if '<think>' in content and '</think>' not in content:
82
- content = re.sub(r'<think>(.*?)$',
83
- r'<details open style="font-style: italic; background: rgba(222, 222, 222, 0.5); padding: 10px; border-radius: 10px;"><summary style="font-weight:bold;">推理中...</summary>\1</details>',
84
- content,
85
- flags=re.DOTALL)
86
 
87
  if '<think>' not in content and '</think>' in content:
88
- content = re.sub(r'(.*?)</think>',
89
- r'<details style="font-style: italic; background: rgba(222, 222, 222, 0.5); padding: 10px; border-radius: 10px;"><summary style="font-weight:bold;">推理内容(展开)</summary>\1</details>',
90
- content,
91
- flags=re.DOTALL)
 
 
92
 
93
  return content
94
 
@@ -116,17 +218,10 @@ def init_chat_messages():
116
  if "messages" in st.session_state:
117
  for i, message in enumerate(st.session_state.messages):
118
  if message["role"] == "assistant":
119
- with st.chat_message("assistant", avatar=image_url):
120
- st.markdown(process_assistant_content(message["content"]), unsafe_allow_html=True)
121
- if st.button("🗑", key=f"delete_{i}"):
122
- st.session_state.messages.pop(i)
123
- st.session_state.messages.pop(i - 1)
124
- st.session_state.chat_messages.pop(i)
125
- st.session_state.chat_messages.pop(i - 1)
126
- st.rerun()
127
  else:
128
  st.markdown(
129
- f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: #ddd; border-radius: 10px; color: black;">{message["content"]}</div></div>',
130
  unsafe_allow_html=True)
131
 
132
  else:
@@ -135,56 +230,70 @@ def init_chat_messages():
135
 
136
  return st.session_state.messages
137
 
138
-
139
  def regenerate_answer(index):
140
  st.session_state.messages.pop()
141
  st.session_state.chat_messages.pop()
142
  st.rerun()
143
 
144
 
145
- def delete_conversation(index):
146
- st.session_state.messages.pop(index)
147
- st.session_state.messages.pop(index - 1)
148
- st.session_state.chat_messages.pop(index)
149
- st.session_state.chat_messages.pop(index - 1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  st.rerun()
151
 
 
152
 
153
- st.sidebar.title("模型设定调整")
154
-
155
- # st.sidebar.text("训练数据偏差,增加上下文记忆时\n多轮对话(较单轮)容易出现能力衰减")
156
- st.session_state.history_chat_num = st.sidebar.slider("Number of Historical Dialogues", 0, 6, 0, step=2)
157
- # st.session_state.history_chat_num = 0
158
- st.session_state.max_new_tokens = st.sidebar.slider("Max Sequence Length", 256, 8192, 8192, step=1)
159
- st.session_state.temperature = st.sidebar.slider("Temperature", 0.6, 1.2, 0.85, step=0.01)
160
 
161
- model_source = st.sidebar.radio("选择模型来源", ["本地模型", "API"], index=0)
162
-
163
- if model_source == "API":
164
- api_url = st.sidebar.text_input("API URL", value="http://127.0.0.1:8000/v1")
165
- api_model_id = st.sidebar.text_input("Model ID", value="minimind")
166
- api_model_name = st.sidebar.text_input("Model Name", value="MiniMind2")
167
- api_key = st.sidebar.text_input("API Key", value="none", type="password")
168
- slogan = f"Hi, I'm {api_model_name}"
169
- else:
170
- MODEL_PATHS = {
171
- "MiniMind2 (0.1B)": ["./MiniMind2", "MiniMind2"],
172
- "MiniMind2-R1 (0.1B)": ["./MiniMind2-R1", "MiniMind2-R1"]
173
- }
174
 
175
- selected_model = st.sidebar.selectbox('Models', list(MODEL_PATHS.keys()), index=0) # 默认选择 MiniMind2
176
- model_path = MODEL_PATHS[selected_model][0]
177
- slogan = f"Hi, I'm {MODEL_PATHS[selected_model][1]}"
 
 
 
 
 
 
 
 
 
178
 
179
  image_url = "https://www.modelscope.cn/api/v1/studio/gongjy/MiniMind/repo?Revision=master&FilePath=images%2Flogo2.png&View=true"
180
 
181
  st.markdown(
182
  f'<div style="display: flex; flex-direction: column; align-items: center; text-align: center; margin: 0; padding: 0;">'
183
  '<div style="font-style: italic; font-weight: 900; margin: 0; padding-top: 4px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%;">'
184
- f'<img src="{image_url}" style="width: 45px; height: 45px; "> '
185
  f'<span style="font-size: 26px; margin-left: 10px;">{slogan}</span>'
186
  '</div>'
187
- '<span style="color: #bbb; font-style: italic; margin-top: 6px; margin-bottom: 10px;">内容完全由AI生成,请务必仔细甄别<br>Content AI-generated, please discern with care</span>'
188
  '</div>',
189
  unsafe_allow_html=True
190
  )
@@ -201,10 +310,7 @@ def setup_seed(seed):
201
 
202
 
203
  def main():
204
- if model_source == "本地模型":
205
- model, tokenizer = load_model_tokenizer(model_path)
206
- else:
207
- model, tokenizer = None, None
208
 
209
  if "messages" not in st.session_state:
210
  st.session_state.messages = []
@@ -214,18 +320,13 @@ def main():
214
 
215
  for i, message in enumerate(messages):
216
  if message["role"] == "assistant":
217
- with st.chat_message("assistant", avatar=image_url):
218
- st.markdown(process_assistant_content(message["content"]), unsafe_allow_html=True)
219
- if st.button("×", key=f"delete_{i}"):
220
- st.session_state.messages = st.session_state.messages[:i - 1]
221
- st.session_state.chat_messages = st.session_state.chat_messages[:i - 1]
222
- st.rerun()
223
  else:
224
  st.markdown(
225
- f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: gray; border-radius: 10px; color:white; ">{message["content"]}</div></div>',
226
  unsafe_allow_html=True)
227
 
228
- prompt = st.chat_input(key="input", placeholder="给 MiniMind 发送消息")
229
 
230
  if hasattr(st.session_state, 'regenerate') and st.session_state.regenerate:
231
  prompt = st.session_state.last_user_message
@@ -236,89 +337,84 @@ def main():
236
 
237
  if prompt:
238
  st.markdown(
239
- f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: gray; border-radius: 10px; color:white; ">{prompt}</div></div>',
240
  unsafe_allow_html=True)
241
  messages.append({"role": "user", "content": prompt[-st.session_state.max_new_tokens:]})
242
  st.session_state.chat_messages.append({"role": "user", "content": prompt[-st.session_state.max_new_tokens:]})
243
 
244
- with st.chat_message("assistant", avatar=image_url):
245
- placeholder = st.empty()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
- if model_source == "API":
248
- try:
249
- from openai import OpenAI
250
-
251
- client = OpenAI(
252
- api_key=api_key,
253
- base_url=api_url
254
- )
255
- history_num = st.session_state.history_chat_num + 1 # +1 是为了包含当前的用户消息
256
- conversation_history = system_prompt + st.session_state.chat_messages[-history_num:]
257
- answer = ""
258
- response = client.chat.completions.create(
259
- model=api_model_id,
260
- messages=conversation_history,
261
- stream=True,
262
- temperature=st.session_state.temperature
263
- )
264
-
265
- for chunk in response:
266
- content = chunk.choices[0].delta.content or ""
267
- answer += content
268
- placeholder.markdown(process_assistant_content(answer), unsafe_allow_html=True)
269
-
270
- except Exception as e:
271
- answer = f"API调用出错: {str(e)}"
272
- placeholder.markdown(answer, unsafe_allow_html=True)
273
- else:
274
- random_seed = random.randint(0, 2 ** 32 - 1)
275
- setup_seed(random_seed)
276
-
277
- st.session_state.chat_messages = system_prompt + st.session_state.chat_messages[
278
- -(st.session_state.history_chat_num + 1):]
279
- new_prompt = tokenizer.apply_chat_template(
280
- st.session_state.chat_messages,
281
- tokenize=False,
282
- add_generation_prompt=True
283
- )
284
-
285
- inputs = tokenizer(
286
- new_prompt,
287
- return_tensors="pt",
288
- truncation=True
289
- ).to(device)
290
-
291
- streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
292
- generation_kwargs = {
293
- "input_ids": inputs.input_ids,
294
- "max_length": inputs.input_ids.shape[1] + st.session_state.max_new_tokens,
295
- "num_return_sequences": 1,
296
- "do_sample": True,
297
- "attention_mask": inputs.attention_mask,
298
- "pad_token_id": tokenizer.pad_token_id,
299
- "eos_token_id": tokenizer.eos_token_id,
300
- "temperature": st.session_state.temperature,
301
- "top_p": 0.85,
302
- "streamer": streamer,
303
- }
304
-
305
- Thread(target=model.generate, kwargs=generation_kwargs).start()
306
-
307
- answer = ""
308
- for new_text in streamer:
309
- answer += new_text
310
- placeholder.markdown(process_assistant_content(answer), unsafe_allow_html=True)
311
-
312
- messages.append({"role": "assistant", "content": answer})
313
  st.session_state.chat_messages.append({"role": "assistant", "content": answer})
314
- with st.empty():
315
- if st.button("×", key=f"delete_{len(messages) - 1}"):
316
- st.session_state.messages = st.session_state.messages[:-2]
317
- st.session_state.chat_messages = st.session_state.chat_messages[:-2]
318
- st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
 
320
 
321
  if __name__ == "__main__":
322
- from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
323
-
324
- main()
 
1
  import random
2
  import re
3
+ import json
4
+ import os
5
  from threading import Thread
6
 
7
  import torch
8
  import numpy as np
9
  import streamlit as st
10
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
11
 
12
  st.set_page_config(page_title="MiniMind", initial_sidebar_state="collapsed")
13
 
14
  st.markdown("""
15
  <style>
16
+ /* 添加操作按钮样式 */
17
+ .stButton button {
18
+ border-radius: 50% !important; /* 改为圆形 */
19
+ width: 32px !important; /* 固定宽度 */
20
+ height: 32px !important; /* 固定高度 */
21
+ padding: 0 !important; /* 移除内边距 */
22
+ background-color: transparent !important;
23
+ border: 1px solid #ddd !important;
24
+ display: flex !important;
25
+ align-items: center !important;
26
+ justify-content: center !important;
27
+ font-size: 14px !important;
28
+ color: #666 !important; /* 更柔和的颜色 */
29
+ margin: 5px 10px 5px 0 !important; /* 调整按钮间距 */
30
  }
31
+ .stButton button:hover {
32
+ border-color: #999 !important;
33
+ color: #333 !important;
34
+ background-color: #f5f5f5 !important;
35
+ }
36
+ .stMainBlockContainer > div:first-child {
37
+ margin-top: -50px !important;
38
+ }
39
+ .stApp > div:last-child {
40
+ margin-bottom: -35px !important;
41
  }
42
 
43
+ /* 重置按钮基础样式 */
44
  .stButton > button {
45
+ all: unset !important; /* 重置所有默认样式 */
46
  box-sizing: border-box !important;
47
  border-radius: 50% !important;
48
+ width: 18px !important;
49
+ height: 18px !important;
50
+ min-width: 18px !important;
51
+ min-height: 18px !important;
52
+ max-width: 18px !important;
53
+ max-height: 18px !important;
54
  padding: 0 !important;
55
  background-color: transparent !important;
56
  border: 1px solid #ddd !important;
 
61
  color: #888 !important;
62
  cursor: pointer !important;
63
  transition: all 0.2s ease !important;
64
+ margin: 0 2px !important; /* 调整这里的 margin 值 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
+
67
  </style>
68
  """, unsafe_allow_html=True)
69
 
 
70
  device = "cuda" if torch.cuda.is_available() else "cpu"
71
 
72
+ # 多语言文本
73
+ LANG_TEXTS = {
74
+ 'zh': {
75
+ 'settings': '模型设定调整',
76
+ 'history_rounds': '历史对话轮次',
77
+ 'max_length': '最大生成长度',
78
+ 'temperature': '温度',
79
+ 'thinking': '思考',
80
+ 'tools': '工具',
81
+ 'language': '语言',
82
+ 'send': '给 MiniMind 发送消息',
83
+ 'disclaimer': 'AI 生成内容可能存在错误,请仔细核实',
84
+ 'think_tip': '自适应思考,目前多轮对话或Tool Call共存时思考不稳定',
85
+ 'tool_select': '工具选择(最多4个)',
86
+ },
87
+ 'en': {
88
+ 'settings': 'Model Settings',
89
+ 'history_rounds': 'History Rounds',
90
+ 'max_length': 'Max Length',
91
+ 'temperature': 'Temperature',
92
+ 'thinking': 'Thinking',
93
+ 'tools': 'Tools',
94
+ 'language': 'Language',
95
+ 'send': 'Send a message to MiniMind',
96
+ 'disclaimer': 'AI-generated content may be inaccurate, please verify',
97
+ 'think_tip': 'Adaptive thinking; may be unstable with multi-turn or Tool Call',
98
+ 'tool_select': 'Tool Selection (max 4)',
99
+ }
100
+ }
101
+
102
+ def get_text(key):
103
+ lang = st.session_state.get('lang', 'en')
104
+ return LANG_TEXTS.get(lang, {}).get(key, LANG_TEXTS['zh'].get(key, key))
105
+
106
+ # 工具定义
107
+ TOOLS = [
108
+ {"type": "function", "function": {"name": "calculate_math", "description": "计算数学表达式", "parameters": {"type": "object", "properties": {"expression": {"type": "string", "description": "数学表达式"}}, "required": ["expression"]}}},
109
+ {"type": "function", "function": {"name": "get_current_time", "description": "获取当前时间", "parameters": {"type": "object", "properties": {"timezone": {"type": "string", "default": "Asia/Shanghai"}}, "required": []}}},
110
+ {"type": "function", "function": {"name": "random_number", "description": "生成随机数", "parameters": {"type": "object", "properties": {"min": {"type": "integer"}, "max": {"type": "integer"}}, "required": ["min", "max"]}}},
111
+ {"type": "function", "function": {"name": "text_length", "description": "计算文本长度", "parameters": {"type": "object", "properties": {"text": {"type": "string"}}, "required": ["text"]}}},
112
+ {"type": "function", "function": {"name": "unit_converter", "description": "单位转换", "parameters": {"type": "object", "properties": {"value": {"type": "number"}, "from_unit": {"type": "string"}, "to_unit": {"type": "string"}}, "required": ["value", "from_unit", "to_unit"]}}},
113
+ {"type": "function", "function": {"name": "get_current_weather", "description": "获取天气", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}},
114
+ {"type": "function", "function": {"name": "get_exchange_rate", "description": "获取汇率", "parameters": {"type": "object", "properties": {"from_currency": {"type": "string"}, "to_currency": {"type": "string"}}, "required": ["from_currency", "to_currency"]}}},
115
+ {"type": "function", "function": {"name": "translate_text", "description": "翻译文本", "parameters": {"type": "object", "properties": {"text": {"type": "string"}, "target_lang": {"type": "string"}}, "required": ["text", "target_lang"]}}},
116
+ ]
117
+
118
+ TOOL_SHORT_NAMES = {
119
+ 'calculate_math': '数学', 'get_current_time': '时间', 'random_number': '随机',
120
+ 'text_length': '字数', 'unit_converter': '单位', 'get_current_weather': '天气',
121
+ 'get_exchange_rate': '汇率', 'translate_text': '翻译'
122
+ }
123
+
124
+ def execute_tool(tool_name, args):
125
+ import datetime
126
+ try:
127
+ if tool_name == 'calculate_math':
128
+ return {"result": eval(args.get('expression', '0'))}
129
+ elif tool_name == 'get_current_time':
130
+ tz = args.get('timezone', 'Asia/Shanghai')
131
+ return {"result": datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
132
+ elif tool_name == 'random_number':
133
+ return {"result": random.randint(args.get('min', 0), args.get('max', 100))}
134
+ elif tool_name == 'text_length':
135
+ return {"result": len(args.get('text', ''))}
136
+ elif tool_name == 'unit_converter':
137
+ return {"result": f"{args.get('value', 0)} {args.get('from_unit', '')} = ? {args.get('to_unit', '')}"}
138
+ elif tool_name == 'get_current_weather':
139
+ return {"result": f"{args.get('city', 'Unknown')}: 晴, 7~10°C"}
140
+ elif tool_name == 'get_exchange_rate':
141
+ return {"result": f"1 {args.get('from_currency', 'USD')} = 7.2 {args.get('to_currency', 'CNY')}"}
142
+ elif tool_name == 'translate_text':
143
+ return {"result": f"[翻译结果]: hello world"}
144
+ return {"result": "Unknown tool"}
145
+ except Exception as e:
146
+ return {"error": str(e)}
147
+
148
+
149
+ def process_assistant_content(content, is_streaming=False):
150
+ # 处理tool_call标签,格式化显示
151
+ if '<tool_call>' in content:
152
+ def format_tool_call(match):
153
+ try:
154
+ tc = json.loads(match.group(1))
155
+ name = tc.get('name', 'unknown')
156
+ args = tc.get('arguments', {})
157
+ return f'<div style="background: rgba(80, 110, 150, 0.20); border: 1px solid rgba(140, 170, 210, 0.30); padding: 10px 12px; border-radius: 12px; margin: 6px 0;"><div style="font-size:12px;opacity:.75;display:block;margin:0 0 6px 0;line-height:1;">ToolCalling</div><div><b>{name}</b>: {json.dumps(args, ensure_ascii=False)}</div></div>'
158
+ except:
159
+ return match.group(0)
160
+ content = re.sub(r'<tool_call>(.*?)</tool_call>', format_tool_call, content, flags=re.DOTALL)
161
+
162
+ # 流式生成且开启思考时,一开始就放到折叠里
163
+ if is_streaming and st.session_state.get('enable_thinking', False) and '</think>' not in content and '<think>' not in content:
164
+ m = re.search(r'(\n\n(?:我是|您好|你好)[^\n]*)', content)
165
+ if m and m.start(1) > 5:
166
+ i = m.start(1)
167
+ think_part = content[:i]
168
+ answer_part = content[i:]
169
+ return f'<details open style="border-left: 2px solid #666; padding-left: 12px; margin: 8px 0;"><summary style="cursor: pointer; color: #888;">已思考</summary><div style="color: #aaa; font-size: 0.95em; margin-top: 8px; max-height: 100px; overflow-y: auto;">{think_part.strip()}</div></details>{answer_part}'
170
+ elif len(content) > 5:
171
+ return f'<details open style="border-left: 2px solid #666; padding-left: 12px; margin: 8px 0;"><summary style="cursor: pointer; color: #888;">思考中...</summary><div style="color: #aaa; font-size: 0.95em; margin-top: 8px; max-height: 100px; overflow-y: auto; display: flex; flex-direction: column-reverse;"><div style="margin-bottom: auto;">{content.strip().replace(chr(10), "<br>")}</div></div></details>'
172
 
173
  if '<think>' in content and '</think>' in content:
174
+ def format_think(match):
175
+ think_content = match.group(2)
176
+ if think_content.replace('\n', '').strip(): # 不是全换行
177
+ return f'<details open style="border-left: 2px solid #666; padding-left: 12px; margin: 8px 0;"><summary style="cursor: pointer; color: #888;">已思考</summary><div style="color: #aaa; font-size: 0.95em; margin-top: 8px; max-height: 100px; overflow-y: auto;">{think_content.strip()}</div></details>'
178
+ return ''
179
+ content = re.sub(r'(<think>)(.*?)(</think>)', format_think, content, flags=re.DOTALL)
180
 
181
  if '<think>' in content and '</think>' not in content:
182
+ def format_think_in_progress(match):
183
+ tc = match.group(1)
184
+ return f'<details open style="border-left: 2px solid #666; padding-left: 12px; margin: 8px 0;"><summary style="cursor: pointer; color: #888;">思考中...</summary><div style="color: #aaa; font-size: 0.95em; margin-top: 8px; max-height: 100px; overflow-y: auto; display: flex; flex-direction: column-reverse;"><div style="margin-bottom: auto;">{tc.strip().replace(chr(10), "<br>")}</div></div></details>'
185
+ content = re.sub(r'<think>(.*?)$', format_think_in_progress, content, flags=re.DOTALL)
186
 
187
  if '<think>' not in content and '</think>' in content:
188
+ def format_think_no_start(match):
189
+ think_content = match.group(1)
190
+ if think_content.replace('\n', '').strip():
191
+ return f'<details open style="border-left: 2px solid #666; padding-left: 12px; margin: 8px 0;"><summary style="cursor: pointer; color: #888;">已思考</summary><div style="color: #aaa; font-size: 0.95em; margin-top: 8px; max-height: 100px; overflow-y: auto;">{think_content.strip()}</div></details>'
192
+ return ''
193
+ content = re.sub(r'(.*?)</think>', format_think_no_start, content, flags=re.DOTALL)
194
 
195
  return content
196
 
 
218
  if "messages" in st.session_state:
219
  for i, message in enumerate(st.session_state.messages):
220
  if message["role"] == "assistant":
221
+ st.markdown(process_assistant_content(message["content"]), unsafe_allow_html=True)
 
 
 
 
 
 
 
222
  else:
223
  st.markdown(
224
+ f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: #3d4450; border-radius: 22px; color: white;">{message["content"]}</div></div>',
225
  unsafe_allow_html=True)
226
 
227
  else:
 
230
 
231
  return st.session_state.messages
232
 
 
233
  def regenerate_answer(index):
234
  st.session_state.messages.pop()
235
  st.session_state.chat_messages.pop()
236
  st.rerun()
237
 
238
 
239
+ # 动态扫描模型目录
240
+ script_dir = os.path.dirname(os.path.abspath(__file__))
241
+ MODEL_PATHS = {}
242
+ for d in sorted(os.listdir(script_dir), reverse=True):
243
+ full_path = os.path.join(script_dir, d)
244
+ if os.path.isdir(full_path) and not d.startswith('.') and not d.startswith('_'):
245
+ if any(f.endswith(('.bin', '.safetensors', '.pt')) or os.path.exists(os.path.join(full_path, 'model.safetensors.index.json')) for f in os.listdir(full_path) if os.path.isfile(os.path.join(full_path, f))):
246
+ MODEL_PATHS[d] = [d, d]
247
+ if not MODEL_PATHS:
248
+ MODEL_PATHS = {"No models found": ["", "No models"]}
249
+
250
+ # 模型选择
251
+ selected_model = st.sidebar.selectbox('Model', list(MODEL_PATHS.keys()), index=0, accept_new_options=False)
252
+ model_path = MODEL_PATHS[selected_model][0]
253
+ slogan = f"我是 {MODEL_PATHS[selected_model][1]},有什么可以帮你的?" if st.session_state.get('lang', 'en') == 'zh' else f"I am {MODEL_PATHS[selected_model][1]}, how can I help you?"
254
+
255
+ st.sidebar.markdown('<hr style="margin: 12px 0 16px 0;">', unsafe_allow_html=True)
256
+
257
+ # 语言选择
258
+ lang_options = {'中文': 'zh', 'English': 'en'}
259
+ current_lang = st.session_state.get('lang', 'en')
260
+ lang_index = 0 if current_lang == 'zh' else 1
261
+ lang_label = st.sidebar.radio('Language / 语言', list(lang_options.keys()), index=lang_index, horizontal=True)
262
+ if lang_options[lang_label] != current_lang:
263
+ st.session_state.lang = lang_options[lang_label]
264
  st.rerun()
265
 
266
+ st.sidebar.markdown('<hr style="margin: 12px 0 16px 0;">', unsafe_allow_html=True)
267
 
268
+ # 参数设置
269
+ st.session_state.history_chat_num = st.sidebar.slider(get_text('history_rounds'), 0, 8, 0, step=2)
270
+ st.session_state.max_new_tokens = st.sidebar.slider(get_text('max_length'), 256, 8192, 8192, step=1)
271
+ st.session_state.temperature = st.sidebar.slider(get_text('temperature'), 0.6, 1.2, 0.90, step=0.01)
 
 
 
272
 
273
+ st.sidebar.markdown('<hr style="margin: 12px 0 16px 0;">', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
+ # 功能开关
276
+ st.session_state.enable_thinking = st.sidebar.checkbox(get_text('thinking'), value=False, help=get_text('think_tip'))
277
+ st.session_state.selected_tools = []
278
+ with st.sidebar.expander(get_text('tools')):
279
+ st.caption(get_text('tool_select'))
280
+ selected_count = sum(1 for tool in TOOLS if st.session_state.get(f"tool_{tool['function']['name']}", False))
281
+ for tool in TOOLS:
282
+ name = tool['function']['name']
283
+ short_name = TOOL_SHORT_NAMES.get(name, name)
284
+ checked = st.checkbox(short_name, key=f"tool_{name}", disabled=(selected_count >= 4 and not st.session_state.get(f"tool_{name}", False)))
285
+ if checked and len(st.session_state.selected_tools) < 4:
286
+ st.session_state.selected_tools.append(name)
287
 
288
  image_url = "https://www.modelscope.cn/api/v1/studio/gongjy/MiniMind/repo?Revision=master&FilePath=images%2Flogo2.png&View=true"
289
 
290
  st.markdown(
291
  f'<div style="display: flex; flex-direction: column; align-items: center; text-align: center; margin: 0; padding: 0;">'
292
  '<div style="font-style: italic; font-weight: 900; margin: 0; padding-top: 4px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%;">'
293
+ f'<img src="{image_url}" style="width: 40px; height: 40px; "> '
294
  f'<span style="font-size: 26px; margin-left: 10px;">{slogan}</span>'
295
  '</div>'
296
+ f'<span style="color: #bbb; font-style: italic; margin-top: 6px; margin-bottom: 10px;">{get_text("disclaimer")}</span>'
297
  '</div>',
298
  unsafe_allow_html=True
299
  )
 
310
 
311
 
312
  def main():
313
+ model, tokenizer = load_model_tokenizer(model_path)
 
 
 
314
 
315
  if "messages" not in st.session_state:
316
  st.session_state.messages = []
 
320
 
321
  for i, message in enumerate(messages):
322
  if message["role"] == "assistant":
323
+ st.markdown(process_assistant_content(message["content"]), unsafe_allow_html=True)
 
 
 
 
 
324
  else:
325
  st.markdown(
326
+ f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: #3d4450; border-radius: 22px; color: white;">{message["content"]}</div></div>',
327
  unsafe_allow_html=True)
328
 
329
+ prompt = st.chat_input(key="input", placeholder=get_text('send'))
330
 
331
  if hasattr(st.session_state, 'regenerate') and st.session_state.regenerate:
332
  prompt = st.session_state.last_user_message
 
337
 
338
  if prompt:
339
  st.markdown(
340
+ f'<div style="display: flex; justify-content: flex-end;"><div style="display: inline-block; margin: 10px 0; padding: 8px 12px 8px 12px; background-color: #3d4450; border-radius: 22px; color: white;">{prompt}</div></div>',
341
  unsafe_allow_html=True)
342
  messages.append({"role": "user", "content": prompt[-st.session_state.max_new_tokens:]})
343
  st.session_state.chat_messages.append({"role": "user", "content": prompt[-st.session_state.max_new_tokens:]})
344
 
345
+ placeholder = st.empty()
346
+
347
+ random_seed = random.randint(0, 2 ** 32 - 1)
348
+ setup_seed(random_seed)
349
+
350
+ tools = [t for t in TOOLS if t['function']['name'] in st.session_state.get('selected_tools', [])] or None
351
+ sys_prompt = [] if tools else [{"role": "system", "content": "你是MiniMind,一个乐于助人、知识渊博的AI助手。请用完整且友好的方式回答用户问题。"}]
352
+ st.session_state.chat_messages = sys_prompt + st.session_state.chat_messages[-(st.session_state.history_chat_num + 1):]
353
+ template_kwargs = {"tokenize": False, "add_generation_prompt": True}
354
+ if st.session_state.get('enable_thinking', False):
355
+ template_kwargs["open_thinking"] = True
356
+ if tools:
357
+ template_kwargs["tools"] = tools
358
+ new_prompt = tokenizer.apply_chat_template(st.session_state.chat_messages, **template_kwargs)
359
+
360
+ inputs = tokenizer(new_prompt, return_tensors="pt", truncation=True).to(device)
361
+
362
+ streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
363
+ generation_kwargs = {
364
+ "input_ids": inputs.input_ids,
365
+ "max_length": inputs.input_ids.shape[1] + st.session_state.max_new_tokens,
366
+ "num_return_sequences": 1,
367
+ "do_sample": True,
368
+ "attention_mask": inputs.attention_mask,
369
+ "pad_token_id": tokenizer.pad_token_id,
370
+ "eos_token_id": tokenizer.eos_token_id,
371
+ "temperature": st.session_state.temperature,
372
+ "top_p": 0.85,
373
+ "streamer": streamer,
374
+ }
375
 
376
+ Thread(target=model.generate, kwargs=generation_kwargs).start()
377
+
378
+ answer = ""
379
+ for new_text in streamer:
380
+ answer += new_text
381
+ placeholder.markdown(process_assistant_content(answer, is_streaming=True), unsafe_allow_html=True)
382
+
383
+ full_answer = answer
384
+ for _ in range(16):
385
+ tool_calls = re.findall(r'<tool_call>(.*?)</tool_call>', answer, re.DOTALL)
386
+ if not tool_calls:
387
+ break
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  st.session_state.chat_messages.append({"role": "assistant", "content": answer})
389
+ tool_results = []
390
+ for tc_str in tool_calls:
391
+ try:
392
+ tc = json.loads(tc_str.strip())
393
+ result = execute_tool(tc.get('name', ''), tc.get('arguments', {}))
394
+ st.session_state.chat_messages.append({"role": "tool", "content": json.dumps(result, ensure_ascii=False)})
395
+ tool_results.append(f'<div style="background: rgba(90, 130, 110, 0.20); border: 1px solid rgba(150, 200, 170, 0.30); padding: 10px 12px; border-radius: 12px; margin: 6px 0;"><div style="font-size:12px;opacity:.75;display:block;margin:0 0 6px 0;line-height:1;">ToolCalled</div><div><b>{tc.get("name", "")}</b>: {json.dumps(result, ensure_ascii=False)}</div></div>')
396
+ except:
397
+ pass
398
+ full_answer += "\n" + "\n".join(tool_results) + "\n"
399
+ placeholder.markdown(process_assistant_content(full_answer, is_streaming=True), unsafe_allow_html=True)
400
+ new_prompt = tokenizer.apply_chat_template(st.session_state.chat_messages, **template_kwargs)
401
+ inputs = tokenizer(new_prompt, return_tensors="pt", truncation=True).to(device)
402
+ streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
403
+ generation_kwargs["input_ids"] = inputs.input_ids
404
+ generation_kwargs["attention_mask"] = inputs.attention_mask
405
+ generation_kwargs["max_length"] = inputs.input_ids.shape[1] + st.session_state.max_new_tokens
406
+ generation_kwargs["streamer"] = streamer
407
+ Thread(target=model.generate, kwargs=generation_kwargs).start()
408
+ answer = ""
409
+ for new_text in streamer:
410
+ answer += new_text
411
+ placeholder.markdown(process_assistant_content(full_answer + answer, is_streaming=True), unsafe_allow_html=True)
412
+ full_answer += answer
413
+ answer = full_answer
414
+
415
+ messages.append({"role": "assistant", "content": answer})
416
+ st.session_state.chat_messages.append({"role": "assistant", "content": answer})
417
 
418
 
419
  if __name__ == "__main__":
420
+ main()
 
 
minimind-3-moe/chat_template.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if true %}
44
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
45
+ {%- endif %}
46
+ {%- if message.tool_calls %}
47
+ {%- for tool_call in message.tool_calls %}
48
+ {%- if (loop.first and content) or (not loop.first) %}
49
+ {{- '\n' }}
50
+ {%- endif %}
51
+ {%- if tool_call.function %}
52
+ {%- set tool_call = tool_call.function %}
53
+ {%- endif %}
54
+ {{- '<tool_call>\n{"name": "' }}
55
+ {{- tool_call.name }}
56
+ {{- '", "arguments": ' }}
57
+ {%- if tool_call.arguments is string %}
58
+ {{- tool_call.arguments }}
59
+ {%- else %}
60
+ {{- tool_call.arguments | tojson }}
61
+ {%- endif %}
62
+ {{- '}\n</tool_call>' }}
63
+ {%- endfor %}
64
+ {%- endif %}
65
+ {{- '<|im_end|>\n' }}
66
+ {%- elif message.role == "tool" %}
67
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
68
+ {{- '<|im_start|>user' }}
69
+ {%- endif %}
70
+ {{- '\n<tool_response>\n' }}
71
+ {{- content }}
72
+ {{- '\n</tool_response>' }}
73
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
74
+ {{- '<|im_end|>\n' }}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if add_generation_prompt %}
79
+ {{- '<|im_start|>assistant\n' }}
80
+ {%- if open_thinking is defined and open_thinking is true %}
81
+ {{- '<think>\n' }}
82
+ {%- else %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
minimind-3-moe/config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3MoeForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "decoder_sparse_step": 1,
8
+ "dtype": "float16",
9
+ "head_dim": 96,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 2432,
14
+ "max_position_embeddings": 32768,
15
+ "mlp_only_layers": [],
16
+ "model_type": "qwen3_moe",
17
+ "moe_intermediate_size": 2432,
18
+ "norm_topk_prob": true,
19
+ "num_attention_heads": 8,
20
+ "num_experts": 4,
21
+ "num_experts_per_tok": 1,
22
+ "num_hidden_layers": 8,
23
+ "num_key_value_heads": 4,
24
+ "output_router_logits": false,
25
+ "rms_norm_eps": 1e-06,
26
+ "rope_scaling": null,
27
+ "rope_theta": 1000000.0,
28
+ "router_aux_loss_coef": 0.001,
29
+ "sliding_window": null,
30
+ "tie_word_embeddings": true,
31
+ "transformers_version": "4.57.6",
32
+ "use_cache": true,
33
+ "use_sliding_window": false,
34
+ "vocab_size": 6400
35
+ }
minimind-3-moe/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.57.6"
4
+ }
minimind-3-moe/minimind.modelfile ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ./Minimind-3-Moe-4x64M-F16.gguf
2
+
3
+ SYSTEM "你的名字叫MiniMind,你是一个乐于助人、知识渊博的AI助手。请用完整且友好的方式回答用户问题,当被问到名字时请回答MiniMind。"
4
+
5
+
6
+ TEMPLATE """{{- if .Tools }}<|im_start|>system
7
+ {{ if .System }}{{ .System }}
8
+
9
+ {{ end }}# Tools
10
+
11
+ You may call one or more functions to assist with the user query.
12
+
13
+ You are provided with function signatures within <tools></tools> XML tags:
14
+ <tools>
15
+ {{- range .Tools }}
16
+ {"type": "function", "function": {{ .Function }}}
17
+ {{- end }}
18
+ </tools>
19
+
20
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
21
+ <tool_call>
22
+ {"name": <function-name>, "arguments": <args-json-object>}
23
+ </tool_call><|im_end|>
24
+ {{ else if .System }}<|im_start|>system
25
+ {{ .System }}<|im_end|>
26
+ {{ end }}
27
+ {{- range $i, $_ := .Messages }}
28
+ {{- $last := eq (len (slice $.Messages $i)) 1 -}}
29
+ {{- if eq .Role "user" }}<|im_start|>user
30
+ {{ .Content }}<|im_end|>
31
+ {{ else if eq .Role "assistant" }}<|im_start|>assistant
32
+ <think>
33
+ {{ .Thinking }}
34
+ </think>
35
+
36
+ {{ .Content }}
37
+ {{- if .ToolCalls }}
38
+ {{- range .ToolCalls }}
39
+ <tool_call>
40
+ {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
41
+ </tool_call>
42
+ {{- end }}
43
+ {{- end }}
44
+ {{- if not $last }}<|im_end|>
45
+ {{ end }}
46
+ {{- else if eq .Role "tool" }}<|im_start|>user
47
+ <tool_response>
48
+ {{ .Content }}
49
+ </tool_response><|im_end|>
50
+ {{ end }}
51
+ {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
52
+ {{ if and $.IsThinkSet $.Think -}}
53
+ <think>
54
+ {{ else -}}
55
+ <think>
56
+
57
+ </think>
58
+
59
+ {{ end -}}
60
+ {{ end }}
61
+ {{- end }}"""
62
+
63
+ PARAMETER repeat_penalty 1
64
+ PARAMETER stop "<|im_start|>"
65
+ PARAMETER stop "<|im_end|>"
66
+ PARAMETER temperature 0.9
67
+ PARAMETER top_p 0.9
68
+ PARAMETER num_ctx 8192
minimind-3-moe/special_tokens_map.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>",
16
+ "<|audio_start|>",
17
+ "<|audio_end|>",
18
+ "<|audio_pad|>",
19
+ "<tts_pad>",
20
+ "<tts_text_bos>",
21
+ "<tts_text_eod>",
22
+ "<tts_text_bos_single>"
23
+ ],
24
+ "bos_token": {
25
+ "content": "<|im_start|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "eos_token": {
32
+ "content": "<|im_end|>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ },
38
+ "pad_token": {
39
+ "content": "<|endoftext|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false
44
+ },
45
+ "unk_token": {
46
+ "content": "<|endoftext|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false
51
+ }
52
+ }
minimind-3-moe/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
minimind-3-moe/tokenizer_config.json ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|im_start|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "<|im_end|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "3": {
31
+ "content": "<|object_ref_start|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "4": {
39
+ "content": "<|object_ref_end|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "5": {
47
+ "content": "<|box_start|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "6": {
55
+ "content": "<|box_end|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "7": {
63
+ "content": "<|quad_start|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "8": {
71
+ "content": "<|quad_end|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "9": {
79
+ "content": "<|vision_start|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "10": {
87
+ "content": "<|vision_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "11": {
95
+ "content": "<|vision_pad|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "12": {
103
+ "content": "<|image_pad|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "13": {
111
+ "content": "<|video_pad|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "14": {
119
+ "content": "<|audio_start|>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": true
125
+ },
126
+ "15": {
127
+ "content": "<|audio_end|>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": true
133
+ },
134
+ "16": {
135
+ "content": "<|audio_pad|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": true
141
+ },
142
+ "17": {
143
+ "content": "<tts_pad>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": true
149
+ },
150
+ "18": {
151
+ "content": "<tts_text_bos>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": true
157
+ },
158
+ "19": {
159
+ "content": "<tts_text_eod>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": true
165
+ },
166
+ "20": {
167
+ "content": "<tts_text_bos_single>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": true
173
+ },
174
+ "21": {
175
+ "content": "<tool_call>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "22": {
183
+ "content": "</tool_call>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "23": {
191
+ "content": "<tool_response>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "24": {
199
+ "content": "</tool_response>",
200
+ "lstrip": false,
201
+ "normalized": false,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ },
206
+ "25": {
207
+ "content": "<think>",
208
+ "lstrip": false,
209
+ "normalized": false,
210
+ "rstrip": false,
211
+ "single_word": false,
212
+ "special": false
213
+ },
214
+ "26": {
215
+ "content": "</think>",
216
+ "lstrip": false,
217
+ "normalized": false,
218
+ "rstrip": false,
219
+ "single_word": false,
220
+ "special": false
221
+ },
222
+ "27": {
223
+ "content": "<|buffer1|>",
224
+ "lstrip": false,
225
+ "normalized": false,
226
+ "rstrip": false,
227
+ "single_word": false,
228
+ "special": false
229
+ },
230
+ "28": {
231
+ "content": "<|buffer2|>",
232
+ "lstrip": false,
233
+ "normalized": false,
234
+ "rstrip": false,
235
+ "single_word": false,
236
+ "special": false
237
+ },
238
+ "29": {
239
+ "content": "<|buffer3|>",
240
+ "lstrip": false,
241
+ "normalized": false,
242
+ "rstrip": false,
243
+ "single_word": false,
244
+ "special": false
245
+ },
246
+ "30": {
247
+ "content": "<|buffer4|>",
248
+ "lstrip": false,
249
+ "normalized": false,
250
+ "rstrip": false,
251
+ "single_word": false,
252
+ "special": false
253
+ },
254
+ "31": {
255
+ "content": "<|buffer5|>",
256
+ "lstrip": false,
257
+ "normalized": false,
258
+ "rstrip": false,
259
+ "single_word": false,
260
+ "special": false
261
+ },
262
+ "32": {
263
+ "content": "<|buffer6|>",
264
+ "lstrip": false,
265
+ "normalized": false,
266
+ "rstrip": false,
267
+ "single_word": false,
268
+ "special": false
269
+ },
270
+ "33": {
271
+ "content": "<|buffer7|>",
272
+ "lstrip": false,
273
+ "normalized": false,
274
+ "rstrip": false,
275
+ "single_word": false,
276
+ "special": false
277
+ },
278
+ "34": {
279
+ "content": "<|buffer8|>",
280
+ "lstrip": false,
281
+ "normalized": false,
282
+ "rstrip": false,
283
+ "single_word": false,
284
+ "special": false
285
+ },
286
+ "35": {
287
+ "content": "<|buffer9|>",
288
+ "lstrip": false,
289
+ "normalized": false,
290
+ "rstrip": false,
291
+ "single_word": false,
292
+ "special": false
293
+ }
294
+ },
295
+ "additional_special_tokens": [
296
+ "<|im_start|>",
297
+ "<|im_end|>",
298
+ "<|object_ref_start|>",
299
+ "<|object_ref_end|>",
300
+ "<|box_start|>",
301
+ "<|box_end|>",
302
+ "<|quad_start|>",
303
+ "<|quad_end|>",
304
+ "<|vision_start|>",
305
+ "<|vision_end|>",
306
+ "<|vision_pad|>",
307
+ "<|image_pad|>",
308
+ "<|video_pad|>",
309
+ "<|audio_start|>",
310
+ "<|audio_end|>",
311
+ "<|audio_pad|>",
312
+ "<tts_pad>",
313
+ "<tts_text_bos>",
314
+ "<tts_text_eod>",
315
+ "<tts_text_bos_single>"
316
+ ],
317
+ "audio_bos_token": "<|audio_start|>",
318
+ "audio_eos_token": "<|audio_end|>",
319
+ "audio_token": "<|audio_pad|>",
320
+ "bos_token": "<|im_start|>",
321
+ "clean_up_tokenization_spaces": false,
322
+ "eos_token": "<|im_end|>",
323
+ "extra_special_tokens": {},
324
+ "image_token": "<|image_pad|>",
325
+ "legacy": true,
326
+ "model_max_length": 131072,
327
+ "pad_token": "<|endoftext|>",
328
+ "sp_model_kwargs": {},
329
+ "spaces_between_special_tokens": false,
330
+ "tokenizer_class": "PreTrainedTokenizerFast",
331
+ "unk_token": "<|endoftext|>",
332
+ "video_token": "<|video_pad|>",
333
+ "vision_bos_token": "<|vision_start|>",
334
+ "vision_eos_token": "<|vision_end|>"
335
+ }
minimind-3/chat_template.jinja ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if true %}
44
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
45
+ {%- endif %}
46
+ {%- if message.tool_calls %}
47
+ {%- for tool_call in message.tool_calls %}
48
+ {%- if (loop.first and content) or (not loop.first) %}
49
+ {{- '\n' }}
50
+ {%- endif %}
51
+ {%- if tool_call.function %}
52
+ {%- set tool_call = tool_call.function %}
53
+ {%- endif %}
54
+ {{- '<tool_call>\n{"name": "' }}
55
+ {{- tool_call.name }}
56
+ {{- '", "arguments": ' }}
57
+ {%- if tool_call.arguments is string %}
58
+ {{- tool_call.arguments }}
59
+ {%- else %}
60
+ {{- tool_call.arguments | tojson }}
61
+ {%- endif %}
62
+ {{- '}\n</tool_call>' }}
63
+ {%- endfor %}
64
+ {%- endif %}
65
+ {{- '<|im_end|>\n' }}
66
+ {%- elif message.role == "tool" %}
67
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
68
+ {{- '<|im_start|>user' }}
69
+ {%- endif %}
70
+ {{- '\n<tool_response>\n' }}
71
+ {{- content }}
72
+ {{- '\n</tool_response>' }}
73
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
74
+ {{- '<|im_end|>\n' }}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if add_generation_prompt %}
79
+ {{- '<|im_start|>assistant\n' }}
80
+ {%- if open_thinking is defined and open_thinking is true %}
81
+ {{- '<think>\n' }}
82
+ {%- else %}
83
+ {{- '<think>\n\n</think>\n\n' }}
84
+ {%- endif %}
85
+ {%- endif %}
minimind-3/config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "dtype": "float16",
8
+ "head_dim": 96,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 2432,
13
+ "layer_types": [
14
+ "full_attention",
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention"
22
+ ],
23
+ "max_position_embeddings": 32768,
24
+ "max_window_layers": 28,
25
+ "model_type": "qwen3",
26
+ "num_attention_heads": 8,
27
+ "num_hidden_layers": 8,
28
+ "num_key_value_heads": 4,
29
+ "rms_norm_eps": 1e-06,
30
+ "rope_scaling": null,
31
+ "rope_theta": 1000000.0,
32
+ "sliding_window": null,
33
+ "tie_word_embeddings": true,
34
+ "transformers_version": "4.57.6",
35
+ "use_cache": true,
36
+ "use_sliding_window": false,
37
+ "vocab_size": 6400
38
+ }
minimind-3/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.57.6"
4
+ }
minimind-3/minimind.modelfile ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ./minimind-64M-3-F16.gguf
2
+
3
+ SYSTEM "你的名字叫MiniMind,你是一个乐于助人、知识渊博的AI助手。请用完整且友好的方式回答用户问题,当被问到名字时请回答MiniMind。"
4
+
5
+
6
+ TEMPLATE """{{- if .Tools }}<|im_start|>system
7
+ {{ if .System }}{{ .System }}
8
+
9
+ {{ end }}# Tools
10
+
11
+ You may call one or more functions to assist with the user query.
12
+
13
+ You are provided with function signatures within <tools></tools> XML tags:
14
+ <tools>
15
+ {{- range .Tools }}
16
+ {"type": "function", "function": {{ .Function }}}
17
+ {{- end }}
18
+ </tools>
19
+
20
+ For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
21
+ <tool_call>
22
+ {"name": <function-name>, "arguments": <args-json-object>}
23
+ </tool_call><|im_end|>
24
+ {{ else if .System }}<|im_start|>system
25
+ {{ .System }}<|im_end|>
26
+ {{ end }}
27
+ {{- range $i, $_ := .Messages }}
28
+ {{- $last := eq (len (slice $.Messages $i)) 1 -}}
29
+ {{- if eq .Role "user" }}<|im_start|>user
30
+ {{ .Content }}<|im_end|>
31
+ {{ else if eq .Role "assistant" }}<|im_start|>assistant
32
+ <think>
33
+ {{ .Thinking }}
34
+ </think>
35
+
36
+ {{ .Content }}
37
+ {{- if .ToolCalls }}
38
+ {{- range .ToolCalls }}
39
+ <tool_call>
40
+ {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
41
+ </tool_call>
42
+ {{- end }}
43
+ {{- end }}
44
+ {{- if not $last }}<|im_end|>
45
+ {{ end }}
46
+ {{- else if eq .Role "tool" }}<|im_start|>user
47
+ <tool_response>
48
+ {{ .Content }}
49
+ </tool_response><|im_end|>
50
+ {{ end }}
51
+ {{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
52
+ {{ if and $.IsThinkSet $.Think -}}
53
+ <think>
54
+ {{ else -}}
55
+ <think>
56
+
57
+ </think>
58
+
59
+ {{ end -}}
60
+ {{ end }}
61
+ {{- end }}"""
62
+
63
+ PARAMETER repeat_penalty 1
64
+ PARAMETER stop "<|im_start|>"
65
+ PARAMETER stop "<|im_end|>"
66
+ PARAMETER temperature 0.9
67
+ PARAMETER top_p 0.9
68
+ PARAMETER num_ctx 8192
minimind-3/special_tokens_map.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>",
16
+ "<|audio_start|>",
17
+ "<|audio_end|>",
18
+ "<|audio_pad|>",
19
+ "<tts_pad>",
20
+ "<tts_text_bos>",
21
+ "<tts_text_eod>",
22
+ "<tts_text_bos_single>"
23
+ ],
24
+ "bos_token": {
25
+ "content": "<|im_start|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "eos_token": {
32
+ "content": "<|im_end|>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ },
38
+ "pad_token": {
39
+ "content": "<|endoftext|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false
44
+ },
45
+ "unk_token": {
46
+ "content": "<|endoftext|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false
51
+ }
52
+ }
minimind-3/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
minimind-3/tokenizer_config.json ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|im_start|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "<|im_end|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "3": {
31
+ "content": "<|object_ref_start|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "4": {
39
+ "content": "<|object_ref_end|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "5": {
47
+ "content": "<|box_start|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "6": {
55
+ "content": "<|box_end|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "7": {
63
+ "content": "<|quad_start|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "8": {
71
+ "content": "<|quad_end|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "9": {
79
+ "content": "<|vision_start|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "10": {
87
+ "content": "<|vision_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "11": {
95
+ "content": "<|vision_pad|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "12": {
103
+ "content": "<|image_pad|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "13": {
111
+ "content": "<|video_pad|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "14": {
119
+ "content": "<|audio_start|>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": true
125
+ },
126
+ "15": {
127
+ "content": "<|audio_end|>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": true
133
+ },
134
+ "16": {
135
+ "content": "<|audio_pad|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": true
141
+ },
142
+ "17": {
143
+ "content": "<tts_pad>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": true
149
+ },
150
+ "18": {
151
+ "content": "<tts_text_bos>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": true
157
+ },
158
+ "19": {
159
+ "content": "<tts_text_eod>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": true
165
+ },
166
+ "20": {
167
+ "content": "<tts_text_bos_single>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": true
173
+ },
174
+ "21": {
175
+ "content": "<tool_call>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "22": {
183
+ "content": "</tool_call>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "23": {
191
+ "content": "<tool_response>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "24": {
199
+ "content": "</tool_response>",
200
+ "lstrip": false,
201
+ "normalized": false,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ },
206
+ "25": {
207
+ "content": "<think>",
208
+ "lstrip": false,
209
+ "normalized": false,
210
+ "rstrip": false,
211
+ "single_word": false,
212
+ "special": false
213
+ },
214
+ "26": {
215
+ "content": "</think>",
216
+ "lstrip": false,
217
+ "normalized": false,
218
+ "rstrip": false,
219
+ "single_word": false,
220
+ "special": false
221
+ },
222
+ "27": {
223
+ "content": "<|buffer1|>",
224
+ "lstrip": false,
225
+ "normalized": false,
226
+ "rstrip": false,
227
+ "single_word": false,
228
+ "special": false
229
+ },
230
+ "28": {
231
+ "content": "<|buffer2|>",
232
+ "lstrip": false,
233
+ "normalized": false,
234
+ "rstrip": false,
235
+ "single_word": false,
236
+ "special": false
237
+ },
238
+ "29": {
239
+ "content": "<|buffer3|>",
240
+ "lstrip": false,
241
+ "normalized": false,
242
+ "rstrip": false,
243
+ "single_word": false,
244
+ "special": false
245
+ },
246
+ "30": {
247
+ "content": "<|buffer4|>",
248
+ "lstrip": false,
249
+ "normalized": false,
250
+ "rstrip": false,
251
+ "single_word": false,
252
+ "special": false
253
+ },
254
+ "31": {
255
+ "content": "<|buffer5|>",
256
+ "lstrip": false,
257
+ "normalized": false,
258
+ "rstrip": false,
259
+ "single_word": false,
260
+ "special": false
261
+ },
262
+ "32": {
263
+ "content": "<|buffer6|>",
264
+ "lstrip": false,
265
+ "normalized": false,
266
+ "rstrip": false,
267
+ "single_word": false,
268
+ "special": false
269
+ },
270
+ "33": {
271
+ "content": "<|buffer7|>",
272
+ "lstrip": false,
273
+ "normalized": false,
274
+ "rstrip": false,
275
+ "single_word": false,
276
+ "special": false
277
+ },
278
+ "34": {
279
+ "content": "<|buffer8|>",
280
+ "lstrip": false,
281
+ "normalized": false,
282
+ "rstrip": false,
283
+ "single_word": false,
284
+ "special": false
285
+ },
286
+ "35": {
287
+ "content": "<|buffer9|>",
288
+ "lstrip": false,
289
+ "normalized": false,
290
+ "rstrip": false,
291
+ "single_word": false,
292
+ "special": false
293
+ }
294
+ },
295
+ "additional_special_tokens": [
296
+ "<|im_start|>",
297
+ "<|im_end|>",
298
+ "<|object_ref_start|>",
299
+ "<|object_ref_end|>",
300
+ "<|box_start|>",
301
+ "<|box_end|>",
302
+ "<|quad_start|>",
303
+ "<|quad_end|>",
304
+ "<|vision_start|>",
305
+ "<|vision_end|>",
306
+ "<|vision_pad|>",
307
+ "<|image_pad|>",
308
+ "<|video_pad|>",
309
+ "<|audio_start|>",
310
+ "<|audio_end|>",
311
+ "<|audio_pad|>",
312
+ "<tts_pad>",
313
+ "<tts_text_bos>",
314
+ "<tts_text_eod>",
315
+ "<tts_text_bos_single>"
316
+ ],
317
+ "audio_bos_token": "<|audio_start|>",
318
+ "audio_eos_token": "<|audio_end|>",
319
+ "audio_token": "<|audio_pad|>",
320
+ "bos_token": "<|im_start|>",
321
+ "clean_up_tokenization_spaces": false,
322
+ "eos_token": "<|im_end|>",
323
+ "extra_special_tokens": {},
324
+ "image_token": "<|image_pad|>",
325
+ "legacy": true,
326
+ "model_max_length": 131072,
327
+ "pad_token": "<|endoftext|>",
328
+ "sp_model_kwargs": {},
329
+ "spaces_between_special_tokens": false,
330
+ "tokenizer_class": "PreTrainedTokenizerFast",
331
+ "unk_token": "<|endoftext|>",
332
+ "video_token": "<|video_pad|>",
333
+ "vision_bos_token": "<|vision_start|>",
334
+ "vision_eos_token": "<|vision_end|>"
335
+ }