tarekziade HF Staff commited on
Commit
ffb7204
ยท
verified ยท
1 Parent(s): ad04e6b

Publish MIC usage, slim fixture and reviewed Transformers expectations

Browse files
Files changed (30) hide show
  1. .gitattributes +1 -0
  2. .mic-repo.json +7 -0
  3. README.md +37 -0
  4. added_tokens.json +3 -0
  5. build.json +148 -0
  6. config.json +46 -0
  7. config_sentence_transformers.json +26 -0
  8. generation_config.json +7 -0
  9. integration.json +88 -0
  10. integrations/transformers/expectations/cpu-x86_64-bf16/embeddinggemma-300m-mic.bfloat16.json +112 -0
  11. integrations/transformers/expectations/cpu-x86_64-bf16/embeddinggemma-300m.bfloat16.json +112 -0
  12. integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m-mic.eager.json +112 -0
  13. integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m-mic.json +112 -0
  14. integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m.eager.json +112 -0
  15. integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m.json +112 -0
  16. integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.bfloat16.json +113 -0
  17. integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.eager.json +113 -0
  18. integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.json +113 -0
  19. integrations/transformers/expectations/cuda/embeddinggemma-300m.bfloat16.json +113 -0
  20. integrations/transformers/expectations/cuda/embeddinggemma-300m.eager.json +113 -0
  21. integrations/transformers/expectations/cuda/embeddinggemma-300m.json +113 -0
  22. integrations/transformers/usage.md +91 -0
  23. model.safetensors +3 -0
  24. modules.json +32 -0
  25. notebook.ipynb +656 -0
  26. sentence_bert_config.json +4 -0
  27. special_tokens_map.json +33 -0
  28. tokenizer.json +3 -0
  29. tokenizer.model +3 -0
  30. tokenizer_config.json +0 -0
