IlyasMoutawwakil HF Staff commited on
Commit
9f1691f
·
verified ·
1 Parent(s): 295fd01

Mirror from hf-internal-testing/tiny-random-llama4

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+ ## Conversion code
12
+
13
+ ```py
14
+ from transformers import (
15
+ AutoProcessor,
16
+ Llama4ForConditionalGeneration,
17
+ Llama4VisionConfig,
18
+ Llama4TextConfig,
19
+ Llama4Config,
20
+ )
21
+ import torch
22
+
23
+ torch.manual_seed(0)
24
+
25
+ model_id = "meta-llama/Llama-4-Scout-17B-16E-Instruct"
26
+ torch_dtype = torch.bfloat16 # or torch.float32
27
+
28
+ intermediate_size_mlp = 64
29
+ config = Llama4Config.from_pretrained(
30
+ model_id,
31
+ text_config=Llama4TextConfig.from_pretrained(
32
+ model_id,
33
+ head_dim=8,
34
+ hidden_size=16,
35
+ intermediate_size=32,
36
+ intermediate_size_mlp=intermediate_size_mlp,
37
+ moe_layers=[0,1,2,3,4],
38
+ no_rope_layers=[1,1,1,0,1],
39
+ num_attention_heads=10,
40
+ num_experts_per_tok=1,
41
+ num_hidden_layers=5,
42
+ num_key_value_heads=2,
43
+ num_local_experts=4,
44
+ ),
45
+ vision_config=Llama4VisionConfig.from_pretrained(
46
+ model_id,
47
+ hidden_size=16,
48
+ intermediate_size=intermediate_size_mlp,
49
+ num_attention_heads=4,
50
+ num_hidden_layers=2,
51
+ projector_input_dim=128,
52
+ projector_output_dim=128,
53
+ vision_output_dim=128,
54
+ ),
55
+ )
56
+
57
+ model = Llama4ForConditionalGeneration(config).to(torch_dtype)
58
+ print(model.num_parameters()) # 6571696
59
+
60
+ processor = AutoProcessor.from_pretrained(model_id)
61
+ ```
62
+
63
+
64
+ ## Model Details
65
+
66
+ ### Model Description
67
+
68
+ <!-- Provide a longer summary of what this model is. -->
69
+
70
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
71
+
72
+ - **Developed by:** [More Information Needed]
73
+ - **Funded by [optional]:** [More Information Needed]
74
+ - **Shared by [optional]:** [More Information Needed]
75
+ - **Model type:** [More Information Needed]
76
+ - **Language(s) (NLP):** [More Information Needed]
77
+ - **License:** [More Information Needed]
78
+ - **Finetuned from model [optional]:** [More Information Needed]
79
+
80
+ ### Model Sources [optional]
81
+
82
+ <!-- Provide the basic links for the model. -->
83
+
84
+ - **Repository:** [More Information Needed]
85
+ - **Paper [optional]:** [More Information Needed]
86
+ - **Demo [optional]:** [More Information Needed]
87
+
88
+ ## Uses
89
+
90
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
91
+
92
+ ### Direct Use
93
+
94
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
95
+
96
+ [More Information Needed]
97
+
98
+ ### Downstream Use [optional]
99
+
100
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
101
+
102
+ [More Information Needed]
103
+
104
+ ### Out-of-Scope Use
105
+
106
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
107
+
108
+ [More Information Needed]
109
+
110
+ ## Bias, Risks, and Limitations
111
+
112
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
113
+
114
+ [More Information Needed]
115
+
116
+ ### Recommendations
117
+
118
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
119
+
120
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
121
+
122
+ ## How to Get Started with the Model
123
+
124
+ Use the code below to get started with the model.
125
+
126
+ [More Information Needed]
127
+
128
+ ## Training Details
129
+
130
+ ### Training Data
131
+
132
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
133
+
134
+ [More Information Needed]
135
+
136
+ ### Training Procedure
137
+
138
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
139
+
140
+ #### Preprocessing [optional]
141
+
142
+ [More Information Needed]
143
+
144
+
145
+ #### Training Hyperparameters
146
+
147
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
148
+
149
+ #### Speeds, Sizes, Times [optional]
150
+
151
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
152
+
153
+ [More Information Needed]
154
+
155
+ ## Evaluation
156
+
157
+ <!-- This section describes the evaluation protocols and provides the results. -->
158
+
159
+ ### Testing Data, Factors & Metrics
160
+
161
+ #### Testing Data
162
+
163
+ <!-- This should link to a Dataset Card if possible. -->
164
+
165
+ [More Information Needed]
166
+
167
+ #### Factors
168
+
169
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
170
+
171
+ [More Information Needed]
172
+
173
+ #### Metrics
174
+
175
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
176
+
177
+ [More Information Needed]
178
+
179
+ ### Results
180
+
181
+ [More Information Needed]
182
+
183
+ #### Summary
184
+
185
+
186
+
187
+ ## Model Examination [optional]
188
+
189
+ <!-- Relevant interpretability work for the model goes here -->
190
+
191
+ [More Information Needed]
192
+
193
+ ## Environmental Impact
194
+
195
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
196
+
197
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
198
+
199
+ - **Hardware Type:** [More Information Needed]
200
+ - **Hours used:** [More Information Needed]
201
+ - **Cloud Provider:** [More Information Needed]
202
+ - **Compute Region:** [More Information Needed]
203
+ - **Carbon Emitted:** [More Information Needed]
204
+
205
+ ## Technical Specifications [optional]
206
+
207
+ ### Model Architecture and Objective
208
+
209
+ [More Information Needed]
210
+
211
+ ### Compute Infrastructure
212
+
213
+ [More Information Needed]
214
+
215
+ #### Hardware
216
+
217
+ [More Information Needed]
218
+
219
+ #### Software
220
+
221
+ [More Information Needed]
222
+
223
+ ## Citation [optional]
224
+
225
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
226
+
227
+ **BibTeX:**
228
+
229
+ [More Information Needed]
230
+
231
+ **APA:**
232
+
233
+ [More Information Needed]
234
+
235
+ ## Glossary [optional]
236
+
237
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
238
+
239
+ [More Information Needed]
240
+
241
+ ## More Information [optional]
242
+
243
+ [More Information Needed]
244
+
245
+ ## Model Card Authors [optional]
246
+
247
+ [More Information Needed]
248
+
249
+ ## Model Card Contact
250
+
251
+ [More Information Needed]
chat_template.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "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 {%- if messages[0]['content'] is string %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- else %}\n {#- FIXME: The processor requires an array, always. #}\n {%- set system_message = messages[0]['content'][0]['text']|trim %}\n {%- endif %}\n {%- set messages = messages[1:] %}\n {%- set user_supplied_system_message = true %}\n{%- else %}\n {%- set system_message = \"\" %}\n {%- set user_supplied_system_message = false %}\n{%- endif %}\n\n{#- System message if the user supplied one #}\n{%- if user_supplied_system_message %}\n {{- \"<|header_start|>system<|header_end|>\\n\\n\" }}\n {%- if tools is not none %}\n {{- \"Environment: ipython\\n\" }}\n {%- endif %}\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|>\" }}\n{%- endif %}\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 {{- '<|header_start|>user<|header_end|>\\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|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|header_start|>' + message['role'] + '<|header_end|>\\n\\n' }}\n {%- if message['content'] is string %}\n {{- message['content'] }}\n {%- else %}\n {%- for content in message['content'] %}\n {%- if content['type'] == 'image' %}\n {{- '<|image|>' }}\n {%- elif content['type'] == 'text' %}\n {{- content['text'] }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- \"<|eot|>\" }}\n {%- elif 'tool_calls' in message and message.tool_calls|length > 0 %}\n {{- '<|header_start|>assistant<|header_end|>\\n\\n' -}}\n {{- '<|python_start|>' }}\n {%- if message['content'] is string %}\n {{- message['content'] }}\n {%- else %}\n {%- for content in message['content'] %}\n {%- if content['type'] == 'image' %}\n {{- '<|image|>' }}\n {%- elif content['type'] == 'text' %}\n {{- content['text'] }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- '<|python_end|>' }}\n {%- for tool_call in message.tool_calls %}\n {{- '{\"name\": \"' + tool_call.function.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.function.arguments | tojson }}\n {{- \"}\" }}\n {%- endfor %}\n {{- \"<|eot|>\" }}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|header_start|>ipython<|header_end|>\\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|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|header_start|>assistant<|header_end|>\\n\\n' }}\n{%- endif %}\n"
3
+ }
config.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Llama4ForConditionalGeneration"
4
+ ],
5
+ "boi_token_index": 200080,
6
+ "eoi_token_index": 200081,
7
+ "image_token_index": 200092,
8
+ "model_type": "llama4",
9
+ "text_config": {
10
+ "_attn_implementation_autoset": true,
11
+ "attention_bias": false,
12
+ "attention_chunk_size": 8192,
13
+ "attention_dropout": 0.0,
14
+ "attn_scale": 0.1,
15
+ "attn_temperature_tuning": 4,
16
+ "bos_token_id": 200000,
17
+ "eos_token_id": [
18
+ 200001,
19
+ 200007,
20
+ 200008
21
+ ],
22
+ "floor_scale": 8192,
23
+ "for_llm_compressor": false,
24
+ "head_dim": 8,
25
+ "hidden_act": "silu",
26
+ "hidden_size": 16,
27
+ "initializer_range": 0.02,
28
+ "interleave_moe_layer_step": 1,
29
+ "intermediate_size": 32,
30
+ "intermediate_size_mlp": 64,
31
+ "max_position_embeddings": 10485760,
32
+ "model_type": "llama4_text",
33
+ "moe_layers": [
34
+ 0,
35
+ 1,
36
+ 2,
37
+ 3,
38
+ 4
39
+ ],
40
+ "no_rope_layers": [
41
+ 1,
42
+ 1,
43
+ 1,
44
+ 0,
45
+ 1
46
+ ],
47
+ "num_attention_heads": 10,
48
+ "num_experts_per_tok": 1,
49
+ "num_hidden_layers": 5,
50
+ "num_key_value_heads": 2,
51
+ "num_local_experts": 4,
52
+ "output_router_logits": false,
53
+ "pad_token_id": 200018,
54
+ "rms_norm_eps": 1e-05,
55
+ "rope_scaling": {
56
+ "factor": 8.0,
57
+ "high_freq_factor": 4.0,
58
+ "low_freq_factor": 1.0,
59
+ "original_max_position_embeddings": 8192,
60
+ "rope_type": "llama3"
61
+ },
62
+ "rope_theta": 500000.0,
63
+ "router_aux_loss_coef": 0.001,
64
+ "router_jitter_noise": 0.0,
65
+ "torch_dtype": "bfloat16",
66
+ "use_cache": true,
67
+ "use_qk_norm": true,
68
+ "vocab_size": 202048
69
+ },
70
+ "tie_word_embeddings": false,
71
+ "torch_dtype": "bfloat16",
72
+ "transformers_version": "4.52.0.dev0",
73
+ "vision_config": {
74
+ "_attn_implementation_autoset": true,
75
+ "attention_dropout": 0.0,
76
+ "hidden_act": "gelu",
77
+ "hidden_size": 16,
78
+ "image_size": 336,
79
+ "initializer_range": 0.02,
80
+ "intermediate_size": 64,
81
+ "model_type": "llama4_vision_model",
82
+ "multi_modal_projector_bias": false,
83
+ "norm_eps": 1e-05,
84
+ "num_attention_heads": 4,
85
+ "num_channels": 3,
86
+ "num_hidden_layers": 2,
87
+ "patch_size": 14,
88
+ "pixel_shuffle_ratio": 0.5,
89
+ "projector_dropout": 0.0,
90
+ "projector_input_dim": 128,
91
+ "projector_output_dim": 128,
92
+ "rope_theta": 10000,
93
+ "vision_feature_layer": -1,
94
+ "vision_feature_select_strategy": "default",
95
+ "vision_output_dim": 128
96
+ }
97
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 200000,
4
+ "eos_token_id": [
5
+ 200001,
6
+ 200007,
7
+ 200008
8
+ ],
9
+ "pad_token_id": 200018,
10
+ "transformers_version": "4.52.0.dev0"
11
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d3586b9b1c0ebcc17dadbc25b16fecea4b0799d6e7a0705cde7a1d49e3a3225
3
+ size 13156424
preprocessor_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "data_format": "channels_first",
4
+ "default_to_square": true,
5
+ "device": null,
6
+ "do_center_crop": null,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_rescale": true,
10
+ "do_resize": true,
11
+ "image_mean": [
12
+ 0.5,
13
+ 0.5,
14
+ 0.5
15
+ ],
16
+ "image_processor_type": "Llama4ImageProcessorFast",
17
+ "image_std": [
18
+ 0.5,
19
+ 0.5,
20
+ 0.5
21
+ ],
22
+ "input_data_format": null,
23
+ "max_patches": 16,
24
+ "processor_class": "Llama4Processor",
25
+ "resample": 2,
26
+ "rescale_factor": 0.00392156862745098,
27
+ "resize_to_max_canvas": false,
28
+ "return_tensors": null,
29
+ "size": {
30
+ "height": 336,
31
+ "width": 336
32
+ }
33
+ }
processor_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "fake_image_token": "<|image|>",
3
+ "image_token": "<|image|>",
4
+ "patch_size": 14,
5
+ "processor_class": "Llama4Processor"
6
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin_of_text|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|eot|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|finetune_right_pad_id|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:172c9eb4beafc72601690da3ccfcede5c2e6806a8d5ec1fca33e22acea8023a4
3
+ size 27948578
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff