anemll commited on
Commit
b577aa1
·
verified ·
1 Parent(s): 6534d1c

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ANEMLL
2
+
3
+ ANEMLL (pronounced like “animal”) is an open-source project
4
+ focused on accelerating the porting of Large Language Models (LLMs)
5
+ to tensor processors, starting with the Apple Neural Engine (ANE).
6
+
7
+ The goal is to provide a fully open-source pipeline
8
+ from model conversion to inference for common LLM architectures
9
+ running on ANE.
10
+
11
+ This enables seamless integration and on-device inference
12
+ for low-power applications on edge devices,
13
+ ensuring maximum privacy and security.
14
+
15
+ This is critical for autonomous applications,
16
+ where models run directly on the device
17
+ without requiring an internet connection.
18
+
19
+ License
20
+
21
+ ANEMLL is licensed under the MIT License.
22
+ https://opensource.org/license/mit
23
+ The model is based on Meta’s LLaMA 3.2 and may require a separate license.
24
+
25
+
26
+
27
+ This test model is exclusively for the Meta's LLaMA 3.2 1B (1024 context) model converted for CoreML,
28
+ released before the official launch of the ANEMLL repository and minimal documentation.
29
+ It is intended for early adopters only who requested an early release.
30
+
31
+
32
+ Requirements
33
+ • macOS Sequoia with Apple Neural Engine and 16GB RAM
34
+ • CoreML Tools and HuggingFace Transformers libraries
35
+ • Python 3.9
36
+
37
+ chat.py provides a sample inference script.
38
+ We apologize for the current quality of chat.py and appreciate your patience.
39
+
40
+
41
+ Prerequisites:
42
+ pip install coremltools transformers
43
+
44
+ How to RUN:
45
+ python chat.py
46
+
47
+ Ctr-D to exit, Ctr-C to interrupt inference.
48
+
49
+ alternative way to run:
50
+ python chat.py S123 -d /path/to/anemll-LLAMA32-1B-ctx1024 ctx=1024
51
+
52
+ The first time the model loads, macOS will take some time to place it on the device.
53
+ Subsequent loads will be instantaneous.
54
+
55
+ Please check following links for later updates:
56
+ https://huggingface.co/anemll
57
+ https://x.com/anemll
58
+ https://github.com/anemll
59
+ https://anemll.com
60
+
61
62
+
chat.py ADDED
@@ -0,0 +1,1563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025, Anemll All rights reserved.
2
+ #
3
+ # Use of this source code is governed by a MIT license that can be
4
+ # found in the LICENSE.txt file or at https://opensource.org/license/mit
5
+
6
+ import coremltools as ct
7
+ import numpy as np
8
+ import torch
9
+ from transformers import AutoTokenizer
10
+ import os
11
+ import time, sys
12
+ import signal
13
+ import traceback
14
+ import torch.nn.functional as F
15
+ import queue
16
+ import threading
17
+ import re
18
+
19
+ # Configuration
20
+ CONTEXT_LENGTH = 1024 # Changed default from 512 to 1024
21
+ PREFILL_BATCH_SIZE = 64
22
+ MODEL_PATH = os.path.expanduser("../DeepSeekR1-8B")
23
+ ENABLE_VACAB_SPLIT8 = True # Enable 8-way vocab split
24
+ ENABLE_LOGITS2 = False # Enable 2-way vocab split
25
+ ENABLE_DEBUG = bool(0)
26
+ ENABLE_ARGMAX = bool(0)
27
+ ENABLE_PREFILL_BATCH = bool(1)
28
+ ENABLE_CHAT_DEBUG = bool(0) # Debug flag for chat loop
29
+
30
+ # ANSI color codes
31
+ LIGHT_BLUE = "\033[94m"
32
+ DARK_BLUE = "\033[34m"
33
+ LIGHT_GREEN = "\033[92m"
34
+ RESET_COLOR = "\033[0m"
35
+
36
+ if ENABLE_LOGITS2:
37
+ assert not ENABLE_ARGMAX, "ENABLE_ARGMAX must be False when ENABLE_LOGITS2 is True"
38
+
39
+
40
+ def load_model(path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name=None):
41
+ """Load either compiled or uncompiled CoreML model.
42
+
43
+ Args:
44
+ path: Path to the model file (.mlmodelc or .mlpackage)
45
+ compute_unit: CoreML compute unit to use
46
+ function_name: Optional function name to select from multi-function models
47
+ """
48
+ DebugLog(f"Attempting to load model: {path}")
49
+ DebugLog(f"File exists: {os.path.exists(path)}")
50
+ DebugLog(f"Is directory (for mlmodelc): {os.path.isdir(path)}")
51
+
52
+ try:
53
+ if path.endswith('.mlmodelc'):
54
+ DebugLog(f"Loading compiled model: {path}")
55
+ if function_name is None:
56
+ DebugLog("Loading without function name")
57
+ model = ct.models.CompiledMLModel(path, compute_unit)
58
+ else:
59
+ DebugLog(f"Loading with function name: {function_name}")
60
+ model = ct.models.CompiledMLModel(path, compute_unit, function_name=function_name)
61
+ else:
62
+ DebugLog(f"Loading uncompiled model: {path}")
63
+ if function_name is None:
64
+ DebugLog("Loading without function name")
65
+ model = ct.models.MLModel(model=path, compute_units=compute_unit, is_temp_package=False)
66
+ else:
67
+ DebugLog(f"Loading with function name: {function_name}")
68
+ model = ct.models.MLModel(model=path, compute_units=compute_unit, is_temp_package=False, function_name=function_name)
69
+ DebugLog("Model loaded successfully")
70
+
71
+ return model
72
+
73
+ except Exception as e:
74
+ DebugLog(f"Error loading model: {str(e)}")
75
+ DebugLog(f"Error type: {type(e)}")
76
+ raise
77
+
78
+ class SplitModelInference:
79
+ def __init__(self, model_parts, model_dir="."):
80
+ """Initialize split model inference.
81
+
82
+ Args:
83
+ model_parts (list): List of model part numbers to load
84
+ Special cases:
85
+ - 'C123' for combined part2 with prefill/infer functions
86
+ - 'S123' for split model with prefill/infer functions
87
+ - 'Q123' for quad split (2Q1-2Q4)
88
+ - 'Q123S' for quad split with combined prefill/infer (2Q1S-2Q4S)
89
+ - '123D' for dual split without prefill/infer (2D1-2D2)
90
+ model_dir (str): Directory containing the model files (default: current directory)
91
+ """
92
+ self.context_size = CONTEXT_LENGTH
93
+ self.model_dir = model_dir
94
+ DebugLog(f"Loading models from directory: {self.model_dir}")
95
+
96
+ # Parse configuration
97
+ self.quant_configs = {}
98
+ global_lut = None
99
+ if model_parts and model_parts[-1].startswith('lut'):
100
+ global_lut = model_parts[-1]
101
+ model_parts = model_parts[:-1]
102
+
103
+ # Special handling for different split modes
104
+ if len(model_parts) == 1:
105
+ if model_parts[0] == '123D': # Dual split without prefill/infer
106
+ self.use_combined_part2 = False
107
+ self.use_split_model = True
108
+ self.use_split_functions = False
109
+ self.use_quad_split = False
110
+ self.use_quad_split_combined = False
111
+ self.model_parts = ['1', '2D1', '2D2', '3']
112
+ if global_lut:
113
+ self.quant_configs = {part: global_lut for part in self.model_parts}
114
+ DebugLog(f"Using dual split model with parts: {self.model_parts}")
115
+ elif model_parts[0].startswith('C123'): # Combined part2
116
+ self.use_combined_part2 = True
117
+ self.use_split_model = False
118
+ self.use_split_functions = False
119
+ self.use_quad_split = False
120
+ self.use_quad_split_combined = False
121
+ self.model_parts = ['1', '2', '3']
122
+ if global_lut:
123
+ self.quant_configs = {part: global_lut for part in self.model_parts}
124
+ DebugLog(f"Using combined part2 model with parts: {self.model_parts}")
125
+ elif model_parts[0].startswith('S123'): # Split model with prefill/infer functions
126
+ self.use_combined_part2 = False
127
+ self.use_split_model = True
128
+ self.use_split_functions = True
129
+ self.use_quad_split = False
130
+ self.use_quad_split_combined = False
131
+ self.model_parts = ['1', '2D1S', '2D2S', '3']
132
+ elif model_parts[0].startswith('Q123S'): # Quad split with combined prefill/infer
133
+ self.use_combined_part2 = False
134
+ self.use_split_model = True
135
+ self.use_split_functions = False
136
+ self.use_quad_split = False
137
+ self.use_quad_split_combined = True
138
+ self.model_parts = ['1', '2Q1S', '2Q2S', '2Q3S', '2Q4S', '3']
139
+ elif model_parts[0].startswith('Q123'): # Regular quad split
140
+ self.use_combined_part2 = False
141
+ self.use_split_model = True
142
+ self.use_split_functions = False
143
+ self.use_quad_split = True
144
+ self.use_quad_split_combined = False
145
+ self.model_parts = ['1', '2Q1', '2Q2', '2Q3', '2Q4', '3']
146
+ else:
147
+ self.use_combined_part2 = False
148
+ self.use_split_model = False
149
+ self.use_split_functions = False
150
+ self.use_quad_split = False
151
+ self.use_quad_split_combined = False
152
+ self.model_parts = model_parts
153
+ else:
154
+ self.use_combined_part2 = False
155
+ self.use_split_model = False
156
+ self.use_split_functions = False
157
+ self.use_quad_split = False
158
+ self.use_quad_split_combined = False
159
+ self.model_parts = model_parts
160
+
161
+ # Apply global quantization if specified
162
+ if global_lut and not self.use_combined_part2: # Skip if already applied for C123
163
+ self.quant_configs = {part: global_lut for part in self.model_parts}
164
+
165
+ DebugLog(f"Using model parts: {self.model_parts}")
166
+ if global_lut:
167
+ DebugLog(f"With global quantization: {global_lut}")
168
+ if self.use_combined_part2:
169
+ DebugLog("Using combined part2 model with prefill/infer functions")
170
+ elif self.use_split_functions:
171
+ DebugLog("Using split model with prefill/infer functions")
172
+ elif self.use_quad_split:
173
+ DebugLog("Using quad split transformer model (2Q1-2Q4)")
174
+ elif self.use_quad_split_combined:
175
+ DebugLog("Using combined quad split transformer model (2Q1S-2Q4S)")
176
+
177
+ self.models = {}
178
+ self.states = {}
179
+ self.load_models()
180
+
181
+ def find_model_path(self, base_name, description="model"):
182
+ """Find model path, checking mlmodelc first then mlpackage.
183
+ Also tries both with and without lut suffix.
184
+
185
+ Args:
186
+ base_name: Base name of the model without extension
187
+ description: Description for error message (e.g., "Split model part 2D1S")
188
+
189
+ Returns:
190
+ str: Path to the found model file
191
+
192
+ Raises:
193
+ FileNotFoundError: If neither mlmodelc nor mlpackage exists
194
+ """
195
+ # For quad split parts, only try mlmodelc
196
+ if any(part in base_name for part in ['2Q1S', '2Q2S', '2Q3S', '2Q4S', '2Q1', '2Q2', '2Q3', '2Q4']):
197
+ model_path = os.path.join(self.model_dir, f"{base_name}.mlmodelc")
198
+ if os.path.exists(model_path):
199
+ return model_path
200
+ # If not found, try without lut suffix
201
+ if '_lut' in base_name:
202
+ base_without_lut = base_name.split('_lut')[0]
203
+ model_path = os.path.join(self.model_dir, f"{base_without_lut}.mlmodelc")
204
+ if os.path.exists(model_path):
205
+ return model_path
206
+ # Neither exists
207
+ raise FileNotFoundError(f"{description} not found: {base_name}.mlmodelc does not exist" +
208
+ (f" (also tried {base_name.split('_lut')[0]}.mlmodelc)" if '_lut' in base_name else ""))
209
+
210
+ # For other parts, try both mlmodelc and mlpackage
211
+ for ext in ['.mlmodelc', '.mlpackage']:
212
+ model_path = os.path.join(self.model_dir, f"{base_name}{ext}")
213
+ if os.path.exists(model_path):
214
+ return model_path
215
+
216
+ # If not found, try without lut suffix
217
+ if '_lut' in base_name:
218
+ base_without_lut = base_name.split('_lut')[0]
219
+ for ext in ['.mlmodelc', '.mlpackage']:
220
+ model_path = os.path.join(self.model_dir, f"{base_without_lut}{ext}")
221
+ if os.path.exists(model_path):
222
+ return model_path
223
+
224
+ # Neither exists
225
+ raise FileNotFoundError(f"{description} not found: neither {base_name}.mlmodelc nor {base_name}.mlpackage exist in {self.model_dir}" +
226
+ (f" (also tried {base_name.split('_lut')[0]}.mlmodelc/mlpackage)" if '_lut' in base_name else ""))
227
+
228
+ def load_models(self):
229
+ """Load each model part."""
230
+ DebugLog("Loading model parts...")
231
+
232
+ for part in self.model_parts:
233
+ quant_suffix = f"_{self.quant_configs[part]}" if part in self.quant_configs else ""
234
+ model_key = f"{part}{quant_suffix}" # Use this as the key in self.models
235
+
236
+ try:
237
+ if part == '2' and self.use_combined_part2:
238
+ # Load combined part2 with multiple functions
239
+ base_name = f"llama32_part2_combined{quant_suffix}"
240
+ model_path = self.find_model_path(base_name, "Combined part2 model")
241
+
242
+ DebugLog(f"Loading combined part2 model: {model_path}")
243
+ # Load prefill function
244
+ self.models['2_prefill'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='prefill')
245
+ # Load infer function
246
+ self.models['2_infer'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='infer')
247
+ # Create shared state
248
+ self.states['transformer'] = self.models['2_prefill'].make_state()
249
+ DebugLog("Combined part2 model loaded successfully")
250
+ elif part == '2' and not self.use_combined_part2:
251
+ # Load regular part2 model
252
+ base_name = f"llama32_part2{quant_suffix}"
253
+ model_path = self.find_model_path(base_name, "Regular part2 model")
254
+
255
+ DebugLog(f"Loading regular part2 model: {model_path}")
256
+ self.models[model_key] = load_model(model_path)
257
+ self.states['transformer'] = self.models[model_key].make_state()
258
+ DebugLog("Regular part2 model loaded successfully")
259
+ elif part in ['2D1S', '2D2S'] and self.use_split_functions:
260
+ # Load split model with prefill/infer functions
261
+ base_name = f"llama32_part{part}{quant_suffix}"
262
+ model_path = self.find_model_path(base_name, f"Split model part {part}")
263
+
264
+ DebugLog(f"Loading split model part {part}: {model_path}")
265
+ # Load prefill function
266
+ self.models[f'{part}_prefill'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='prefill')
267
+ # Load infer function
268
+ self.models[f'{part}_infer'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='infer')
269
+ # Create shared state for first part only
270
+ if part == '2D1S':
271
+ self.states['transformer'] = self.models[f'{part}_infer'].make_state()
272
+ DebugLog(f"Split model part {part} loaded successfully")
273
+ elif part.endswith('S') and self.use_quad_split_combined:
274
+ # Load combined quad split model with prefill/infer functions
275
+ base_name = f"llama32_part{part}{quant_suffix}"
276
+ model_path = self.find_model_path(base_name, f"Combined quad split part {part}")
277
+
278
+ DebugLog(f"Loading combined quad split part {part}: {model_path}")
279
+ # Load prefill function
280
+ self.models[f'{part}_prefill'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='prefill')
281
+ # Load infer function
282
+ self.models[f'{part}_infer'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='infer')
283
+ # Create shared state for first part only
284
+ if part == '2Q1S':
285
+ self.states['transformer'] = self.models[f'{part}_infer'].make_state()
286
+ DebugLog(f"Created shared transformer state for all quad split parts")
287
+ DebugLog(f"Combined quad split part {part} loaded successfully")
288
+ elif part.startswith('2Q') and self.use_quad_split:
289
+ # Load quad split model with prefill/infer functions
290
+ # Append 'S' to part name for file lookup
291
+ base_name = f"llama32_part{part}S{quant_suffix}"
292
+ model_path = self.find_model_path(base_name, f"Quad split part {part}")
293
+
294
+ DebugLog(f"Loading quad split part {part}: {model_path}")
295
+ # Load prefill function
296
+ self.models[f'{part}_prefill'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='prefill')
297
+ # Load infer function
298
+ self.models[f'{part}_infer'] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE, function_name='infer')
299
+ # Create shared state for first part only
300
+ if part == '2Q1':
301
+ self.states['transformer'] = self.models[f'{part}_infer'].make_state()
302
+ DebugLog(f"Created shared transformer state for all quad split parts")
303
+ print(f"Created shared transformer state for all quad split parts")
304
+ print(f"Quad split part {part} loaded successfully")
305
+ else:
306
+ # Load regular models (part 1 and part3)
307
+ base_name = f"llama32_part{part}{quant_suffix}"
308
+ model_path = self.find_model_path(base_name, f"Regular part {part}")
309
+
310
+ print(f"[MODEL LOAD] Regular part {part}:")
311
+ print(f" - File: {model_path}")
312
+ print(f" - Loading as: '{model_key}'")
313
+
314
+ # Try loading with CPU first, then fall back to CPU_AND_NE if needed
315
+ try:
316
+ self.models[model_key] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU_AND_NE)
317
+ print(f" - Loaded with CPU_AND_NE compute unit")
318
+ except Exception as cpu_error:
319
+ print(f" - CPU load failed, trying CPU_AND_NE: {str(cpu_error)}")
320
+ self.models[model_key] = load_model(model_path, compute_unit=ct.ComputeUnit.CPU)
321
+ print(f" - Loaded with CPU compute unit")
322
+
323
+ print(f"[MODEL LOAD] Current model_parts keys: {list(self.models.keys())}")
324
+
325
+ except Exception as e:
326
+ print(f"Error loading model part {part}: {str(e)}")
327
+ raise
328
+
329
+ def run_transformer_prefill(self, hidden_states, update_mask, position_ids, causal_mask, current_pos):
330
+ """Run the transformer model in prefill mode."""
331
+ if self.use_split_functions:
332
+ # Use prefill variants for split model
333
+ for part in ['2D1S', '2D2S']:
334
+ inputs = {
335
+ 'hidden_states': hidden_states.numpy(),
336
+ 'position_ids': position_ids.numpy(),
337
+ 'causal_mask': causal_mask.numpy(),
338
+ 'start_pos': current_pos.numpy()
339
+ }
340
+ output = self.models[f'{part}_prefill'].predict(inputs, self.states['transformer'])
341
+ hidden_states = torch.from_numpy(output['dummy_output'])
342
+ return hidden_states
343
+ else:
344
+ # Use existing prefill implementation
345
+ return super().run_transformer_prefill(hidden_states, update_mask, position_ids, causal_mask, current_pos)
346
+
347
+ def run_transformer_infer(self, hidden_states, update_mask, position_ids, causal_mask, current_pos):
348
+ """Run the transformer model in infer mode."""
349
+ if self.use_split_functions:
350
+ # Use infer variants for split model
351
+ for part in ['2D1S', '2D2S']:
352
+ inputs = {
353
+ 'hidden_states': hidden_states.numpy(),
354
+ 'update_mask': update_mask.numpy(),
355
+ 'position_ids': position_ids.numpy(),
356
+ 'causal_mask': causal_mask.numpy(),
357
+ 'current_pos': current_pos.numpy()
358
+ }
359
+ output = self.models[f'{part}_infer'].predict(inputs, self.states['transformer'])
360
+ hidden_states = torch.from_numpy(output['transformer_output'])
361
+ return hidden_states
362
+ else:
363
+ # Use existing infer implementation
364
+ return super().run_transformer_infer(hidden_states, update_mask, position_ids, causal_mask, current_pos)
365
+
366
+ def get_state(self, part):
367
+ """Get the appropriate state for a model part."""
368
+ return self.states['transformer']
369
+
370
+ def run_embeddings(self, input_ids):
371
+ """Run the embeddings model (part 1)."""
372
+ if '1' not in self.models:
373
+ raise ValueError("Embeddings model (part 1) not loaded")
374
+
375
+ output_dict = self.models['1'].predict({
376
+ 'input_ids': input_ids.numpy()
377
+ })
378
+ return torch.from_numpy(output_dict['hidden_states'])
379
+
380
+ def run_transformer(self, hidden_states, update_mask, position_ids, causal_mask, current_pos, part='2'):
381
+ """Run the transformer model."""
382
+ if part not in self.models:
383
+ raise ValueError(f"Transformer model (part {part}) not loaded")
384
+
385
+ inputs = {
386
+ 'hidden_states': hidden_states.numpy(),
387
+ 'update_mask': update_mask.numpy(),
388
+ 'position_ids': position_ids.numpy(),
389
+ 'causal_mask': causal_mask.numpy(),
390
+ 'current_pos': current_pos.numpy()
391
+ }
392
+
393
+ output_dict = self.models[part].predict(inputs, self.get_state(part))
394
+ return torch.from_numpy(output_dict['transformer_output'])
395
+
396
+ def run_transformer_splits(self, hidden_states, update_mask, position_ids, causal_mask, current_pos):
397
+ """Run through transformer splits based on model configuration."""
398
+ if not self.use_split_model:
399
+ return self.run_transformer(hidden_states, update_mask, position_ids, causal_mask, current_pos)
400
+
401
+ # Handle different split configurations
402
+ if any(part.startswith('2Q') for part in self.model_parts): # Quad split
403
+ for i in range(1, 5):
404
+ part = f'2Q{i}'
405
+ hidden_states = self.run_transformer(
406
+ hidden_states, update_mask, position_ids, causal_mask, current_pos, part=part
407
+ )
408
+ elif any(part.startswith('2O') for part in self.model_parts): # Octa split
409
+ for i in range(1, 9):
410
+ part = f'2O{i}'
411
+ hidden_states = self.run_transformer(
412
+ hidden_states, update_mask, position_ids, causal_mask, current_pos, part=part
413
+ )
414
+ elif any(part.startswith('2D') for part in self.model_parts): # Dual split
415
+ # Run through both parts of the dual split
416
+ for base_part in ['2D1', '2D2']:
417
+ # Find the correct model key (with lut suffix if present)
418
+ part_key = next(key for key in self.models.keys() if key.startswith(f'{base_part}_') or key == base_part)
419
+
420
+ # Use the shared transformer state
421
+ if 'transformer' not in self.states:
422
+ raise ValueError("Transformer state not initialized. Make sure 2D1 is loaded first.")
423
+
424
+ inputs = {
425
+ 'hidden_states': hidden_states.numpy(),
426
+ 'update_mask': update_mask.numpy(),
427
+ 'position_ids': position_ids.numpy(),
428
+ 'causal_mask': causal_mask.numpy(),
429
+ 'current_pos': current_pos.numpy()
430
+ }
431
+ output_dict = self.models[part_key].predict(inputs, self.states['transformer'])
432
+ hidden_states = torch.from_numpy(output_dict['transformer_output'])
433
+
434
+ return hidden_states
435
+
436
+ def run_lm_head(self, hidden_states):
437
+ """Run the LM head model (part 3)."""
438
+ if '3' not in self.models:
439
+ raise ValueError("LM head model (part 3) not loaded")
440
+
441
+ output_dict = self.models['3'].predict({
442
+ 'hidden_states': hidden_states.numpy()
443
+ })
444
+
445
+ # Handle split logits
446
+ logits_parts = []
447
+ for i in range(1, 9): # logits1 through logits8
448
+ logits_key = f'logits{i}'
449
+ if logits_key in output_dict:
450
+ logits_part = torch.from_numpy(output_dict[logits_key])
451
+ logits_parts.append(logits_part)
452
+
453
+ # Concatenate along the vocabulary dimension
454
+ return torch.cat(logits_parts, dim=-1)
455
+
456
+ def run_full_model(self, input_ids, update_mask, position_ids, causal_mask, current_pos):
457
+ """Run the full model."""
458
+ if 'full' not in self.models:
459
+ raise ValueError("Full model not loaded")
460
+
461
+ # Update context size from global
462
+ self.context_size = CONTEXT_LENGTH
463
+
464
+ #kv_ was removed from the input names
465
+ inputs = {
466
+ 'input_ids': input_ids.numpy(),
467
+ 'update_mask': update_mask.numpy(),
468
+ 'position_ids': position_ids.numpy(),
469
+ 'causal_mask': causal_mask.numpy(),
470
+ 'current_pos': current_pos.numpy()
471
+ }
472
+
473
+ # Print shapes of all inputs
474
+ if False:
475
+ print("[DEBUG] Input shapes:")
476
+ for key, value in inputs.items():
477
+ print(f" {key}: {value.shape}")
478
+
479
+ output_dict = self.models['full'].predict(inputs, self.states['transformer'])
480
+
481
+ # Handle split logits if necessary
482
+ if ENABLE_VACAB_SPLIT8:
483
+ logits_parts = []
484
+ for i in range(1, 9):
485
+ logits_parts.append(output_dict[f'logits{i}'])
486
+ logits = np.concatenate(logits_parts, axis=-1)
487
+ else:
488
+ logits = output_dict['logits']
489
+
490
+ return torch.from_numpy(logits)
491
+
492
+ def make_causal_mask(length, start):
493
+
494
+ # Initialize the mask with -inf
495
+ mask = np.full((1, 1, length, length), -np.inf, dtype=np.float16)
496
+
497
+ # Create row and column indices
498
+ row_indices = np.arange(length).reshape(length, 1) # Column vector
499
+ col_indices = np.arange(length).reshape(1, length) # Row vector
500
+
501
+ # Set allowed positions to 0 where col_index is within the allowed range of row_index
502
+ mask[:, :, col_indices <= (row_indices + start)] = 0
503
+ return mask
504
+
505
+ def initialize_tokenizer(model_path):
506
+ """Initialize and configure the tokenizer."""
507
+ try:
508
+ print(f"[DEBUG] Loading tokenizer from model path: {model_path}")
509
+ tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
510
+
511
+ print("\n[DEBUG] Tokenizer Configuration:")
512
+ print(f"Tokenizer type: {type(tokenizer)}")
513
+ print(f"Tokenizer name: {tokenizer.__class__.__name__}")
514
+ print(f"Vocabulary size: {len(tokenizer)}")
515
+ print(f"Model max length: {tokenizer.model_max_length}")
516
+ #print(f"Chat template: {tokenizer.chat_template if hasattr(tokenizer, 'chat_template') else 'None'}")
517
+
518
+ if tokenizer.pad_token is None:
519
+ tokenizer.pad_token = tokenizer.eos_token
520
+ tokenizer.pad_token_id = tokenizer.eos_token_id
521
+ print("[DEBUG] Set PAD token to EOS token")
522
+
523
+ print(f"\n[DEBUG] Special Tokens:")
524
+ print(f"PAD token: '{tokenizer.pad_token}' (ID: {tokenizer.pad_token_id})")
525
+ print(f"EOS token: '{tokenizer.eos_token}' (ID: {tokenizer.eos_token_id})")
526
+ print(f"BOS token: '{tokenizer.bos_token}' (ID: {tokenizer.bos_token_id})")
527
+ print(f"UNK token: '{tokenizer.unk_token}' (ID: {tokenizer.unk_token_id})")
528
+
529
+ return tokenizer
530
+
531
+ except Exception as e:
532
+ print(f"[ERROR] Failed to load tokenizer from {model_path}")
533
+ return None
534
+
535
+ class TokenPrinter:
536
+ """Handles background printing of generated tokens."""
537
+ def __init__(self, tokenizer):
538
+ self.tokenizer = tokenizer
539
+ self.token_queue = queue.Queue()
540
+ self.stop_event = threading.Event()
541
+ self.thread = None
542
+ self.buffer = ""
543
+ self.lock = threading.Lock()
544
+ self.thinking = True # Track if we're still in thinking mode
545
+ self.decoding_buffer = [] # <-- Buffer for token IDs
546
+ self.start()
547
+
548
+ def start(self):
549
+ """Start the printer thread."""
550
+ if self.thread is None:
551
+ self.thread = threading.Thread(target=self._print_worker)
552
+ self.thread.daemon = True
553
+ self.thread.start()
554
+
555
+ def add_token(self, token_id):
556
+ """Add a token to the print queue."""
557
+ if not self.stop_event.is_set():
558
+ self.token_queue.put(token_id)
559
+
560
+ def drain_buffer(self):
561
+ """
562
+ Decode token IDs from self.decoding_buffer in the main thread,
563
+ then print them with the correct color logic.
564
+ """
565
+ if not self.decoding_buffer:
566
+ return
567
+
568
+ # Decode all tokens at once in the main thread.
569
+ token_str = self.tokenizer.decode(self.decoding_buffer)
570
+ self.decoding_buffer.clear()
571
+
572
+ # Color-handling logic. Check for "</think>" and handle self.thinking.
573
+ if self.thinking and "</think>" in token_str:
574
+ self.thinking = False
575
+ parts = token_str.split("</think>")
576
+ if len(parts) > 0:
577
+ print(parts[0] + "</think>", end='', flush=True)
578
+ if len(parts) > 1:
579
+ print(LIGHT_BLUE + parts[1], end='', flush=True)
580
+ else:
581
+ if not self.thinking:
582
+ print(LIGHT_BLUE + token_str, end='', flush=True)
583
+ else:
584
+ print(token_str, end='', flush=True)
585
+
586
+ def _print_worker(self):
587
+ """Worker thread that takes token_ids from the queue but doesn't decode."""
588
+ while not self.stop_event.is_set():
589
+ try:
590
+ token_id = self.token_queue.get(timeout=0.01)
591
+ with self.lock:
592
+ # Just store the token_id, decode later on the main thread
593
+ self.decoding_buffer.append(token_id)
594
+ self.token_queue.task_done()
595
+ except queue.Empty:
596
+ continue
597
+ except Exception as e:
598
+ print(f"\n[ERROR] Token printer error: {str(e)}")
599
+ break
600
+
601
+ def stop(self):
602
+ """Stop the printer thread."""
603
+ if self.thread and self.thread.is_alive():
604
+ self.stop_event.set()
605
+ try:
606
+ self.thread.join(timeout=1.0)
607
+ except Exception:
608
+ pass
609
+ print(RESET_COLOR) # Reset color at the end
610
+ return self.buffer
611
+
612
+ def parse_coreml_error(error_str):
613
+ """Parse CoreML error message to extract shape information.
614
+
615
+ Args:
616
+ error_str: The error message string from CoreML
617
+
618
+ Returns:
619
+ tuple: (got_shape, expected_shape) or None if parsing fails
620
+ """
621
+ try:
622
+ # Extract shapes from error message using regex
623
+ pattern = r"shape \(([\d\s x]+)\) does not match the shape \(([\d\s x]+)\)"
624
+ match = re.search(pattern, str(error_str))
625
+ if match:
626
+ got_shape = tuple(int(x) for x in match.group(1).split('x'))
627
+ expected_shape = tuple(int(x) for x in match.group(2).split('x'))
628
+ return got_shape, expected_shape
629
+ return None
630
+ except Exception as e:
631
+ print(f"Error parsing CoreML error message: {e}")
632
+ return None
633
+
634
+ def handle_coreml_shape_error(e, model_name=""):
635
+ """Handle CoreML shape mismatch errors with detailed information.
636
+
637
+ Args:
638
+ e: The exception object
639
+ model_name: Name of the model for better error reporting
640
+ """
641
+ error_str = str(e)
642
+ if "MultiArray shape" in error_str:
643
+ shape_info = parse_coreml_error(error_str)
644
+ if shape_info:
645
+ got_shape, expected_shape = shape_info
646
+ print(f"\n[ERROR] Shape mismatch in {model_name}:")
647
+ print(f" Got shape: {' x '.join(str(x) for x in got_shape)}")
648
+ print(f" Expected shape: {' x '.join(str(x) for x in expected_shape)}")
649
+ print("This usually indicates a mismatch between the model's expected context length")
650
+ print("and the actual input being provided.")
651
+ else:
652
+ print(f"\n[ERROR] Shape mismatch error in {model_name}:")
653
+ print(f" {error_str}")
654
+ else:
655
+ print(f"\n[ERROR] CoreML error in {model_name}:")
656
+ print(f" {error_str}")
657
+
658
+ def PreFillChunk(model_parts, input_ids, current_pos, context_size, causal_mask, batch_size=64):
659
+ tokens_to_process = current_pos
660
+ batch_pos = 0
661
+
662
+ while batch_pos < tokens_to_process:
663
+ batch_end = min(batch_pos + batch_size, tokens_to_process)
664
+ current_batch_size = batch_end - batch_pos
665
+
666
+ try:
667
+ # Get current batch of tokens
668
+ batch_input = input_ids[:, batch_pos:batch_end]
669
+
670
+ # Pad if needed
671
+ if current_batch_size < batch_size:
672
+ batch_input = F.pad(
673
+ batch_input,
674
+ (0, batch_size - current_batch_size),
675
+ value=0
676
+ )
677
+
678
+ # Generate position IDs for this batch
679
+ position_ids = torch.arange(batch_pos, batch_pos + batch_size, dtype=torch.int32)
680
+
681
+ # Prepare causal mask for this batch
682
+ multiple_causal_mask = causal_mask[:, :, batch_pos:batch_pos + batch_size, :]
683
+
684
+ # Find the correct model key for part 1 (with lut suffix if present)
685
+ part1_key = next(key for key in model_parts.keys() if key.startswith('1_') or key == '1')
686
+
687
+ try:
688
+ # Run embeddings (part 1)
689
+ hidden_states = model_parts[part1_key].predict({'input_ids': batch_input.numpy()})['hidden_states']
690
+ hidden_states = torch.from_numpy(hidden_states)
691
+ except Exception as e:
692
+ handle_coreml_shape_error(e, f"embeddings model (part {part1_key})")
693
+ raise
694
+
695
+ # Get shared transformer state
696
+ shared_state = model_parts['states']['transformer']
697
+
698
+ # Handle different model configurations
699
+ if any(f'{part}_prefill' in model_parts for part in ['2D1S', '2D2S']):
700
+ # S123 mode with prefill/infer functions
701
+ for part in ['2D1S', '2D2S']:
702
+ try:
703
+ inputs = {
704
+ 'hidden_states': hidden_states.numpy(),
705
+ 'position_ids': position_ids.numpy(),
706
+ 'causal_mask': multiple_causal_mask.numpy(),
707
+ 'start_pos': np.array([batch_pos], dtype=np.int32)
708
+ }
709
+ output = model_parts[f'{part}_prefill'].predict(inputs, shared_state)
710
+ hidden_states = torch.from_numpy(output['dummy_output'])
711
+ except Exception as e:
712
+ handle_coreml_shape_error(e, f"transformer model (part {part})")
713
+ raise
714
+ elif any(part.endswith('S') for part in model_parts if part.startswith('2Q')):
715
+ # Q123S mode with combined quad split
716
+ for i in range(1, 5):
717
+ part = f'2Q{i}S'
718
+ try:
719
+ inputs = {
720
+ 'hidden_states': hidden_states.numpy(),
721
+ 'position_ids': position_ids.numpy(),
722
+ 'causal_mask': multiple_causal_mask.numpy(),
723
+ 'start_pos': np.array([batch_pos], dtype=np.int32)
724
+ }
725
+ output = model_parts[f'{part}_prefill'].predict(inputs, shared_state)
726
+ hidden_states = torch.from_numpy(output['dummy_output'])
727
+ except Exception as e:
728
+ handle_coreml_shape_error(e, f"transformer model (part {part})")
729
+ raise
730
+ elif any(part.startswith('2Q') for part in model_parts):
731
+ # Q123 mode with quad split
732
+ for i in range(1, 5):
733
+ part = f'2Q{i}'
734
+ if f'{part}_prefill' in model_parts:
735
+ # Use prefill function if available
736
+ try:
737
+ inputs = {
738
+ 'hidden_states': hidden_states.numpy(),
739
+ 'position_ids': position_ids.numpy(),
740
+ 'causal_mask': multiple_causal_mask.numpy(),
741
+ 'start_pos': np.array([batch_pos], dtype=np.int32)
742
+ }
743
+ output = model_parts[f'{part}_prefill'].predict(inputs, shared_state)
744
+ hidden_states = torch.from_numpy(output['dummy_output'])
745
+ except Exception as e:
746
+ handle_coreml_shape_error(e, f"transformer model (part {part})")
747
+ raise
748
+ else:
749
+ # Use regular predict if no prefill function
750
+ try:
751
+ inputs = {
752
+ 'hidden_states': hidden_states.numpy(),
753
+ 'update_mask': torch.zeros((1, 1, context_size, 1), dtype=torch.float16).numpy(),
754
+ 'position_ids': position_ids.numpy(),
755
+ 'causal_mask': multiple_causal_mask.numpy(),
756
+ 'current_pos': position_ids[0].numpy()
757
+ }
758
+ output = model_parts[part].predict(inputs, shared_state)
759
+ hidden_states = torch.from_numpy(output['transformer_output'])
760
+ except Exception as e:
761
+ handle_coreml_shape_error(e, f"transformer model (part {part})")
762
+ raise
763
+ elif any(key.startswith('2D') for key in model_parts.keys()):
764
+ # 123D mode with dual split (no prefill functions)
765
+ for base_part in ['2D1', '2D2']:
766
+ # Find the correct model key (with lut suffix if present)
767
+ part_key = next(key for key in model_parts.keys() if key.startswith(f'{base_part}_') or key == base_part)
768
+ try:
769
+ inputs = {
770
+ 'hidden_states': hidden_states.numpy(),
771
+ 'update_mask': torch.zeros((1, 1, context_size, 1), dtype=torch.float16).numpy(),
772
+ 'position_ids': position_ids.numpy(),
773
+ 'causal_mask': multiple_causal_mask.numpy(),
774
+ 'current_pos': position_ids[0].numpy()
775
+ }
776
+ output = model_parts[part_key].predict(inputs, shared_state)
777
+ hidden_states = torch.from_numpy(output['transformer_output'])
778
+ except Exception as e:
779
+ handle_coreml_shape_error(e, f"transformer model (part {part_key})")
780
+ raise
781
+
782
+ batch_pos = batch_end
783
+
784
+ except Exception as e:
785
+ print(f"\n[ERROR] Failed processing batch {batch_pos}-{batch_end}:")
786
+ print(f" {str(e)}")
787
+ raise
788
+
789
+ return torch.tensor([current_pos], dtype=torch.int32)
790
+
791
+ def PreFillChunkOneByOne(model_parts, input_ids, current_pos, context_size, causal_mask):
792
+ """Process prefill tokens one at a time using infer function."""
793
+ #print(f"[DEBUG] Starting one-by-one prefill for {current_pos} tokens")
794
+
795
+ for pos in range(current_pos):
796
+ # Get current token
797
+ current_token = input_ids[:, pos:pos+1]
798
+ single_causal_mask = causal_mask[:, :, pos:pos+1, :]
799
+ current_pos_tensor = torch.tensor([pos], dtype=torch.int32)
800
+
801
+ # Find the correct model key for part 1 (with lut suffix if present)
802
+ part1_key = next(key for key in model_parts.keys() if key.startswith('1_') or key == '1')
803
+
804
+ # Run embeddings (part 1)
805
+ hidden_states = torch.from_numpy(model_parts[part1_key].predict({
806
+ 'input_ids': current_token.numpy()
807
+ })['hidden_states'])
808
+
809
+ #print(f"[DEBUG] pos: {pos} token: {current_token.item()} states: {hidden_states.shape}")
810
+
811
+ # Get shared transformer state
812
+ shared_state = model_parts['states']['transformer']
813
+
814
+ # Handle different model configurations
815
+ if any(f'{part}_infer' in model_parts for part in ['2D1S', '2D2S']):
816
+ # S123 mode with prefill/infer functions
817
+ for part in ['2D1S', '2D2S']:
818
+ inputs = {
819
+ 'hidden_states': hidden_states.numpy(),
820
+ 'update_mask': np.zeros((1, 1, context_size, 1), dtype=np.float16),
821
+ 'position_ids': current_pos_tensor.numpy(),
822
+ 'causal_mask': single_causal_mask.numpy(),
823
+ 'current_pos': current_pos_tensor.numpy()
824
+ }
825
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
826
+ hidden_states = torch.from_numpy(output['transformer_output'])
827
+ elif any(key.startswith('2D') for key in model_parts.keys()):
828
+ # 123D mode or individual parts mode
829
+ for base_part in ['2D1', '2D2']:
830
+ # Find the correct model key (with lut suffix if present)
831
+ part_key = next(key for key in model_parts.keys() if key.startswith(f'{base_part}_') or key == base_part)
832
+ inputs = {
833
+ 'hidden_states': hidden_states.numpy(),
834
+ 'update_mask': np.zeros((1, 1, context_size, 1), dtype=np.float16),
835
+ 'position_ids': current_pos_tensor.numpy(),
836
+ 'causal_mask': single_causal_mask.numpy(),
837
+ 'current_pos': current_pos_tensor.numpy()
838
+ }
839
+ output = model_parts[part_key].predict(inputs, shared_state)
840
+ hidden_states = torch.from_numpy(output['transformer_output'])
841
+
842
+ return torch.tensor([current_pos], dtype=torch.int32)
843
+
844
+ def run_inference(model_parts, tokenizer, prompt, context_size=CONTEXT_LENGTH, num_iterations=5, temperature=0.0):
845
+ """Run inference using model parts."""
846
+ DebugLog(f"\nPrompt: {prompt}")
847
+ if temperature > 0:
848
+ DebugLog(f"Using temperature: {temperature}")
849
+
850
+ # Prepare the prompt
851
+ messages = [{"role": "user", "content": prompt}]
852
+ formatted_input = tokenizer.apply_chat_template(
853
+ messages,
854
+ return_tensors="pt",
855
+ add_generation_prompt=False
856
+ )
857
+ decoded_input = tokenizer.decode(formatted_input[0])
858
+ DebugLog(f"Decoded input: {decoded_input}")
859
+ DebugLog(f"prompt: {prompt}")
860
+ DebugLog(f"formatted_input size: {formatted_input.size()}")
861
+ DebugLog(f"formatted_input: {formatted_input}")
862
+
863
+ base_input_ids = formatted_input.to(torch.int32)
864
+ context_pos = base_input_ids.size(1)
865
+ prompt_tokens = context_pos - 1
866
+
867
+ # Pad sequence to context_size
868
+ input_ids = F.pad(
869
+ base_input_ids,
870
+ (0, context_size - context_pos),
871
+ value=0
872
+ )
873
+
874
+ DebugLog(f"context_pos (prompt length) = {context_pos}")
875
+
876
+ # Create causal mask
877
+ causal_mask = make_causal_mask(context_size, 0)
878
+ causal_mask = torch.tensor(causal_mask, dtype=torch.float16)
879
+
880
+ # Prefill phase
881
+ DebugLog("\nStarting prefill...")
882
+ start_time = time.time()
883
+
884
+ # Check if we're using 123D mode or individual parts
885
+ use_single_token = any(key.contains('2D') for key in model_parts.keys()) or any(part.contains('2D') for part in model_parts)
886
+
887
+ if False: #use_single_token:
888
+ print("\nRunning ST prefill...")
889
+ current_pos = PreFillChunkOneByOne(
890
+ model_parts,
891
+ input_ids,
892
+ context_pos - 1,
893
+ context_size,
894
+ causal_mask
895
+ )
896
+ sequential_prefill_time = time.time() - start_time
897
+ batch_prefll_time = 0.0
898
+ else:
899
+ print("\nRunning batch prefill...")
900
+ current_pos = PreFillChunk(
901
+ model_parts,
902
+ input_ids,
903
+ context_pos - 1,
904
+ context_size,
905
+ causal_mask,
906
+ batch_size=PREFILL_BATCH_SIZE
907
+ )
908
+ batch_prefill_time = time.time() - start_time
909
+ sequential_prefill_time = 0.0
910
+
911
+ # Initialize token printer
912
+ token_printer = TokenPrinter(tokenizer)
913
+ print("\nGenerated response:", end=' ', flush=True)
914
+
915
+ # Generation loop
916
+ start_gen_time = time.time()
917
+ pos = context_pos - 1
918
+
919
+ tokens_generated = 0
920
+ try:
921
+ DebugLog(f"\nStarting inference... context_pos: {context_pos}")
922
+ pos = context_pos
923
+ for step in range(num_iterations):
924
+ with torch.no_grad():
925
+ # Check if we need to shift cache
926
+ if pos >= context_size - 2:
927
+ shift_size = context_size // 4
928
+ new_size = context_size - shift_size
929
+
930
+ # Create shifted input_ids and preserve the most recent context
931
+ # Don't add BOS token since this is a continuation
932
+ tmp = torch.zeros((1, context_size), dtype=torch.int32)
933
+ tmp[:,0:new_size] = input_ids[:,shift_size:context_size]
934
+ input_ids = tmp
935
+
936
+ # Adjust position after shift
937
+ pos = new_size
938
+
939
+ # Create update mask for current position
940
+ update_mask = torch.zeros((1, 1, context_size, 1), dtype=torch.float16)
941
+ update_mask[0, 0, pos-1, 0] = 1.0
942
+
943
+ #print(f"\n[DEBUG] Shifted cache by {shift_size} tokens, maintaining context window of {new_size} tokens, new pos: {pos}")
944
+
945
+ # For Q123 mode, we need to run prefill on the shifted sequence
946
+ if any(part.startswith('2Q') for part in model_parts):
947
+ # Run prefill using PreFillChunk with proper batch size
948
+ # No need to adjust position since we're not adding BOS
949
+ current_pos = PreFillChunk(
950
+ model_parts,
951
+ input_ids,
952
+ pos-1, # how much ob
953
+ context_size, # Use full context size
954
+ causal_mask,
955
+ batch_size=PREFILL_BATCH_SIZE
956
+ )
957
+ #print(f"[DEBUG] Ran prefill after shift for position {pos} with batch_size={PREFILL_BATCH_SIZE}")
958
+ # Position should already be correct since we didn't add BOS
959
+ pos = current_pos
960
+
961
+ # Get current token
962
+ current_token = input_ids[:, pos-1:pos]
963
+
964
+ # Find the correct model key for part 1 (with lut suffix if present)
965
+ part1_key = next(key for key in model_parts.keys() if key.startswith('1_') or key == '1')
966
+
967
+ # Run embeddings (part 1)
968
+ hidden_states = model_parts[part1_key].predict({
969
+ 'input_ids': current_token.numpy()
970
+ })['hidden_states']
971
+ hidden_states = torch.from_numpy(hidden_states)
972
+
973
+ # Get shared transformer state
974
+ shared_state = model_parts['states']['transformer']
975
+
976
+ # Create update mask for current position
977
+ update_mask = torch.zeros((1, 1, context_size, 1), dtype=torch.float16)
978
+ update_mask[0, 0, pos-1, 0] = 1.0
979
+
980
+ # Create position IDs tensor
981
+ position_ids = torch.tensor([pos-1], dtype=torch.int32)
982
+
983
+ # Create causal mask for current position
984
+ single_causal_mask = causal_mask[:, :, pos-1:pos, :]
985
+
986
+ # Run transformer layers based on model type
987
+ if any(f'{part}_infer' in model_parts for part in ['2D1S', '2D2S']):
988
+ # S123 mode with prefill/infer functions
989
+ for part in ['2D1S', '2D2S']:
990
+ inputs = {
991
+ 'hidden_states': hidden_states.numpy(),
992
+ 'update_mask': update_mask.numpy(),
993
+ 'position_ids': position_ids.numpy(),
994
+ 'causal_mask': single_causal_mask.numpy(),
995
+ 'current_pos': position_ids.numpy()
996
+ }
997
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
998
+ hidden_states = torch.from_numpy(output['transformer_output'])
999
+ elif any(part.startswith('2Q') for part in model_parts.keys()):
1000
+ # Q123S mode with combined quad split
1001
+ for i in range(1, 5):
1002
+ part = f'2Q{i}S'
1003
+ inputs = {
1004
+ 'hidden_states': hidden_states.numpy(),
1005
+ 'update_mask': update_mask.numpy(),
1006
+ 'position_ids': position_ids.numpy(),
1007
+ 'causal_mask': single_causal_mask.numpy(),
1008
+ 'current_pos': position_ids.numpy()
1009
+ }
1010
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
1011
+ hidden_states = torch.from_numpy(output['transformer_output'])
1012
+ elif any(part.startswith('2Q') for part in model_parts):
1013
+ # Q123 mode with quad split
1014
+ #print(f"[DEBUG] Running quad split inference at position {pos}")
1015
+ for i in range(1, 5):
1016
+ part = f'2Q{i}'
1017
+ if f'{part}_infer' in model_parts:
1018
+ # Use infer function if available
1019
+ inputs = {
1020
+ 'hidden_states': hidden_states.numpy(),
1021
+ 'update_mask': update_mask.numpy(),
1022
+ 'position_ids': position_ids.numpy(),
1023
+ 'causal_mask': single_causal_mask.numpy(),
1024
+ 'current_pos': position_ids.numpy()
1025
+ }
1026
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
1027
+ else:
1028
+ # Use regular predict if no infer function
1029
+ inputs = {
1030
+ 'hidden_states': hidden_states.numpy(),
1031
+ 'update_mask': update_mask.numpy(),
1032
+ 'position_ids': position_ids.numpy(),
1033
+ 'causal_mask': single_causal_mask.numpy(),
1034
+ 'current_pos': position_ids.numpy()
1035
+ }
1036
+ output = model_parts[part].predict(inputs, shared_state)
1037
+ hidden_states = torch.from_numpy(output['transformer_output'])
1038
+ elif any(key.startswith('2D') for key in model_parts.keys()):
1039
+ # 123D mode or individual parts mode
1040
+ for base_part in ['2D1', '2D2']:
1041
+ # Find the correct model key (with lut suffix if present)
1042
+ part_key = next(key for key in model_parts.keys() if key.startswith(f'{base_part}_') or key == base_part)
1043
+ inputs = {
1044
+ 'hidden_states': hidden_states.numpy(),
1045
+ 'update_mask': update_mask.numpy(),
1046
+ 'position_ids': position_ids.numpy(),
1047
+ 'causal_mask': single_causal_mask.numpy(),
1048
+ 'current_pos': position_ids.numpy()
1049
+ }
1050
+ output = model_parts[part_key].predict(inputs, shared_state)
1051
+ hidden_states = torch.from_numpy(output['transformer_output'])
1052
+ else:
1053
+ print("\n[ERROR] No transformer model parts found!")
1054
+ break
1055
+
1056
+ try:
1057
+ # Run final layer norm and get logits
1058
+ # Find the correct model key for part 3 (with lut suffix if present)
1059
+ part3_key = next(key for key in model_parts.keys() if key.startswith('3_') or key == '3')
1060
+ output_dict = model_parts[part3_key].predict({
1061
+ 'hidden_states': hidden_states.numpy()
1062
+ })
1063
+
1064
+ if ENABLE_VACAB_SPLIT8:
1065
+ # Get all logits parts in a single call
1066
+ logits_parts = []
1067
+ for i in range(1, 9):
1068
+ logits_parts.append(output_dict[f'logits{i}'])
1069
+ logits = np.concatenate(logits_parts, axis=-1)
1070
+ elif ENABLE_LOGITS2:
1071
+ # Get both logits parts in a single call
1072
+ logits = np.concatenate([
1073
+ output_dict['logits1'],
1074
+ output_dict['logits2']
1075
+ ], axis=-1)
1076
+ else:
1077
+ logits = output_dict['logits']
1078
+
1079
+ # Convert to tensor and get next token
1080
+ logits = torch.from_numpy(logits)
1081
+
1082
+ # Apply temperature if specified
1083
+ if temperature > 0:
1084
+ # Scale logits by temperature
1085
+ logits = logits / temperature
1086
+ # Apply softmax to get probabilities
1087
+ probs = F.softmax(logits[0, -1, :], dim=-1)
1088
+ # Sample from the distribution
1089
+ next_token = torch.multinomial(probs, num_samples=1).item()
1090
+ else:
1091
+ # Use argmax if no temperature
1092
+ next_token = torch.argmax(logits[0, -1, :]).item()
1093
+
1094
+ # Add token to input sequence
1095
+ input_ids[0, pos] = next_token
1096
+ token_printer.add_token(next_token)
1097
+
1098
+ # Safely decode tokens in the main thread
1099
+ token_printer.drain_buffer()
1100
+
1101
+ # Update position and count
1102
+ pos += 1
1103
+ tokens_generated += 1
1104
+
1105
+ if next_token == tokenizer.eos_token_id:
1106
+ print("\n[DEBUG] Generated EOS token, stopping...")
1107
+ break
1108
+ except Exception as e:
1109
+ print(f"\n[ERROR] Error in final layer or token generation: {str(e)}")
1110
+ break
1111
+
1112
+ except KeyboardInterrupt:
1113
+ print("\n[DEBUG] Interrupted by user")
1114
+ except Exception as e:
1115
+ print(f"\n[ERROR] Exception during inference: {str(e)}")
1116
+ print(traceback.format_exc())
1117
+
1118
+ # Print timing statistics
1119
+ end_time = time.time()
1120
+ total_time = end_time - start_gen_time
1121
+
1122
+ print(f"\n\nTotal time: {total_time:.2f} seconds")
1123
+ print(f"Generation tokens: {tokens_generated}")
1124
+ print(f"Prefill tokens: {prompt_tokens}")
1125
+ print(f"Total tokens (prefill + generation): {prompt_tokens + tokens_generated}")
1126
+
1127
+ if prompt_tokens > 0:
1128
+ if batch_prefill_time > 0: # If using batch prefill
1129
+ prefill_tokens_per_second = prompt_tokens / batch_prefill_time
1130
+ effective_prefill_tokens_per_second = prompt_tokens / batch_prefill_time # Don't multiply by batch size
1131
+ print(f"Actual prefill tokens per second: {prefill_tokens_per_second:.2f}")
1132
+ print(f"Effective prefill tokens per second (batch={PREFILL_BATCH_SIZE}): {effective_prefill_tokens_per_second:.2f}")
1133
+ elif sequential_prefill_time > 0: # If using sequential prefill
1134
+ prefill_tokens_per_second = prompt_tokens / sequential_prefill_time
1135
+ print(f"Sequential prefill tokens per second: {prefill_tokens_per_second:.2f}")
1136
+
1137
+ if tokens_generated > 0:
1138
+ total_processing_time = total_time + (batch_prefill_time if batch_prefill_time > 0 else sequential_prefill_time)
1139
+ overall_tokens_per_second = (prompt_tokens + tokens_generated) / total_processing_time
1140
+ generation_tokens_per_second = tokens_generated / total_time
1141
+ print(f"Overall tokens processed per second (including prefill): {overall_tokens_per_second:.2f}")
1142
+ print(f"Generation-only tokens per second: {generation_tokens_per_second:.2f}")
1143
+
1144
+ return token_printer.stop(), {
1145
+ 'total_time': total_time,
1146
+ 'batch_prefill_time': batch_prefill_time,
1147
+ 'sequential_prefill_time': sequential_prefill_time,
1148
+ 'tokens_generated': tokens_generated,
1149
+ 'prompt_tokens': prompt_tokens
1150
+ }
1151
+
1152
+ def DebugLog(message, always_print=False):
1153
+ """Print debug message if ENABLE_CHAT_DEBUG is True or always_print is True.
1154
+
1155
+ Args:
1156
+ message: Message to print
1157
+ always_print: If True, print regardless of ENABLE_CHAT_DEBUG setting
1158
+ """
1159
+ if ENABLE_CHAT_DEBUG or always_print:
1160
+ print(f"[DEBUG] {message}")
1161
+
1162
+ def chat_loop(model_parts, tokenizer, context_size=CONTEXT_LENGTH, temperature=0.0):
1163
+ """Interactive chat loop that maintains conversation history."""
1164
+ print("\nStarting chat session. Press Ctrl+D to exit.")
1165
+ print("Type your message and press Enter to chat.")
1166
+
1167
+ DebugLog(f"Using context size: {context_size}")
1168
+ DebugLog(f"Temperature: {temperature}")
1169
+ DebugLog(f"Model parts loaded: {list(model_parts.keys())}")
1170
+
1171
+ # Initialize conversation history
1172
+ conversation = []
1173
+ input_ids = None
1174
+ current_pos = 0
1175
+
1176
+ try:
1177
+ while True:
1178
+ try:
1179
+ print(f"\n{LIGHT_GREEN}You:{RESET_COLOR}", end=' ', flush=True)
1180
+ user_input = input().strip()
1181
+ except EOFError:
1182
+ print("\nExiting chat...")
1183
+ break
1184
+
1185
+ if not user_input:
1186
+ continue
1187
+
1188
+ # Add user message to conversation
1189
+ conversation.append({"role": "user", "content": user_input})
1190
+
1191
+ DebugLog("\nFormatting conversation:")
1192
+ for msg in conversation:
1193
+ DebugLog(f" {msg['role']}: {msg['content'][:50]}...")
1194
+
1195
+ # Format entire conversation
1196
+ formatted_input = tokenizer.apply_chat_template(
1197
+ conversation,
1198
+ return_tensors="pt",
1199
+ add_generation_prompt=True
1200
+ )
1201
+
1202
+ DebugLog("\nTokenization:")
1203
+ DebugLog(f"Input token IDs: {formatted_input[0][:50]}...")
1204
+ DebugLog(f"Decoded tokens: {tokenizer.decode(formatted_input[0][:50])}...")
1205
+ DebugLog(f"Total tokens: {formatted_input.size(1)}")
1206
+
1207
+ # Convert to int32 tensor
1208
+ base_input_ids = formatted_input.to(torch.int32)
1209
+ context_pos = base_input_ids.size(1)
1210
+
1211
+ DebugLog(f"Context position: {context_pos}")
1212
+
1213
+ # Check if we need to truncate history
1214
+ if context_pos >= context_size - 100:
1215
+ DebugLog(f"\nNeed to truncate: {context_pos} tokens > {context_size-100} limit")
1216
+ while context_pos >= context_size - 100 and len(conversation) > 2:
1217
+ removed = conversation.pop(0)
1218
+ DebugLog(f"Removed message: {removed['role']}: {removed['content'][:30]}...")
1219
+ formatted_input = tokenizer.apply_chat_template(
1220
+ conversation,
1221
+ return_tensors="pt",
1222
+ add_generation_prompt=True
1223
+ )
1224
+ base_input_ids = formatted_input.to(torch.int32)
1225
+ context_pos = base_input_ids.size(1)
1226
+ DebugLog(f"New context size: {context_pos}")
1227
+
1228
+ # Pad sequence to context_size
1229
+ input_ids = F.pad(
1230
+ base_input_ids,
1231
+ (0, context_size - context_pos),
1232
+ value=0
1233
+ )
1234
+
1235
+ # Create causal mask for the entire context
1236
+ causal_mask = make_causal_mask(context_size, 0)
1237
+ causal_mask = torch.tensor(causal_mask, dtype=torch.float16)
1238
+ DebugLog(f"Created causal mask with shape: {causal_mask.shape}")
1239
+
1240
+ print(f"\n{LIGHT_BLUE}Assistant:{RESET_COLOR}", end=' ', flush=True)
1241
+
1242
+ # Run prefill on entire context
1243
+ if False: #any(key.contains('2D') for key in model_parts.keys()):
1244
+ DebugLog("Using sequential prefill")
1245
+ current_pos = PreFillChunkOneByOne(
1246
+ model_parts,
1247
+ input_ids,
1248
+ context_pos,
1249
+ context_size,
1250
+ causal_mask
1251
+ )
1252
+ elif any(part.startswith('2Q') for part in model_parts.keys()):
1253
+ DebugLog(f"Using quad split prefill (size={PREFILL_BATCH_SIZE})")
1254
+ current_pos = PreFillChunk(
1255
+ model_parts,
1256
+ input_ids,
1257
+ context_pos,
1258
+ context_size,
1259
+ causal_mask,
1260
+ batch_size=PREFILL_BATCH_SIZE
1261
+ )
1262
+ else:
1263
+ DebugLog(f"Using standard batch prefill (size={PREFILL_BATCH_SIZE})")
1264
+ current_pos = PreFillChunk(
1265
+ model_parts,
1266
+ input_ids,
1267
+ context_pos,
1268
+ context_size,
1269
+ causal_mask,
1270
+ batch_size=PREFILL_BATCH_SIZE
1271
+ )
1272
+
1273
+ # Initialize token printer
1274
+ token_printer = TokenPrinter(tokenizer)
1275
+
1276
+ # Generation loop
1277
+ pos = context_pos
1278
+ response_tokens = []
1279
+ generation_start_time = time.time() # Add timing
1280
+
1281
+ try:
1282
+ while True: # Changed from context_size - 1 to True for continuous generation
1283
+ # Check if we need to shift window
1284
+ if pos >= context_size - 2:
1285
+ DebugLog("\nShifting context window...")
1286
+
1287
+ shift_size = context_size // 4 # Shift by 1/4 of context
1288
+ new_size = context_size - shift_size
1289
+
1290
+ # Create shifted input_ids and preserve the most recent context
1291
+ tmp = torch.zeros((1, context_size), dtype=torch.int32)
1292
+ tmp[:,0:new_size] = input_ids[:,shift_size:context_size]
1293
+ input_ids = tmp
1294
+
1295
+ # Adjust position after shift
1296
+ pos = new_size
1297
+
1298
+ DebugLog(f"Shifted window by {shift_size} tokens, new position: {pos}")
1299
+
1300
+ # Run prefill on the shifted sequence
1301
+ if False: #if any(key.contains('2D') for key in model_parts.keys()):
1302
+ DebugLog("Running sequential prefill after shift")
1303
+ current_pos = PreFillChunkOneByOne(
1304
+ model_parts,
1305
+ input_ids,
1306
+ pos,
1307
+ context_size,
1308
+ causal_mask
1309
+ )
1310
+ else:
1311
+ DebugLog("Running batch prefill after shift (size={PREFILL_BATCH_SIZE})")
1312
+ current_pos = PreFillChunk(
1313
+ model_parts,
1314
+ input_ids,
1315
+ pos,
1316
+ context_size,
1317
+ causal_mask,
1318
+ batch_size=PREFILL_BATCH_SIZE
1319
+ )
1320
+
1321
+ # Get current token
1322
+ current_token = input_ids[:, pos-1:pos]
1323
+
1324
+ # Find the correct model key for part 1
1325
+ part1_key = next(key for key in model_parts.keys() if key.startswith('1_') or key == '1')
1326
+
1327
+ # Run embeddings (part 1)
1328
+ hidden_states = model_parts[part1_key].predict({
1329
+ 'input_ids': current_token.numpy()
1330
+ })['hidden_states']
1331
+ hidden_states = torch.from_numpy(hidden_states)
1332
+
1333
+ # Get shared transformer state
1334
+ shared_state = model_parts['states']['transformer']
1335
+
1336
+ # Create update mask for current position
1337
+ update_mask = torch.zeros((1, 1, context_size, 1), dtype=torch.float16)
1338
+ update_mask[0, 0, pos-1, 0] = 1.0
1339
+
1340
+ # Create position IDs tensor
1341
+ position_ids = torch.tensor([pos-1], dtype=torch.int32)
1342
+
1343
+ # Create causal mask for current position
1344
+ single_causal_mask = causal_mask[:, :, pos-1:pos, :]
1345
+
1346
+ # Run transformer layers based on model type
1347
+ if any(f'{part}_infer' in model_parts for part in ['2D1S', '2D2S']):
1348
+ for part in ['2D1S', '2D2S']:
1349
+ inputs = {
1350
+ 'hidden_states': hidden_states.numpy(),
1351
+ 'update_mask': update_mask.numpy(),
1352
+ 'position_ids': position_ids.numpy(),
1353
+ 'causal_mask': single_causal_mask.numpy(),
1354
+ 'current_pos': position_ids.numpy()
1355
+ }
1356
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
1357
+ hidden_states = torch.from_numpy(output['transformer_output'])
1358
+ elif any(part.startswith('2Q') for part in model_parts.keys()):
1359
+ DebugLog(f"Running quad split inference at position {pos}")
1360
+ for i in range(1, 5):
1361
+ part = f'2Q{i}'
1362
+ if f'{part}_infer' in model_parts:
1363
+ # Use infer function if available
1364
+ inputs = {
1365
+ 'hidden_states': hidden_states.numpy(),
1366
+ 'update_mask': update_mask.numpy(),
1367
+ 'position_ids': position_ids.numpy(),
1368
+ 'causal_mask': single_causal_mask.numpy(),
1369
+ 'current_pos': position_ids.numpy()
1370
+ }
1371
+ output = model_parts[f'{part}_infer'].predict(inputs, shared_state)
1372
+ else:
1373
+ # Use regular predict if no infer function
1374
+ inputs = {
1375
+ 'hidden_states': hidden_states.numpy(),
1376
+ 'update_mask': update_mask.numpy(),
1377
+ 'position_ids': position_ids.numpy(),
1378
+ 'causal_mask': single_causal_mask.numpy(),
1379
+ 'current_pos': position_ids.numpy()
1380
+ }
1381
+ output = model_parts[part].predict(inputs, shared_state)
1382
+ hidden_states = torch.from_numpy(output['transformer_output'])
1383
+ elif any(key.startswith('2D') for key in model_parts.keys()):
1384
+ for base_part in ['2D1', '2D2']:
1385
+ part_key = next(key for key in model_parts.keys() if key.startswith(f'{base_part}_') or key == base_part)
1386
+ inputs = {
1387
+ 'hidden_states': hidden_states.numpy(),
1388
+ 'update_mask': update_mask.numpy(),
1389
+ 'position_ids': position_ids.numpy(),
1390
+ 'causal_mask': single_causal_mask.numpy(),
1391
+ 'current_pos': position_ids.numpy()
1392
+ }
1393
+ output = model_parts[part_key].predict(inputs, shared_state)
1394
+ hidden_states = torch.from_numpy(output['transformer_output'])
1395
+
1396
+ # Run final layer norm and get logits
1397
+ part3_key = next(key for key in model_parts.keys() if key.startswith('3_') or key == '3')
1398
+ output_dict = model_parts[part3_key].predict({
1399
+ 'hidden_states': hidden_states.numpy()
1400
+ })
1401
+
1402
+ if ENABLE_VACAB_SPLIT8:
1403
+ logits_parts = []
1404
+ for i in range(1, 9):
1405
+ logits_parts.append(output_dict[f'logits{i}'])
1406
+ logits = np.concatenate(logits_parts, axis=-1)
1407
+ else:
1408
+ logits = output_dict['logits']
1409
+
1410
+ # Convert to tensor and get next token
1411
+ logits = torch.from_numpy(logits)
1412
+
1413
+ # Apply temperature if specified
1414
+ if temperature > 0:
1415
+ logits = logits / temperature
1416
+ probs = F.softmax(logits[0, -1, :], dim=-1)
1417
+ next_token = torch.multinomial(probs, num_samples=1).item()
1418
+ else:
1419
+ next_token = torch.argmax(logits[0, -1, :]).item()
1420
+
1421
+ # Add token to input sequence and response
1422
+ input_ids[0, pos] = next_token
1423
+ response_tokens.append(next_token)
1424
+ token_printer.add_token(next_token)
1425
+
1426
+ # Safely decode tokens in the main thread
1427
+ token_printer.drain_buffer()
1428
+
1429
+ pos += 1
1430
+
1431
+ # Add debug output for generated tokens
1432
+ if ENABLE_CHAT_DEBUG and len(response_tokens) > 0 and len(response_tokens) % 10 == 0:
1433
+ DebugLog(f"\nGenerated {len(response_tokens)} tokens")
1434
+ DebugLog(f"Last token: {next_token} -> '{tokenizer.decode([next_token])}'")
1435
+
1436
+ if next_token == tokenizer.eos_token_id:
1437
+ DebugLog("\nGenerated EOS token")
1438
+ break
1439
+
1440
+ # Get the complete response text and calculate stats
1441
+ response_text = token_printer.stop()
1442
+ generation_time = time.time() - generation_start_time
1443
+ tokens_per_second = len(response_tokens) / generation_time if generation_time > 0 else 0
1444
+
1445
+ DebugLog(f"\nFinal response length: {len(response_tokens)} tokens")
1446
+
1447
+ # Print generation stats in dark blue
1448
+ print(f"\n{DARK_BLUE}[{len(response_tokens)} tokens, {tokens_per_second:.1f} tokens/s]{RESET_COLOR}")
1449
+
1450
+ except KeyboardInterrupt:
1451
+ DebugLog("\nGeneration interrupted by user")
1452
+ response_text = token_printer.stop()
1453
+ generation_time = time.time() - generation_start_time
1454
+ tokens_per_second = len(response_tokens) / generation_time if generation_time > 0 else 0
1455
+ print(f"\n{DARK_BLUE}[{len(response_tokens)} tokens, {tokens_per_second:.1f} tokens/s]{RESET_COLOR}")
1456
+
1457
+ # Add assistant's response to conversation history
1458
+ conversation.append({"role": "assistant", "content": response_text})
1459
+
1460
+ except Exception as e:
1461
+ print(f"\n[ERROR] Chat loop error: {str(e)}")
1462
+ print(traceback.format_exc())
1463
+
1464
+ def main():
1465
+ global CONTEXT_LENGTH, PREFILL_BATCH_SIZE, MODEL_PATH
1466
+
1467
+ print("ANEMLL Chat. Pre-relase alpha version, 2025-01-31")
1468
+ print("Copyright (c) 2025, Anemll All rights reserved.")
1469
+ # Set default parameters
1470
+ model_type = "S123" # Default model type
1471
+ lut_suffix = "lut4" # Default LUT suffix
1472
+ temperature = 0.0
1473
+ model_parts = {}
1474
+ model_path = "." # Default to current directory
1475
+
1476
+ if len(sys.argv) < 2:
1477
+ print("Usage: python chat.py [model_parts] [options]")
1478
+ print("Usage: python chat.py [model_parts] [options]")
1479
+ print("\nOptions:")
1480
+ print(" -d PATH # Model directory path (for both tokenizer and CoreML models)")
1481
+ print(" S123 # Combined split model (2D1S+2D2S)")
1482
+ print(" C123 # Combined part2 model with prefill/infer")
1483
+ print(" Q123 # Quad split model (2Q1-2Q4) [default]")
1484
+ print(" Q123S # Combined quad split model (2Q1S-2Q4S)")
1485
+ print(" 1 2D1 2D2 3 # Individual split parts")
1486
+ print(" pfN # Prefill batch size (e.g., pf128)")
1487
+ print(" ctx=N # Context length (e.g., ctx=2048) [default: 1024]")
1488
+ print(" temp=X # Temperature for sampling (e.g., temp=0.01)")
1489
+ print(" lut4 # LUT suffix [default]")
1490
+ print("\nDefault configuration: Q123 lut4 ctx=1024")
1491
+ print(" python chat.py Q123 -d ../anemll-DeepSeek-8B-ctx1024")
1492
+ # Use defaults instead of exiting
1493
+ print("\nUsing default configuration...")
1494
+ else:
1495
+ # Process command line arguments
1496
+ i = 1
1497
+ while i < len(sys.argv):
1498
+ if sys.argv[i] == '-d' and i + 1 < len(sys.argv):
1499
+ model_path = sys.argv[i + 1]
1500
+ i += 2
1501
+ # Extract context length from model path if present
1502
+ ctx_match = re.search(r'ctx(\d+)', model_path)
1503
+ if ctx_match:
1504
+ ctx_value = int(ctx_match.group(1))
1505
+ if 512 <= ctx_value <= 4096*2:
1506
+ CONTEXT_LENGTH = ctx_value
1507
+ print(f"Setting context length to {CONTEXT_LENGTH} from model path")
1508
+ continue
1509
+ elif sys.argv[i].startswith('lut'):
1510
+ lut_suffix = sys.argv[i]
1511
+ elif sys.argv[i] in ['S123', 'Q123', 'Q123S', 'C123', '123D']:
1512
+ model_type = sys.argv[i]
1513
+ i += 1
1514
+
1515
+ # Initialize tokenizer using the same path
1516
+ tokenizer = initialize_tokenizer(model_path)
1517
+ if tokenizer is None:
1518
+ print("[ERROR] Failed to initialize tokenizer. Exiting.")
1519
+ return
1520
+
1521
+ # Process model parts
1522
+ parts = [model_type]
1523
+ if lut_suffix:
1524
+ parts.append(lut_suffix)
1525
+
1526
+ try:
1527
+ split_model = SplitModelInference(parts, model_dir=model_path)
1528
+ model_parts.update(split_model.models)
1529
+ model_parts['states'] = {'transformer': split_model.states['transformer']}
1530
+ except Exception as e:
1531
+ print(f"Error loading model parts: {str(e)}")
1532
+ return
1533
+
1534
+ # Process remaining arguments
1535
+ i = 1
1536
+ while i < len(sys.argv):
1537
+ arg = sys.argv[i]
1538
+ if arg.startswith('pf') and arg[2:].isdigit():
1539
+ PREFILL_BATCH_SIZE = int(arg[2:])
1540
+ elif arg.startswith('ctx='):
1541
+ try:
1542
+ CONTEXT_LENGTH = int(arg.split('=')[1])
1543
+ except (IndexError, ValueError):
1544
+ print(f"[WARNING] Invalid context length format. Using default: {CONTEXT_LENGTH}")
1545
+ elif arg.startswith('temp='):
1546
+ try:
1547
+ temperature = float(arg.split('=')[1])
1548
+ if temperature < 0:
1549
+ print(f"[WARNING] Temperature must be non-negative. Using default: 0.0")
1550
+ temperature = 0.0
1551
+ except (IndexError, ValueError):
1552
+ print(f"[WARNING] Invalid temperature format. Using default: 0.0")
1553
+ i += 1
1554
+
1555
+ try:
1556
+ # Start interactive chat loop
1557
+ chat_loop(model_parts, tokenizer, context_size=CONTEXT_LENGTH, temperature=temperature)
1558
+ except Exception as e:
1559
+ print("An error occurred:")
1560
+ print(traceback.format_exc())
1561
+
1562
+ if __name__ == "__main__":
1563
+ main()
llama32_part1_lut4.mlmodelc.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf31ef851b46f12fc3023aa13a8ac38cb550388b22a3d9db93c66e95c515e98b
3
+ size 404206569
llama32_part2D1S_lut4.mlmodelc.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77166d7d359ad90c4bb5cb4a2752f7b4daf3d737d7cb1f6ba4b29a33d21746ce
3
+ size 238094080
llama32_part2D2S_lut4.mlmodelc.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1c848e39d0c7990ccb4cd2c1f3d21859c8a78fa9fe04d9b33ea50c3068e1dda
3
+ size 237185518
llama32_part3_lut4.mlmodelc.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a21f28b5c69d55ca9203d7456df978cdd7684b435b548b43eb726c7addfe1831
3
+ size 196181205
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,2062 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "128000": {
4
+ "content": "<|begin_of_text|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "128001": {
12
+ "content": "<|end_of_text|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "128002": {
20
+ "content": "<|reserved_special_token_0|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "128003": {
28
+ "content": "<|reserved_special_token_1|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128004": {
36
+ "content": "<|finetune_right_pad_id|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "128005": {
44
+ "content": "<|reserved_special_token_2|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "128006": {
52
+ "content": "<|start_header_id|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "128007": {
60
+ "content": "<|end_header_id|>",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "128008": {
68
+ "content": "<|eom_id|>",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "128009": {
76
+ "content": "<|eot_id|>",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "128010": {
84
+ "content": "<|python_tag|>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "128011": {
92
+ "content": "<|reserved_special_token_3|>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "128012": {
100
+ "content": "<|reserved_special_token_4|>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "128013": {
108
+ "content": "<|reserved_special_token_5|>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ },
115
+ "128014": {
116
+ "content": "<|reserved_special_token_6|>",
117
+ "lstrip": false,
118
+ "normalized": false,
119
+ "rstrip": false,
120
+ "single_word": false,
121
+ "special": true
122
+ },
123
+ "128015": {
124
+ "content": "<|reserved_special_token_7|>",
125
+ "lstrip": false,
126
+ "normalized": false,
127
+ "rstrip": false,
128
+ "single_word": false,
129
+ "special": true
130
+ },
131
+ "128016": {
132
+ "content": "<|reserved_special_token_8|>",
133
+ "lstrip": false,
134
+ "normalized": false,
135
+ "rstrip": false,
136
+ "single_word": false,
137
+ "special": true
138
+ },
139
+ "128017": {
140
+ "content": "<|reserved_special_token_9|>",
141
+ "lstrip": false,
142
+ "normalized": false,
143
+ "rstrip": false,
144
+ "single_word": false,
145
+ "special": true
146
+ },
147
+ "128018": {
148
+ "content": "<|reserved_special_token_10|>",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false,
153
+ "special": true
154
+ },
155
+ "128019": {
156
+ "content": "<|reserved_special_token_11|>",
157
+ "lstrip": false,
158
+ "normalized": false,
159
+ "rstrip": false,
160
+ "single_word": false,
161
+ "special": true
162
+ },
163
+ "128020": {
164
+ "content": "<|reserved_special_token_12|>",
165
+ "lstrip": false,
166
+ "normalized": false,
167
+ "rstrip": false,
168
+ "single_word": false,
169
+ "special": true
170
+ },
171
+ "128021": {
172
+ "content": "<|reserved_special_token_13|>",
173
+ "lstrip": false,
174
+ "normalized": false,
175
+ "rstrip": false,
176
+ "single_word": false,
177
+ "special": true
178
+ },
179
+ "128022": {
180
+ "content": "<|reserved_special_token_14|>",
181
+ "lstrip": false,
182
+ "normalized": false,
183
+ "rstrip": false,
184
+ "single_word": false,
185
+ "special": true
186
+ },
187
+ "128023": {
188
+ "content": "<|reserved_special_token_15|>",
189
+ "lstrip": false,
190
+ "normalized": false,
191
+ "rstrip": false,
192
+ "single_word": false,
193
+ "special": true
194
+ },
195
+ "128024": {
196
+ "content": "<|reserved_special_token_16|>",
197
+ "lstrip": false,
198
+ "normalized": false,
199
+ "rstrip": false,
200
+ "single_word": false,
201
+ "special": true
202
+ },
203
+ "128025": {
204
+ "content": "<|reserved_special_token_17|>",
205
+ "lstrip": false,
206
+ "normalized": false,
207
+ "rstrip": false,
208
+ "single_word": false,
209
+ "special": true
210
+ },
211
+ "128026": {
212
+ "content": "<|reserved_special_token_18|>",
213
+ "lstrip": false,
214
+ "normalized": false,
215
+ "rstrip": false,
216
+ "single_word": false,
217
+ "special": true
218
+ },
219
+ "128027": {
220
+ "content": "<|reserved_special_token_19|>",
221
+ "lstrip": false,
222
+ "normalized": false,
223
+ "rstrip": false,
224
+ "single_word": false,
225
+ "special": true
226
+ },
227
+ "128028": {
228
+ "content": "<|reserved_special_token_20|>",
229
+ "lstrip": false,
230
+ "normalized": false,
231
+ "rstrip": false,
232
+ "single_word": false,
233
+ "special": true
234
+ },
235
+ "128029": {
236
+ "content": "<|reserved_special_token_21|>",
237
+ "lstrip": false,
238
+ "normalized": false,
239
+ "rstrip": false,
240
+ "single_word": false,
241
+ "special": true
242
+ },
243
+ "128030": {
244
+ "content": "<|reserved_special_token_22|>",
245
+ "lstrip": false,
246
+ "normalized": false,
247
+ "rstrip": false,
248
+ "single_word": false,
249
+ "special": true
250
+ },
251
+ "128031": {
252
+ "content": "<|reserved_special_token_23|>",
253
+ "lstrip": false,
254
+ "normalized": false,
255
+ "rstrip": false,
256
+ "single_word": false,
257
+ "special": true
258
+ },
259
+ "128032": {
260
+ "content": "<|reserved_special_token_24|>",
261
+ "lstrip": false,
262
+ "normalized": false,
263
+ "rstrip": false,
264
+ "single_word": false,
265
+ "special": true
266
+ },
267
+ "128033": {
268
+ "content": "<|reserved_special_token_25|>",
269
+ "lstrip": false,
270
+ "normalized": false,
271
+ "rstrip": false,
272
+ "single_word": false,
273
+ "special": true
274
+ },
275
+ "128034": {
276
+ "content": "<|reserved_special_token_26|>",
277
+ "lstrip": false,
278
+ "normalized": false,
279
+ "rstrip": false,
280
+ "single_word": false,
281
+ "special": true
282
+ },
283
+ "128035": {
284
+ "content": "<|reserved_special_token_27|>",
285
+ "lstrip": false,
286
+ "normalized": false,
287
+ "rstrip": false,
288
+ "single_word": false,
289
+ "special": true
290
+ },
291
+ "128036": {
292
+ "content": "<|reserved_special_token_28|>",
293
+ "lstrip": false,
294
+ "normalized": false,
295
+ "rstrip": false,
296
+ "single_word": false,
297
+ "special": true
298
+ },
299
+ "128037": {
300
+ "content": "<|reserved_special_token_29|>",
301
+ "lstrip": false,
302
+ "normalized": false,
303
+ "rstrip": false,
304
+ "single_word": false,
305
+ "special": true
306
+ },
307
+ "128038": {
308
+ "content": "<|reserved_special_token_30|>",
309
+ "lstrip": false,
310
+ "normalized": false,
311
+ "rstrip": false,
312
+ "single_word": false,
313
+ "special": true
314
+ },
315
+ "128039": {
316
+ "content": "<|reserved_special_token_31|>",
317
+ "lstrip": false,
318
+ "normalized": false,
319
+ "rstrip": false,
320
+ "single_word": false,
321
+ "special": true
322
+ },
323
+ "128040": {
324
+ "content": "<|reserved_special_token_32|>",
325
+ "lstrip": false,
326
+ "normalized": false,
327
+ "rstrip": false,
328
+ "single_word": false,
329
+ "special": true
330
+ },
331
+ "128041": {
332
+ "content": "<|reserved_special_token_33|>",
333
+ "lstrip": false,
334
+ "normalized": false,
335
+ "rstrip": false,
336
+ "single_word": false,
337
+ "special": true
338
+ },
339
+ "128042": {
340
+ "content": "<|reserved_special_token_34|>",
341
+ "lstrip": false,
342
+ "normalized": false,
343
+ "rstrip": false,
344
+ "single_word": false,
345
+ "special": true
346
+ },
347
+ "128043": {
348
+ "content": "<|reserved_special_token_35|>",
349
+ "lstrip": false,
350
+ "normalized": false,
351
+ "rstrip": false,
352
+ "single_word": false,
353
+ "special": true
354
+ },
355
+ "128044": {
356
+ "content": "<|reserved_special_token_36|>",
357
+ "lstrip": false,
358
+ "normalized": false,
359
+ "rstrip": false,
360
+ "single_word": false,
361
+ "special": true
362
+ },
363
+ "128045": {
364
+ "content": "<|reserved_special_token_37|>",
365
+ "lstrip": false,
366
+ "normalized": false,
367
+ "rstrip": false,
368
+ "single_word": false,
369
+ "special": true
370
+ },
371
+ "128046": {
372
+ "content": "<|reserved_special_token_38|>",
373
+ "lstrip": false,
374
+ "normalized": false,
375
+ "rstrip": false,
376
+ "single_word": false,
377
+ "special": true
378
+ },
379
+ "128047": {
380
+ "content": "<|reserved_special_token_39|>",
381
+ "lstrip": false,
382
+ "normalized": false,
383
+ "rstrip": false,
384
+ "single_word": false,
385
+ "special": true
386
+ },
387
+ "128048": {
388
+ "content": "<|reserved_special_token_40|>",
389
+ "lstrip": false,
390
+ "normalized": false,
391
+ "rstrip": false,
392
+ "single_word": false,
393
+ "special": true
394
+ },
395
+ "128049": {
396
+ "content": "<|reserved_special_token_41|>",
397
+ "lstrip": false,
398
+ "normalized": false,
399
+ "rstrip": false,
400
+ "single_word": false,
401
+ "special": true
402
+ },
403
+ "128050": {
404
+ "content": "<|reserved_special_token_42|>",
405
+ "lstrip": false,
406
+ "normalized": false,
407
+ "rstrip": false,
408
+ "single_word": false,
409
+ "special": true
410
+ },
411
+ "128051": {
412
+ "content": "<|reserved_special_token_43|>",
413
+ "lstrip": false,
414
+ "normalized": false,
415
+ "rstrip": false,
416
+ "single_word": false,
417
+ "special": true
418
+ },
419
+ "128052": {
420
+ "content": "<|reserved_special_token_44|>",
421
+ "lstrip": false,
422
+ "normalized": false,
423
+ "rstrip": false,
424
+ "single_word": false,
425
+ "special": true
426
+ },
427
+ "128053": {
428
+ "content": "<|reserved_special_token_45|>",
429
+ "lstrip": false,
430
+ "normalized": false,
431
+ "rstrip": false,
432
+ "single_word": false,
433
+ "special": true
434
+ },
435
+ "128054": {
436
+ "content": "<|reserved_special_token_46|>",
437
+ "lstrip": false,
438
+ "normalized": false,
439
+ "rstrip": false,
440
+ "single_word": false,
441
+ "special": true
442
+ },
443
+ "128055": {
444
+ "content": "<|reserved_special_token_47|>",
445
+ "lstrip": false,
446
+ "normalized": false,
447
+ "rstrip": false,
448
+ "single_word": false,
449
+ "special": true
450
+ },
451
+ "128056": {
452
+ "content": "<|reserved_special_token_48|>",
453
+ "lstrip": false,
454
+ "normalized": false,
455
+ "rstrip": false,
456
+ "single_word": false,
457
+ "special": true
458
+ },
459
+ "128057": {
460
+ "content": "<|reserved_special_token_49|>",
461
+ "lstrip": false,
462
+ "normalized": false,
463
+ "rstrip": false,
464
+ "single_word": false,
465
+ "special": true
466
+ },
467
+ "128058": {
468
+ "content": "<|reserved_special_token_50|>",
469
+ "lstrip": false,
470
+ "normalized": false,
471
+ "rstrip": false,
472
+ "single_word": false,
473
+ "special": true
474
+ },
475
+ "128059": {
476
+ "content": "<|reserved_special_token_51|>",
477
+ "lstrip": false,
478
+ "normalized": false,
479
+ "rstrip": false,
480
+ "single_word": false,
481
+ "special": true
482
+ },
483
+ "128060": {
484
+ "content": "<|reserved_special_token_52|>",
485
+ "lstrip": false,
486
+ "normalized": false,
487
+ "rstrip": false,
488
+ "single_word": false,
489
+ "special": true
490
+ },
491
+ "128061": {
492
+ "content": "<|reserved_special_token_53|>",
493
+ "lstrip": false,
494
+ "normalized": false,
495
+ "rstrip": false,
496
+ "single_word": false,
497
+ "special": true
498
+ },
499
+ "128062": {
500
+ "content": "<|reserved_special_token_54|>",
501
+ "lstrip": false,
502
+ "normalized": false,
503
+ "rstrip": false,
504
+ "single_word": false,
505
+ "special": true
506
+ },
507
+ "128063": {
508
+ "content": "<|reserved_special_token_55|>",
509
+ "lstrip": false,
510
+ "normalized": false,
511
+ "rstrip": false,
512
+ "single_word": false,
513
+ "special": true
514
+ },
515
+ "128064": {
516
+ "content": "<|reserved_special_token_56|>",
517
+ "lstrip": false,
518
+ "normalized": false,
519
+ "rstrip": false,
520
+ "single_word": false,
521
+ "special": true
522
+ },
523
+ "128065": {
524
+ "content": "<|reserved_special_token_57|>",
525
+ "lstrip": false,
526
+ "normalized": false,
527
+ "rstrip": false,
528
+ "single_word": false,
529
+ "special": true
530
+ },
531
+ "128066": {
532
+ "content": "<|reserved_special_token_58|>",
533
+ "lstrip": false,
534
+ "normalized": false,
535
+ "rstrip": false,
536
+ "single_word": false,
537
+ "special": true
538
+ },
539
+ "128067": {
540
+ "content": "<|reserved_special_token_59|>",
541
+ "lstrip": false,
542
+ "normalized": false,
543
+ "rstrip": false,
544
+ "single_word": false,
545
+ "special": true
546
+ },
547
+ "128068": {
548
+ "content": "<|reserved_special_token_60|>",
549
+ "lstrip": false,
550
+ "normalized": false,
551
+ "rstrip": false,
552
+ "single_word": false,
553
+ "special": true
554
+ },
555
+ "128069": {
556
+ "content": "<|reserved_special_token_61|>",
557
+ "lstrip": false,
558
+ "normalized": false,
559
+ "rstrip": false,
560
+ "single_word": false,
561
+ "special": true
562
+ },
563
+ "128070": {
564
+ "content": "<|reserved_special_token_62|>",
565
+ "lstrip": false,
566
+ "normalized": false,
567
+ "rstrip": false,
568
+ "single_word": false,
569
+ "special": true
570
+ },
571
+ "128071": {
572
+ "content": "<|reserved_special_token_63|>",
573
+ "lstrip": false,
574
+ "normalized": false,
575
+ "rstrip": false,
576
+ "single_word": false,
577
+ "special": true
578
+ },
579
+ "128072": {
580
+ "content": "<|reserved_special_token_64|>",
581
+ "lstrip": false,
582
+ "normalized": false,
583
+ "rstrip": false,
584
+ "single_word": false,
585
+ "special": true
586
+ },
587
+ "128073": {
588
+ "content": "<|reserved_special_token_65|>",
589
+ "lstrip": false,
590
+ "normalized": false,
591
+ "rstrip": false,
592
+ "single_word": false,
593
+ "special": true
594
+ },
595
+ "128074": {
596
+ "content": "<|reserved_special_token_66|>",
597
+ "lstrip": false,
598
+ "normalized": false,
599
+ "rstrip": false,
600
+ "single_word": false,
601
+ "special": true
602
+ },
603
+ "128075": {
604
+ "content": "<|reserved_special_token_67|>",
605
+ "lstrip": false,
606
+ "normalized": false,
607
+ "rstrip": false,
608
+ "single_word": false,
609
+ "special": true
610
+ },
611
+ "128076": {
612
+ "content": "<|reserved_special_token_68|>",
613
+ "lstrip": false,
614
+ "normalized": false,
615
+ "rstrip": false,
616
+ "single_word": false,
617
+ "special": true
618
+ },
619
+ "128077": {
620
+ "content": "<|reserved_special_token_69|>",
621
+ "lstrip": false,
622
+ "normalized": false,
623
+ "rstrip": false,
624
+ "single_word": false,
625
+ "special": true
626
+ },
627
+ "128078": {
628
+ "content": "<|reserved_special_token_70|>",
629
+ "lstrip": false,
630
+ "normalized": false,
631
+ "rstrip": false,
632
+ "single_word": false,
633
+ "special": true
634
+ },
635
+ "128079": {
636
+ "content": "<|reserved_special_token_71|>",
637
+ "lstrip": false,
638
+ "normalized": false,
639
+ "rstrip": false,
640
+ "single_word": false,
641
+ "special": true
642
+ },
643
+ "128080": {
644
+ "content": "<|reserved_special_token_72|>",
645
+ "lstrip": false,
646
+ "normalized": false,
647
+ "rstrip": false,
648
+ "single_word": false,
649
+ "special": true
650
+ },
651
+ "128081": {
652
+ "content": "<|reserved_special_token_73|>",
653
+ "lstrip": false,
654
+ "normalized": false,
655
+ "rstrip": false,
656
+ "single_word": false,
657
+ "special": true
658
+ },
659
+ "128082": {
660
+ "content": "<|reserved_special_token_74|>",
661
+ "lstrip": false,
662
+ "normalized": false,
663
+ "rstrip": false,
664
+ "single_word": false,
665
+ "special": true
666
+ },
667
+ "128083": {
668
+ "content": "<|reserved_special_token_75|>",
669
+ "lstrip": false,
670
+ "normalized": false,
671
+ "rstrip": false,
672
+ "single_word": false,
673
+ "special": true
674
+ },
675
+ "128084": {
676
+ "content": "<|reserved_special_token_76|>",
677
+ "lstrip": false,
678
+ "normalized": false,
679
+ "rstrip": false,
680
+ "single_word": false,
681
+ "special": true
682
+ },
683
+ "128085": {
684
+ "content": "<|reserved_special_token_77|>",
685
+ "lstrip": false,
686
+ "normalized": false,
687
+ "rstrip": false,
688
+ "single_word": false,
689
+ "special": true
690
+ },
691
+ "128086": {
692
+ "content": "<|reserved_special_token_78|>",
693
+ "lstrip": false,
694
+ "normalized": false,
695
+ "rstrip": false,
696
+ "single_word": false,
697
+ "special": true
698
+ },
699
+ "128087": {
700
+ "content": "<|reserved_special_token_79|>",
701
+ "lstrip": false,
702
+ "normalized": false,
703
+ "rstrip": false,
704
+ "single_word": false,
705
+ "special": true
706
+ },
707
+ "128088": {
708
+ "content": "<|reserved_special_token_80|>",
709
+ "lstrip": false,
710
+ "normalized": false,
711
+ "rstrip": false,
712
+ "single_word": false,
713
+ "special": true
714
+ },
715
+ "128089": {
716
+ "content": "<|reserved_special_token_81|>",
717
+ "lstrip": false,
718
+ "normalized": false,
719
+ "rstrip": false,
720
+ "single_word": false,
721
+ "special": true
722
+ },
723
+ "128090": {
724
+ "content": "<|reserved_special_token_82|>",
725
+ "lstrip": false,
726
+ "normalized": false,
727
+ "rstrip": false,
728
+ "single_word": false,
729
+ "special": true
730
+ },
731
+ "128091": {
732
+ "content": "<|reserved_special_token_83|>",
733
+ "lstrip": false,
734
+ "normalized": false,
735
+ "rstrip": false,
736
+ "single_word": false,
737
+ "special": true
738
+ },
739
+ "128092": {
740
+ "content": "<|reserved_special_token_84|>",
741
+ "lstrip": false,
742
+ "normalized": false,
743
+ "rstrip": false,
744
+ "single_word": false,
745
+ "special": true
746
+ },
747
+ "128093": {
748
+ "content": "<|reserved_special_token_85|>",
749
+ "lstrip": false,
750
+ "normalized": false,
751
+ "rstrip": false,
752
+ "single_word": false,
753
+ "special": true
754
+ },
755
+ "128094": {
756
+ "content": "<|reserved_special_token_86|>",
757
+ "lstrip": false,
758
+ "normalized": false,
759
+ "rstrip": false,
760
+ "single_word": false,
761
+ "special": true
762
+ },
763
+ "128095": {
764
+ "content": "<|reserved_special_token_87|>",
765
+ "lstrip": false,
766
+ "normalized": false,
767
+ "rstrip": false,
768
+ "single_word": false,
769
+ "special": true
770
+ },
771
+ "128096": {
772
+ "content": "<|reserved_special_token_88|>",
773
+ "lstrip": false,
774
+ "normalized": false,
775
+ "rstrip": false,
776
+ "single_word": false,
777
+ "special": true
778
+ },
779
+ "128097": {
780
+ "content": "<|reserved_special_token_89|>",
781
+ "lstrip": false,
782
+ "normalized": false,
783
+ "rstrip": false,
784
+ "single_word": false,
785
+ "special": true
786
+ },
787
+ "128098": {
788
+ "content": "<|reserved_special_token_90|>",
789
+ "lstrip": false,
790
+ "normalized": false,
791
+ "rstrip": false,
792
+ "single_word": false,
793
+ "special": true
794
+ },
795
+ "128099": {
796
+ "content": "<|reserved_special_token_91|>",
797
+ "lstrip": false,
798
+ "normalized": false,
799
+ "rstrip": false,
800
+ "single_word": false,
801
+ "special": true
802
+ },
803
+ "128100": {
804
+ "content": "<|reserved_special_token_92|>",
805
+ "lstrip": false,
806
+ "normalized": false,
807
+ "rstrip": false,
808
+ "single_word": false,
809
+ "special": true
810
+ },
811
+ "128101": {
812
+ "content": "<|reserved_special_token_93|>",
813
+ "lstrip": false,
814
+ "normalized": false,
815
+ "rstrip": false,
816
+ "single_word": false,
817
+ "special": true
818
+ },
819
+ "128102": {
820
+ "content": "<|reserved_special_token_94|>",
821
+ "lstrip": false,
822
+ "normalized": false,
823
+ "rstrip": false,
824
+ "single_word": false,
825
+ "special": true
826
+ },
827
+ "128103": {
828
+ "content": "<|reserved_special_token_95|>",
829
+ "lstrip": false,
830
+ "normalized": false,
831
+ "rstrip": false,
832
+ "single_word": false,
833
+ "special": true
834
+ },
835
+ "128104": {
836
+ "content": "<|reserved_special_token_96|>",
837
+ "lstrip": false,
838
+ "normalized": false,
839
+ "rstrip": false,
840
+ "single_word": false,
841
+ "special": true
842
+ },
843
+ "128105": {
844
+ "content": "<|reserved_special_token_97|>",
845
+ "lstrip": false,
846
+ "normalized": false,
847
+ "rstrip": false,
848
+ "single_word": false,
849
+ "special": true
850
+ },
851
+ "128106": {
852
+ "content": "<|reserved_special_token_98|>",
853
+ "lstrip": false,
854
+ "normalized": false,
855
+ "rstrip": false,
856
+ "single_word": false,
857
+ "special": true
858
+ },
859
+ "128107": {
860
+ "content": "<|reserved_special_token_99|>",
861
+ "lstrip": false,
862
+ "normalized": false,
863
+ "rstrip": false,
864
+ "single_word": false,
865
+ "special": true
866
+ },
867
+ "128108": {
868
+ "content": "<|reserved_special_token_100|>",
869
+ "lstrip": false,
870
+ "normalized": false,
871
+ "rstrip": false,
872
+ "single_word": false,
873
+ "special": true
874
+ },
875
+ "128109": {
876
+ "content": "<|reserved_special_token_101|>",
877
+ "lstrip": false,
878
+ "normalized": false,
879
+ "rstrip": false,
880
+ "single_word": false,
881
+ "special": true
882
+ },
883
+ "128110": {
884
+ "content": "<|reserved_special_token_102|>",
885
+ "lstrip": false,
886
+ "normalized": false,
887
+ "rstrip": false,
888
+ "single_word": false,
889
+ "special": true
890
+ },
891
+ "128111": {
892
+ "content": "<|reserved_special_token_103|>",
893
+ "lstrip": false,
894
+ "normalized": false,
895
+ "rstrip": false,
896
+ "single_word": false,
897
+ "special": true
898
+ },
899
+ "128112": {
900
+ "content": "<|reserved_special_token_104|>",
901
+ "lstrip": false,
902
+ "normalized": false,
903
+ "rstrip": false,
904
+ "single_word": false,
905
+ "special": true
906
+ },
907
+ "128113": {
908
+ "content": "<|reserved_special_token_105|>",
909
+ "lstrip": false,
910
+ "normalized": false,
911
+ "rstrip": false,
912
+ "single_word": false,
913
+ "special": true
914
+ },
915
+ "128114": {
916
+ "content": "<|reserved_special_token_106|>",
917
+ "lstrip": false,
918
+ "normalized": false,
919
+ "rstrip": false,
920
+ "single_word": false,
921
+ "special": true
922
+ },
923
+ "128115": {
924
+ "content": "<|reserved_special_token_107|>",
925
+ "lstrip": false,
926
+ "normalized": false,
927
+ "rstrip": false,
928
+ "single_word": false,
929
+ "special": true
930
+ },
931
+ "128116": {
932
+ "content": "<|reserved_special_token_108|>",
933
+ "lstrip": false,
934
+ "normalized": false,
935
+ "rstrip": false,
936
+ "single_word": false,
937
+ "special": true
938
+ },
939
+ "128117": {
940
+ "content": "<|reserved_special_token_109|>",
941
+ "lstrip": false,
942
+ "normalized": false,
943
+ "rstrip": false,
944
+ "single_word": false,
945
+ "special": true
946
+ },
947
+ "128118": {
948
+ "content": "<|reserved_special_token_110|>",
949
+ "lstrip": false,
950
+ "normalized": false,
951
+ "rstrip": false,
952
+ "single_word": false,
953
+ "special": true
954
+ },
955
+ "128119": {
956
+ "content": "<|reserved_special_token_111|>",
957
+ "lstrip": false,
958
+ "normalized": false,
959
+ "rstrip": false,
960
+ "single_word": false,
961
+ "special": true
962
+ },
963
+ "128120": {
964
+ "content": "<|reserved_special_token_112|>",
965
+ "lstrip": false,
966
+ "normalized": false,
967
+ "rstrip": false,
968
+ "single_word": false,
969
+ "special": true
970
+ },
971
+ "128121": {
972
+ "content": "<|reserved_special_token_113|>",
973
+ "lstrip": false,
974
+ "normalized": false,
975
+ "rstrip": false,
976
+ "single_word": false,
977
+ "special": true
978
+ },
979
+ "128122": {
980
+ "content": "<|reserved_special_token_114|>",
981
+ "lstrip": false,
982
+ "normalized": false,
983
+ "rstrip": false,
984
+ "single_word": false,
985
+ "special": true
986
+ },
987
+ "128123": {
988
+ "content": "<|reserved_special_token_115|>",
989
+ "lstrip": false,
990
+ "normalized": false,
991
+ "rstrip": false,
992
+ "single_word": false,
993
+ "special": true
994
+ },
995
+ "128124": {
996
+ "content": "<|reserved_special_token_116|>",
997
+ "lstrip": false,
998
+ "normalized": false,
999
+ "rstrip": false,
1000
+ "single_word": false,
1001
+ "special": true
1002
+ },
1003
+ "128125": {
1004
+ "content": "<|reserved_special_token_117|>",
1005
+ "lstrip": false,
1006
+ "normalized": false,
1007
+ "rstrip": false,
1008
+ "single_word": false,
1009
+ "special": true
1010
+ },
1011
+ "128126": {
1012
+ "content": "<|reserved_special_token_118|>",
1013
+ "lstrip": false,
1014
+ "normalized": false,
1015
+ "rstrip": false,
1016
+ "single_word": false,
1017
+ "special": true
1018
+ },
1019
+ "128127": {
1020
+ "content": "<|reserved_special_token_119|>",
1021
+ "lstrip": false,
1022
+ "normalized": false,
1023
+ "rstrip": false,
1024
+ "single_word": false,
1025
+ "special": true
1026
+ },
1027
+ "128128": {
1028
+ "content": "<|reserved_special_token_120|>",
1029
+ "lstrip": false,
1030
+ "normalized": false,
1031
+ "rstrip": false,
1032
+ "single_word": false,
1033
+ "special": true
1034
+ },
1035
+ "128129": {
1036
+ "content": "<|reserved_special_token_121|>",
1037
+ "lstrip": false,
1038
+ "normalized": false,
1039
+ "rstrip": false,
1040
+ "single_word": false,
1041
+ "special": true
1042
+ },
1043
+ "128130": {
1044
+ "content": "<|reserved_special_token_122|>",
1045
+ "lstrip": false,
1046
+ "normalized": false,
1047
+ "rstrip": false,
1048
+ "single_word": false,
1049
+ "special": true
1050
+ },
1051
+ "128131": {
1052
+ "content": "<|reserved_special_token_123|>",
1053
+ "lstrip": false,
1054
+ "normalized": false,
1055
+ "rstrip": false,
1056
+ "single_word": false,
1057
+ "special": true
1058
+ },
1059
+ "128132": {
1060
+ "content": "<|reserved_special_token_124|>",
1061
+ "lstrip": false,
1062
+ "normalized": false,
1063
+ "rstrip": false,
1064
+ "single_word": false,
1065
+ "special": true
1066
+ },
1067
+ "128133": {
1068
+ "content": "<|reserved_special_token_125|>",
1069
+ "lstrip": false,
1070
+ "normalized": false,
1071
+ "rstrip": false,
1072
+ "single_word": false,
1073
+ "special": true
1074
+ },
1075
+ "128134": {
1076
+ "content": "<|reserved_special_token_126|>",
1077
+ "lstrip": false,
1078
+ "normalized": false,
1079
+ "rstrip": false,
1080
+ "single_word": false,
1081
+ "special": true
1082
+ },
1083
+ "128135": {
1084
+ "content": "<|reserved_special_token_127|>",
1085
+ "lstrip": false,
1086
+ "normalized": false,
1087
+ "rstrip": false,
1088
+ "single_word": false,
1089
+ "special": true
1090
+ },
1091
+ "128136": {
1092
+ "content": "<|reserved_special_token_128|>",
1093
+ "lstrip": false,
1094
+ "normalized": false,
1095
+ "rstrip": false,
1096
+ "single_word": false,
1097
+ "special": true
1098
+ },
1099
+ "128137": {
1100
+ "content": "<|reserved_special_token_129|>",
1101
+ "lstrip": false,
1102
+ "normalized": false,
1103
+ "rstrip": false,
1104
+ "single_word": false,
1105
+ "special": true
1106
+ },
1107
+ "128138": {
1108
+ "content": "<|reserved_special_token_130|>",
1109
+ "lstrip": false,
1110
+ "normalized": false,
1111
+ "rstrip": false,
1112
+ "single_word": false,
1113
+ "special": true
1114
+ },
1115
+ "128139": {
1116
+ "content": "<|reserved_special_token_131|>",
1117
+ "lstrip": false,
1118
+ "normalized": false,
1119
+ "rstrip": false,
1120
+ "single_word": false,
1121
+ "special": true
1122
+ },
1123
+ "128140": {
1124
+ "content": "<|reserved_special_token_132|>",
1125
+ "lstrip": false,
1126
+ "normalized": false,
1127
+ "rstrip": false,
1128
+ "single_word": false,
1129
+ "special": true
1130
+ },
1131
+ "128141": {
1132
+ "content": "<|reserved_special_token_133|>",
1133
+ "lstrip": false,
1134
+ "normalized": false,
1135
+ "rstrip": false,
1136
+ "single_word": false,
1137
+ "special": true
1138
+ },
1139
+ "128142": {
1140
+ "content": "<|reserved_special_token_134|>",
1141
+ "lstrip": false,
1142
+ "normalized": false,
1143
+ "rstrip": false,
1144
+ "single_word": false,
1145
+ "special": true
1146
+ },
1147
+ "128143": {
1148
+ "content": "<|reserved_special_token_135|>",
1149
+ "lstrip": false,
1150
+ "normalized": false,
1151
+ "rstrip": false,
1152
+ "single_word": false,
1153
+ "special": true
1154
+ },
1155
+ "128144": {
1156
+ "content": "<|reserved_special_token_136|>",
1157
+ "lstrip": false,
1158
+ "normalized": false,
1159
+ "rstrip": false,
1160
+ "single_word": false,
1161
+ "special": true
1162
+ },
1163
+ "128145": {
1164
+ "content": "<|reserved_special_token_137|>",
1165
+ "lstrip": false,
1166
+ "normalized": false,
1167
+ "rstrip": false,
1168
+ "single_word": false,
1169
+ "special": true
1170
+ },
1171
+ "128146": {
1172
+ "content": "<|reserved_special_token_138|>",
1173
+ "lstrip": false,
1174
+ "normalized": false,
1175
+ "rstrip": false,
1176
+ "single_word": false,
1177
+ "special": true
1178
+ },
1179
+ "128147": {
1180
+ "content": "<|reserved_special_token_139|>",
1181
+ "lstrip": false,
1182
+ "normalized": false,
1183
+ "rstrip": false,
1184
+ "single_word": false,
1185
+ "special": true
1186
+ },
1187
+ "128148": {
1188
+ "content": "<|reserved_special_token_140|>",
1189
+ "lstrip": false,
1190
+ "normalized": false,
1191
+ "rstrip": false,
1192
+ "single_word": false,
1193
+ "special": true
1194
+ },
1195
+ "128149": {
1196
+ "content": "<|reserved_special_token_141|>",
1197
+ "lstrip": false,
1198
+ "normalized": false,
1199
+ "rstrip": false,
1200
+ "single_word": false,
1201
+ "special": true
1202
+ },
1203
+ "128150": {
1204
+ "content": "<|reserved_special_token_142|>",
1205
+ "lstrip": false,
1206
+ "normalized": false,
1207
+ "rstrip": false,
1208
+ "single_word": false,
1209
+ "special": true
1210
+ },
1211
+ "128151": {
1212
+ "content": "<|reserved_special_token_143|>",
1213
+ "lstrip": false,
1214
+ "normalized": false,
1215
+ "rstrip": false,
1216
+ "single_word": false,
1217
+ "special": true
1218
+ },
1219
+ "128152": {
1220
+ "content": "<|reserved_special_token_144|>",
1221
+ "lstrip": false,
1222
+ "normalized": false,
1223
+ "rstrip": false,
1224
+ "single_word": false,
1225
+ "special": true
1226
+ },
1227
+ "128153": {
1228
+ "content": "<|reserved_special_token_145|>",
1229
+ "lstrip": false,
1230
+ "normalized": false,
1231
+ "rstrip": false,
1232
+ "single_word": false,
1233
+ "special": true
1234
+ },
1235
+ "128154": {
1236
+ "content": "<|reserved_special_token_146|>",
1237
+ "lstrip": false,
1238
+ "normalized": false,
1239
+ "rstrip": false,
1240
+ "single_word": false,
1241
+ "special": true
1242
+ },
1243
+ "128155": {
1244
+ "content": "<|reserved_special_token_147|>",
1245
+ "lstrip": false,
1246
+ "normalized": false,
1247
+ "rstrip": false,
1248
+ "single_word": false,
1249
+ "special": true
1250
+ },
1251
+ "128156": {
1252
+ "content": "<|reserved_special_token_148|>",
1253
+ "lstrip": false,
1254
+ "normalized": false,
1255
+ "rstrip": false,
1256
+ "single_word": false,
1257
+ "special": true
1258
+ },
1259
+ "128157": {
1260
+ "content": "<|reserved_special_token_149|>",
1261
+ "lstrip": false,
1262
+ "normalized": false,
1263
+ "rstrip": false,
1264
+ "single_word": false,
1265
+ "special": true
1266
+ },
1267
+ "128158": {
1268
+ "content": "<|reserved_special_token_150|>",
1269
+ "lstrip": false,
1270
+ "normalized": false,
1271
+ "rstrip": false,
1272
+ "single_word": false,
1273
+ "special": true
1274
+ },
1275
+ "128159": {
1276
+ "content": "<|reserved_special_token_151|>",
1277
+ "lstrip": false,
1278
+ "normalized": false,
1279
+ "rstrip": false,
1280
+ "single_word": false,
1281
+ "special": true
1282
+ },
1283
+ "128160": {
1284
+ "content": "<|reserved_special_token_152|>",
1285
+ "lstrip": false,
1286
+ "normalized": false,
1287
+ "rstrip": false,
1288
+ "single_word": false,
1289
+ "special": true
1290
+ },
1291
+ "128161": {
1292
+ "content": "<|reserved_special_token_153|>",
1293
+ "lstrip": false,
1294
+ "normalized": false,
1295
+ "rstrip": false,
1296
+ "single_word": false,
1297
+ "special": true
1298
+ },
1299
+ "128162": {
1300
+ "content": "<|reserved_special_token_154|>",
1301
+ "lstrip": false,
1302
+ "normalized": false,
1303
+ "rstrip": false,
1304
+ "single_word": false,
1305
+ "special": true
1306
+ },
1307
+ "128163": {
1308
+ "content": "<|reserved_special_token_155|>",
1309
+ "lstrip": false,
1310
+ "normalized": false,
1311
+ "rstrip": false,
1312
+ "single_word": false,
1313
+ "special": true
1314
+ },
1315
+ "128164": {
1316
+ "content": "<|reserved_special_token_156|>",
1317
+ "lstrip": false,
1318
+ "normalized": false,
1319
+ "rstrip": false,
1320
+ "single_word": false,
1321
+ "special": true
1322
+ },
1323
+ "128165": {
1324
+ "content": "<|reserved_special_token_157|>",
1325
+ "lstrip": false,
1326
+ "normalized": false,
1327
+ "rstrip": false,
1328
+ "single_word": false,
1329
+ "special": true
1330
+ },
1331
+ "128166": {
1332
+ "content": "<|reserved_special_token_158|>",
1333
+ "lstrip": false,
1334
+ "normalized": false,
1335
+ "rstrip": false,
1336
+ "single_word": false,
1337
+ "special": true
1338
+ },
1339
+ "128167": {
1340
+ "content": "<|reserved_special_token_159|>",
1341
+ "lstrip": false,
1342
+ "normalized": false,
1343
+ "rstrip": false,
1344
+ "single_word": false,
1345
+ "special": true
1346
+ },
1347
+ "128168": {
1348
+ "content": "<|reserved_special_token_160|>",
1349
+ "lstrip": false,
1350
+ "normalized": false,
1351
+ "rstrip": false,
1352
+ "single_word": false,
1353
+ "special": true
1354
+ },
1355
+ "128169": {
1356
+ "content": "<|reserved_special_token_161|>",
1357
+ "lstrip": false,
1358
+ "normalized": false,
1359
+ "rstrip": false,
1360
+ "single_word": false,
1361
+ "special": true
1362
+ },
1363
+ "128170": {
1364
+ "content": "<|reserved_special_token_162|>",
1365
+ "lstrip": false,
1366
+ "normalized": false,
1367
+ "rstrip": false,
1368
+ "single_word": false,
1369
+ "special": true
1370
+ },
1371
+ "128171": {
1372
+ "content": "<|reserved_special_token_163|>",
1373
+ "lstrip": false,
1374
+ "normalized": false,
1375
+ "rstrip": false,
1376
+ "single_word": false,
1377
+ "special": true
1378
+ },
1379
+ "128172": {
1380
+ "content": "<|reserved_special_token_164|>",
1381
+ "lstrip": false,
1382
+ "normalized": false,
1383
+ "rstrip": false,
1384
+ "single_word": false,
1385
+ "special": true
1386
+ },
1387
+ "128173": {
1388
+ "content": "<|reserved_special_token_165|>",
1389
+ "lstrip": false,
1390
+ "normalized": false,
1391
+ "rstrip": false,
1392
+ "single_word": false,
1393
+ "special": true
1394
+ },
1395
+ "128174": {
1396
+ "content": "<|reserved_special_token_166|>",
1397
+ "lstrip": false,
1398
+ "normalized": false,
1399
+ "rstrip": false,
1400
+ "single_word": false,
1401
+ "special": true
1402
+ },
1403
+ "128175": {
1404
+ "content": "<|reserved_special_token_167|>",
1405
+ "lstrip": false,
1406
+ "normalized": false,
1407
+ "rstrip": false,
1408
+ "single_word": false,
1409
+ "special": true
1410
+ },
1411
+ "128176": {
1412
+ "content": "<|reserved_special_token_168|>",
1413
+ "lstrip": false,
1414
+ "normalized": false,
1415
+ "rstrip": false,
1416
+ "single_word": false,
1417
+ "special": true
1418
+ },
1419
+ "128177": {
1420
+ "content": "<|reserved_special_token_169|>",
1421
+ "lstrip": false,
1422
+ "normalized": false,
1423
+ "rstrip": false,
1424
+ "single_word": false,
1425
+ "special": true
1426
+ },
1427
+ "128178": {
1428
+ "content": "<|reserved_special_token_170|>",
1429
+ "lstrip": false,
1430
+ "normalized": false,
1431
+ "rstrip": false,
1432
+ "single_word": false,
1433
+ "special": true
1434
+ },
1435
+ "128179": {
1436
+ "content": "<|reserved_special_token_171|>",
1437
+ "lstrip": false,
1438
+ "normalized": false,
1439
+ "rstrip": false,
1440
+ "single_word": false,
1441
+ "special": true
1442
+ },
1443
+ "128180": {
1444
+ "content": "<|reserved_special_token_172|>",
1445
+ "lstrip": false,
1446
+ "normalized": false,
1447
+ "rstrip": false,
1448
+ "single_word": false,
1449
+ "special": true
1450
+ },
1451
+ "128181": {
1452
+ "content": "<|reserved_special_token_173|>",
1453
+ "lstrip": false,
1454
+ "normalized": false,
1455
+ "rstrip": false,
1456
+ "single_word": false,
1457
+ "special": true
1458
+ },
1459
+ "128182": {
1460
+ "content": "<|reserved_special_token_174|>",
1461
+ "lstrip": false,
1462
+ "normalized": false,
1463
+ "rstrip": false,
1464
+ "single_word": false,
1465
+ "special": true
1466
+ },
1467
+ "128183": {
1468
+ "content": "<|reserved_special_token_175|>",
1469
+ "lstrip": false,
1470
+ "normalized": false,
1471
+ "rstrip": false,
1472
+ "single_word": false,
1473
+ "special": true
1474
+ },
1475
+ "128184": {
1476
+ "content": "<|reserved_special_token_176|>",
1477
+ "lstrip": false,
1478
+ "normalized": false,
1479
+ "rstrip": false,
1480
+ "single_word": false,
1481
+ "special": true
1482
+ },
1483
+ "128185": {
1484
+ "content": "<|reserved_special_token_177|>",
1485
+ "lstrip": false,
1486
+ "normalized": false,
1487
+ "rstrip": false,
1488
+ "single_word": false,
1489
+ "special": true
1490
+ },
1491
+ "128186": {
1492
+ "content": "<|reserved_special_token_178|>",
1493
+ "lstrip": false,
1494
+ "normalized": false,
1495
+ "rstrip": false,
1496
+ "single_word": false,
1497
+ "special": true
1498
+ },
1499
+ "128187": {
1500
+ "content": "<|reserved_special_token_179|>",
1501
+ "lstrip": false,
1502
+ "normalized": false,
1503
+ "rstrip": false,
1504
+ "single_word": false,
1505
+ "special": true
1506
+ },
1507
+ "128188": {
1508
+ "content": "<|reserved_special_token_180|>",
1509
+ "lstrip": false,
1510
+ "normalized": false,
1511
+ "rstrip": false,
1512
+ "single_word": false,
1513
+ "special": true
1514
+ },
1515
+ "128189": {
1516
+ "content": "<|reserved_special_token_181|>",
1517
+ "lstrip": false,
1518
+ "normalized": false,
1519
+ "rstrip": false,
1520
+ "single_word": false,
1521
+ "special": true
1522
+ },
1523
+ "128190": {
1524
+ "content": "<|reserved_special_token_182|>",
1525
+ "lstrip": false,
1526
+ "normalized": false,
1527
+ "rstrip": false,
1528
+ "single_word": false,
1529
+ "special": true
1530
+ },
1531
+ "128191": {
1532
+ "content": "<|reserved_special_token_183|>",
1533
+ "lstrip": false,
1534
+ "normalized": false,
1535
+ "rstrip": false,
1536
+ "single_word": false,
1537
+ "special": true
1538
+ },
1539
+ "128192": {
1540
+ "content": "<|reserved_special_token_184|>",
1541
+ "lstrip": false,
1542
+ "normalized": false,
1543
+ "rstrip": false,
1544
+ "single_word": false,
1545
+ "special": true
1546
+ },
1547
+ "128193": {
1548
+ "content": "<|reserved_special_token_185|>",
1549
+ "lstrip": false,
1550
+ "normalized": false,
1551
+ "rstrip": false,
1552
+ "single_word": false,
1553
+ "special": true
1554
+ },
1555
+ "128194": {
1556
+ "content": "<|reserved_special_token_186|>",
1557
+ "lstrip": false,
1558
+ "normalized": false,
1559
+ "rstrip": false,
1560
+ "single_word": false,
1561
+ "special": true
1562
+ },
1563
+ "128195": {
1564
+ "content": "<|reserved_special_token_187|>",
1565
+ "lstrip": false,
1566
+ "normalized": false,
1567
+ "rstrip": false,
1568
+ "single_word": false,
1569
+ "special": true
1570
+ },
1571
+ "128196": {
1572
+ "content": "<|reserved_special_token_188|>",
1573
+ "lstrip": false,
1574
+ "normalized": false,
1575
+ "rstrip": false,
1576
+ "single_word": false,
1577
+ "special": true
1578
+ },
1579
+ "128197": {
1580
+ "content": "<|reserved_special_token_189|>",
1581
+ "lstrip": false,
1582
+ "normalized": false,
1583
+ "rstrip": false,
1584
+ "single_word": false,
1585
+ "special": true
1586
+ },
1587
+ "128198": {
1588
+ "content": "<|reserved_special_token_190|>",
1589
+ "lstrip": false,
1590
+ "normalized": false,
1591
+ "rstrip": false,
1592
+ "single_word": false,
1593
+ "special": true
1594
+ },
1595
+ "128199": {
1596
+ "content": "<|reserved_special_token_191|>",
1597
+ "lstrip": false,
1598
+ "normalized": false,
1599
+ "rstrip": false,
1600
+ "single_word": false,
1601
+ "special": true
1602
+ },
1603
+ "128200": {
1604
+ "content": "<|reserved_special_token_192|>",
1605
+ "lstrip": false,
1606
+ "normalized": false,
1607
+ "rstrip": false,
1608
+ "single_word": false,
1609
+ "special": true
1610
+ },
1611
+ "128201": {
1612
+ "content": "<|reserved_special_token_193|>",
1613
+ "lstrip": false,
1614
+ "normalized": false,
1615
+ "rstrip": false,
1616
+ "single_word": false,
1617
+ "special": true
1618
+ },
1619
+ "128202": {
1620
+ "content": "<|reserved_special_token_194|>",
1621
+ "lstrip": false,
1622
+ "normalized": false,
1623
+ "rstrip": false,
1624
+ "single_word": false,
1625
+ "special": true
1626
+ },
1627
+ "128203": {
1628
+ "content": "<|reserved_special_token_195|>",
1629
+ "lstrip": false,
1630
+ "normalized": false,
1631
+ "rstrip": false,
1632
+ "single_word": false,
1633
+ "special": true
1634
+ },
1635
+ "128204": {
1636
+ "content": "<|reserved_special_token_196|>",
1637
+ "lstrip": false,
1638
+ "normalized": false,
1639
+ "rstrip": false,
1640
+ "single_word": false,
1641
+ "special": true
1642
+ },
1643
+ "128205": {
1644
+ "content": "<|reserved_special_token_197|>",
1645
+ "lstrip": false,
1646
+ "normalized": false,
1647
+ "rstrip": false,
1648
+ "single_word": false,
1649
+ "special": true
1650
+ },
1651
+ "128206": {
1652
+ "content": "<|reserved_special_token_198|>",
1653
+ "lstrip": false,
1654
+ "normalized": false,
1655
+ "rstrip": false,
1656
+ "single_word": false,
1657
+ "special": true
1658
+ },
1659
+ "128207": {
1660
+ "content": "<|reserved_special_token_199|>",
1661
+ "lstrip": false,
1662
+ "normalized": false,
1663
+ "rstrip": false,
1664
+ "single_word": false,
1665
+ "special": true
1666
+ },
1667
+ "128208": {
1668
+ "content": "<|reserved_special_token_200|>",
1669
+ "lstrip": false,
1670
+ "normalized": false,
1671
+ "rstrip": false,
1672
+ "single_word": false,
1673
+ "special": true
1674
+ },
1675
+ "128209": {
1676
+ "content": "<|reserved_special_token_201|>",
1677
+ "lstrip": false,
1678
+ "normalized": false,
1679
+ "rstrip": false,
1680
+ "single_word": false,
1681
+ "special": true
1682
+ },
1683
+ "128210": {
1684
+ "content": "<|reserved_special_token_202|>",
1685
+ "lstrip": false,
1686
+ "normalized": false,
1687
+ "rstrip": false,
1688
+ "single_word": false,
1689
+ "special": true
1690
+ },
1691
+ "128211": {
1692
+ "content": "<|reserved_special_token_203|>",
1693
+ "lstrip": false,
1694
+ "normalized": false,
1695
+ "rstrip": false,
1696
+ "single_word": false,
1697
+ "special": true
1698
+ },
1699
+ "128212": {
1700
+ "content": "<|reserved_special_token_204|>",
1701
+ "lstrip": false,
1702
+ "normalized": false,
1703
+ "rstrip": false,
1704
+ "single_word": false,
1705
+ "special": true
1706
+ },
1707
+ "128213": {
1708
+ "content": "<|reserved_special_token_205|>",
1709
+ "lstrip": false,
1710
+ "normalized": false,
1711
+ "rstrip": false,
1712
+ "single_word": false,
1713
+ "special": true
1714
+ },
1715
+ "128214": {
1716
+ "content": "<|reserved_special_token_206|>",
1717
+ "lstrip": false,
1718
+ "normalized": false,
1719
+ "rstrip": false,
1720
+ "single_word": false,
1721
+ "special": true
1722
+ },
1723
+ "128215": {
1724
+ "content": "<|reserved_special_token_207|>",
1725
+ "lstrip": false,
1726
+ "normalized": false,
1727
+ "rstrip": false,
1728
+ "single_word": false,
1729
+ "special": true
1730
+ },
1731
+ "128216": {
1732
+ "content": "<|reserved_special_token_208|>",
1733
+ "lstrip": false,
1734
+ "normalized": false,
1735
+ "rstrip": false,
1736
+ "single_word": false,
1737
+ "special": true
1738
+ },
1739
+ "128217": {
1740
+ "content": "<|reserved_special_token_209|>",
1741
+ "lstrip": false,
1742
+ "normalized": false,
1743
+ "rstrip": false,
1744
+ "single_word": false,
1745
+ "special": true
1746
+ },
1747
+ "128218": {
1748
+ "content": "<|reserved_special_token_210|>",
1749
+ "lstrip": false,
1750
+ "normalized": false,
1751
+ "rstrip": false,
1752
+ "single_word": false,
1753
+ "special": true
1754
+ },
1755
+ "128219": {
1756
+ "content": "<|reserved_special_token_211|>",
1757
+ "lstrip": false,
1758
+ "normalized": false,
1759
+ "rstrip": false,
1760
+ "single_word": false,
1761
+ "special": true
1762
+ },
1763
+ "128220": {
1764
+ "content": "<|reserved_special_token_212|>",
1765
+ "lstrip": false,
1766
+ "normalized": false,
1767
+ "rstrip": false,
1768
+ "single_word": false,
1769
+ "special": true
1770
+ },
1771
+ "128221": {
1772
+ "content": "<|reserved_special_token_213|>",
1773
+ "lstrip": false,
1774
+ "normalized": false,
1775
+ "rstrip": false,
1776
+ "single_word": false,
1777
+ "special": true
1778
+ },
1779
+ "128222": {
1780
+ "content": "<|reserved_special_token_214|>",
1781
+ "lstrip": false,
1782
+ "normalized": false,
1783
+ "rstrip": false,
1784
+ "single_word": false,
1785
+ "special": true
1786
+ },
1787
+ "128223": {
1788
+ "content": "<|reserved_special_token_215|>",
1789
+ "lstrip": false,
1790
+ "normalized": false,
1791
+ "rstrip": false,
1792
+ "single_word": false,
1793
+ "special": true
1794
+ },
1795
+ "128224": {
1796
+ "content": "<|reserved_special_token_216|>",
1797
+ "lstrip": false,
1798
+ "normalized": false,
1799
+ "rstrip": false,
1800
+ "single_word": false,
1801
+ "special": true
1802
+ },
1803
+ "128225": {
1804
+ "content": "<|reserved_special_token_217|>",
1805
+ "lstrip": false,
1806
+ "normalized": false,
1807
+ "rstrip": false,
1808
+ "single_word": false,
1809
+ "special": true
1810
+ },
1811
+ "128226": {
1812
+ "content": "<|reserved_special_token_218|>",
1813
+ "lstrip": false,
1814
+ "normalized": false,
1815
+ "rstrip": false,
1816
+ "single_word": false,
1817
+ "special": true
1818
+ },
1819
+ "128227": {
1820
+ "content": "<|reserved_special_token_219|>",
1821
+ "lstrip": false,
1822
+ "normalized": false,
1823
+ "rstrip": false,
1824
+ "single_word": false,
1825
+ "special": true
1826
+ },
1827
+ "128228": {
1828
+ "content": "<|reserved_special_token_220|>",
1829
+ "lstrip": false,
1830
+ "normalized": false,
1831
+ "rstrip": false,
1832
+ "single_word": false,
1833
+ "special": true
1834
+ },
1835
+ "128229": {
1836
+ "content": "<|reserved_special_token_221|>",
1837
+ "lstrip": false,
1838
+ "normalized": false,
1839
+ "rstrip": false,
1840
+ "single_word": false,
1841
+ "special": true
1842
+ },
1843
+ "128230": {
1844
+ "content": "<|reserved_special_token_222|>",
1845
+ "lstrip": false,
1846
+ "normalized": false,
1847
+ "rstrip": false,
1848
+ "single_word": false,
1849
+ "special": true
1850
+ },
1851
+ "128231": {
1852
+ "content": "<|reserved_special_token_223|>",
1853
+ "lstrip": false,
1854
+ "normalized": false,
1855
+ "rstrip": false,
1856
+ "single_word": false,
1857
+ "special": true
1858
+ },
1859
+ "128232": {
1860
+ "content": "<|reserved_special_token_224|>",
1861
+ "lstrip": false,
1862
+ "normalized": false,
1863
+ "rstrip": false,
1864
+ "single_word": false,
1865
+ "special": true
1866
+ },
1867
+ "128233": {
1868
+ "content": "<|reserved_special_token_225|>",
1869
+ "lstrip": false,
1870
+ "normalized": false,
1871
+ "rstrip": false,
1872
+ "single_word": false,
1873
+ "special": true
1874
+ },
1875
+ "128234": {
1876
+ "content": "<|reserved_special_token_226|>",
1877
+ "lstrip": false,
1878
+ "normalized": false,
1879
+ "rstrip": false,
1880
+ "single_word": false,
1881
+ "special": true
1882
+ },
1883
+ "128235": {
1884
+ "content": "<|reserved_special_token_227|>",
1885
+ "lstrip": false,
1886
+ "normalized": false,
1887
+ "rstrip": false,
1888
+ "single_word": false,
1889
+ "special": true
1890
+ },
1891
+ "128236": {
1892
+ "content": "<|reserved_special_token_228|>",
1893
+ "lstrip": false,
1894
+ "normalized": false,
1895
+ "rstrip": false,
1896
+ "single_word": false,
1897
+ "special": true
1898
+ },
1899
+ "128237": {
1900
+ "content": "<|reserved_special_token_229|>",
1901
+ "lstrip": false,
1902
+ "normalized": false,
1903
+ "rstrip": false,
1904
+ "single_word": false,
1905
+ "special": true
1906
+ },
1907
+ "128238": {
1908
+ "content": "<|reserved_special_token_230|>",
1909
+ "lstrip": false,
1910
+ "normalized": false,
1911
+ "rstrip": false,
1912
+ "single_word": false,
1913
+ "special": true
1914
+ },
1915
+ "128239": {
1916
+ "content": "<|reserved_special_token_231|>",
1917
+ "lstrip": false,
1918
+ "normalized": false,
1919
+ "rstrip": false,
1920
+ "single_word": false,
1921
+ "special": true
1922
+ },
1923
+ "128240": {
1924
+ "content": "<|reserved_special_token_232|>",
1925
+ "lstrip": false,
1926
+ "normalized": false,
1927
+ "rstrip": false,
1928
+ "single_word": false,
1929
+ "special": true
1930
+ },
1931
+ "128241": {
1932
+ "content": "<|reserved_special_token_233|>",
1933
+ "lstrip": false,
1934
+ "normalized": false,
1935
+ "rstrip": false,
1936
+ "single_word": false,
1937
+ "special": true
1938
+ },
1939
+ "128242": {
1940
+ "content": "<|reserved_special_token_234|>",
1941
+ "lstrip": false,
1942
+ "normalized": false,
1943
+ "rstrip": false,
1944
+ "single_word": false,
1945
+ "special": true
1946
+ },
1947
+ "128243": {
1948
+ "content": "<|reserved_special_token_235|>",
1949
+ "lstrip": false,
1950
+ "normalized": false,
1951
+ "rstrip": false,
1952
+ "single_word": false,
1953
+ "special": true
1954
+ },
1955
+ "128244": {
1956
+ "content": "<|reserved_special_token_236|>",
1957
+ "lstrip": false,
1958
+ "normalized": false,
1959
+ "rstrip": false,
1960
+ "single_word": false,
1961
+ "special": true
1962
+ },
1963
+ "128245": {
1964
+ "content": "<|reserved_special_token_237|>",
1965
+ "lstrip": false,
1966
+ "normalized": false,
1967
+ "rstrip": false,
1968
+ "single_word": false,
1969
+ "special": true
1970
+ },
1971
+ "128246": {
1972
+ "content": "<|reserved_special_token_238|>",
1973
+ "lstrip": false,
1974
+ "normalized": false,
1975
+ "rstrip": false,
1976
+ "single_word": false,
1977
+ "special": true
1978
+ },
1979
+ "128247": {
1980
+ "content": "<|reserved_special_token_239|>",
1981
+ "lstrip": false,
1982
+ "normalized": false,
1983
+ "rstrip": false,
1984
+ "single_word": false,
1985
+ "special": true
1986
+ },
1987
+ "128248": {
1988
+ "content": "<|reserved_special_token_240|>",
1989
+ "lstrip": false,
1990
+ "normalized": false,
1991
+ "rstrip": false,
1992
+ "single_word": false,
1993
+ "special": true
1994
+ },
1995
+ "128249": {
1996
+ "content": "<|reserved_special_token_241|>",
1997
+ "lstrip": false,
1998
+ "normalized": false,
1999
+ "rstrip": false,
2000
+ "single_word": false,
2001
+ "special": true
2002
+ },
2003
+ "128250": {
2004
+ "content": "<|reserved_special_token_242|>",
2005
+ "lstrip": false,
2006
+ "normalized": false,
2007
+ "rstrip": false,
2008
+ "single_word": false,
2009
+ "special": true
2010
+ },
2011
+ "128251": {
2012
+ "content": "<|reserved_special_token_243|>",
2013
+ "lstrip": false,
2014
+ "normalized": false,
2015
+ "rstrip": false,
2016
+ "single_word": false,
2017
+ "special": true
2018
+ },
2019
+ "128252": {
2020
+ "content": "<|reserved_special_token_244|>",
2021
+ "lstrip": false,
2022
+ "normalized": false,
2023
+ "rstrip": false,
2024
+ "single_word": false,
2025
+ "special": true
2026
+ },
2027
+ "128253": {
2028
+ "content": "<|reserved_special_token_245|>",
2029
+ "lstrip": false,
2030
+ "normalized": false,
2031
+ "rstrip": false,
2032
+ "single_word": false,
2033
+ "special": true
2034
+ },
2035
+ "128254": {
2036
+ "content": "<|reserved_special_token_246|>",
2037
+ "lstrip": false,
2038
+ "normalized": false,
2039
+ "rstrip": false,
2040
+ "single_word": false,
2041
+ "special": true
2042
+ },
2043
+ "128255": {
2044
+ "content": "<|reserved_special_token_247|>",
2045
+ "lstrip": false,
2046
+ "normalized": false,
2047
+ "rstrip": false,
2048
+ "single_word": false,
2049
+ "special": true
2050
+ }
2051
+ },
2052
+ "bos_token": "<|begin_of_text|>",
2053
+ "chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- if strftime_now is defined %}\n {%- set date_string = strftime_now(\"%d %b %Y\") %}\n {%- else %}\n {%- set date_string = \"26 Jul 2024\" %}\n {%- endif %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message #}\n{{- \"<|start_header_id|>system<|end_header_id|>\\n\\n\" }}\n{%- if tools is not none %}\n {{- \"Environment: ipython\\n\" }}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2023\\n\" }}\n{{- \"Today Date: \" + date_string + \"\\n\\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\\n\\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\\n\\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\\n\\n'+ message['content'] | trim + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {{- \"<|eot_id|>\" }}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\\n\\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' }}\n{%- endif %}\n",
2054
+ "clean_up_tokenization_spaces": true,
2055
+ "eos_token": "<|eot_id|>",
2056
+ "model_input_names": [
2057
+ "input_ids",
2058
+ "attention_mask"
2059
+ ],
2060
+ "model_max_length": 131072,
2061
+ "tokenizer_class": "PreTrainedTokenizerFast"
2062
+ }