dpshade22 commited on
Commit
f1b065c
·
verified ·
1 Parent(s): 81dcb2b

Upload fine-tuned EmbeddingGemma ONNX for web deployment

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers.js
3
+ pipeline_tag: sentence-similarity
4
+ tags:
5
+ - sentence-transformers
6
+ - transformers.js
7
+ - onnx
8
+ - biblical-search
9
+ - semantic-search
10
+ - embeddinggemma
11
+ - fine-tuned
12
+ license: apache-2.0
13
+ datasets:
14
+ - biblical-text-pairs
15
+ metrics:
16
+ - accuracy@1: 12.00%
17
+ - accuracy@3: 15.00%
18
+ - accuracy@10: 31.00%
19
+ language:
20
+ - en
21
+ ---
22
+
23
+ # EmbeddingGemma-300M Fine-tuned for Biblical Text Search (ONNX)
24
+
25
+ This is the ONNX version of our fine-tuned EmbeddingGemma-300M model specialized for biblical text search and retrieval. This version is optimized for web deployment using transformers.js.
26
+
27
+ ## Model Performance
28
+
29
+ - **Accuracy@1**: 12.00% (13x improvement over base model)
30
+ - **Accuracy@3**: 15.00%
31
+ - **Accuracy@10**: 31.00%
32
+ - **Training Steps**: 25 (optimal stopping point)
33
+ - **Base Model Accuracy@1**: 0.91%
34
+
35
+ ## Usage with Transformers.js
36
+
37
+ ```javascript
38
+ import { AutoTokenizer, AutoModel } from '@huggingface/transformers';
39
+
40
+ // Load the model
41
+ const model = await AutoModel.from_pretrained('dpshade22/embeddinggemma-scripture-v1-onnx');
42
+ const tokenizer = await AutoTokenizer.from_pretrained('dpshade22/embeddinggemma-scripture-v1-onnx');
43
+
44
+ // Encode queries (use search_query: prefix)
45
+ const query = "search_query: What is love?";
46
+ const query_embedding = await model.encode([query]);
47
+
48
+ // Encode documents (use search_document: prefix)
49
+ const document = "search_document: Love is patient and kind";
50
+ const doc_embedding = await model.encode([document]);
51
+ ```
52
+
53
+ ## Prefixes
54
+
55
+ For optimal performance, use these prefixes:
56
+
57
+ - **Queries**: `"search_query: your question here"`
58
+ - **Documents**: `"search_document: scripture text here"`
59
+
60
+ ## Model Details
61
+
62
+ - **Base Model**: `google/embeddinggemma-300m`
63
+ - **Training Data**: 26,276 biblical text pairs
64
+ - **Training Steps**: 25 steps (optimal stopping point)
65
+ - **Learning Rate**: 2.0e-04
66
+ - **Batch Size**: 8
67
+ - **Output Dimensions**: 768D (supports Matryoshka 384D, 128D)
68
+ - **ONNX Conversion**: Using nixiesearch/onnx-convert specialized tool
69
+
70
+ ## Training Details
71
+
72
+ - **Training Data**: 26,276 biblical text pairs
73
+ - **Learning Rate**: 2.0e-04
74
+ - **Batch Size**: 8
75
+ - **Training Strategy**: Early stopping at 25 steps to prevent overfitting
76
+ - **Output Dimensions**: 768D (supports Matryoshka 384D, 128D)
77
+
78
+ ## Intended Use
79
+
80
+ This model is designed for:
81
+ - Biblical text search and retrieval in web applications
82
+ - Finding relevant scripture passages
83
+ - Semantic similarity of religious texts
84
+ - Question answering on biblical topics
85
+ - Offline PWA applications using transformers.js
86
+
87
+ ## Conversion Details
88
+
89
+ - **Converted using**: nixiesearch/onnx-convert specialized tool
90
+ - **ONNX Opset**: 17
91
+ - **Optimization Level**: 1
92
+ - **Max difference from original**: 1.9e-05 (within acceptable tolerance)
93
+
94
+ ## Related Models
95
+
96
+ - **Original PyTorch version**: dpshade22/embeddinggemma-scripture-v1
97
+ - **Base model**: google/embeddinggemma-300m
98
+ - **Reference ONNX**: onnx-community/embeddinggemma-300m-ONNX
config.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "export_model_type": "transformer",
13
+ "final_logit_softcapping": null,
14
+ "head_dim": 256,
15
+ "hidden_activation": "gelu_pytorch_tanh",
16
+ "hidden_size": 768,
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 1152,
19
+ "layer_types": [
20
+ "sliding_attention",
21
+ "sliding_attention",
22
+ "sliding_attention",
23
+ "sliding_attention",
24
+ "sliding_attention",
25
+ "full_attention",
26
+ "sliding_attention",
27
+ "sliding_attention",
28
+ "sliding_attention",
29
+ "sliding_attention",
30
+ "sliding_attention",
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "full_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "sliding_attention",
42
+ "sliding_attention",
43
+ "full_attention"
44
+ ],
45
+ "max_position_embeddings": 2048,
46
+ "model_type": "gemma3_text",
47
+ "num_attention_heads": 3,
48
+ "num_hidden_layers": 24,
49
+ "num_key_value_heads": 1,
50
+ "pad_token_id": 0,
51
+ "query_pre_attn_scalar": 256,
52
+ "rms_norm_eps": 1e-06,
53
+ "rope_local_base_freq": 10000.0,
54
+ "rope_scaling": null,
55
+ "rope_theta": 1000000.0,
56
+ "sliding_window": 512,
57
+ "torch_dtype": "float32",
58
+ "transformers_version": "4.53.3",
59
+ "use_bidirectional_attention": true,
60
+ "use_cache": true,
61
+ "vocab_size": 262144
62
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f055dfae8de21cdf8180314311d3cba2435f38f7c2204131ef708955c3bece05
3
+ size 1231684213
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f055dfae8de21cdf8180314311d3cba2435f38f7c2204131ef708955c3bece05
3
+ size 1231684213
onnx/model_opt1_Float32.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:425f0ed772ce3861172142b543fa73fd8f26ef2185e0bcdbbac61b53a2077173
3
+ size 1231131653
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:c79a190be01275b078b3574d02188abc5784e5651a101b20d826371ba8e897dc
3
+ size 33385261
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff