Upload 12 files
Browse files- config.json +1 -1
- create.py +1 -1
- modeling_minimax.py +1 -1
- print.py +10 -0
- test.py +10 -10
- tokenizer.json +90 -0
- tokenizer_config.json +1 -1
config.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"architectures": [
|
| 3 |
-
"
|
| 4 |
],
|
| 5 |
"attention_dropout": 0.0,
|
| 6 |
"layer_types": [
|
|
|
|
| 1 |
{
|
| 2 |
"architectures": [
|
| 3 |
+
"MiniMaxForCausalLM"
|
| 4 |
],
|
| 5 |
"attention_dropout": 0.0,
|
| 6 |
"layer_types": [
|
create.py
CHANGED
|
@@ -8,7 +8,7 @@ model_dir = "/Users/Goekdeniz.Guelmez@computacenter.com/Library/CloudStorage/One
|
|
| 8 |
sys.path.append(model_dir)
|
| 9 |
|
| 10 |
# Import your custom model and configuration classes
|
| 11 |
-
from
|
| 12 |
from configuration_minimax import MiniMaxConfig
|
| 13 |
|
| 14 |
# Load the configuration
|
|
|
|
| 8 |
sys.path.append(model_dir)
|
| 9 |
|
| 10 |
# Import your custom model and configuration classes
|
| 11 |
+
from modeling_minimax import MiniMaxForCausalLM
|
| 12 |
from configuration_minimax import MiniMaxConfig
|
| 13 |
|
| 14 |
# Load the configuration
|
modeling_minimax.py
CHANGED
|
@@ -604,7 +604,7 @@ class MiniMaxModel(MiniMaxPreTrainedModel):
|
|
| 604 |
# Initialize weights and apply final processing
|
| 605 |
self.post_init()
|
| 606 |
|
| 607 |
-
@check_model_inputs
|
| 608 |
def forward(
|
| 609 |
self,
|
| 610 |
input_ids: Optional[torch.LongTensor] = None,
|
|
|
|
| 604 |
# Initialize weights and apply final processing
|
| 605 |
self.post_init()
|
| 606 |
|
| 607 |
+
@check_model_inputs
|
| 608 |
def forward(
|
| 609 |
self,
|
| 610 |
input_ids: Optional[torch.LongTensor] = None,
|
print.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoModelForCausalLM
|
| 2 |
+
|
| 3 |
+
model = "/Users/Goekdeniz.Guelmez@computacenter.com/Library/CloudStorage/OneDrive-COMPUTACENTER/Desktop/MiniMax01Text-Dev"
|
| 4 |
+
|
| 5 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 6 |
+
model,
|
| 7 |
+
trust_remote_code=True
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
print(model)
|
test.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, QuantoConfig, GenerationConfig
|
| 2 |
|
| 3 |
-
|
| 4 |
-
hf_config = AutoConfig.from_pretrained("/Users/gokdenizgulmez/Desktop/mlx-lm/mlx_lm/MiniMiniMax01Text", trust_remote_code=True)
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
prompt = "Hello!"
|
| 8 |
messages = [
|
| 9 |
-
{"role": "system", "content":
|
| 10 |
-
{"role": "user", "content":
|
| 11 |
]
|
| 12 |
text = tokenizer.apply_chat_template(
|
| 13 |
messages,
|
| 14 |
tokenize=False,
|
| 15 |
add_generation_prompt=True
|
| 16 |
)
|
| 17 |
-
# tokenize and move to device
|
| 18 |
-
model_inputs = tokenizer(text, return_tensors="pt")
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
model = AutoModelForCausalLM.from_pretrained(
|
| 22 |
-
|
| 23 |
trust_remote_code=True
|
| 24 |
)
|
| 25 |
|
|
@@ -29,8 +29,8 @@ generation_config = GenerationConfig(
|
|
| 29 |
use_cache=True,
|
| 30 |
)
|
| 31 |
generated_ids = model.generate(**model_inputs, generation_config=generation_config)
|
| 32 |
-
print(f"generated_ids: {generated_ids}")
|
| 33 |
generated_ids = [
|
| 34 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 35 |
]
|
| 36 |
-
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
|
|
|
| 1 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, QuantoConfig, GenerationConfig
|
| 2 |
|
| 3 |
+
model = "/Users/Goekdeniz.Guelmez@computacenter.com/Library/CloudStorage/OneDrive-COMPUTACENTER/Desktop/MiniMax01Text-Dev"
|
|
|
|
| 4 |
|
| 5 |
+
hf_config = AutoConfig.from_pretrained(model, trust_remote_code=True)
|
| 6 |
+
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 8 |
prompt = "Hello!"
|
| 9 |
messages = [
|
| 10 |
+
{"role": "system", "content": "You are a helpful assistant created by MiniMax based on MiniMax-Text-01 model."},
|
| 11 |
+
{"role": "user", "content": prompt},
|
| 12 |
]
|
| 13 |
text = tokenizer.apply_chat_template(
|
| 14 |
messages,
|
| 15 |
tokenize=False,
|
| 16 |
add_generation_prompt=True
|
| 17 |
)
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
model_inputs = tokenizer(text, return_tensors="pt")
|
| 20 |
|
| 21 |
model = AutoModelForCausalLM.from_pretrained(
|
| 22 |
+
model,
|
| 23 |
trust_remote_code=True
|
| 24 |
)
|
| 25 |
|
|
|
|
| 29 |
use_cache=True,
|
| 30 |
)
|
| 31 |
generated_ids = model.generate(**model_inputs, generation_config=generation_config)
|
|
|
|
| 32 |
generated_ids = [
|
| 33 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 34 |
]
|
| 35 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 36 |
+
print(response)
|
tokenizer.json
CHANGED
|
@@ -236,6 +236,96 @@
|
|
| 236 |
"rstrip": false,
|
| 237 |
"normalized": false,
|
| 238 |
"special": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
}
|
| 240 |
],
|
| 241 |
"normalizer": {
|
|
|
|
| 236 |
"rstrip": false,
|
| 237 |
"normalized": false,
|
| 238 |
"special": true
|
| 239 |
+
},
|
| 240 |
+
{
|
| 241 |
+
"id": 200026,
|
| 242 |
+
"content": "<video>",
|
| 243 |
+
"single_word": false,
|
| 244 |
+
"lstrip": false,
|
| 245 |
+
"rstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"special": true
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"id": 200027,
|
| 251 |
+
"content": "<start_of_speech>",
|
| 252 |
+
"single_word": false,
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"rstrip": false,
|
| 255 |
+
"normalized": false,
|
| 256 |
+
"special": true
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"id": 200028,
|
| 260 |
+
"content": "<end_of_speech>",
|
| 261 |
+
"single_word": false,
|
| 262 |
+
"lstrip": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"normalized": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"id": 200029,
|
| 269 |
+
"content": "<start_of_image>",
|
| 270 |
+
"single_word": false,
|
| 271 |
+
"lstrip": false,
|
| 272 |
+
"rstrip": false,
|
| 273 |
+
"normalized": false,
|
| 274 |
+
"special": true
|
| 275 |
+
},
|
| 276 |
+
{
|
| 277 |
+
"id": 200030,
|
| 278 |
+
"content": "<end_of_image>",
|
| 279 |
+
"single_word": false,
|
| 280 |
+
"lstrip": false,
|
| 281 |
+
"rstrip": false,
|
| 282 |
+
"normalized": false,
|
| 283 |
+
"special": true
|
| 284 |
+
},
|
| 285 |
+
{
|
| 286 |
+
"id": 200031,
|
| 287 |
+
"content": "<start_of_video>",
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"lstrip": false,
|
| 290 |
+
"rstrip": false,
|
| 291 |
+
"normalized": false,
|
| 292 |
+
"special": true
|
| 293 |
+
},
|
| 294 |
+
{
|
| 295 |
+
"id": 200032,
|
| 296 |
+
"content": "<end_of_video>",
|
| 297 |
+
"single_word": false,
|
| 298 |
+
"lstrip": false,
|
| 299 |
+
"rstrip": false,
|
| 300 |
+
"normalized": false,
|
| 301 |
+
"special": true
|
| 302 |
+
},
|
| 303 |
+
{
|
| 304 |
+
"id": 200033,
|
| 305 |
+
"content": "<vision_pad>",
|
| 306 |
+
"single_word": false,
|
| 307 |
+
"lstrip": false,
|
| 308 |
+
"rstrip": false,
|
| 309 |
+
"normalized": false,
|
| 310 |
+
"special": true
|
| 311 |
+
},
|
| 312 |
+
{
|
| 313 |
+
"id": 200034,
|
| 314 |
+
"content": "<begin_of_document>",
|
| 315 |
+
"single_word": false,
|
| 316 |
+
"lstrip": false,
|
| 317 |
+
"rstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"special": true
|
| 320 |
+
},
|
| 321 |
+
{
|
| 322 |
+
"id": 200035,
|
| 323 |
+
"content": "<jupyter_error>",
|
| 324 |
+
"single_word": false,
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"rstrip": false,
|
| 327 |
+
"normalized": false,
|
| 328 |
+
"special": true
|
| 329 |
}
|
| 330 |
],
|
| 331 |
"normalizer": {
|
tokenizer_config.json
CHANGED
|
@@ -6,5 +6,5 @@
|
|
| 6 |
"model_max_length": 40960000,
|
| 7 |
"tokenizer_class": "GPT2Tokenizer",
|
| 8 |
"unk_token": "<end_of_document>",
|
| 9 |
-
"chat_template": "{% for message in messages
|
| 10 |
}
|
|
|
|
| 6 |
"model_max_length": 40960000,
|
| 7 |
"tokenizer_class": "GPT2Tokenizer",
|
| 8 |
"unk_token": "<end_of_document>",
|
| 9 |
+
"chat_template": "{{ '<begin_of_document>' -}}{% set ns = namespace(system_prompt='') -%}{% for message in messages -%}{% if message['role'] == 'system' -%}{% set text = message['content'][0]['text'] if message['content'] is not string else message['content'] -%}{% set ns.system_prompt = ns.system_prompt + text -%}{% endif -%}{%- endfor -%}{% if ns.system_prompt != '' -%}{{ '<beginning_of_sentence>system ai_setting=assistant\n' + ns.system_prompt + '<end_of_sentence>\n' -}}{%- endif -%}{% if tools -%}{{ '<beginning_of_sentence>system tool_setting=tools\nYou are provided with these tools:\n<tools>\n' -}}{% for tool in tools -%}{{ tool | tojson ~ '\n' -}}{%- endfor -%}{{ '</tools>\n\nIf you need to call tools, please respond with <tool_calls></tool_calls> XML tags, and provide tool-name and json-object of arguments, following the format below:\n<tool_calls>\n{''name'': <tool-name-1>, ''arguments'': <args-json-object-1>}\n...\n</tool_calls><end_of_sentence>\n' -}}{%- endif -%}{% for message in messages -%}{% set text = message['content'][0]['text'] if message['content'] is not string else message['content'] -%}{% if message['role'] == 'user' -%}{{ '<beginning_of_sentence>user name=user\n' + text + '<end_of_sentence>\n' -}}{% elif message['role'] == 'assistant' -%}{{ '<beginning_of_sentence>ai name=assistant\n' -}}{% if message['content'] is string -%}{{ message['content'] -}}{% else -%}{% for content in message['content'] | selectattr('type', 'equalto', 'text') -%}{{ content['text'] -}}{%- endfor -%}{%- endif -%}{{ '<end_of_sentence>\n' -}}{% elif message['role'] == 'tool' -%}{{ '<beginning_of_sentence>tool name=tools\n' }} {%- for content in message['content'] -%}{{- 'tool name: ' + content['name'] + '\n' + 'tool result: ' + (content['text'] if 'text' in content else content) + '\n\n' -}} {%- endfor -%}{{- '<end_of_sentence>\n' -}}{% endif -%}{%- endfor -%}{% if add_generation_prompt -%}{{ '<beginning_of_sentence>ai name=assistant\n' -}}{%- endif -%}"
|
| 10 |
}
|