axi0mX commited on
Commit
03e8065
·
verified ·
1 Parent(s): 177e217

Add files using upload-large-folder tool

Browse files
README.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: mlx
4
+ tags:
5
+ - language
6
+ - granite-4.0
7
+ - mlx
8
+ pipeline_tag: text-generation
9
+ base_model: ibm-granite/granite-4.1-30b
10
+ ---
11
+
12
+ # mlx-community/granite-4.1-30b-4bit
13
+
14
+ This model [mlx-community/granite-4.1-30b-4bit](https://huggingface.co/mlx-community/granite-4.1-30b-4bit) was
15
+ converted to MLX format from [ibm-granite/granite-4.1-30b](https://huggingface.co/ibm-granite/granite-4.1-30b)
16
+ using mlx-lm version **0.31.3**.
17
+
18
+ ## Use with mlx
19
+
20
+ ```bash
21
+ pip install mlx-lm
22
+ ```
23
+
24
+ ```python
25
+ from mlx_lm import load, generate
26
+
27
+ model, tokenizer = load("mlx-community/granite-4.1-30b-4bit")
28
+
29
+ prompt = "hello"
30
+
31
+ if tokenizer.chat_template is not None:
32
+ messages = [{"role": "user", "content": prompt}]
33
+ prompt = tokenizer.apply_chat_template(
34
+ messages, add_generation_prompt=True, return_dict=False,
35
+ )
36
+
37
+ response = generate(model, tokenizer, prompt=prompt, verbose=True)
38
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set tools_system_message_prefix = 'You are a helpful assistant with access to the following tools. You may call one or more tools to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>' %}
2
+ {%- set tools_system_message_suffix = '\n</tools>\n\nFor each tool call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.' %}
3
+ {%- set documents_system_message_prefix = 'You are a helpful assistant with access to the following documents. You may use one or more documents to assist with the user query.\n\nYou are given a list of documents within <documents></documents> XML tags:\n<documents>' %}
4
+ {%- set documents_system_message_suffix = '\n</documents>\n\nWrite the response to the user\'s input by strictly aligning with the facts in the provided documents. If the information needed to answer the question is not available in the documents, inform the user that the question cannot be answered based on the available data.' %}
5
+ {%- if available_tools is defined and available_tools %}
6
+ {%- set tools = available_tools %}
7
+ {%- endif %}
8
+ {%- set ns = namespace(tools_system_message=tools_system_message_prefix,
9
+ documents_system_message=documents_system_message_prefix,
10
+ system_message=''
11
+ ) %}
12
+ {%- if tools %}
13
+ {%- for tool in tools %}
14
+ {%- set ns.tools_system_message = ns.tools_system_message + '\n' + (tool | tojson) %}
15
+ {%- endfor %}
16
+ {%- set ns.tools_system_message = ns.tools_system_message + tools_system_message_suffix %}
17
+ {%- else %}
18
+ {%- set ns.tools_system_message = '' %}
19
+ {%- endif %}
20
+ {%- if documents %}
21
+ {%- for document in documents %}
22
+ {%- set ns.documents_system_message = ns.documents_system_message + '\n' + (document | tojson) %}
23
+ {%- endfor %}
24
+ {%- set ns.documents_system_message = ns.documents_system_message + documents_system_message_suffix %}
25
+ {%- else %}
26
+ {%- set ns.documents_system_message = '' %}
27
+ {%- endif %}
28
+ {%- if messages[0].role == 'system' %}
29
+ {%- if messages[0].content is string %}
30
+ {%- set ns.system_message = messages[0].content %}
31
+ {%- elif messages[0].content is iterable %}
32
+ {%- for entry in messages[0].content %}
33
+ {%- if entry.type== 'text' %}
34
+ {%- if ns.system_message != '' %}
35
+ {%- set ns.system_message = ns.system_message + '\n' %}
36
+ {%- endif %}
37
+ {%- set ns.system_message = ns.system_message + entry.text %}
38
+ {%- endif %}
39
+ {%- endfor %}
40
+ {%- endif %}
41
+ {%- if tools and documents %}
42
+ {%- set ns.system_message = ns.system_message + '\n\n' + ns.tools_system_message + '\n\n' + ns.documents_system_message %}
43
+ {%- elif tools %}
44
+ {%- set ns.system_message = ns.system_message + '\n\n' + ns.tools_system_message %}
45
+ {%- elif documents %}
46
+ {%- set ns.system_message = ns.system_message + '\n\n' + ns.documents_system_message %}
47
+ {%- endif %}
48
+ {%- else %}
49
+ {%- if tools and documents %}
50
+ {%- set ns.system_message = ns.tools_system_message + '\n\n' + ns.documents_system_message %}
51
+ {%- elif tools %}
52
+ {%- set ns.system_message = ns.tools_system_message %}
53
+ {%- elif documents %}
54
+ {%- set ns.system_message = ns.documents_system_message %}
55
+ {%- endif %}
56
+ {%- endif %}
57
+ {%- if ns.system_message %}
58
+ {{- '<|start_of_role|>system<|end_of_role|>' + ns.system_message + '<|end_of_text|>\n' }}
59
+ {%- endif %}
60
+ {%- for message in messages %}
61
+ {%- set content = namespace(val='') %}
62
+ {%- if message.content is string %}
63
+ {%- set content.val = message.content %}
64
+ {%- else %}
65
+ {%- if message.content is iterable %}
66
+ {%- for entry in message.content %}
67
+ {%- if entry.type== 'text' %}
68
+ {%- if content.val != '' %}
69
+ {%- set content.val = content.val + '\n' %}
70
+ {%- endif %}
71
+ {%- set content.val = content.val + entry.text %}
72
+ {%- endif %}
73
+ {%- endfor %}
74
+ {%- endif %}
75
+ {%- endif %}
76
+ {%- if (message.role == 'user') or (message.role == 'system' and not loop.first) %}
77
+ {{- '<|start_of_role|>' + message.role + '<|end_of_role|>' + content.val + '<|end_of_text|>\n' }}
78
+ {%- elif message.role == 'assistant' %}
79
+ {{- '<|start_of_role|>' + message.role + '<|end_of_role|>' + content.val }}
80
+ {%- if message.tool_calls %}
81
+ {%- for tool_call in message.tool_calls %}
82
+ {%- if (loop.first and content.val) or (not loop.first) %}
83
+ {{- '\n' }}
84
+ {%- endif %}
85
+ {%- if tool_call.function %}
86
+ {%- set tool_call = tool_call.function %}
87
+ {%- endif %}
88
+ {{- '<tool_call>\n{"name": "' }}
89
+ {{- tool_call.name }}
90
+ {{- '", "arguments": ' }}
91
+ {%- if tool_call.arguments is string %}
92
+ {{- tool_call.arguments }}
93
+ {%- else %}
94
+ {{- tool_call.arguments | tojson }}
95
+ {%- endif %}
96
+ {{- '}\n</tool_call>' }}
97
+ {%- endfor %}
98
+ {%- endif %}
99
+ {{- '<|end_of_text|>\n' }}
100
+ {%- elif message.role == 'tool' %}
101
+ {%- if loop.first or (messages[loop.index0 - 1].role != 'tool') %}
102
+ {{- '<|start_of_role|>user<|end_of_role|>' }}
103
+ {%- endif %}
104
+ {{- '\n<tool_response>\n' }}
105
+ {{- content.val }}
106
+ {{- '\n</tool_response>' }}
107
+ {%- if loop.last or (messages[loop.index0 + 1].role != 'tool') %}
108
+ {{- '<|end_of_text|>\n' }}
109
+ {%- endif %}
110
+ {%- endif %}
111
+ {%- endfor %}
112
+ {%- if add_generation_prompt %}
113
+ {{- '<|start_of_role|>assistant<|end_of_role|>' }}
114
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GraniteForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "attention_multiplier": 0.0078125,
8
+ "bos_token_id": 100257,
9
+ "embedding_multiplier": 12.0,
10
+ "eos_token_id": 100257,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 4096,
13
+ "init_method": "mup",
14
+ "initializer_range": 0.1,
15
+ "intermediate_size": 32768,
16
+ "logits_scaling": 16.0,
17
+ "max_position_embeddings": 131072,
18
+ "mlp_bias": false,
19
+ "model_type": "granite",
20
+ "num_attention_heads": 32,
21
+ "num_hidden_layers": 64,
22
+ "num_key_value_heads": 8,
23
+ "pad_token_id": 100256,
24
+ "quantization": {
25
+ "group_size": 32,
26
+ "bits": 4,
27
+ "mode": "affine"
28
+ },
29
+ "quantization_config": {
30
+ "group_size": 32,
31
+ "bits": 4,
32
+ "mode": "affine"
33
+ },
34
+ "residual_multiplier": 0.175,
35
+ "rms_norm_eps": 1e-05,
36
+ "rope_scaling": null,
37
+ "rope_theta": 50000000,
38
+ "tie_word_embeddings": true,
39
+ "torch_dtype": "bfloat16",
40
+ "transformers_version": "4.53.3",
41
+ "use_cache": true,
42
+ "vocab_size": 100352
43
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 100257,
4
+ "eos_token_id": 100257,
5
+ "pad_token_id": 100256,
6
+ "transformers_version": "4.53.3"
7
+ }
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4641a3af6957f6433be7e3a8f29540accad3f7b9d8d8b35c7289d56243deae90
3
+ size 5360664833
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e468eebe28cd470f44413d538d4edeaa13f2a2ed30df560cd0c642afff79e6c4
3
+ size 5363828231
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c329ba648d5014ea90b7ce1653dbdbfd2e2dea804de8ff6e2cee46a368014c5c
3
+ size 5363828281
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f0cd375203a60387f49b0e5c9e6dc7b03757eff2b0e00436db00cc6240d302b
3
+ size 1953655228
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|end_of_text|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|end_of_text|>",
7
+ "errors": "replace",
8
+ "is_local": true,
9
+ "model_max_length": 1000000000000000019884624838656,
10
+ "pad_token": "<|pad|>",
11
+ "padding_side": "left",
12
+ "tokenizer_class": "GPT2Tokenizer",
13
+ "tool_parser_type": "json_tools",
14
+ "unk_token": "<|unk|>"
15
+ }