TrishanuDas commited on
Commit
e163944
·
verified ·
1 Parent(s): 117f3b4

Upload TinyAyaVision (SigLIP + LoRA-merged instruct)

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,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - multilingual
6
+ library_name: transformers
7
+ pipeline_tag: image-text-to-text
8
+ ---
9
+
10
+ # TayaVision — Tiny Aya Vision (Instruct)
11
+
12
+ ```python
13
+ import torch
14
+ from PIL import Image
15
+ from transformers import AutoModelForCausalLM, AutoProcessor
16
+
17
+ repo = "TrishanuDas/tayavision-alignment"
18
+
19
+ model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, trust_remote_code=True)
20
+ model = model.to("cuda").eval()
21
+
22
+ processor = AutoProcessor.from_pretrained(repo, trust_remote_code=True)
23
+
24
+ image = Image.open("your_image.jpg").convert("RGB")
25
+
26
+ messages = [
27
+ {"role": "user", "content": [
28
+ {"type": "image"},
29
+ {"type": "text", "text": "Describe this image in detail."},
30
+ ]},
31
+ ]
32
+
33
+ inputs = processor.apply_chat_template(
34
+ messages, images=image, add_generation_prompt=True, return_tensors="pt",
35
+ )
36
+ inputs = {k: v.to("cuda") for k, v in inputs.items()}
37
+
38
+ with torch.no_grad():
39
+ output_ids = model.generate(**inputs, max_new_tokens=256)
40
+
41
+ response = processor.tokenizer.decode(
42
+ output_ids[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True,
43
+ )
44
+ print(response)
45
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}{% set ns = namespace(system_prompt=false, expect_user=true) %}{% for message in messages %}{% if message['role']|lower == 'system' %}{% set ns.system_prompt = message['content'] %}{% break %}{% endif %}{% endfor %}<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble
2
+ You are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.
3
+
4
+ Your information cutoff date is June 2024.
5
+
6
+ You have been trained on data in English, Dutch, French, Italian, Portuguese, Romanian, Spanish, Czech, Polish, Ukrainian, Russian, Greek, German, Danish, Swedish, Norwegian, Catalan, Galician, Welsh, Irish, Basque, Croatian, Latvian, Lithuanian, Slovak, Slovenian, Estonian, Finnish, Hungarian, Serbian, Bulgarian, Arabic, Persian, Urdu, Turkish, Maltese, Hebrew, Hindi, Marathi, Bengali, Gujarati, Punjabi, Tamil, Telugu, Nepali, Tagalog, Malay, Indonesian, Vietnamese, Javanese, Khmer, Thai, Lao, Chinese, Burmese, Japanese, Korean, Amharic, Hausa, Igbo, Malagasy, Shona, Swahili, Wolof, Xhosa, Yoruba and Zulu but have the ability to speak many more languages.
7
+
8
+ # Default Preamble
9
+ The following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.
10
+ - Your name is Aya.
11
+ - You are a large language model built by Cohere.
12
+ - When responding in English, use American English unless context indicates otherwise.
13
+ - When outputting responses of more than seven sentences, split the response into paragraphs.
14
+ - Prefer the active voice.
15
+ - Use gender-neutral pronouns for unspecified persons.
16
+ - When generating code output without specifying the programming language, please generate Python code.{% if ns.system_prompt and ns.system_prompt != "" %}
17
+
18
+ # Developer Preamble
19
+ The following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.
20
+ {{ ns.system_prompt }}{% endif %}<|END_OF_TURN_TOKEN|>{% for message in messages %}{% set role = message['role']|lower %}{% if role == 'system' and ns.system_prompt and message['content'] == ns.system_prompt %}{% continue %}{% endif %}{% if role == 'user' %}{% if not ns.expect_user %}{{- raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") -}}{% endif %}{% set ns.expect_user = false %}{% elif role == 'assistant' or role == 'chatbot' %}{% if ns.expect_user %}{{- raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") -}}{% endif %}{% set ns.expect_user = true %}{% endif %}<|START_OF_TURN_TOKEN|>{% if role == 'user' %}<|USER_TOKEN|>{%- if message['content'] is string -%}{{ message['content'] }}{%- else -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'image') -%}<image>{%- endfor -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'text') -%}{{ item['text'] }}{%- endfor -%}{%- endif -%}{% elif role == 'assistant' or role == 'chatbot' %}<|CHATBOT_TOKEN|><|START_RESPONSE|>{%- if message['content'] is string -%}{{ message['content'] }}{%- else -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'image') -%}<image>{%- endfor -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'text') -%}{{ item['text'] }}{%- endfor -%}{%- endif -%}<|END_RESPONSE|>{% elif role == 'system' %}<|SYSTEM_TOKEN|>{%- if message['content'] is string -%}{{ message['content'] }}{%- else -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'image') -%}<image>{%- endfor -%}{%- for item in message['content'] | selectattr('type', 'equalto', 'text') -%}{{ item['text'] }}{%- endfor -%}{%- endif -%}{% endif %}<|END_OF_TURN_TOKEN|>{% endfor %}{% if add_generation_prompt %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>{% endif %}
config.json ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_text_config_obj": {
3
+ "_name_or_path": "CohereLabs/tiny-aya-global",
4
+ "_sliding_window_pattern": 4,
5
+ "architectures": [
6
+ "Cohere2ForCausalLM"
7
+ ],
8
+ "attention_bias": false,
9
+ "attention_dropout": 0.0,
10
+ "bos_token_id": 2,
11
+ "cache_implementation": "hybrid",
12
+ "chunk_size_feed_forward": 0,
13
+ "dtype": "bfloat16",
14
+ "eos_token_id": 3,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2048,
18
+ "id2label": {
19
+ "0": "LABEL_0",
20
+ "1": "LABEL_1"
21
+ },
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 11008,
24
+ "is_encoder_decoder": false,
25
+ "label2id": {
26
+ "LABEL_0": 0,
27
+ "LABEL_1": 1
28
+ },
29
+ "layer_norm_eps": 1e-05,
30
+ "layer_switch": 4,
31
+ "layer_types": [
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "full_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "full_attention",
40
+ "sliding_attention",
41
+ "sliding_attention",
42
+ "sliding_attention",
43
+ "full_attention",
44
+ "sliding_attention",
45
+ "sliding_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "sliding_attention",
50
+ "sliding_attention",
51
+ "full_attention",
52
+ "sliding_attention",
53
+ "sliding_attention",
54
+ "sliding_attention",
55
+ "full_attention",
56
+ "sliding_attention",
57
+ "sliding_attention",
58
+ "sliding_attention",
59
+ "full_attention",
60
+ "sliding_attention",
61
+ "sliding_attention",
62
+ "sliding_attention",
63
+ "full_attention",
64
+ "sliding_attention",
65
+ "sliding_attention",
66
+ "sliding_attention",
67
+ "full_attention"
68
+ ],
69
+ "logit_scale": 1.0,
70
+ "max_position_embeddings": 500000,
71
+ "model_type": "cohere2",
72
+ "num_attention_heads": 16,
73
+ "num_hidden_layers": 36,
74
+ "num_key_value_heads": 4,
75
+ "order_of_interleaved_layers": "local_attn_first",
76
+ "output_attentions": false,
77
+ "output_hidden_states": false,
78
+ "pad_token_id": 0,
79
+ "position_embedding_type": "rope_gptj",
80
+ "problem_type": null,
81
+ "return_dict": true,
82
+ "rope_parameters": {
83
+ "rope_theta": 50000,
84
+ "rope_type": "default"
85
+ },
86
+ "rotary_pct": 1.0,
87
+ "sliding_window": 4096,
88
+ "sliding_window_pattern": 4,
89
+ "tie_word_embeddings": true,
90
+ "use_cache": true,
91
+ "use_embedding_sharing": true,
92
+ "use_gated_activation": true,
93
+ "use_parallel_block": true,
94
+ "use_parallel_embedding": false,
95
+ "use_qk_norm": false,
96
+ "vocab_size": 262144
97
+ },
98
+ "adapter_layer_norm_eps": 1e-06,
99
+ "architectures": [
100
+ "TinyAyaVisionForConditionalGeneration"
101
+ ],
102
+ "cache_dir": null,
103
+ "connector_intermediate_size": 2048,
104
+ "connector_type": "pixel_shuffle",
105
+ "downsample_factor": 2,
106
+ "dtype": "bfloat16",
107
+ "image_size": 384,
108
+ "image_token": "<image>",
109
+ "image_token_id": 261010,
110
+ "in_token_limit": 1024,
111
+ "llm_hidden_size": 2048,
112
+ "llm_model_name": "CohereLabs/tiny-aya-global",
113
+ "llm_vocab_size": 262144,
114
+ "model_type": "tiny_aya_vision",
115
+ "num_llm_layers": 36,
116
+ "num_tokens_after_shuffle": 196,
117
+ "num_vision_tokens": 729,
118
+ "padded_grid_size": 28,
119
+ "patch_size": 14,
120
+ "pixel_shuffle_embed_dim": 4608,
121
+ "post_projector_rms_norm": false,
122
+ "text_config": {
123
+ "_name_or_path": "CohereLabs/tiny-aya-global",
124
+ "_sliding_window_pattern": 4,
125
+ "architectures": [
126
+ "Cohere2ForCausalLM"
127
+ ],
128
+ "attention_bias": false,
129
+ "attention_dropout": 0.0,
130
+ "bos_token_id": 2,
131
+ "cache_implementation": "hybrid",
132
+ "chunk_size_feed_forward": 0,
133
+ "dtype": "bfloat16",
134
+ "eos_token_id": 3,
135
+ "head_dim": 128,
136
+ "hidden_act": "silu",
137
+ "hidden_size": 2048,
138
+ "id2label": {
139
+ "0": "LABEL_0",
140
+ "1": "LABEL_1"
141
+ },
142
+ "initializer_range": 0.02,
143
+ "intermediate_size": 11008,
144
+ "is_encoder_decoder": false,
145
+ "label2id": {
146
+ "LABEL_0": 0,
147
+ "LABEL_1": 1
148
+ },
149
+ "layer_norm_eps": 1e-05,
150
+ "layer_switch": 4,
151
+ "layer_types": [
152
+ "sliding_attention",
153
+ "sliding_attention",
154
+ "sliding_attention",
155
+ "full_attention",
156
+ "sliding_attention",
157
+ "sliding_attention",
158
+ "sliding_attention",
159
+ "full_attention",
160
+ "sliding_attention",
161
+ "sliding_attention",
162
+ "sliding_attention",
163
+ "full_attention",
164
+ "sliding_attention",
165
+ "sliding_attention",
166
+ "sliding_attention",
167
+ "full_attention",
168
+ "sliding_attention",
169
+ "sliding_attention",
170
+ "sliding_attention",
171
+ "full_attention",
172
+ "sliding_attention",
173
+ "sliding_attention",
174
+ "sliding_attention",
175
+ "full_attention",
176
+ "sliding_attention",
177
+ "sliding_attention",
178
+ "sliding_attention",
179
+ "full_attention",
180
+ "sliding_attention",
181
+ "sliding_attention",
182
+ "sliding_attention",
183
+ "full_attention",
184
+ "sliding_attention",
185
+ "sliding_attention",
186
+ "sliding_attention",
187
+ "full_attention"
188
+ ],
189
+ "logit_scale": 1.0,
190
+ "max_position_embeddings": 500000,
191
+ "model_type": "cohere2",
192
+ "num_attention_heads": 16,
193
+ "num_hidden_layers": 36,
194
+ "num_key_value_heads": 4,
195
+ "order_of_interleaved_layers": "local_attn_first",
196
+ "output_attentions": false,
197
+ "output_hidden_states": false,
198
+ "pad_token_id": 0,
199
+ "position_embedding_type": "rope_gptj",
200
+ "problem_type": null,
201
+ "return_dict": true,
202
+ "rope_parameters": {
203
+ "rope_theta": 50000,
204
+ "rope_type": "default"
205
+ },
206
+ "rotary_pct": 1.0,
207
+ "sliding_window": 4096,
208
+ "sliding_window_pattern": 4,
209
+ "tie_word_embeddings": true,
210
+ "transformers_version": "5.5.3",
211
+ "use_cache": true,
212
+ "use_embedding_sharing": true,
213
+ "use_gated_activation": true,
214
+ "use_parallel_block": true,
215
+ "use_parallel_embedding": false,
216
+ "use_qk_norm": false,
217
+ "vocab_size": 262144
218
+ },
219
+ "tokens_per_tile": 4,
220
+ "transformers_version": "5.5.3",
221
+ "trust_remote_code": false,
222
+ "vision_encoder_type": "siglip",
223
+ "vision_feature_layer": -1,
224
+ "vision_feature_select_strategy": "full",
225
+ "vision_grid_size": 27,
226
+ "vision_hidden_size": 1152,
227
+ "vision_model_name": "google/siglip2-so400m-patch14-384",
228
+ "vision_tower_config": {
229
+ "_name_or_path": "google/siglip2-so400m-patch14-384",
230
+ "architectures": null,
231
+ "attention_dropout": 0.0,
232
+ "chunk_size_feed_forward": 0,
233
+ "dtype": "bfloat16",
234
+ "hidden_act": "gelu_pytorch_tanh",
235
+ "hidden_size": 1152,
236
+ "id2label": {
237
+ "0": "LABEL_0",
238
+ "1": "LABEL_1"
239
+ },
240
+ "image_size": 384,
241
+ "intermediate_size": 4304,
242
+ "is_encoder_decoder": false,
243
+ "label2id": {
244
+ "LABEL_0": 0,
245
+ "LABEL_1": 1
246
+ },
247
+ "layer_norm_eps": 1e-06,
248
+ "model_type": "siglip_vision_model",
249
+ "num_attention_heads": 16,
250
+ "num_channels": 3,
251
+ "num_hidden_layers": 27,
252
+ "output_attentions": false,
253
+ "output_hidden_states": false,
254
+ "patch_size": 14,
255
+ "problem_type": null,
256
+ "return_dict": true,
257
+ "transformers_version": "5.5.3"
258
+ }
259
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 2,
4
+ "eos_token_id": 3,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "5.5.3"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea96348e54f7ae31b4d20bfda408ca13413bd4b9b2269b6df694ac9f35ee5e30
3
+ size 7578108576
preprocessor_config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "data_format": "channels_first",
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.5,
8
+ 0.5,
9
+ 0.5
10
+ ],
11
+ "image_processor_type": "SiglipImageProcessorFast",
12
+ "image_std": [
13
+ 0.5,
14
+ 0.5,
15
+ 0.5
16
+ ],
17
+ "resample": 2,
18
+ "rescale_factor": 0.00392156862745098,
19
+ "size": {
20
+ "height": 384,
21
+ "width": 384
22
+ }
23
+ }
processor_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": null,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "SiglipImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 384,
22
+ "width": 384
23
+ }
24
+ },
25
+ "image_token": "<image>",
26
+ "in_token_limit": 1024,
27
+ "num_tokens_after_shuffle": 196,
28
+ "patch_chat_template": true,
29
+ "processor_class": "TinyAyaVisionProcessor",
30
+ "tokens_per_tile": 4,
31
+ "vision_encoder_type": "siglip"
32
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a31ca4d1f5b4fef7131235325cff8ae1852fc9b6f043fb5dd52d24842292033a
3
+ size 21376524
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<BOS_TOKEN>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "cls_token": "<CLS>",
7
+ "eos_token": "<|END_OF_TURN_TOKEN|>",
8
+ "errors": "replace",
9
+ "extra_special_tokens": [
10
+ "<image>"
11
+ ],
12
+ "is_local": false,
13
+ "legacy": true,
14
+ "mask_token": "<MASK_TOKEN>",
15
+ "model_max_length": 1000000000000000019884624838656,
16
+ "pad_token": "<PAD>",
17
+ "processor_class": "TinyAyaVisionProcessor",
18
+ "sep_token": "<SEP>",
19
+ "sp_model_kwargs": {},
20
+ "spaces_between_special_tokens": false,
21
+ "tokenizer_class": "CohereTokenizer",
22
+ "unk_token": "<UNK>",
23
+ "use_default_system_prompt": false
24
+ }