Update README.md
Browse files
README.md
CHANGED
@@ -12,26 +12,44 @@ Code to generate this model:
|
|
12 |
```py
|
13 |
from transformers import PaliGemmaForConditionalGeneration, PaliGemmaConfig, SiglipVisionConfig, GemmaConfig
|
14 |
|
|
|
|
|
15 |
# Initializing a Siglip-like vision config
|
16 |
vision_config = SiglipVisionConfig(
|
17 |
hidden_size=16,
|
18 |
intermediate_size=32,
|
|
|
19 |
num_hidden_layers=2,
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
)
|
22 |
|
23 |
# Initializing a PaliGemma config
|
24 |
text_config = GemmaConfig(
|
25 |
-
hidden_size=
|
26 |
-
intermediate_size=
|
27 |
-
num_hidden_layers=2,
|
28 |
num_attention_heads=4,
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
)
|
32 |
|
33 |
# Initializing a PaliGemma paligemma-3b-224 style configuration
|
34 |
-
configuration = PaliGemmaConfig(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Initializing a model from the paligemma-3b-224 style configuration
|
37 |
model = PaliGemmaForConditionalGeneration(configuration)
|
|
|
12 |
```py
|
13 |
from transformers import PaliGemmaForConditionalGeneration, PaliGemmaConfig, SiglipVisionConfig, GemmaConfig
|
14 |
|
15 |
+
shared_dim = 16
|
16 |
+
|
17 |
# Initializing a Siglip-like vision config
|
18 |
vision_config = SiglipVisionConfig(
|
19 |
hidden_size=16,
|
20 |
intermediate_size=32,
|
21 |
+
num_attention_heads=16,
|
22 |
num_hidden_layers=2,
|
23 |
+
num_image_tokens=256,
|
24 |
+
patch_size=14,
|
25 |
+
projection_dim=shared_dim,
|
26 |
+
projector_hidden_act="gelu_fast",
|
27 |
+
vision_use_head=False,
|
28 |
)
|
29 |
|
30 |
# Initializing a PaliGemma config
|
31 |
text_config = GemmaConfig(
|
32 |
+
hidden_size=shared_dim,
|
33 |
+
intermediate_size=16,
|
|
|
34 |
num_attention_heads=4,
|
35 |
+
num_hidden_layers=2,
|
36 |
+
num_image_tokens=256,
|
37 |
+
num_key_value_heads=1,
|
38 |
+
vocab_size=257216,
|
39 |
)
|
40 |
|
41 |
# Initializing a PaliGemma paligemma-3b-224 style configuration
|
42 |
+
configuration = PaliGemmaConfig(
|
43 |
+
vision_config,
|
44 |
+
text_config,
|
45 |
+
bos_token_id=2,
|
46 |
+
eos_token_id=1,
|
47 |
+
hidden_size=shared_dim,
|
48 |
+
ignore_index=-100,
|
49 |
+
image_token_index=257152,
|
50 |
+
pad_token_id=0,
|
51 |
+
projection_dim=shared_dim,
|
52 |
+
)
|
53 |
|
54 |
# Initializing a model from the paligemma-3b-224 style configuration
|
55 |
model = PaliGemmaForConditionalGeneration(configuration)
|