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
Update README.md
Browse filesfix prompt for task instructions
README.md
CHANGED
|
@@ -117,7 +117,7 @@ For optimal embedding quality and runtime efficiency, follow these configuration
|
|
| 117 |
|
| 118 |
EmbeddingGemma 2 is trained with short task instruction prefixes prepended to text inputs. Using the right prefix improves retrieval quality; omitting it still works but reduces precision. Prefixes apply to text only. Pass images, video, and audio without any prefix.
|
| 119 |
|
| 120 |
-
Documents with a real title should be formatted as `title: {title} | text: {content}`
|
| 121 |
|
| 122 |
**Prefix Notation & Usage**
|
| 123 |
|
|
@@ -128,13 +128,13 @@ We offer two types of task prefixes, depending on how embeddings are used in the
|
|
| 128 |
|
| 129 |
| Use Case | Task Type | Query Task Instruction | Document Task Instruction *(use `none` if no title)* |
|
| 130 |
| :---- | :---- | :---- | :---- |
|
| 131 |
-
| Web / document search | Asymmetric | `task: search result | query: {query}` | `title: {title} | text: {content}` |
|
| 132 |
-
| Question answering | Asymmetric | `task: question answering | query: {question}` | `title: {title} | text: {passage}` |
|
| 133 |
-
| Fact checking | Asymmetric | `task: fact checking | query: {claim}` | `title: {title} | text: {evidence}` |
|
| 134 |
-
| Code search | Asymmetric | `task: code retrieval | query: {query}` | `title: {title or filename} | text: {code}` |
|
| 135 |
-
| Text classification | Symmetric | `task: classification | query: {content}` | N/A |
|
| 136 |
-
| Clustering | Symmetric | `task: clustering | query: {content}` | N/A |
|
| 137 |
-
| Measuring similarity | Symmetric | `task: sentence similarity | query: {content}` | N/A |
|
| 138 |
|
| 139 |
**Please note:** Prefixes are used on text inputs only when encoding images, video, or audio pass them directly.
|
| 140 |
|
|
|
|
| 117 |
|
| 118 |
EmbeddingGemma 2 is trained with short task instruction prefixes prepended to text inputs. Using the right prefix improves retrieval quality; omitting it still works but reduces precision. Prefixes apply to text only. Pass images, video, and audio without any prefix.
|
| 119 |
|
| 120 |
+
Documents with a real title should be formatted as `title: {title} | text: {content}`. Use `title: none` when no title is available.
|
| 121 |
|
| 122 |
**Prefix Notation & Usage**
|
| 123 |
|
|
|
|
| 128 |
|
| 129 |
| Use Case | Task Type | Query Task Instruction | Document Task Instruction *(use `none` if no title)* |
|
| 130 |
| :---- | :---- | :---- | :---- |
|
| 131 |
+
| Web / document search | Asymmetric | `task: search result \| query: {query}` | `title: {title} \| text: {content}` |
|
| 132 |
+
| Question answering | Asymmetric | `task: question answering \| query: {question}` | `title: {title} \| text: {passage}` |
|
| 133 |
+
| Fact checking | Asymmetric | `task: fact checking \| query: {claim}` | `title: {title} \| text: {evidence}` |
|
| 134 |
+
| Code search | Asymmetric | `task: code retrieval \| query: {query}` | `title: {title or filename} \| text: {code}` |
|
| 135 |
+
| Text classification | Symmetric | `task: classification \| query: {content}` | N/A |
|
| 136 |
+
| Clustering | Symmetric | `task: clustering \| query: {content}` | N/A |
|
| 137 |
+
| Measuring similarity | Symmetric | `task: sentence similarity \| query: {content}` | N/A |
|
| 138 |
|
| 139 |
**Please note:** Prefixes are used on text inputs only when encoding images, video, or audio pass them directly.
|
| 140 |
|