VovaM commited on
Commit
1ef47ec
·
verified ·
1 Parent(s): 99c2bdf

Add new SentenceTransformer model.

Browse files
1_Pooling/config.json CHANGED
@@ -1,10 +1,10 @@
1
  {
2
- "word_embedding_dimension": 768,
3
- "pooling_mode_cls_token": false,
4
- "pooling_mode_mean_tokens": true,
5
- "pooling_mode_max_tokens": false,
6
- "pooling_mode_mean_sqrt_len_tokens": false,
7
- "pooling_mode_weightedmean_tokens": false,
8
- "pooling_mode_lasttoken": false,
9
- "include_prompt": true
10
  }
 
1
  {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
  }
README.md CHANGED
@@ -1,95 +1,144 @@
1
  ---
2
- library_name: sentence-transformers
3
- pipeline_tag: sentence-similarity
4
  tags:
5
  - sentence-transformers
6
- - feature-extraction
7
  - sentence-similarity
8
- - transformers
9
-
 
 
 
10
  ---
11
 
12
- # Randstad/gemma-embedding-st
13
 
14
- This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
15
 
16
- <!--- Describe your model here -->
17
 
18
- ## Usage (Sentence-Transformers)
 
 
 
 
 
 
 
 
19
 
20
- Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
 
 
 
 
 
 
21
 
22
  ```
23
- pip install -U sentence-transformers
 
 
 
24
  ```
25
 
26
- Then you can use the model like this:
27
 
 
 
 
 
 
 
 
 
 
28
  ```python
29
  from sentence_transformers import SentenceTransformer
30
- sentences = ["This is an example sentence", "Each sentence is converted"]
31
 
32
- model = SentenceTransformer('Randstad/gemma-embedding-st')
 
 
 
 
 
 
 
33
  embeddings = model.encode(sentences)
34
- print(embeddings)
 
 
 
 
 
 
 
 
35
  ```
36
 
 
 
37
 
 
38
 
39
- ## Usage (HuggingFace Transformers)
40
- Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
41
 
42
- ```python
43
- from transformers import AutoTokenizer, AutoModel
44
- import torch
45
 
 
46
 
47
- #Mean Pooling - Take attention mask into account for correct averaging
48
- def mean_pooling(model_output, attention_mask):
49
- token_embeddings = model_output[0] #First element of model_output contains all token embeddings
50
- input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
51
- return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
52
 
 
 
53
 
54
- # Sentences we want sentence embeddings for
55
- sentences = ['This is an example sentence', 'Each sentence is converted']
56
 
57
- # Load model from HuggingFace Hub
58
- tokenizer = AutoTokenizer.from_pretrained('Randstad/gemma-embedding-st')
59
- model = AutoModel.from_pretrained('Randstad/gemma-embedding-st')
60
 
61
- # Tokenize sentences
62
- encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
63
 
64
- # Compute token embeddings
65
- with torch.no_grad():
66
- model_output = model(**encoded_input)
67
 
68
- # Perform pooling. In this case, mean pooling.
69
- sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
70
 
71
- print("Sentence embeddings:")
72
- print(sentence_embeddings)
73
- ```
74
 
 
75
 
 
 
 
 
 
 
 
 
76
 
77
- ## Evaluation Results
78
 
79
- <!--- Describe how your model was evaluated -->
80
 
81
- For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=Randstad/gemma-embedding-st)
 
82
 
 
 
83
 
 
 
84
 
85
- ## Full Model Architecture
86
- ```
87
- SentenceTransformer(
88
- (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: Gemma3TextModel
89
- (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})
90
- )
91
- ```
92
 
93
- ## Citing & Authors
 
94
 
95
- <!--- Describe where people can find more information -->
 
 
1
  ---
 
 
2
  tags:
3
  - sentence-transformers
 
4
  - sentence-similarity
5
+ - feature-extraction
6
+ - dense
7
+ base_model: google/embeddinggemma-300m
8
+ pipeline_tag: sentence-similarity
9
+ library_name: sentence-transformers
10
  ---
11
 
12
+ # SentenceTransformer based on google/embeddinggemma-300m
13
 
14
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [google/embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
15
 
16
+ ## Model Details
17
 
18
+ ### Model Description
19
+ - **Model Type:** Sentence Transformer
20
+ - **Base model:** [google/embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m) <!-- at revision 57c266a740f537b4dc058e1b0cda161fd15afa75 -->
21
+ - **Maximum Sequence Length:** 512 tokens
22
+ - **Output Dimensionality:** 768 dimensions
23
+ - **Similarity Function:** Cosine Similarity
24
+ <!-- - **Training Dataset:** Unknown -->
25
+ <!-- - **Language:** Unknown -->
26
+ <!-- - **License:** Unknown -->
27
 
28
+ ### Model Sources
29
+
30
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
31
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
32
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
33
+
34
+ ### Full Model Architecture
35
 
36
  ```
37
+ SentenceTransformer(
38
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'Gemma3TextModel'})
39
+ (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})
40
+ )
41
  ```
42
 
43
+ ## Usage
44
 
45
+ ### Direct Usage (Sentence Transformers)
46
+
47
+ First install the Sentence Transformers library:
48
+
49
+ ```bash
50
+ pip install -U sentence-transformers
51
+ ```
52
+
53
+ Then you can load this model and run inference.
54
  ```python
55
  from sentence_transformers import SentenceTransformer
 
56
 
57
+ # Download from the 🤗 Hub
58
+ model = SentenceTransformer("Randstad/gemma-embedding-st")
59
+ # Run inference
60
+ sentences = [
61
+ 'The weather is lovely today.',
62
+ "It's so sunny outside!",
63
+ 'He drove to the stadium.',
64
+ ]
65
  embeddings = model.encode(sentences)
66
+ print(embeddings.shape)
67
+ # [3, 768]
68
+
69
+ # Get the similarity scores for the embeddings
70
+ similarities = model.similarity(embeddings, embeddings)
71
+ print(similarities)
72
+ # tensor([[1.0000, 0.9254, 0.9106],
73
+ # [0.9254, 1.0000, 0.9032],
74
+ # [0.9106, 0.9032, 1.0000]])
75
  ```
76
 
77
+ <!--
78
+ ### Direct Usage (Transformers)
79
 
80
+ <details><summary>Click to see the direct usage in Transformers</summary>
81
 
82
+ </details>
83
+ -->
84
 
85
+ <!--
86
+ ### Downstream Usage (Sentence Transformers)
 
87
 
88
+ You can finetune this model on your own dataset.
89
 
90
+ <details><summary>Click to expand</summary>
 
 
 
 
91
 
92
+ </details>
93
+ -->
94
 
95
+ <!--
96
+ ### Out-of-Scope Use
97
 
98
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
99
+ -->
 
100
 
101
+ <!--
102
+ ## Bias, Risks and Limitations
103
 
104
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
105
+ -->
 
106
 
107
+ <!--
108
+ ### Recommendations
109
 
110
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
111
+ -->
 
112
 
113
+ ## Training Details
114
 
115
+ ### Framework Versions
116
+ - Python: 3.10.18
117
+ - Sentence Transformers: 5.1.1
118
+ - Transformers: 4.52.4
119
+ - PyTorch: 2.7.1+cu126
120
+ - Accelerate: 1.8.1
121
+ - Datasets: 3.6.0
122
+ - Tokenizers: 0.21.1
123
 
124
+ ## Citation
125
 
126
+ ### BibTeX
127
 
128
+ <!--
129
+ ## Glossary
130
 
131
+ *Clearly define terms in order to be accessible across audiences.*
132
+ -->
133
 
134
+ <!--
135
+ ## Model Card Authors
136
 
137
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
138
+ -->
 
 
 
 
 
139
 
140
+ <!--
141
+ ## Model Card Contact
142
 
143
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
144
+ -->
config.json CHANGED
@@ -7,6 +7,7 @@
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,
@@ -52,8 +53,10 @@
52
  "rope_local_base_freq": 10000.0,
53
  "rope_scaling": null,
54
  "rope_theta": 1000000.0,
55
- "sliding_window": 257,
56
- "transformers_version": "4.57.1",
 
 
57
  "use_bidirectional_attention": true,
58
  "use_cache": true,
59
  "vocab_size": 262144
 
7
  "attention_dropout": 0.0,
8
  "attn_logit_softcapping": null,
9
  "bos_token_id": 2,
10
+ "cache_implementation": "hybrid",
11
  "dtype": "float32",
12
  "eos_token_id": 1,
13
  "final_logit_softcapping": null,
 
53
  "rope_local_base_freq": 10000.0,
54
  "rope_scaling": null,
55
  "rope_theta": 1000000.0,
56
+ "sliding_window": 512,
57
+ "sliding_window_pattern": 6,
58
+ "torch_dtype": "float32",
59
+ "transformers_version": "4.52.4",
60
  "use_bidirectional_attention": true,
61
  "use_cache": true,
62
  "vocab_size": 262144
config_sentence_transformers.json CHANGED
@@ -1,9 +1,14 @@
1
  {
 
2
  "__version__": {
3
- "sentence_transformers": "2.7.0",
4
- "transformers": "4.57.1",
5
- "pytorch": "2.3.1+cu121"
6
  },
7
- "prompts": {},
8
- "default_prompt_name": null
 
 
 
 
9
  }
 
1
  {
2
+ "model_type": "SentenceTransformer",
3
  "__version__": {
4
+ "sentence_transformers": "5.1.1",
5
+ "transformers": "4.52.4",
6
+ "pytorch": "2.7.1+cu126"
7
  },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
  }
sentence_bert_config.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "max_seq_length": 512,
3
- "do_lower_case": false
4
  }
 
1
  {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
  }
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6852f8d561078cc0cebe70ca03c5bfdd0d60a45f9d2e0e1e4cc05b68e9ec329e
3
- size 33385008
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c79a190be01275b078b3574d02188abc5784e5651a101b20d826371ba8e897dc
3
+ size 33385261
tokenizer_config.json CHANGED
@@ -51334,7 +51334,7 @@
51334
  "image_token": "<image_soft_token>"
51335
  },
51336
  "image_token": "<image_soft_token>",
51337
- "model_max_length": 2048,
51338
  "pad_token": "<pad>",
51339
  "padding_side": "right",
51340
  "sp_model_kwargs": null,
 
51334
  "image_token": "<image_soft_token>"
51335
  },
51336
  "image_token": "<image_soft_token>",
51337
+ "model_max_length": 512,
51338
  "pad_token": "<pad>",
51339
  "padding_side": "right",
51340
  "sp_model_kwargs": null,