Upload folder using huggingface_hub
#1
by kyoui-dev - opened
- README.md +22 -10
- config.json +27 -14
- generation_config.json +4 -1
- model.safetensors +2 -2
- processor_config.json +25 -0
- tokenizer_config.json +0 -0
README.md
CHANGED
|
@@ -4,6 +4,7 @@ license: apache-2.0
|
|
| 4 |
|
| 5 |
```python
|
| 6 |
import os
|
|
|
|
| 7 |
from transformers import (
|
| 8 |
AutoConfig,
|
| 9 |
AutoModelForImageTextToText,
|
|
@@ -12,28 +13,39 @@ from transformers import (
|
|
| 12 |
)
|
| 13 |
|
| 14 |
model_id = "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
|
|
|
|
| 15 |
config = AutoConfig.from_pretrained(model_id)
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
config.text_config.num_hidden_layers = 2
|
| 18 |
-
config.text_config.hidden_size =
|
| 19 |
-
config.text_config.intermediate_size =
|
| 20 |
-
config.text_config.num_attention_heads =
|
| 21 |
-
config.text_config.num_key_value_heads =
|
| 22 |
-
config.text_config.head_dim =
|
|
|
|
| 23 |
|
| 24 |
config.vision_config.num_hidden_layers = 2
|
| 25 |
-
config.vision_config.hidden_size =
|
| 26 |
-
config.vision_config.intermediate_size =
|
| 27 |
config.vision_config.num_attention_heads = 4
|
| 28 |
-
config.vision_config.head_dim =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
model = AutoModelForImageTextToText.from_config(config)
|
| 31 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 32 |
processor = AutoProcessor.from_pretrained(model_id)
|
|
|
|
| 33 |
|
| 34 |
output_dir = "./tiny-random-mistral3"
|
| 35 |
os.makedirs(output_dir, exist_ok=True)
|
| 36 |
-
model.save_pretrained(output_dir)
|
| 37 |
tokenizer.save_pretrained(output_dir)
|
| 38 |
processor.save_pretrained(output_dir)
|
| 39 |
-
```
|
|
|
|
| 4 |
|
| 5 |
```python
|
| 6 |
import os
|
| 7 |
+
import torch
|
| 8 |
from transformers import (
|
| 9 |
AutoConfig,
|
| 10 |
AutoModelForImageTextToText,
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
model_id = "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
|
| 16 |
+
torch.manual_seed(42)
|
| 17 |
config = AutoConfig.from_pretrained(model_id)
|
| 18 |
|
| 19 |
+
config.tie_word_embeddings = False
|
| 20 |
+
config.text_config.tie_word_embeddings = False
|
| 21 |
+
|
| 22 |
config.text_config.num_hidden_layers = 2
|
| 23 |
+
config.text_config.hidden_size = 64
|
| 24 |
+
config.text_config.intermediate_size = 128
|
| 25 |
+
config.text_config.num_attention_heads = 4
|
| 26 |
+
config.text_config.num_key_value_heads = 2
|
| 27 |
+
config.text_config.head_dim = 16
|
| 28 |
+
config.text_config.max_position_embeddings = 512
|
| 29 |
|
| 30 |
config.vision_config.num_hidden_layers = 2
|
| 31 |
+
config.vision_config.hidden_size = 64
|
| 32 |
+
config.vision_config.intermediate_size = 128
|
| 33 |
config.vision_config.num_attention_heads = 4
|
| 34 |
+
config.vision_config.head_dim = 16
|
| 35 |
+
config.vision_config.image_size = 56
|
| 36 |
+
|
| 37 |
+
for subconfig in (config, config.text_config, config.vision_config):
|
| 38 |
+
subconfig.dtype = "float32"
|
| 39 |
+
subconfig.torch_dtype = "float32"
|
| 40 |
|
| 41 |
model = AutoModelForImageTextToText.from_config(config)
|
| 42 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 43 |
processor = AutoProcessor.from_pretrained(model_id)
|
| 44 |
+
processor.image_processor.size = {"longest_edge": 56}
|
| 45 |
|
| 46 |
output_dir = "./tiny-random-mistral3"
|
| 47 |
os.makedirs(output_dir, exist_ok=True)
|
| 48 |
+
model.save_pretrained(output_dir, safe_serialization=True)
|
| 49 |
tokenizer.save_pretrained(output_dir)
|
| 50 |
processor.save_pretrained(output_dir)
|
| 51 |
+
```
|
config.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"architectures": [
|
| 3 |
"Mistral3ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
-
"dtype": "
|
| 6 |
"image_token_index": 10,
|
| 7 |
"model_type": "mistral3",
|
| 8 |
"multimodal_projector_bias": false,
|
|
@@ -10,37 +10,50 @@
|
|
| 10 |
"spatial_merge_size": 2,
|
| 11 |
"text_config": {
|
| 12 |
"attention_dropout": 0.0,
|
| 13 |
-
"
|
|
|
|
|
|
|
|
|
|
| 14 |
"hidden_act": "silu",
|
| 15 |
-
"hidden_size":
|
| 16 |
"initializer_range": 0.02,
|
| 17 |
-
"intermediate_size":
|
| 18 |
-
"max_position_embeddings":
|
| 19 |
"model_type": "mistral",
|
| 20 |
-
"num_attention_heads":
|
| 21 |
"num_hidden_layers": 2,
|
| 22 |
-
"num_key_value_heads":
|
|
|
|
| 23 |
"rms_norm_eps": 1e-05,
|
| 24 |
-
"
|
|
|
|
|
|
|
|
|
|
| 25 |
"sliding_window": null,
|
|
|
|
| 26 |
"use_cache": true,
|
| 27 |
"vocab_size": 131072
|
| 28 |
},
|
| 29 |
-
"
|
|
|
|
| 30 |
"vision_config": {
|
| 31 |
"attention_dropout": 0.0,
|
| 32 |
-
"
|
|
|
|
| 33 |
"hidden_act": "silu",
|
| 34 |
-
"hidden_size":
|
| 35 |
-
"image_size":
|
| 36 |
"initializer_range": 0.02,
|
| 37 |
-
"intermediate_size":
|
| 38 |
"model_type": "pixtral",
|
| 39 |
"num_attention_heads": 4,
|
| 40 |
"num_channels": 3,
|
| 41 |
"num_hidden_layers": 2,
|
| 42 |
"patch_size": 14,
|
| 43 |
-
"
|
|
|
|
|
|
|
|
|
|
| 44 |
},
|
| 45 |
"vision_feature_layer": -1
|
| 46 |
}
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"Mistral3ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
+
"dtype": "float32",
|
| 6 |
"image_token_index": 10,
|
| 7 |
"model_type": "mistral3",
|
| 8 |
"multimodal_projector_bias": false,
|
|
|
|
| 10 |
"spatial_merge_size": 2,
|
| 11 |
"text_config": {
|
| 12 |
"attention_dropout": 0.0,
|
| 13 |
+
"bos_token_id": 1,
|
| 14 |
+
"dtype": "float32",
|
| 15 |
+
"eos_token_id": 2,
|
| 16 |
+
"head_dim": 16,
|
| 17 |
"hidden_act": "silu",
|
| 18 |
+
"hidden_size": 64,
|
| 19 |
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 128,
|
| 21 |
+
"max_position_embeddings": 512,
|
| 22 |
"model_type": "mistral",
|
| 23 |
+
"num_attention_heads": 4,
|
| 24 |
"num_hidden_layers": 2,
|
| 25 |
+
"num_key_value_heads": 2,
|
| 26 |
+
"pad_token_id": null,
|
| 27 |
"rms_norm_eps": 1e-05,
|
| 28 |
+
"rope_parameters": {
|
| 29 |
+
"rope_theta": 1000000000.0,
|
| 30 |
+
"rope_type": "default"
|
| 31 |
+
},
|
| 32 |
"sliding_window": null,
|
| 33 |
+
"tie_word_embeddings": false,
|
| 34 |
"use_cache": true,
|
| 35 |
"vocab_size": 131072
|
| 36 |
},
|
| 37 |
+
"tie_word_embeddings": false,
|
| 38 |
+
"transformers_version": "5.17.0",
|
| 39 |
"vision_config": {
|
| 40 |
"attention_dropout": 0.0,
|
| 41 |
+
"dtype": "float32",
|
| 42 |
+
"head_dim": 16,
|
| 43 |
"hidden_act": "silu",
|
| 44 |
+
"hidden_size": 64,
|
| 45 |
+
"image_size": 56,
|
| 46 |
"initializer_range": 0.02,
|
| 47 |
+
"intermediate_size": 128,
|
| 48 |
"model_type": "pixtral",
|
| 49 |
"num_attention_heads": 4,
|
| 50 |
"num_channels": 3,
|
| 51 |
"num_hidden_layers": 2,
|
| 52 |
"patch_size": 14,
|
| 53 |
+
"rope_parameters": {
|
| 54 |
+
"rope_theta": 10000.0,
|
| 55 |
+
"rope_type": "axial"
|
| 56 |
+
}
|
| 57 |
},
|
| 58 |
"vision_feature_layer": -1
|
| 59 |
}
|
generation_config.json
CHANGED
|
@@ -2,5 +2,8 @@
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
-
"
|
|
|
|
|
|
|
|
|
|
| 6 |
}
|
|
|
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
"eos_token_id": 2,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"transformers_version": "5.17.0",
|
| 8 |
+
"use_cache": true
|
| 9 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c681b8749bf9ba8ef5123b4fbcbf9997bc250d272f0be81ae55feb06b278f15
|
| 3 |
+
size 67988584
|
processor_config.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
| 1 |
{
|
| 2 |
"image_break_token": "[IMG_BREAK]",
|
| 3 |
"image_end_token": "[IMG_END]",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"image_token": "[IMG]",
|
| 5 |
"patch_size": 14,
|
| 6 |
"processor_class": "PixtralProcessor",
|
|
|
|
| 1 |
{
|
| 2 |
"image_break_token": "[IMG_BREAK]",
|
| 3 |
"image_end_token": "[IMG_END]",
|
| 4 |
+
"image_processor": {
|
| 5 |
+
"data_format": "channels_first",
|
| 6 |
+
"default_to_square": true,
|
| 7 |
+
"do_convert_rgb": true,
|
| 8 |
+
"do_normalize": true,
|
| 9 |
+
"do_rescale": true,
|
| 10 |
+
"do_resize": true,
|
| 11 |
+
"image_mean": [
|
| 12 |
+
0.48145466,
|
| 13 |
+
0.4578275,
|
| 14 |
+
0.40821073
|
| 15 |
+
],
|
| 16 |
+
"image_processor_type": "PixtralImageProcessor",
|
| 17 |
+
"image_std": [
|
| 18 |
+
0.26862954,
|
| 19 |
+
0.26130258,
|
| 20 |
+
0.27577711
|
| 21 |
+
],
|
| 22 |
+
"patch_size": 14,
|
| 23 |
+
"resample": 3,
|
| 24 |
+
"rescale_factor": 0.00392156862745098,
|
| 25 |
+
"size": {
|
| 26 |
+
"longest_edge": 56
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
"image_token": "[IMG]",
|
| 30 |
"patch_size": 14,
|
| 31 |
"processor_class": "PixtralProcessor",
|
tokenizer_config.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|