.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
.mic-repo.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "mic-umbrella-v1",
3
+ "contract_files": [
4
+ "integration.json",
5
+ "integrations/transformers/usage.md"
6
+ ]
7
+ }
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - mic
4
+ - test-artifact
5
+ base_model: google/embeddinggemma-300m
6
+ ---
7
+
8
+ # embeddinggemma-300m-mic
9
+
10
+ Slim model weights, executable usage and framework expectations in one repository.
11
+
12
+ - [Contract manifest](integration.json)
13
+ - [Transformers usage](integrations/transformers/usage.md)
14
+ - [Transformers expectations](integrations/transformers/expectations)
15
+ - [Fixture provenance](build.json)
16
+
17
+ ## Contract
18
+
19
+ ### EmbeddingGemma embedding
20
+
21
+ Runnable usage and the framework expectations directory are linked above.
22
+
23
+ ## Slim model
24
+
25
+ ### Slim fixture: embeddinggemma-300m-mic
26
+
27
+ A 16.9M-parameter fixture for the [EmbeddingGemma MIC](https://huggingface.co/huggingface-mic/embeddinggemma-300m-mic), covering [`google/embeddinggemma-300m`](https://huggingface.co/google/embeddinggemma-300m). It is a test artifact, not a usable model, tagged `test-artifact` to keep it out of candidate-model search.
28
+
29
+ - **Fixture key `cf79e3a783d5`.** It covers every checkpoint whose processor files are byte-identical and whose config matches after shrinking.
30
+ - **Same architecture, smaller config:** `Gemma3TextModel`, shrunk by the generic rule in [`sweep.py`](https://github.com/huggingface/transformers-mic/blob/main/experiments/sweep.py) (num_hidden_layers 2).
31
+ - **Processor files copied byte for byte** from `google/embeddinggemma-300m`: `added_tokens.json`, `config_sentence_transformers.json`, `generation_config.json`, `modules.json`, `notebook.ipynb`, `sentence_bert_config.json`, `special_tokens_map.json`, `tokenizer.json`, `tokenizer.model`, `tokenizer_config.json`.
32
+ - **Random weights (seed 17).** They passed the input-sensitivity gate: every perturbation of the contract's inputs moved the logits by at least 0.001 (weakest: `input_ids:reverse`, 1.62), so no training was needed.
33
+ - **Same tensor names as the real checkpoint.** The real checkpoint has every parameter, and so does the fixture.
34
+ - **Saved in float32**, the dtype `google/embeddinggemma-300m` loads in by default.
35
+ - **Finite in float32, bfloat16, and float16** (forward, loss, gradients).
36
+
37
+ Built by [`build_fixtures.py`](https://github.com/huggingface/transformers-mic/blob/main/example/build_fixtures.py); [`build.json`](build.json) records the pinned sources, gate results, and file hashes. This repository includes the slim weights, usage and framework expectations; rebuild the other files with `python example/build_fixtures.py --fixture embeddinggemma-300m-mic`.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "<image_soft_token>": 262144
3
+ }
build.json ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fixture": "huggingface-mic/embeddinggemma-300m-mic",
3
+ "key": "cf79e3a783d53651b5bb4bba2bf79a95372eb691a1bf5f217c921636acccae7e",
4
+ "key_fields": {
5
+ "architectures": [
6
+ "Gemma3TextModel"
7
+ ],
8
+ "output_hidden_states": false,
9
+ "return_dict": true,
10
+ "chunk_size_feed_forward": 0,
11
+ "is_encoder_decoder": false,
12
+ "id2label": {
13
+ "0": "LABEL_0",
14
+ "1": "LABEL_1"
15
+ },
16
+ "label2id": {
17
+ "LABEL_0": 0,
18
+ "LABEL_1": 1
19
+ },
20
+ "problem_type": null,
21
+ "vocab_size": 262144,
22
+ "hidden_size": 64,
23
+ "intermediate_size": 128,
24
+ "num_hidden_layers": 2,
25
+ "num_attention_heads": 4,
26
+ "num_key_value_heads": 2,
27
+ "head_dim": 16,
28
+ "hidden_activation": "gelu_pytorch_tanh",
29
+ "max_position_embeddings": 2048,
30
+ "initializer_range": 0.02,
31
+ "rms_norm_eps": 1e-06,
32
+ "use_cache": true,
33
+ "pad_token_id": 0,
34
+ "eos_token_id": 1,
35
+ "bos_token_id": 2,
36
+ "tie_word_embeddings": true,
37
+ "rope_parameters": {
38
+ "sliding_attention": {
39
+ "rope_type": "default",
40
+ "rope_theta": 10000.0
41
+ },
42
+ "full_attention": {
43
+ "rope_type": "default",
44
+ "rope_theta": 1000000.0
45
+ }
46
+ },
47
+ "attention_bias": false,
48
+ "attention_dropout": 0.0,
49
+ "query_pre_attn_scalar": 256,
50
+ "sliding_window": 512,
51
+ "layer_types": [
52
+ "sliding_attention",
53
+ "full_attention"
54
+ ],
55
+ "final_logit_softcapping": null,
56
+ "attn_logit_softcapping": null,
57
+ "use_bidirectional_attention": true,
58
+ "_sliding_window_pattern": 6,
59
+ "model_type": "gemma3_text",
60
+ "output_attentions": false
61
+ },
62
+ "covers": {
63
+ "google/embeddinggemma-300m": "57c266a740f537b4dc058e1b0cda161fd15afa75"
64
+ },
65
+ "built_from": {
66
+ "repo": "google/embeddinggemma-300m",
67
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75"
68
+ },
69
+ "seed": 17,
70
+ "dtype": "float32",
71
+ "builder": "example/build_fixtures.py",
72
+ "model_class": "Gemma3TextModel",
73
+ "parameters": 16851584,
74
+ "missing_parameters": [],
75
+ "checkpoint_inspection": "parameter headers/indexes; bounded binary fallback",
76
+ "numeric_health_scope": "CPU float32/bfloat16/float16; autocast for low-precision losses",
77
+ "captured": {
78
+ "call": "training step",
79
+ "inputs": [
80
+ "attention_mask",
81
+ "input_ids"
82
+ ],
83
+ "class": "Gemma3TextModel"
84
+ },
85
+ "weights": "random",
86
+ "gate": {
87
+ "random": {
88
+ "pass": true,
89
+ "accepted_insensitive": {},
90
+ "threshold": 0.001,
91
+ "deltas": {
92
+ "input_ids:roll_batch": null,
93
+ "input_ids:reverse": 1.6200441122055054,
94
+ "attention_mask:all_ones": null
95
+ },
96
+ "weakest": "input_ids:reverse",
97
+ "no_perturbation_defined": [],
98
+ "not_a_forward_parameter": []
99
+ }
100
+ },
101
+ "numeric_health": {
102
+ "float32": {
103
+ "outputs_finite": true,
104
+ "finite": true
105
+ },
106
+ "bfloat16": {
107
+ "outputs_finite": true,
108
+ "finite": true
109
+ },
110
+ "float16": {
111
+ "outputs_finite": true,
112
+ "finite": true
113
+ }
114
+ },
115
+ "copied_unchanged": [
116
+ "added_tokens.json",
117
+ "config_sentence_transformers.json",
118
+ "generation_config.json",
119
+ "modules.json",
120
+ "notebook.ipynb",
121
+ "sentence_bert_config.json",
122
+ "special_tokens_map.json",
123
+ "tokenizer.json",
124
+ "tokenizer.model",
125
+ "tokenizer_config.json"
126
+ ],
127
+ "environment": {
128
+ "python": "3.12.12",
129
+ "machine": "arm64",
130
+ "torch": "2.14.1",
131
+ "transformers": "5.22.0.dev0",
132
+ "tokenizers": "0.23.3"
133
+ },
134
+ "sha256": {
135
+ "added_tokens.json": "50b2f405ba56a26d4913fd772089992252d7f942123cc0a034d96424221ba946",
136
+ "config.json": "9752cb243706514b43c9d343eab162bb27725d4e8d4a94ff062c4147669bf0ec",
137
+ "config_sentence_transformers.json": "8eadac15526f83d8950aa8d962a7f4f6e3d678bea71689960194561f33a5f64f",
138
+ "generation_config.json": "1fb1efd221c1ca88a736d1b36cb47d754c177677e222acb3b1e5424c5d664870",
139
+ "model.safetensors": "b8e4abe3cdfb60f18caa060da8ef89756a4f2c9ea2f610b22177bc6bf3ee92b2",
140
+ "modules.json": "5b5649645fb756dad1a8e2efe7872d3bb32bc00b93c95f276dd17f474eedccdc",
141
+ "notebook.ipynb": "8ec86b999574184bd47be2bef8aa9710458f33bb54efaf216a705a8fd360517c",
142
+ "sentence_bert_config.json": "5ea26221ce733ace29a3897360e7c6ac8816b2ca0f7306657d69e594fece7325",
143
+ "special_tokens_map.json": "2f7b0adf4fb469770bb1490e3e35df87b1dc578246c5e7e6fc76ecf33213a397",
144
+ "tokenizer.json": "6852f8d561078cc0cebe70ca03c5bfdd0d60a45f9d2e0e1e4cc05b68e9ec329e",
145
+ "tokenizer.model": "1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c",
146
+ "tokenizer_config.json": "9076840490613047bc9115963ee96b7702018b0d26ba644240bf856efda93118"
147
+ }
148
+ }
config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_sliding_window_pattern": 6,
3
+ "architectures": [
4
+ "Gemma3TextModel"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "attn_logit_softcapping": null,
9
+ "bos_token_id": 2,
10
+ "dtype": "float32",
11
+ "eos_token_id": 1,
12
+ "final_logit_softcapping": null,
13
+ "head_dim": 16,
14
+ "hidden_activation": "gelu_pytorch_tanh",
15
+ "hidden_size": 64,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 128,
18
+ "layer_types": [
19
+ "sliding_attention",
20
+ "full_attention"
21
+ ],
22
+ "max_position_embeddings": 2048,
23
+ "model_type": "gemma3_text",
24
+ "num_attention_heads": 4,
25
+ "num_hidden_layers": 2,
26
+ "num_key_value_heads": 2,
27
+ "pad_token_id": 0,
28
+ "query_pre_attn_scalar": 256,
29
+ "rms_norm_eps": 1e-06,
30
+ "rope_parameters": {
31
+ "full_attention": {
32
+ "rope_theta": 1000000.0,
33
+ "rope_type": "default"
34
+ },
35
+ "sliding_attention": {
36
+ "rope_theta": 10000.0,
37
+ "rope_type": "default"
38
+ }
39
+ },
40
+ "sliding_window": 512,
41
+ "tie_word_embeddings": true,
42
+ "transformers_version": "5.22.0.dev0",
43
+ "use_bidirectional_attention": true,
44
+ "use_cache": true,
45
+ "vocab_size": 262144
46
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.1.0",
5
+ "transformers": "4.57.0.dev0",
6
+ "pytorch": "2.8.0+cu128"
7
+ },
8
+ "prompts": {
9
+ "query": "task: search result | query: ",
10
+ "document": "title: none | text: ",
11
+ "BitextMining": "task: search result | query: ",
12
+ "Clustering": "task: clustering | query: ",
13
+ "Classification": "task: classification | query: ",
14
+ "InstructionRetrieval": "task: code retrieval | query: ",
15
+ "MultilabelClassification": "task: classification | query: ",
16
+ "PairClassification": "task: sentence similarity | query: ",
17
+ "Reranking": "task: search result | query: ",
18
+ "Retrieval": "task: search result | query: ",
19
+ "Retrieval-query": "task: search result | query: ",
20
+ "Retrieval-document": "title: none | text: ",
21
+ "STS": "task: sentence similarity | query: ",
22
+ "Summarization": "task: summarization | query: "
23
+ },
24
+ "default_prompt_name": null,
25
+ "similarity_fn_name": "cosine"
26
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cache_implementation": "hybrid",
3
+ "do_sample": true,
4
+ "top_k": 64,
5
+ "top_p": 0.95,
6
+ "transformers_version": "4.57.0.dev0"
7
+ }
integration.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mic": "0.3",
3
+ "name": "EmbeddingGemma embedding",
4
+ "usage": "AutoTokenizer + AutoModel (Gemma3TextModel), batched mean-pooled embeddings, right padding",
5
+ "architecture": "Gemma3TextModel",
6
+ "checkpoints": {
7
+ "google/embeddinggemma-300m": {
8
+ "fixture": "huggingface-mic/embeddinggemma-300m-mic"
9
+ }
10
+ },
11
+ "fixtures": {
12
+ "huggingface-mic/embeddinggemma-300m-mic": {
13
+ "built_from": "google/embeddinggemma-300m",
14
+ "covers": [
15
+ "google/embeddinggemma-300m"
16
+ ],
17
+ "build": {
18
+ "seed": 17,
19
+ "model_class": "Gemma3TextModel"
20
+ }
21
+ }
22
+ },
23
+ "integrations": {
24
+ "transformers": {
25
+ "entry_point": "integrations/transformers/usage.md",
26
+ "format": "runnable-markdown",
27
+ "requires": [
28
+ "transformers>=5",
29
+ "torch"
30
+ ],
31
+ "targets": [
32
+ "fixtures",
33
+ "checkpoints"
34
+ ],
35
+ "variants": {
36
+ "default": {},
37
+ "eager": {
38
+ "attn_implementation": "eager"
39
+ },
40
+ "bfloat16": {
41
+ "dtype": "bfloat16"
42
+ }
43
+ },
44
+ "training": true,
45
+ "resources": {
46
+ "fixture": {
47
+ "memory_gb": 2,
48
+ "download_mb": 40
49
+ },
50
+ "google/embeddinggemma-300m": {
51
+ "memory_gb": 4,
52
+ "download_mb": 1200
53
+ }
54
+ }
55
+ }
56
+ },
57
+ "outputs": {
58
+ "runtime": {
59
+ "compare": "exact"
60
+ },
61
+ "query_embedding": {
62
+ "compare": "allclose",
63
+ "atol": 0.0001,
64
+ "rtol": 0.0001
65
+ },
66
+ "document_embeddings": {
67
+ "compare": "allclose",
68
+ "atol": 0.0001,
69
+ "rtol": 0.0001
70
+ },
71
+ "similarities": {
72
+ "compare": "allclose",
73
+ "atol": 0.0001,
74
+ "rtol": 0.0001
75
+ },
76
+ "training.loss": {
77
+ "compare": "allclose",
78
+ "atol": 0.0001,
79
+ "rtol": 0.0001
80
+ },
81
+ "training.gradients": {
82
+ "compare": "all_true"
83
+ },
84
+ "training.updated": {
85
+ "compare": "true"
86
+ }
87
+ }
88
+ }
integrations/transformers/expectations/cpu-x86_64-bf16/embeddinggemma-300m-mic.bfloat16.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "bfloat16",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 12.64,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64-bf16"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "bfloat16",
41
+ "attn_implementation": "sdpa"
42
+ },
43
+ "query_embedding": [
44
+ 0.04975864663720131,
45
+ 0.07667621225118637,
46
+ -0.13734187185764313,
47
+ 0.20841862261295319,
48
+ 0.01554276142269373,
49
+ 0.06426732987165451,
50
+ -0.1731334924697876,
51
+ -0.1861332803964615
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ 0.06230051442980766,
56
+ -0.008644337765872478,
57
+ -0.05066407471895218,
58
+ 0.0684361681342125,
59
+ -0.050237011164426804,
60
+ -0.01580583117902279,
61
+ 0.2114441692829132,
62
+ -0.051793817430734634
63
+ ],
64
+ [
65
+ 0.07983896881341934,
66
+ 0.1395244151353836,
67
+ 0.056635014712810516,
68
+ 0.18140846490859985,
69
+ -0.009004268795251846,
70
+ 0.1429724246263504,
71
+ 0.06380835920572281,
72
+ -0.04003307968378067
73
+ ],
74
+ [
75
+ 0.03217808157205582,
76
+ -0.1910402923822403,
77
+ -0.25420865416526794,
78
+ 0.16980411112308502,
79
+ -0.08822020888328552,
80
+ 0.17790625989437103,
81
+ -0.49647730588912964,
82
+ -0.1910402923822403
83
+ ],
84
+ [
85
+ 0.1044110655784607,
86
+ 0.1312604397535324,
87
+ 0.15343298017978668,
88
+ 0.12480869889259338,
89
+ 0.11176435649394989,
90
+ -0.048356324434280396,
91
+ 0.032950252294540405,
92
+ -0.001622948911972344
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.4272065758705139,
98
+ 0.688780665397644,
99
+ 0.5229540467262268,
100
+ 0.4388265311717987
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.04723476245999336,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cpu-x86_64-bf16/embeddinggemma-300m.bfloat16.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "bfloat16",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 10.66,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64-bf16"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "bfloat16",
41
+ "attn_implementation": "sdpa"
42
+ },
43
+ "query_embedding": [
44
+ -0.02329990267753601,
45
+ 0.017730191349983215,
46
+ -0.015453960746526718,
47
+ -0.02791048027575016,
48
+ -0.048533208668231964,
49
+ -0.03464573621749878,
50
+ -0.019969085231423378,
51
+ -0.002086083171889186
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ -0.011671621352434158,
56
+ 0.0017884662374854088,
57
+ 0.0040152124129235744,
58
+ -0.00918267760425806,
59
+ -0.01677032560110092,
60
+ -0.015729248523712158,
61
+ 0.008384117856621742,
62
+ -0.024183817207813263
63
+ ],
64
+ [
65
+ -0.03276636078953743,
66
+ 0.015365165658295155,
67
+ 0.0034669707529246807,
68
+ -0.015433508902788162,
69
+ -0.042645685374736786,
70
+ -0.016164708882570267,
71
+ -0.02237374149262905,
72
+ 0.01808006316423416
73
+ ],
74
+ [
75
+ 0.001202692394144833,
76
+ 0.0486375093460083,
77
+ -0.007147048134356737,
78
+ 0.0068815345875918865,
79
+ -0.04659099131822586,
80
+ -0.0035341214388608932,
81
+ 0.013733970932662487,
82
+ 0.018998175859451294
83
+ ],
84
+ [
85
+ 0.03559581935405731,
86
+ -0.013018195517361164,
87
+ 0.008089791052043438,
88
+ -0.01404484361410141,
89
+ -0.03023429587483406,
90
+ -0.03866712749004364,
91
+ 0.02575196512043476,
92
+ -0.022506054490804672
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.5958203077316284,
98
+ 0.8016785979270935,
99
+ 0.6942115426063538,
100
+ 0.701768159866333
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.2377796322107315,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m-mic.eager.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "eager",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 8.86,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "float32",
41
+ "attn_implementation": "eager"
42
+ },
43
+ "query_embedding": [
44
+ 0.04895991459488869,
45
+ 0.0757419541478157,
46
+ -0.13579989969730377,
47
+ 0.2084997296333313,
48
+ 0.015248225070536137,
49
+ 0.0637703388929367,
50
+ -0.17289799451828003,
51
+ -0.18548817932605743
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ 0.06276535987854004,
56
+ -0.00818958692252636,
57
+ -0.052127230912446976,
58
+ 0.06772171705961227,
59
+ -0.05004480481147766,
60
+ -0.01550104096531868,
61
+ 0.21142098307609558,
62
+ -0.05199683457612991
63
+ ],
64
+ [
65
+ 0.08008917421102524,
66
+ 0.13913531601428986,
67
+ 0.05598484352231026,
68
+ 0.18264152109622955,
69
+ -0.009675421752035618,
70
+ 0.14239740371704102,
71
+ 0.06423041969537735,
72
+ -0.040302399545907974
73
+ ],
74
+ [
75
+ 0.030902931466698647,
76
+ -0.19138385355472565,
77
+ -0.25513356924057007,
78
+ 0.16954132914543152,
79
+ -0.08723358064889908,
80
+ 0.1769617795944214,
81
+ -0.4967009425163269,
82
+ -0.19188079237937927
83
+ ],
84
+ [
85
+ 0.10486319661140442,
86
+ 0.13165351748466492,
87
+ 0.15209618210792542,
88
+ 0.12593281269073486,
89
+ 0.11173971742391586,
90
+ -0.04867382347583771,
91
+ 0.03299744799733162,
92
+ -0.0024599716998636723
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.42700549960136414,
98
+ 0.6900584697723389,
99
+ 0.5220156908035278,
100
+ 0.43939143419265747
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.04549326375126839,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m-mic.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "default",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 8.74,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "float32",
41
+ "attn_implementation": "sdpa"
42
+ },
43
+ "query_embedding": [
44
+ 0.04895992577075958,
45
+ 0.0757419541478157,
46
+ -0.13579989969730377,
47
+ 0.20849968492984772,
48
+ 0.015248232521116734,
49
+ 0.06377030909061432,
50
+ -0.17289794981479645,
51
+ -0.18548816442489624
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ 0.06276535987854004,
56
+ -0.008189584128558636,
57
+ -0.0521271750330925,
58
+ 0.06772170960903168,
59
+ -0.050044819712638855,
60
+ -0.01550102699548006,
61
+ 0.2114209681749344,
62
+ -0.051996827125549316
63
+ ],
64
+ [
65
+ 0.08008918911218643,
66
+ 0.13913530111312866,
67
+ 0.05598485469818115,
68
+ 0.18264152109622955,
69
+ -0.009675417095422745,
70
+ 0.1423974335193634,
71
+ 0.06423041969537735,
72
+ -0.04030241444706917
73
+ ],
74
+ [
75
+ 0.030902918428182602,
76
+ -0.19138383865356445,
77
+ -0.25513356924057007,
78
+ 0.1695413589477539,
79
+ -0.08723358064889908,
80
+ 0.17696179449558258,
81
+ -0.4967009723186493,
82
+ -0.19188080728054047
83
+ ],
84
+ [
85
+ 0.10486320406198502,
86
+ 0.13165351748466492,
87
+ 0.15209618210792542,
88
+ 0.12593281269073486,
89
+ 0.11173973232507706,
90
+ -0.0486738346517086,
91
+ 0.03299744427204132,
92
+ -0.0024599649477750063
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.4270055294036865,
98
+ 0.6900584697723389,
99
+ 0.5220156311988831,
100
+ 0.43939143419265747
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.04549326375126839,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m.eager.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "eager",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 10.58,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "float32",
41
+ "attn_implementation": "eager"
42
+ },
43
+ "query_embedding": [
44
+ -0.02361578308045864,
45
+ 0.017527932301163673,
46
+ -0.015706032514572144,
47
+ -0.027991868555545807,
48
+ -0.04871593415737152,
49
+ -0.03428861126303673,
50
+ -0.02059108577668667,
51
+ -0.0018244554521515965
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ -0.011662169359624386,
56
+ 0.001927302684634924,
57
+ 0.003972983453422785,
58
+ -0.00911825429648161,
59
+ -0.016588790342211723,
60
+ -0.015891125425696373,
61
+ 0.008612650446593761,
62
+ -0.024441711604595184
63
+ ],
64
+ [
65
+ -0.03200550004839897,
66
+ 0.014902050606906414,
67
+ 0.0036016113590449095,
68
+ -0.015484854578971863,
69
+ -0.04247631877660751,
70
+ -0.016066446900367737,
71
+ -0.022201456129550934,
72
+ 0.01747259870171547
73
+ ],
74
+ [
75
+ 0.0007863556384108961,
76
+ 0.0488256961107254,
77
+ -0.007232298608869314,
78
+ 0.006866308394819498,
79
+ -0.04670890048146248,
80
+ -0.0038641467690467834,
81
+ 0.013661552220582962,
82
+ 0.01932848058640957
83
+ ],
84
+ [
85
+ 0.03536593168973923,
86
+ -0.01297716610133648,
87
+ 0.008200340904295444,
88
+ -0.014375610277056694,
89
+ -0.03033606894314289,
90
+ -0.038361094892024994,
91
+ 0.025424648076295853,
92
+ -0.02255341038107872
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.5958749651908875,
98
+ 0.8016548156738281,
99
+ 0.6938391327857971,
100
+ 0.7031511068344116
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.24020807445049286,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cpu-x86_64/embeddinggemma-300m.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "default",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cpu",
15
+ "torchvision": "0.29.2+cpu",
16
+ "torchaudio": "2.11.1+cpu",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.3.5",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.15.0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 10.47,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2+cpu (pinned 0.29.1)",
32
+ "torchaudio": "2.11.1+cpu (pinned 2.11.0)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)"
34
+ },
35
+ "platform": "cpu-x86_64"
36
+ },
37
+ "outputs": {
38
+ "runtime": {
39
+ "device": "cpu",
40
+ "dtype": "float32",
41
+ "attn_implementation": "sdpa"
42
+ },
43
+ "query_embedding": [
44
+ -0.023615762591362,
45
+ 0.017527956515550613,
46
+ -0.01570606790482998,
47
+ -0.02799186110496521,
48
+ -0.048715926706790924,
49
+ -0.03428858891129494,
50
+ -0.02059105411171913,
51
+ -0.0018244773382321
52
+ ],
53
+ "document_embeddings": [
54
+ [
55
+ -0.011662133038043976,
56
+ 0.0019273078069090843,
57
+ 0.003972972743213177,
58
+ -0.009118231013417244,
59
+ -0.016588840633630753,
60
+ -0.01589113473892212,
61
+ 0.0086126197129488,
62
+ -0.02444171905517578
63
+ ],
64
+ [
65
+ -0.03200548514723778,
66
+ 0.014902114868164062,
67
+ 0.003601615782827139,
68
+ -0.015484862960875034,
69
+ -0.04247632250189781,
70
+ -0.016066426411271095,
71
+ -0.02220148965716362,
72
+ 0.017472656443715096
73
+ ],
74
+ [
75
+ 0.0007863619830459356,
76
+ 0.048825737088918686,
77
+ -0.007232354022562504,
78
+ 0.006866271607577801,
79
+ -0.046708911657333374,
80
+ -0.0038641139399260283,
81
+ 0.013661551289260387,
82
+ 0.01932849921286106
83
+ ],
84
+ [
85
+ 0.03536596521735191,
86
+ -0.012977213598787785,
87
+ 0.008200355805456638,
88
+ -0.014375594444572926,
89
+ -0.0303360428661108,
90
+ -0.038361068814992905,
91
+ 0.02542463131248951,
92
+ -0.022553423419594765
93
+ ]
94
+ ],
95
+ "similarities": [
96
+ [
97
+ 0.5958749055862427,
98
+ 0.8016547560691833,
99
+ 0.6938391923904419,
100
+ 0.7031509280204773
101
+ ]
102
+ ],
103
+ "training": {
104
+ "loss": 0.24020826816558838,
105
+ "gradients": {
106
+ "layers.0.self_attn.q_proj.weight": true,
107
+ "layers.0.mlp.up_proj.weight": true
108
+ },
109
+ "updated": true
110
+ }
111
+ }
112
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.bfloat16.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "bfloat16",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 9.46,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "bfloat16",
42
+ "attn_implementation": "sdpa"
43
+ },
44
+ "query_embedding": [
45
+ 0.049672190099954605,
46
+ 0.07620774954557419,
47
+ -0.13678710162639618,
48
+ 0.2083316445350647,
49
+ 0.015392769128084183,
50
+ 0.06444073468446732,
51
+ -0.17310799658298492,
52
+ -0.18633092939853668
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ 0.062241096049547195,
57
+ -0.008443081751465797,
58
+ -0.05069458484649658,
59
+ 0.06842505931854248,
60
+ -0.050288718193769455,
61
+ -0.015786977484822273,
62
+ 0.21124078333377838,
63
+ -0.05172906070947647
64
+ ],
65
+ [
66
+ 0.07991877943277359,
67
+ 0.13961899280548096,
68
+ 0.05677032843232155,
69
+ 0.18133898079395294,
70
+ -0.008998462930321693,
71
+ 0.14301326870918274,
72
+ 0.06392299383878708,
73
+ -0.03984079137444496
74
+ ],
75
+ [
76
+ 0.03250779211521149,
77
+ -0.19083699584007263,
78
+ -0.2541270852088928,
79
+ 0.16976873576641083,
80
+ -0.08805900067090988,
81
+ 0.17815624177455902,
82
+ -0.49642640352249146,
83
+ -0.19140565395355225
84
+ ],
85
+ [
86
+ 0.1042504608631134,
87
+ 0.1311124563217163,
88
+ 0.15331199765205383,
89
+ 0.12471741437911987,
90
+ 0.11181464046239853,
91
+ -0.04829736053943634,
92
+ 0.03316459804773331,
93
+ -0.0016612672479823232
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.42755767703056335,
99
+ 0.6886997222900391,
100
+ 0.5229560732841492,
101
+ 0.4384382963180542
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.047297071665525436,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.eager.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "eager",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 10.46,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "float32",
42
+ "attn_implementation": "eager"
43
+ },
44
+ "query_embedding": [
45
+ 0.048959892243146896,
46
+ 0.07574192434549332,
47
+ -0.13579989969730377,
48
+ 0.2084997445344925,
49
+ 0.015248244628310204,
50
+ 0.0637703388929367,
51
+ -0.17289793491363525,
52
+ -0.18548820912837982
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ 0.06276535987854004,
57
+ -0.008189555257558823,
58
+ -0.05212721973657608,
59
+ 0.06772170215845108,
60
+ -0.050044842064380646,
61
+ -0.015501046553254128,
62
+ 0.2114209681749344,
63
+ -0.05199684202671051
64
+ ],
65
+ [
66
+ 0.08008921891450882,
67
+ 0.13913530111312866,
68
+ 0.05598489195108414,
69
+ 0.18264147639274597,
70
+ -0.009675447829067707,
71
+ 0.1423974335193634,
72
+ 0.06423045694828033,
73
+ -0.04030241072177887
74
+ ],
75
+ [
76
+ 0.030902942642569542,
77
+ -0.19138383865356445,
78
+ -0.25513356924057007,
79
+ 0.1695413887500763,
80
+ -0.08723361790180206,
81
+ 0.176961749792099,
82
+ -0.4967009723186493,
83
+ -0.19188077747821808
84
+ ],
85
+ [
86
+ 0.10486321896314621,
87
+ 0.13165351748466492,
88
+ 0.1520961970090866,
89
+ 0.12593281269073486,
90
+ 0.11173968017101288,
91
+ -0.04867379739880562,
92
+ 0.03299744427204132,
93
+ -0.0024599635507911444
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.42700543999671936,
99
+ 0.6900584101676941,
100
+ 0.5220155715942383,
101
+ 0.43939143419265747
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.04549326375126839,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m-mic.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "default",
8
+ "target": "embeddinggemma-300m-mic",
9
+ "kind": "fixture",
10
+ "revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 9.7,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "float32",
42
+ "attn_implementation": "sdpa"
43
+ },
44
+ "query_embedding": [
45
+ 0.048959881067276,
46
+ 0.07574193924665451,
47
+ -0.13579989969730377,
48
+ 0.2084997296333313,
49
+ 0.015248275361955166,
50
+ 0.0637703686952591,
51
+ -0.17289794981479645,
52
+ -0.18548822402954102
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ 0.06276538968086243,
57
+ -0.008189579471945763,
58
+ -0.05212719738483429,
59
+ 0.06772173196077347,
60
+ -0.05004484951496124,
61
+ -0.015501052141189575,
62
+ 0.21142098307609558,
63
+ -0.05199683830142021
64
+ ],
65
+ [
66
+ 0.08008919656276703,
67
+ 0.13913528621196747,
68
+ 0.055984895676374435,
69
+ 0.18264149129390717,
70
+ -0.009675470180809498,
71
+ 0.1423974335193634,
72
+ 0.06423041969537735,
73
+ -0.04030243307352066
74
+ ],
75
+ [
76
+ 0.03090295009315014,
77
+ -0.19138380885124207,
78
+ -0.25513356924057007,
79
+ 0.1695413887500763,
80
+ -0.08723362535238266,
81
+ 0.176961749792099,
82
+ -0.4967009425163269,
83
+ -0.19188077747821808
84
+ ],
85
+ [
86
+ 0.10486321151256561,
87
+ 0.1316535323858261,
88
+ 0.1520962119102478,
89
+ 0.12593279778957367,
90
+ 0.11173971742391586,
91
+ -0.048673853278160095,
92
+ 0.032997459173202515,
93
+ -0.0024599621538072824
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.42700546979904175,
99
+ 0.6900584697723389,
100
+ 0.5220156908035278,
101
+ 0.4393914043903351
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.04549326375126839,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m.bfloat16.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "bfloat16",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 10.69,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "bfloat16",
42
+ "attn_implementation": "sdpa"
43
+ },
44
+ "query_embedding": [
45
+ -0.02340698055922985,
46
+ 0.017748070880770683,
47
+ -0.015666723251342773,
48
+ -0.02828904241323471,
49
+ -0.04903126507997513,
50
+ -0.034548915922641754,
51
+ -0.020223520696163177,
52
+ -0.0017388085834681988
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ -0.012059898115694523,
57
+ 0.0024110169615596533,
58
+ 0.003802679246291518,
59
+ -0.009228109382092953,
60
+ -0.016961850225925446,
61
+ -0.016271153464913368,
62
+ 0.008327508345246315,
63
+ -0.024114662781357765
64
+ ],
65
+ [
66
+ -0.032370150089263916,
67
+ 0.015151742845773697,
68
+ 0.003516141325235367,
69
+ -0.01570335030555725,
70
+ -0.042552269995212555,
71
+ -0.015960538759827614,
72
+ -0.02204011008143425,
73
+ 0.017538607120513916
74
+ ],
75
+ [
76
+ 0.00077188661089167,
77
+ 0.0487038679420948,
78
+ -0.007337762974202633,
79
+ 0.0071611241437494755,
80
+ -0.04647894948720932,
81
+ -0.0035243036691099405,
82
+ 0.013768135569989681,
83
+ 0.019158033654093742
84
+ ],
85
+ [
86
+ 0.03631485253572464,
87
+ -0.012437551282346249,
88
+ 0.008330974727869034,
89
+ -0.01416406873613596,
90
+ -0.029884980991482735,
91
+ -0.03919534385204315,
92
+ 0.025434141978621483,
93
+ -0.02255057916045189
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.5964765548706055,
99
+ 0.8019767999649048,
100
+ 0.693893551826477,
101
+ 0.7018018364906311
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.23618103563785553,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m.eager.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "eager",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 11.65,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "float32",
42
+ "attn_implementation": "eager"
43
+ },
44
+ "query_embedding": [
45
+ -0.023615796118974686,
46
+ 0.017527958378195763,
47
+ -0.01570604182779789,
48
+ -0.027991876006126404,
49
+ -0.04871594160795212,
50
+ -0.03428858146071434,
51
+ -0.02059105411171913,
52
+ -0.0018244687234982848
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ -0.011662139557301998,
57
+ 0.0019273138605058193,
58
+ 0.003972961101680994,
59
+ -0.009118223562836647,
60
+ -0.01658882573246956,
61
+ -0.015891140326857567,
62
+ 0.008612641133368015,
63
+ -0.024441702291369438
64
+ ],
65
+ [
66
+ -0.032005466520786285,
67
+ 0.014902101829648018,
68
+ 0.003601587377488613,
69
+ -0.01548482570797205,
70
+ -0.042476311326026917,
71
+ -0.016066428273916245,
72
+ -0.02220146730542183,
73
+ 0.01747262105345726
74
+ ],
75
+ [
76
+ 0.0007863486534915864,
77
+ 0.04882575199007988,
78
+ -0.007232312113046646,
79
+ 0.0068663242273032665,
80
+ -0.046708885580301285,
81
+ -0.00386414909735322,
82
+ 0.013661547563970089,
83
+ 0.01932848058640957
84
+ ],
85
+ [
86
+ 0.03536597639322281,
87
+ -0.012977219186723232,
88
+ 0.008200347423553467,
89
+ -0.014375591650605202,
90
+ -0.030336078256368637,
91
+ -0.038361117243766785,
92
+ 0.02542463317513466,
93
+ -0.022553421556949615
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.5958749055862427,
99
+ 0.8016548156738281,
100
+ 0.6938391923904419,
101
+ 0.7031512260437012
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.2402084618806839,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/expectations/cuda/embeddinggemma-300m.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "recorded_with": {
3
+ "contract": "huggingface-mic/embeddinggemma-300m-mic",
4
+ "contract_name": "EmbeddingGemma",
5
+ "contract_revision": "7bd0b979dda3ef574381f249b791b5f941b388a5",
6
+ "framework": "transformers",
7
+ "variant": "default",
8
+ "target": "embeddinggemma-300m",
9
+ "kind": "checkpoint",
10
+ "revision": "57c266a740f537b4dc058e1b0cda161fd15afa75",
11
+ "environment": {
12
+ "python": "3.11.18",
13
+ "transformers": "5.22.0.dev0",
14
+ "torch": "2.14.0+cu130",
15
+ "torchvision": "0.29.2",
16
+ "torchaudio": "2.11.0+cu130",
17
+ "tokenizers": "0.23.3",
18
+ "numpy": "2.4.6",
19
+ "pillow": "13.0.0",
20
+ "accelerate": "1.16.0.dev0",
21
+ "safetensors": "0.8.0",
22
+ "huggingface-hub": "2.3.0",
23
+ "sentencepiece": "0.2.2",
24
+ "protobuf": "7.36.2",
25
+ "librosa": "0.11.0",
26
+ "soundfile": "0.14.0",
27
+ "scipy": "1.17.1"
28
+ },
29
+ "seconds": 11.43,
30
+ "environment_differs": {
31
+ "torchvision": "0.29.2 (pinned 0.29.1)",
32
+ "numpy": "2.4.6 (pinned 2.3.5)",
33
+ "pillow": "13.0.0 (pinned 12.3.0)",
34
+ "accelerate": "1.16.0.dev0 (pinned 1.15.0)"
35
+ },
36
+ "platform": "cuda"
37
+ },
38
+ "outputs": {
39
+ "runtime": {
40
+ "device": "cuda",
41
+ "dtype": "float32",
42
+ "attn_implementation": "sdpa"
43
+ },
44
+ "query_embedding": [
45
+ -0.02361583523452282,
46
+ 0.017527947202324867,
47
+ -0.015706054866313934,
48
+ -0.027991868555545807,
49
+ -0.04871596023440361,
50
+ -0.03428858146071434,
51
+ -0.020591087639331818,
52
+ -0.0018244804814457893
53
+ ],
54
+ "document_embeddings": [
55
+ [
56
+ -0.011662168428301811,
57
+ 0.0019273071084171534,
58
+ 0.003972963429987431,
59
+ -0.009118226356804371,
60
+ -0.01658882200717926,
61
+ -0.015891144052147865,
62
+ 0.008612625300884247,
63
+ -0.024441704154014587
64
+ ],
65
+ [
66
+ -0.03200544789433479,
67
+ 0.014902140945196152,
68
+ 0.0036015785299241543,
69
+ -0.01548487413674593,
70
+ -0.042476341128349304,
71
+ -0.01606644317507744,
72
+ -0.0222015418112278,
73
+ 0.01747262291610241
74
+ ],
75
+ [
76
+ 0.0007863460923545063,
77
+ 0.04882573336362839,
78
+ -0.007232347968965769,
79
+ 0.006866332609206438,
80
+ -0.046708863228559494,
81
+ -0.003864126279950142,
82
+ 0.013661542907357216,
83
+ 0.019328471273183823
84
+ ],
85
+ [
86
+ 0.03536595404148102,
87
+ -0.0129772387444973,
88
+ 0.00820035021752119,
89
+ -0.014375596307218075,
90
+ -0.030336065217852592,
91
+ -0.03836105763912201,
92
+ 0.025424620136618614,
93
+ -0.022553393617272377
94
+ ]
95
+ ],
96
+ "similarities": [
97
+ [
98
+ 0.5958747267723083,
99
+ 0.8016548156738281,
100
+ 0.6938391923904419,
101
+ 0.7031512260437012
102
+ ]
103
+ ],
104
+ "training": {
105
+ "loss": 0.24020835757255554,
106
+ "gradients": {
107
+ "layers.0.self_attn.q_proj.weight": true,
108
+ "layers.0.mlp.up_proj.weight": true
109
+ },
110
+ "updated": true
111
+ }
112
+ }
113
+ }
integrations/transformers/usage.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EmbeddingGemma: sentence embeddings with Transformers
2
+
3
+ This page is the Transformers contract of the EmbeddingGemma MIC and also a usage example. [doc-builder](https://github.com/huggingface/doc-builder/blob/main/docs/runnable-code-blocks.md) renders the `runnable` blocks below as documentation, and its pytest plugin runs them as written against `google/embeddinggemma-300m`. The MIC runner runs the same blocks against the slim fixture and the checkpoint in [`integration.json`](../../integration.json). Lines marked `# doc-builder: hide` only matter there: they swap in the pinned checkpoint or variant and print the result record.
4
+
5
+ ## Embed queries and documents
6
+
7
+ ```py runnable:embed
8
+ import torch
9
+ from transformers import AutoModel, AutoTokenizer, set_seed
10
+ import json # doc-builder: hide
11
+ import os # doc-builder: hide
12
+
13
+ model_id = "google/embeddinggemma-300m"
14
+ model_id = os.environ.get("MIC_MODEL", model_id) # doc-builder: hide
15
+ variant = json.loads(os.environ.get("MIC_MODEL_KWARGS", "{}")) # doc-builder: hide
16
+ device = "cuda" if torch.cuda.is_available() else "cpu"
17
+ set_seed(0) # seeds torch, NumPy, and Python: loading and dropout draw random numbers
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
20
+ model = AutoModel.from_pretrained(model_id).to(device)
21
+ if variant: # doc-builder: hide
22
+ del model # doc-builder: hide
23
+ model = AutoModel.from_pretrained(model_id, **variant).to(device) # doc-builder: hide
24
+ model.eval()
25
+
26
+ query = "Which planet is known as the Red Planet?"
27
+ documents = [
28
+ "Venus is often called Earth's twin because of its similar size and proximity.",
29
+ "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
30
+ "Jupiter, the largest planet in our solar system, has a prominent red spot.",
31
+ "Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
32
+ ]
33
+
34
+ # EmbeddingGemma uses a prompt prefix for queries; documents are embedded as-is.
35
+ query_inputs = tokenizer(["task: search result | query: " + query], return_tensors="pt", padding=True).to(device)
36
+ doc_inputs = tokenizer(documents, return_tensors="pt", padding=True).to(device)
37
+
38
+ def mean_pool(outputs, attention_mask):
39
+ hidden = outputs.last_hidden_state.float()
40
+ mask = attention_mask.unsqueeze(-1).float()
41
+ return (hidden * mask).sum(dim=1) / mask.sum(dim=1)
42
+
43
+ with torch.no_grad():
44
+ query_embedding = mean_pool(model(**query_inputs), query_inputs["attention_mask"])
45
+ document_embeddings = mean_pool(model(**doc_inputs), doc_inputs["attention_mask"])
46
+
47
+ query_embedding = torch.nn.functional.normalize(query_embedding, dim=-1)
48
+ document_embeddings = torch.nn.functional.normalize(document_embeddings, dim=-1)
49
+ similarities = query_embedding @ document_embeddings.T
50
+ print(query_embedding.shape, document_embeddings.shape)
51
+ print(similarities)
52
+ ```
53
+
54
+ ## One training step
55
+
56
+ ```py runnable:embed:2
57
+ # A contrastive-style loss: pull the matching planet (index 1) towards the query.
58
+ # Recompute the embeddings with gradients: the inference ones ran under no_grad.
59
+ model.train()
60
+ query = torch.nn.functional.normalize(mean_pool(model(**query_inputs), query_inputs["attention_mask"]), dim=-1)
61
+ docs = torch.nn.functional.normalize(mean_pool(model(**doc_inputs), doc_inputs["attention_mask"]), dim=-1)
62
+ target = torch.tensor([1], device=device)
63
+ loss = torch.nn.functional.cross_entropy(query @ docs.T / 0.05, target)
64
+
65
+ optimizer = torch.optim.SGD(model.parameters(), lr=1e-4)
66
+ optimizer.zero_grad()
67
+ loss.backward()
68
+ before = {n: p.detach().cpu().clone() for n, p in model.named_parameters() if p.requires_grad} # doc-builder: hide
69
+ optimizer.step()
70
+ print(f"loss: {loss.item():.4f}")
71
+
72
+ if os.environ.get("MIC_RUNNER"): # doc-builder: hide
73
+ named = dict(model.named_parameters()) # doc-builder: hide
74
+ checked = ("layers.0.self_attn.q_proj.weight", "layers.0.mlp.up_proj.weight") # doc-builder: hide
75
+ result = { # doc-builder: hide
76
+ "runtime": { # doc-builder: hide
77
+ "device": model.device.type, # doc-builder: hide
78
+ "dtype": str(model.dtype).removeprefix("torch."), # doc-builder: hide
79
+ "attn_implementation": model.config._attn_implementation, # doc-builder: hide
80
+ }, # doc-builder: hide
81
+ "query_embedding": query_embedding[0, :8].tolist(), # doc-builder: hide
82
+ "document_embeddings": document_embeddings[:, :8].tolist(), # doc-builder: hide
83
+ "similarities": similarities.tolist(), # doc-builder: hide
84
+ "training": { # doc-builder: hide
85
+ "loss": loss.item(), # doc-builder: hide
86
+ "gradients": {n: bool(named[n].grad is not None and torch.count_nonzero(named[n].grad) > 0 and torch.isfinite(named[n].grad).all()) for n in checked}, # doc-builder: hide
87
+ "updated": any(not torch.equal(p.detach().cpu(), before[n]) for n, p in model.named_parameters() if n in before), # doc-builder: hide
88
+ }, # doc-builder: hide
89
+ } # doc-builder: hide
90
+ print(json.dumps(result)) # doc-builder: hide
91
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8e4abe3cdfb60f18caa060da8ef89756a4f2c9ea2f610b22177bc6bf3ee92b2
3
+ size 67409192
modules.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Dense",
18
+ "type": "sentence_transformers.models.Dense"
19
+ },
20
+ {
21
+ "idx": 3,
22
+ "name": "3",
23
+ "path": "3_Dense",
24
+ "type": "sentence_transformers.models.Dense"
25
+ },
26
+ {
27
+ "idx": 4,
28
+ "name": "4",
29
+ "path": "4_Normalize",
30
+ "type": "sentence_transformers.models.Normalize"
31
+ }
32
+ ]
notebook.ipynb ADDED
@@ -0,0 +1,656 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "-u7xRR3DeFXz"
7
+ },
8
+ "source": [
9
+ "##### Copyright 2025 Google LLC."
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {
16
+ "cellView": "form",
17
+ "id": "oed1Dh9SeIlD"
18
+ },
19
+ "outputs": [],
20
+ "source": [
21
+ "#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
22
+ "# you may not use this file except in compliance with the License.\n",
23
+ "# You may obtain a copy of the License at\n",
24
+ "#\n",
25
+ "# https://www.apache.org/licenses/LICENSE-2.0\n",
26
+ "#\n",
27
+ "# Unless required by applicable law or agreed to in writing, software\n",
28
+ "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
29
+ "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
30
+ "# See the License for the specific language governing permissions and\n",
31
+ "# limitations under the License."
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "markdown",
36
+ "metadata": {
37
+ "id": "UpJl85mfqdUB"
38
+ },
39
+ "source": [
40
+ "<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
41
+ " <td>\n",
42
+ " <a target=\"_blank\" href=\"https://ai.google.dev/gemma/docs/embeddinggemma/inference-embeddinggemma-with-sentence-transformers\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n",
43
+ " </td>\n",
44
+ " <td>\n",
45
+ " <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemma/docs/embeddinggemma/inference-embeddinggemma-with-sentence-transformers.ipynb\"\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
46
+ " </td>\n",
47
+ " <td>\n",
48
+ " <a target=\"_blank\" href=\"https://kaggle.com/kernels/welcome?src=https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/embeddinggemma/inference-embeddinggemma-with-sentence-transformers.ipynb\"><img src=\"https://www.kaggle.com/static/images/logos/kaggle-logo-transparent-300.png\" height=\"32\" width=\"70\"/>Run in Kaggle</a>\n",
49
+ " </td>\n",
50
+ " <td>\n",
51
+ " <a target=\"_blank\" href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/google/generative-ai-docs/main/site/en/gemma/docs/embeddinggemma/inference-embeddinggemma-with-sentence-transformers.ipynb\"><img src=\"https://ai.google.dev/images/cloud-icon.svg\" width=\"40\" />Open in Vertex AI</a>\n",
52
+ " </td>\n",
53
+ " <td>\n",
54
+ " <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemma/docs/embeddinggemma/inference-embeddinggemma-with-sentence-transformers.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
55
+ " </td>\n",
56
+ "</table>"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "markdown",
61
+ "metadata": {
62
+ "id": "Sq3lJyEiqqD-"
63
+ },
64
+ "source": [
65
+ "# Generate Embeddings with Sentence Transformers\n",
66
+ "\n",
67
+ "EmbeddingGemma is a lightweight, open embedding model designed for fast, high-quality retrieval on everyday devices like mobile phones. At only 308 million parameters, it's efficient enough to run advanced AI techniques, such as Retrieval Augmented Generation (RAG), directly on your local machine with no internet connection required.\n",
68
+ "\n",
69
+ "## Setup\n",
70
+ "\n",
71
+ "Before starting this tutorial, complete the following steps:\n",
72
+ "\n",
73
+ "* Get access to Gemma by logging into [Hugging Face](https://huggingface.co/google/embeddinggemma-300M) and selecting **Acknowledge license** for a Gemma model.\n",
74
+ "* Generate a Hugging Face [Access Token](https://huggingface.co/docs/hub/en/security-tokens#how-to-manage-user-access-token) and use it to login from Colab.\n",
75
+ "\n",
76
+ "This notebook will run on either CPU or GPU."
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "markdown",
81
+ "metadata": {
82
+ "id": "R3TOEqprq-X3"
83
+ },
84
+ "source": [
85
+ "### Install Python packages\n",
86
+ "\n",
87
+ "Install the libraries required for running the EmbeddingGemma model and generating embeddings. Sentence Transformers is a Python framework for text and image embeddings. For more information, see the [Sentence Transformers](https://www.sbert.net/) documentation."
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": null,
93
+ "metadata": {
94
+ "id": "jZFuhT3nrHEK"
95
+ },
96
+ "outputs": [],
97
+ "source": [
98
+ "!pip install -U sentence-transformers git+https://github.com/huggingface/transformers@v4.56.0-Embedding-Gemma-preview"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "markdown",
103
+ "metadata": {
104
+ "id": "O3ttIyfSA0Lj"
105
+ },
106
+ "source": [
107
+ "After you have accepted the license, you need a valid Hugging Face Token to access the model."
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "code",
112
+ "execution_count": null,
113
+ "metadata": {
114
+ "id": "WXK1Ev1Sq2iY"
115
+ },
116
+ "outputs": [],
117
+ "source": [
118
+ "# Login into Hugging Face Hub\n",
119
+ "from huggingface_hub import login\n",
120
+ "login()"
121
+ ]
122
+ },
123
+ {
124
+ "cell_type": "markdown",
125
+ "metadata": {
126
+ "id": "NUydcaDBrXDi"
127
+ },
128
+ "source": [
129
+ "### Load Model\n",
130
+ "\n",
131
+ "Use the `sentence-transformers` libraries to create an instance of a model class with EmbeddingGemma."
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": null,
137
+ "metadata": {
138
+ "id": "mkpmqlU_rcOd",
139
+ "outputId": "f8458e59-9a6e-4a89-af83-ffdf391c323a"
140
+ },
141
+ "outputs": [
142
+ {
143
+ "name": "stdout",
144
+ "output_type": "stream",
145
+ "text": [
146
+ "Device: cuda:0\n",
147
+ "SentenceTransformer(\n",
148
+ " (0): Transformer({'max_seq_length': 2048, 'do_lower_case': False, 'architecture': 'Gemma3TextModel'})\n",
149
+ " (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})\n",
150
+ " (2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})\n",
151
+ " (3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})\n",
152
+ " (4): Normalize()\n",
153
+ ")\n",
154
+ "Total number of parameters in the model: 307581696\n"
155
+ ]
156
+ }
157
+ ],
158
+ "source": [
159
+ "import torch\n",
160
+ "from sentence_transformers import SentenceTransformer\n",
161
+ "\n",
162
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
163
+ "\n",
164
+ "model_id = \"google/embeddinggemma-300M\"\n",
165
+ "model = SentenceTransformer(model_id).to(device=device)\n",
166
+ "\n",
167
+ "print(f\"Device: {model.device}\")\n",
168
+ "print(model)\n",
169
+ "print(\"Total number of parameters in the model:\", sum([p.numel() for _, p in model.named_parameters()]))"
170
+ ]
171
+ },
172
+ {
173
+ "cell_type": "markdown",
174
+ "metadata": {
175
+ "id": "JxrZ8na0A7Hv"
176
+ },
177
+ "source": [
178
+ "## Generating Embedding\n",
179
+ "\n",
180
+ "An embedding is a numerical representation of text, like a word or sentence, that captures its semantic meaning. Essentially, it's a list of numbers (a vector) that allows computers to understand the relationships and context of words.\n",
181
+ "\n",
182
+ "Let's see how EmbeddingGemma would process three different words `[\"apple\", \"banana\", \"car\"]`.\n",
183
+ "\n",
184
+ "EmbeddingGemma has been trained on vast amounts of text and has learned the relationships between words and concepts."
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "code",
189
+ "execution_count": null,
190
+ "metadata": {
191
+ "id": "o0UK8UVAA9b7",
192
+ "outputId": "37c91847-57de-4a47-9c1a-0adffacd1867"
193
+ },
194
+ "outputs": [
195
+ {
196
+ "name": "stdout",
197
+ "output_type": "stream",
198
+ "text": [
199
+ "[[-0.18476306 0.00167681 0.03773484 ... -0.07996225 -0.02348064\n",
200
+ " 0.00976741]\n",
201
+ " [-0.21189538 -0.02657359 0.02513712 ... -0.08042689 -0.01999852\n",
202
+ " 0.00512146]\n",
203
+ " [-0.18924113 -0.02551468 0.04486253 ... -0.06377774 -0.03699806\n",
204
+ " 0.03973572]]\n",
205
+ "Embedding 1: (768,)\n",
206
+ "Embedding 2: (768,)\n",
207
+ "Embedding 3: (768,)\n"
208
+ ]
209
+ }
210
+ ],
211
+ "source": [
212
+ "words = [\"apple\", \"banana\", \"car\"]\n",
213
+ "\n",
214
+ "# Calculate embeddings by calling model.encode()\n",
215
+ "embeddings = model.encode(words)\n",
216
+ "\n",
217
+ "print(embeddings)\n",
218
+ "for idx, embedding in enumerate(embeddings):\n",
219
+ " print(f\"Embedding {idx+1} (shape): {embedding.shape}\")"
220
+ ]
221
+ },
222
+ {
223
+ "cell_type": "markdown",
224
+ "metadata": {
225
+ "id": "inuWOAuMBAR7"
226
+ },
227
+ "source": [
228
+ "The model outpus a numerical vector for each sentence. The actual vectors are very long (768), but for simplicity, those are presented with a few dimensions.\n",
229
+ "\n",
230
+ "The key isn't the individual numbers themselves, but **the distance between the vectors**. If we were to plot these vectors in a multi-dimensional space, The vectors for `apple` and `banana` would be very close to each other. And the vector for `car` would be far away from the other two."
231
+ ]
232
+ },
233
+ {
234
+ "cell_type": "markdown",
235
+ "metadata": {
236
+ "id": "2oCpMMJUr4RT"
237
+ },
238
+ "source": [
239
+ "## Determining Similarity\n",
240
+ "\n",
241
+ "In this section, we use embeddings to determine how sementically similar different sentences are. Here we show examples with high, medieum, and low similarity scores.\n",
242
+ "\n",
243
+ "- High Similarity:\n",
244
+ " - Sentence A: \"The chef prepared a delicious meal for the guests.\"\n",
245
+ " - Sentence B: \"A tasty dinner was cooked by the chef for the visitors.\"\n",
246
+ " - Reasoning: Both sentences describe the same event using different words and grammatical structures (active vs. passive voice). They convey the same core meaning.\n",
247
+ "\n",
248
+ "- Medium Similarity:\n",
249
+ " - Sentence A: \"She is an expert in machine learning.\"\n",
250
+ " - Sentence B: \"He has a deep interest in artificial intelligence.\"\n",
251
+ " - Reasoning: The sentences are related as machine learning is a subfield of artificial intelligence. However, they talk about different people with different levels of engagement (expert vs. interest).\n",
252
+ "\n",
253
+ "- Low Similarity:\n",
254
+ " - Sentence A: \"The weather in Tokyo is sunny today.\"\n",
255
+ " - Sentence B: \"I need to buy groceries for the week.\"\n",
256
+ " - Reasoning: The two sentences are on completely unrelated topics and share no semantic overlap."
257
+ ]
258
+ },
259
+ {
260
+ "cell_type": "code",
261
+ "execution_count": null,
262
+ "metadata": {
263
+ "id": "VeTEvnTyslyq",
264
+ "outputId": "b387529f-aad8-4150-e4f1-daef4f30cfc0"
265
+ },
266
+ "outputs": [
267
+ {
268
+ "name": "stdout",
269
+ "output_type": "stream",
270
+ "text": [
271
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
272
+ "['The chef prepared a delicious meal for the guests.', 'A tasty dinner was cooked by the chef for the visitors.']\n",
273
+ "`-> ๐Ÿค– score: 0.8002148\n",
274
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
275
+ "['She is an expert in machine learning.', 'He has a deep interest in artificial intelligence.']\n",
276
+ "`-> ๐Ÿค– score: 0.45417833\n",
277
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
278
+ "['The weather in Tokyo is sunny today.', 'I need to buy groceries for the week.']\n",
279
+ "`-> ๐Ÿค– score: 0.22262995\n"
280
+ ]
281
+ }
282
+ ],
283
+ "source": [
284
+ "# The sentences to encode\n",
285
+ "sentence_high = [\n",
286
+ " \"The chef prepared a delicious meal for the guests.\",\n",
287
+ " \"A tasty dinner was cooked by the chef for the visitors.\"\n",
288
+ "]\n",
289
+ "sentence_medium = [\n",
290
+ " \"She is an expert in machine learning.\",\n",
291
+ " \"He has a deep interest in artificial intelligence.\"\n",
292
+ "]\n",
293
+ "sentence_low = [\n",
294
+ " \"The weather in Tokyo is sunny today.\",\n",
295
+ " \"I need to buy groceries for the week.\"\n",
296
+ "]\n",
297
+ "\n",
298
+ "for sentence in [sentence_high, sentence_medium, sentence_low]:\n",
299
+ " print(\"๐Ÿ™‹โ€โ™‚๏ธ\")\n",
300
+ " print(sentence)\n",
301
+ " embeddings = model.encode(sentence)\n",
302
+ " similarities = model.similarity(embeddings[0], embeddings[1])\n",
303
+ " print(\"`-> ๐Ÿค– score: \", similarities.numpy()[0][0])"
304
+ ]
305
+ },
306
+ {
307
+ "cell_type": "markdown",
308
+ "metadata": {
309
+ "id": "obfUiizULZE0"
310
+ },
311
+ "source": [
312
+ "### Using Prompts with EmbeddingGemma\n",
313
+ "\n",
314
+ "To generate the best embeddings with EmbeddingGemma, you should add an \"instructional prompt\" or \"task\" to the beginning of your input text. These prompts optimize the embeddings for specific tasks, such as document retrieval or question answering, and help the model distinguish between different input types, like a search query versus a document.\n",
315
+ "\n",
316
+ "#### How to Apply Prompts\n",
317
+ "\n",
318
+ "You can apply a prompt during inference in three ways.\n",
319
+ "\n",
320
+ "1. **Using the `prompt` argument**<br>\n",
321
+ " Pass the full prompt string directly to the `encode` method. This gives you precise control.\n",
322
+ " ```python\n",
323
+ " embeddings = model.encode(\n",
324
+ " sentence,\n",
325
+ " prompt=\"task: sentence similarity | query: \"\n",
326
+ " )\n",
327
+ " ```\n",
328
+ "2. **Using the `prompt_name` argument**<br>\n",
329
+ " Select a predefined prompt by its name. These prompts are loaded from the model's configuration or during its initialization.\n",
330
+ " ```python\n",
331
+ " embeddings = model.encode(sentence, prompt_name=\"STS\")\n",
332
+ " ```\n",
333
+ "3. **Using the Default Prompt**<br>\n",
334
+ " If you don't specify either `prompt` or `prompt_name`, the system will automatically use the prompt set as `default_prompt_name`, if no default is set, then no prompt is applied.\n",
335
+ " ```python\n",
336
+ " embeddings = model.encode(sentence)\n",
337
+ " ```\n"
338
+ ]
339
+ },
340
+ {
341
+ "cell_type": "code",
342
+ "execution_count": null,
343
+ "metadata": {
344
+ "id": "0p3qe3WDJV-I",
345
+ "outputId": "5fa2638e-e67b-479b-fba4-ca89a22cd10e"
346
+ },
347
+ "outputs": [
348
+ {
349
+ "name": "stdout",
350
+ "output_type": "stream",
351
+ "text": [
352
+ "Available tasks:\n",
353
+ " query: \"task: search result | query: \"\n",
354
+ " document: \"title: none | text: \"\n",
355
+ " BitextMining: \"task: search result | query: \"\n",
356
+ " Clustering: \"task: clustering | query: \"\n",
357
+ " Classification: \"task: classification | query: \"\n",
358
+ " InstructionRetrieval: \"task: code retrieval | query: \"\n",
359
+ " MultilabelClassification: \"task: classification | query: \"\n",
360
+ " PairClassification: \"task: sentence similarity | query: \"\n",
361
+ " Reranking: \"task: search result | query: \"\n",
362
+ " Retrieval: \"task: search result | query: \"\n",
363
+ " Retrieval-query: \"task: search result | query: \"\n",
364
+ " Retrieval-document: \"title: none | text: \"\n",
365
+ " STS: \"task: sentence similarity | query: \"\n",
366
+ " Summarization: \"task: summarization | query: \"\n",
367
+ "--------------------------------------------------------------------------------\n",
368
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
369
+ "['The chef prepared a delicious meal for the guests.', 'A tasty dinner was cooked by the chef for the visitors.']\n",
370
+ "`-> ๐Ÿค– score: 0.9363755\n",
371
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
372
+ "['She is an expert in machine learning.', 'He has a deep interest in artificial intelligence.']\n",
373
+ "`-> ๐Ÿค– score: 0.6425841\n",
374
+ "๐Ÿ™‹โ€โ™‚๏ธ\n",
375
+ "['The weather in Tokyo is sunny today.', 'I need to buy groceries for the week.']\n",
376
+ "`-> ๐Ÿค– score: 0.38587403\n"
377
+ ]
378
+ }
379
+ ],
380
+ "source": [
381
+ "print(\"Available tasks:\")\n",
382
+ "for name, prefix in model.prompts.items():\n",
383
+ " print(f\" {name}: \\\"{prefix}\\\"\")\n",
384
+ "print(\"-\"*80)\n",
385
+ "\n",
386
+ "for sentence in [sentence_high, sentence_medium, sentence_low]:\n",
387
+ " print(\"๐Ÿ™‹โ€โ™‚๏ธ\")\n",
388
+ " print(sentence)\n",
389
+ " embeddings = model.encode(sentence, prompt_name=\"STS\")\n",
390
+ " similarities = model.similarity(embeddings[0], embeddings[1])\n",
391
+ " print(\"`-> ๐Ÿค– score: \", similarities.numpy()[0][0])\n"
392
+ ]
393
+ },
394
+ {
395
+ "cell_type": "markdown",
396
+ "metadata": {
397
+ "id": "2YAqPXDctw2w"
398
+ },
399
+ "source": [
400
+ "#### Use Case: Retrieval-Augmented Generation (RAG)\n",
401
+ "\n",
402
+ "For RAG systems, use the following `prompt_name` values to create specialized embeddings for your queries and documents:\n",
403
+ "\n",
404
+ "* **For Queries:** Use `prompt_name=\"Retrieval-query\"`.<br>\n",
405
+ " ```python\n",
406
+ " query_embedding = model.encode(\n",
407
+ " \"How do I use prompts with this model?\",\n",
408
+ " prompt_name=\"Retrieval-query\"\n",
409
+ " )\n",
410
+ " ```\n",
411
+ "\n",
412
+ "* **For Documents:** Use `prompt_name=\"Retrieval-document\"`. To further improve document embeddings, you can also include a title by using the `prompt` argument directly:<br>\n",
413
+ " * **With a title:**<br>\n",
414
+ " ```python\n",
415
+ " doc_embedding = model.encode(\n",
416
+ " \"The document text...\",\n",
417
+ " prompt=\"title: Using Prompts in RAG | text: \"\n",
418
+ " )\n",
419
+ " ```\n",
420
+ " * **Without a title:**<br>\n",
421
+ " ```python\n",
422
+ " doc_embedding = model.encode(\n",
423
+ " \"The document text...\",\n",
424
+ " prompt=\"title: none | text: \"\n",
425
+ " )\n",
426
+ " ```\n",
427
+ "\n",
428
+ "#### Further Reading\n",
429
+ "\n",
430
+ "* For details on all available EmbeddingGemma prompts, see the [model card](http://ai.google.dev/gemma/docs/embeddinggemma/model_card#prompt_instructions).\n",
431
+ "* For general information on prompt templates, see the [Sentence Transformer documentation](https://sbert.net/examples/sentence_transformer/applications/computing-embeddings/README.html#prompt-templates).\n",
432
+ "* For a demo of RAG, see the [Simple RAG example](https://github.com/google-gemini/gemma-cookbook/blob/main/Gemma/%5BGemma_3%5DRAG_with_EmbeddingGemma.ipynb) in the Gemma Cookbook.\n"
433
+ ]
434
+ },
435
+ {
436
+ "cell_type": "markdown",
437
+ "metadata": {
438
+ "id": "aQh-QFAPsswb"
439
+ },
440
+ "source": [
441
+ "## Classification\n",
442
+ "\n",
443
+ "Classification is the task of assigning a piece of text to one or more predefined categories or labels. It's one of the most fundamental tasks in Natural Language Processing (NLP).\n",
444
+ "\n",
445
+ "A practical application of text classification is customer support ticket routing. This process automatically directs customer queries to the correct department, saving time and reducing manual work."
446
+ ]
447
+ },
448
+ {
449
+ "cell_type": "code",
450
+ "execution_count": null,
451
+ "metadata": {
452
+ "id": "C2Ufawl-tXvr",
453
+ "outputId": "347bd68c-dfee-470d-eef7-e3af5d096e91"
454
+ },
455
+ "outputs": [
456
+ {
457
+ "name": "stdout",
458
+ "output_type": "stream",
459
+ "text": [
460
+ "tensor([[0.4673, 0.5145, 0.3604],\n",
461
+ " [0.4191, 0.5010, 0.5966]])\n",
462
+ "tensor([1, 2])\n",
463
+ "๐Ÿ™‹โ€โ™‚๏ธ Excuse me, the app freezes on the login screen. It won't work even when I try to reset my password. -> ๐Ÿค– Technical Support\n",
464
+ "๐Ÿ™‹โ€โ™‚๏ธ I would like to inquire about your enterprise plan pricing and features for a team of 50 people. -> ๐Ÿค– Sales Inquiry\n"
465
+ ]
466
+ }
467
+ ],
468
+ "source": [
469
+ "labels = [\"Billing Issue\", \"Technical Support\", \"Sales Inquiry\"]\n",
470
+ "\n",
471
+ "sentence = [\n",
472
+ " \"Excuse me, the app freezes on the login screen. It won't work even when I try to reset my password.\",\n",
473
+ " \"I would like to inquire about your enterprise plan pricing and features for a team of 50 people.\",\n",
474
+ "]\n",
475
+ "\n",
476
+ "# Calculate embeddings by calling model.encode()\n",
477
+ "label_embeddings = model.encode(labels, prompt_name=\"Classification\")\n",
478
+ "embeddings = model.encode(sentence, prompt_name=\"Classification\")\n",
479
+ "\n",
480
+ "# Calculate the embedding similarities\n",
481
+ "similarities = model.similarity(embeddings, label_embeddings)\n",
482
+ "print(similarities)\n",
483
+ "\n",
484
+ "idx = similarities.argmax(1)\n",
485
+ "print(idx)\n",
486
+ "\n",
487
+ "for example in sentence:\n",
488
+ " print(\"๐Ÿ™‹โ€โ™‚๏ธ\", example, \"-> ๐Ÿค–\", labels[idx[sentence.index(example)]])"
489
+ ]
490
+ },
491
+ {
492
+ "cell_type": "markdown",
493
+ "metadata": {
494
+ "id": "IRUU2EIDPSmW"
495
+ },
496
+ "source": [
497
+ "## Matryoshka Representation Learning (MRL)\n",
498
+ "\n",
499
+ "EmbeddingGemma leverages MRL to provide multiple embedding sizes from one model. It's a clever training method that creates a single, high-quality embedding where the most important information is concentrated at the beginning of the vector.\n",
500
+ "\n",
501
+ "This means you can get a smaller but still very useful embedding by simply taking the first `N` dimensions of the full embedding. Using smaller, truncated embeddings is significantly cheaper to store and faster to process, but this efficiency comes at the cost of potential lower quality of embeddings. MRL gives you the power to choose the optimal balance between this speed and accuracy for your application's specific needs.\n",
502
+ "\n",
503
+ "Let's use three words `[\"apple\", \"banana\", \"car\"]` and create simplified embeddings to see how MRL works."
504
+ ]
505
+ },
506
+ {
507
+ "cell_type": "code",
508
+ "execution_count": null,
509
+ "metadata": {
510
+ "id": "B1q1F9I5PYSq",
511
+ "outputId": "a5b28e04-4783-4d79-ae82-3fac7e554a7a"
512
+ },
513
+ "outputs": [
514
+ {
515
+ "name": "stdout",
516
+ "output_type": "stream",
517
+ "text": [
518
+ "similarity function: cosine\n",
519
+ "tensor([[0.7510, 0.6685]])\n",
520
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. banana -> ๐Ÿค– score: 0.75102395\n",
521
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. car -> ๐Ÿค– score: 0.6684626\n"
522
+ ]
523
+ }
524
+ ],
525
+ "source": [
526
+ "def check_word_similarities():\n",
527
+ " # Calculate the embedding similarities\n",
528
+ " print(\"similarity function: \", model.similarity_fn_name)\n",
529
+ " similarities = model.similarity(embeddings[0], embeddings[1:])\n",
530
+ " print(similarities)\n",
531
+ "\n",
532
+ " for idx, word in enumerate(words[1:]):\n",
533
+ " print(\"๐Ÿ™‹โ€โ™‚๏ธ apple vs.\", word, \"-> ๐Ÿค– score: \", similarities.numpy()[0][idx])\n",
534
+ "\n",
535
+ "# Calculate embeddings by calling model.encode()\n",
536
+ "embeddings = model.encode(words, prompt_name=\"STS\")\n",
537
+ "\n",
538
+ "check_word_similarities()"
539
+ ]
540
+ },
541
+ {
542
+ "cell_type": "markdown",
543
+ "metadata": {
544
+ "id": "_iv1xG0TPxkm"
545
+ },
546
+ "source": [
547
+ "Now, for a faster application, you don't need a new model. Simply **truncate** the full embeddings to the first **512 dimensions**. For optimal results, it is also recommended to set `normalize_embeddings=True`, which scales the vectors to a unit length of 1."
548
+ ]
549
+ },
550
+ {
551
+ "cell_type": "code",
552
+ "execution_count": null,
553
+ "metadata": {
554
+ "id": "9Ue4aWh8PzdL",
555
+ "outputId": "176dabd4-9d9c-4ce9-c7e5-472ba47ed55f"
556
+ },
557
+ "outputs": [
558
+ {
559
+ "name": "stdout",
560
+ "output_type": "stream",
561
+ "text": [
562
+ "Embedding 1: (512,)\n",
563
+ "Embedding 2: (512,)\n",
564
+ "Embedding 3: (512,)\n",
565
+ "--------------------------------------------------------------------------------\n",
566
+ "similarity function: cosine\n",
567
+ "tensor([[0.7674, 0.7041]])\n",
568
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. banana -> ๐Ÿค– score: 0.767427\n",
569
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. car -> ๐Ÿค– score: 0.7040509\n"
570
+ ]
571
+ }
572
+ ],
573
+ "source": [
574
+ "embeddings = model.encode(words, truncate_dim=512, normalize_embeddings=True)\n",
575
+ "\n",
576
+ "for idx, embedding in enumerate(embeddings):\n",
577
+ " print(f\"Embedding {idx+1}: {embedding.shape}\")\n",
578
+ "\n",
579
+ "print(\"-\"*80)\n",
580
+ "check_word_similarities()"
581
+ ]
582
+ },
583
+ {
584
+ "cell_type": "markdown",
585
+ "metadata": {
586
+ "id": "lgkmgzfVP24M"
587
+ },
588
+ "source": [
589
+ "In extremely constrained environments, you can further shorten the embeddings to just **256 dimensions**. You can also use the more efficient **dot-product** for similarity calculations instead of the standard **cosine** similarity."
590
+ ]
591
+ },
592
+ {
593
+ "cell_type": "code",
594
+ "execution_count": null,
595
+ "metadata": {
596
+ "id": "Gi4NlPv-P4RS",
597
+ "outputId": "656d8d6a-1e79-41be-f17a-cab136bf27ea"
598
+ },
599
+ "outputs": [
600
+ {
601
+ "name": "stdout",
602
+ "output_type": "stream",
603
+ "text": [
604
+ "Embedding 1: (256,)\n",
605
+ "Embedding 2: (256,)\n",
606
+ "Embedding 3: (256,)\n",
607
+ "--------------------------------------------------------------------------------\n",
608
+ "similarity function: dot\n",
609
+ "tensor([[0.7855, 0.7382]])\n",
610
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. banana -> ๐Ÿค– score: 0.7854644\n",
611
+ "๐Ÿ™‹โ€โ™‚๏ธ apple vs. car -> ๐Ÿค– score: 0.7382126\n"
612
+ ]
613
+ }
614
+ ],
615
+ "source": [
616
+ "model = SentenceTransformer(model_id, truncate_dim=256, similarity_fn_name=\"dot\").to(device=device)\n",
617
+ "embeddings = model.encode(words, prompt_name=\"STS\", normalize_embeddings=True)\n",
618
+ "\n",
619
+ "for idx, embedding in enumerate(embeddings):\n",
620
+ " print(f\"Embedding {idx+1}: {embedding.shape}\")\n",
621
+ "\n",
622
+ "print(\"-\"*80)\n",
623
+ "check_word_similarities()"
624
+ ]
625
+ },
626
+ {
627
+ "cell_type": "markdown",
628
+ "metadata": {
629
+ "id": "RYr9uSI_t3fm"
630
+ },
631
+ "source": [
632
+ "## Summary and next steps\n",
633
+ "\n",
634
+ "You are now equipped to generate high-quality text embeddings using EmbeddingGemma and the Sentence Transformers library. Apply these skills to build powerful features like semantic similarity, text classification, and Retrieval-Augmented Generation (RAG) systems, and continue exploring what's possible with Gemma models.\n",
635
+ "\n",
636
+ "Check out the following docs next:\n",
637
+ "\n",
638
+ "* [Fine-tune EmbeddingGemma](https://ai.google.dev/gemma/docs/embeddinggemma/fine-tuning-embeddinggemma-with-sentence-transformers)\n",
639
+ "* [Simple RAG example](https://github.com/google-gemini/gemma-cookbook/blob/main/Gemma/%5BGemma_3%5DRAG_with_EmbeddingGemma.ipynb) in the Gemma Cookbook\n"
640
+ ]
641
+ }
642
+ ],
643
+ "metadata": {
644
+ "colab": {
645
+ "name": "inference-embeddinggemma-with-sentence-transformers.ipynb",
646
+ "provenance": [],
647
+ "toc_visible": true
648
+ },
649
+ "kernelspec": {
650
+ "display_name": "Python 3",
651
+ "name": "python3"
652
+ }
653
+ },
654
+ "nbformat": 4,
655
+ "nbformat_minor": 0
656
+ }
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 2048,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boi_token": "<start_of_image>",
3
+ "bos_token": {
4
+ "content": "<bos>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ "eoi_token": "<end_of_image>",
11
+ "eos_token": {
12
+ "content": "<eos>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "image_token": "<image_soft_token>",
19
+ "pad_token": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "unk_token": {
27
+ "content": "<unk>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6852f8d561078cc0cebe70ca03c5bfdd0d60a45f9d2e0e1e4cc05b68e9ec329e
3
+ size 33385008
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
3
+ size 4689074
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff