Feature Extraction
Transformers
Safetensors
sentence-transformers
multilingual
embedding_gemma2
embedding
multimodal-embedding
multimodal
vision
audio
video
image-feature-extraction
audio-feature-extraction
video-feature-extraction
sentence-similarity
Instructions to use google/embeddinggemma-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/embeddinggemma-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="google/embeddinggemma-2")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("google/embeddinggemma-2") model = AutoModel.from_pretrained("google/embeddinggemma-2", device_map="auto") - sentence-transformers
How to use google/embeddinggemma-2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("google/embeddinggemma-2") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +153 -0
- config.json +1 -2
README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- sentence-transformers
|
| 4 |
+
- sentence-similarity
|
| 5 |
+
- feature-extraction
|
| 6 |
+
- dense
|
| 7 |
+
pipeline_tag: sentence-similarity
|
| 8 |
+
library_name: sentence-transformers
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# SentenceTransformer
|
| 12 |
+
|
| 13 |
+
This is a [sentence-transformers](https://www.SBERT.net) model trained. It maps inputs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
|
| 14 |
+
|
| 15 |
+
## Model Details
|
| 16 |
+
|
| 17 |
+
### Model Description
|
| 18 |
+
- **Model Type:** Sentence Transformer
|
| 19 |
+
<!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
|
| 20 |
+
- **Maximum Sequence Length:** 1000000000000000019884624838656 tokens
|
| 21 |
+
- **Output Dimensionality:** 768 dimensions
|
| 22 |
+
- **Similarity Function:** Cosine Similarity
|
| 23 |
+
- **Supported Modalities:** Text, Image, Audio, Video, Message
|
| 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/huggingface/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({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'image': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'audio': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'video': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'message': {'method': 'forward', 'method_output_name': 'last_hidden_state', 'format': 'structured'}}, 'module_output_name': 'token_embeddings', 'architecture': 'EmbeddingGemma2Model'})
|
| 39 |
+
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
|
| 40 |
+
(2): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
|
| 41 |
+
)
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
### Direct Usage (Sentence Transformers)
|
| 47 |
+
|
| 48 |
+
First install the Sentence Transformers library:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
pip install -U sentence-transformers
|
| 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("sentence_transformers_model_id")
|
| 59 |
+
# Run inference
|
| 60 |
+
queries = [
|
| 61 |
+
'Which planet is known as the Red Planet?',
|
| 62 |
+
]
|
| 63 |
+
documents = [
|
| 64 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 65 |
+
'Mars, known for its reddish appearance, is often referred to as the Red Planet.',
|
| 66 |
+
'Saturn, famous for its rings, is sometimes mistaken for the Red Planet.',
|
| 67 |
+
]
|
| 68 |
+
query_embeddings = model.encode_query(queries)
|
| 69 |
+
document_embeddings = model.encode_document(documents)
|
| 70 |
+
print(query_embeddings.shape, document_embeddings.shape)
|
| 71 |
+
# [1, 768] [3, 768]
|
| 72 |
+
|
| 73 |
+
# Get the similarity scores for the embeddings
|
| 74 |
+
similarities = model.similarity(query_embeddings, document_embeddings)
|
| 75 |
+
print(similarities)
|
| 76 |
+
# tensor([[0.6754, 0.8534, 0.7786]])
|
| 77 |
+
```
|
| 78 |
+
<!--
|
| 79 |
+
### Direct Usage (Transformers)
|
| 80 |
+
|
| 81 |
+
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 82 |
+
|
| 83 |
+
</details>
|
| 84 |
+
-->
|
| 85 |
+
|
| 86 |
+
<!--
|
| 87 |
+
### Downstream Usage (Sentence Transformers)
|
| 88 |
+
|
| 89 |
+
You can finetune this model on your own dataset.
|
| 90 |
+
|
| 91 |
+
<details><summary>Click to expand</summary>
|
| 92 |
+
|
| 93 |
+
</details>
|
| 94 |
+
-->
|
| 95 |
+
|
| 96 |
+
<!--
|
| 97 |
+
### Out-of-Scope Use
|
| 98 |
+
|
| 99 |
+
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 100 |
+
-->
|
| 101 |
+
|
| 102 |
+
<!--
|
| 103 |
+
## Bias, Risks and Limitations
|
| 104 |
+
|
| 105 |
+
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 106 |
+
-->
|
| 107 |
+
|
| 108 |
+
<!--
|
| 109 |
+
### Recommendations
|
| 110 |
+
|
| 111 |
+
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 112 |
+
-->
|
| 113 |
+
|
| 114 |
+
## Training Details
|
| 115 |
+
|
| 116 |
+
### Framework Versions
|
| 117 |
+
- Python: 3.12.11
|
| 118 |
+
- Sentence Transformers: 6.1.0
|
| 119 |
+
- Transformers: 5.18.0.dev0
|
| 120 |
+
- PyTorch: 2.14.0+cu130
|
| 121 |
+
- Accelerate: 1.14.0
|
| 122 |
+
- Datasets: 5.0.1
|
| 123 |
+
- Tokenizers: 0.23.2
|
| 124 |
+
|
| 125 |
+
## Additional Resources
|
| 126 |
+
|
| 127 |
+
- [Training and Finetuning Embedding Models with Sentence Transformers](https://huggingface.co/blog/train-sentence-transformers): the end-to-end guide for training or finetuning Sentence Transformer models.
|
| 128 |
+
- [Introduction to Matryoshka Embedding Models](https://huggingface.co/blog/matryoshka): variable-size embeddings that can be truncated with minimal quality loss.
|
| 129 |
+
- [Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval](https://huggingface.co/blog/embedding-quantization): post-training compression of embedding vectors.
|
| 130 |
+
- [Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/multimodal-sentence-transformers): use text, image, audio, and video models through the same API.
|
| 131 |
+
- [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-multimodal-sentence-transformers): train multimodal embedding models, with a Visual Document Retrieval walkthrough.
|
| 132 |
+
|
| 133 |
+
## Citation
|
| 134 |
+
|
| 135 |
+
### BibTeX
|
| 136 |
+
|
| 137 |
+
<!--
|
| 138 |
+
## Glossary
|
| 139 |
+
|
| 140 |
+
*Clearly define terms in order to be accessible across audiences.*
|
| 141 |
+
-->
|
| 142 |
+
|
| 143 |
+
<!--
|
| 144 |
+
## Model Card Authors
|
| 145 |
+
|
| 146 |
+
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 147 |
+
-->
|
| 148 |
+
|
| 149 |
+
<!--
|
| 150 |
+
## Model Card Contact
|
| 151 |
+
|
| 152 |
+
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 153 |
+
-->
|
config.json
CHANGED
|
@@ -117,9 +117,8 @@
|
|
| 117 |
"rms_norm_eps": 1e-06,
|
| 118 |
"rope_parameters": {
|
| 119 |
"full_attention": {
|
| 120 |
-
"partial_rotary_factor": 0.25,
|
| 121 |
"rope_theta": 1000000.0,
|
| 122 |
-
"rope_type": "
|
| 123 |
},
|
| 124 |
"sliding_attention": {
|
| 125 |
"rope_theta": 10000.0,
|
|
|
|
| 117 |
"rms_norm_eps": 1e-06,
|
| 118 |
"rope_parameters": {
|
| 119 |
"full_attention": {
|
|
|
|
| 120 |
"rope_theta": 1000000.0,
|
| 121 |
+
"rope_type": "default"
|
| 122 |
},
|
| 123 |
"sliding_attention": {
|
| 124 |
"rope_theta": 10000.0,
|