Upload 2 files
Browse files- config.json +50 -0
- test.py +36 -0
config.json
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"MiniMaxText01ForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_dropout": 0.0,
|
6 |
+
"attn_type_list": [
|
7 |
+
0,
|
8 |
+
1,
|
9 |
+
0,
|
10 |
+
1
|
11 |
+
],
|
12 |
+
"auto_map": {
|
13 |
+
"AutoConfig": "configuration_minimax_text_01.MiniMaxText01Config",
|
14 |
+
"AutoModelForCausalLM": "modeling_minimax_text_01.MiniMaxText01ForCausalLM"
|
15 |
+
},
|
16 |
+
"bos_token_id": null,
|
17 |
+
"eos_token_id": 200020,
|
18 |
+
"head_dim": 32,
|
19 |
+
"hidden_act": "silu",
|
20 |
+
"hidden_size": 256,
|
21 |
+
"initializer_range": 0.02,
|
22 |
+
"intermediate_size": 512,
|
23 |
+
"layernorm_full_attention_alpha": 3.5565588200778455,
|
24 |
+
"layernorm_full_attention_beta": 1.0,
|
25 |
+
"layernorm_linear_attention_alpha": 3.5565588200778455,
|
26 |
+
"layernorm_linear_attention_beta": 1.0,
|
27 |
+
"layernorm_mlp_alpha": 3.5565588200778455,
|
28 |
+
"layernorm_mlp_beta": 1.0,
|
29 |
+
"max_position_embeddings": 1024,
|
30 |
+
"model_type": "minimax_text_01",
|
31 |
+
"num_attention_heads": 4,
|
32 |
+
"num_experts_per_tok": 1,
|
33 |
+
"num_hidden_layers": 4,
|
34 |
+
"num_key_value_heads": 2,
|
35 |
+
"num_local_experts": 2,
|
36 |
+
"output_router_logits": false,
|
37 |
+
"postnorm": true,
|
38 |
+
"rms_norm_eps": 1e-05,
|
39 |
+
"rope_theta": 10000,
|
40 |
+
"rotary_dim": 16,
|
41 |
+
"router_aux_loss_coef": 0.001,
|
42 |
+
"router_jitter_noise": 0.0,
|
43 |
+
"shared_intermediate_size": 0,
|
44 |
+
"shared_moe_mode": "sigmoid",
|
45 |
+
"sliding_window": null,
|
46 |
+
"tie_word_embeddings": false,
|
47 |
+
"transformers_version": "4.45.2",
|
48 |
+
"use_cache": true,
|
49 |
+
"vocab_size": 200064
|
50 |
+
}
|
test.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, QuantoConfig, GenerationConfig
|
2 |
+
|
3 |
+
# load hf config
|
4 |
+
hf_config = AutoConfig.from_pretrained("/Users/gokdenizgulmez/Desktop/mlx-lm/mlx_lm/MiniMiniMax01Text", trust_remote_code=True)
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("MiniMaxAI/MiniMax-Text-01")
|
7 |
+
prompt = "Hello!"
|
8 |
+
messages = [
|
9 |
+
{"role": "system", "content": [{"type": "text", "text": "You are a helpful assistant created by MiniMax based on MiniMax-Text-01 model."}]},
|
10 |
+
{"role": "user", "content": [{"type": "text", "text": prompt}]},
|
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 |
+
"/Users/gokdenizgulmez/Desktop/mlx-lm/mlx_lm/MiniMiniMax01Text",
|
23 |
+
trust_remote_code=True
|
24 |
+
)
|
25 |
+
|
26 |
+
generation_config = GenerationConfig(
|
27 |
+
max_new_tokens=20,
|
28 |
+
eos_token_id=200020,
|
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]
|