tomaarsen HF Staff commited on
Commit
db282bf
·
verified ·
1 Parent(s): c186824

Add tiny-random PaliGemma LoRA fixture requiring key_mapping

Browse files
README.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - test-fixture
5
+ - paligemma
6
+ - colpali
7
+ - peft
8
+ - lora
9
+ ---
10
+
11
+ # tomaarsen/tiny-random-paligemma-lora-key-mapping
12
+
13
+ Tiny-random PaliGemma checkpoint bundling a LoRA adapter that **requires a `key_mapping` to load onto the
14
+ underlying `PaliGemmaModel`**.
15
+
16
+ It mirrors [`vidore/colpali`](https://huggingface.co/vidore/colpali) at tiny scale: the adapter's text weights
17
+ are stored under the old `language_model.model.layers.*` layout, so loading them onto today's
18
+ `PaliGemmaModel` (`language_model.layers.*`) needs:
19
+
20
+ ```python
21
+ from transformers import PaliGemmaModel
22
+
23
+ model = PaliGemmaModel.from_pretrained(
24
+ "tomaarsen/tiny-random-paligemma-lora-key-mapping",
25
+ key_mapping={r"language_model\.model\.": "language_model."},
26
+ )
27
+ ```
28
+
29
+ `PaliGemmaForConditionalGeneration` auto-bridges this (via the `llava` conversion) and does not need the
30
+ mapping; the bare `PaliGemmaModel` does. Every `lora_A` weight is filled with `0.0234` and every
31
+ `lora_B` weight with `0.0567`, so a test can assert the adapter was restored from the checkpoint.
32
+
33
+ Generated by `scripts/create_tiny_paligemma_lora_key_mapping_fixture.py`.
adapter_config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "PaliGemmaForConditionalGeneration",
7
+ "parent_library": "transformers.models.paligemma.modeling_paligemma"
8
+ },
9
+ "base_model_name_or_path": "tomaarsen/tiny-random-paligemma-lora-key-mapping",
10
+ "bias": "none",
11
+ "corda_config": null,
12
+ "ensure_weight_tying": false,
13
+ "eva_config": null,
14
+ "exclude_modules": null,
15
+ "fan_in_fan_out": false,
16
+ "inference_mode": true,
17
+ "init_lora_weights": false,
18
+ "layer_replication": null,
19
+ "layers_pattern": null,
20
+ "layers_to_transform": null,
21
+ "loftq_config": {},
22
+ "lora_alpha": 8,
23
+ "lora_bias": false,
24
+ "lora_dropout": 0.0,
25
+ "lora_ga_config": null,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.19.2.dev0@76c37d4686cf7245a9a6998fd1e2619d62c9322d",
31
+ "qalora_group_size": 16,
32
+ "r": 8,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": ".*language_model.*\\.(q_proj|v_proj)$",
36
+ "target_parameters": null,
37
+ "task_type": null,
38
+ "trainable_token_indices": null,
39
+ "use_bdlora": null,
40
+ "use_dora": false,
41
+ "use_qalora": false,
42
+ "use_rslora": false
43
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fce525bfd50c235ff1c11b89ede25b0c1d047e7b9d637297b16492fa0b794e43
3
+ size 7848
config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "PaliGemmaForConditionalGeneration"
4
+ ],
5
+ "dtype": "float32",
6
+ "hidden_size": 2048,
7
+ "image_token_index": 0,
8
+ "model_type": "paligemma",
9
+ "projection_dim": 32,
10
+ "text_config": {
11
+ "attention_bias": false,
12
+ "attention_dropout": 0.0,
13
+ "bos_token_id": 2,
14
+ "eos_token_id": 1,
15
+ "head_dim": 8,
16
+ "hidden_act": "gelu_pytorch_tanh",
17
+ "hidden_activation": "gelu_pytorch_tanh",
18
+ "hidden_size": 32,
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 37,
21
+ "max_position_embeddings": 512,
22
+ "model_type": "gemma",
23
+ "num_attention_heads": 4,
24
+ "num_hidden_layers": 2,
25
+ "num_image_tokens": 16,
26
+ "num_key_value_heads": 1,
27
+ "pad_token_id": 1,
28
+ "rms_norm_eps": 1e-06,
29
+ "rope_parameters": {
30
+ "rope_theta": 10000.0,
31
+ "rope_type": "default"
32
+ },
33
+ "tie_word_embeddings": true,
34
+ "use_bidirectional_attention": true,
35
+ "use_cache": true,
36
+ "vocab_size": 99
37
+ },
38
+ "tie_word_embeddings": true,
39
+ "transformers_version": "5.13.0.dev0",
40
+ "vision_config": {
41
+ "attention_dropout": 0.0,
42
+ "hidden_act": "gelu_pytorch_tanh",
43
+ "hidden_size": 32,
44
+ "image_size": 20,
45
+ "intermediate_size": 37,
46
+ "layer_norm_eps": 1e-06,
47
+ "model_type": "siglip_vision_model",
48
+ "num_attention_heads": 4,
49
+ "num_channels": 3,
50
+ "num_hidden_layers": 2,
51
+ "num_image_tokens": 4,
52
+ "num_key_value_heads": 1,
53
+ "patch_size": 5,
54
+ "projection_dim": 32
55
+ },
56
+ "vocab_size": 257152
57
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 2,
4
+ "eos_token_id": 1,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 1,
8
+ "transformers_version": "5.13.0.dev0",
9
+ "use_cache": true
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e323085a13881dd707a7d21ebc1d6ff968970c743dcea0158fec6ff292b3b36
3
+ size 167508