Add new SentenceTransformer model.
Browse files- 1_Pooling/config.json +8 -8
- README.md +101 -52
- config.json +5 -2
- config_sentence_transformers.json +10 -5
- sentence_bert_config.json +2 -2
- tokenizer.json +2 -2
- tokenizer_config.json +1 -1
1_Pooling/config.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
{
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 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 |
-
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
#
|
| 13 |
|
| 14 |
-
This is a [sentence-transformers](https://www.SBERT.net) model
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
```
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
| 24 |
```
|
| 25 |
|
| 26 |
-
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```python
|
| 29 |
from sentence_transformers import SentenceTransformer
|
| 30 |
-
sentences = ["This is an example sentence", "Each sentence is converted"]
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
embeddings = model.encode(sentences)
|
| 34 |
-
print(embeddings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
```
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
import torch
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
-
|
| 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 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
model = AutoModel.from_pretrained('Randstad/gemma-embedding-st')
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
model_output = model(**encoded_input)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
```
|
| 74 |
|
|
|
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
##
|
| 78 |
|
| 79 |
-
|
| 80 |
|
| 81 |
-
|
|
|
|
| 82 |
|
|
|
|
|
|
|
| 83 |
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
|
| 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 |
-
|
|
|
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
| 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":
|
| 56 |
-
"
|
|
|
|
|
|
|
| 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": "
|
| 4 |
-
"transformers": "4.
|
| 5 |
-
"pytorch": "2.
|
| 6 |
},
|
| 7 |
-
"prompts": {
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 3 |
-
|
| 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:
|
| 3 |
-
size
|
|
|
|
| 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":
|
| 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,
|