Views
No views yet
1@article{embedding_gemma_2025,
2 title={EmbeddingGemma: Powerful and Lightweight Text Representations},
3 author={Schechter Vera, Henrique* and Dua, Sahil* and Zhang, Biao and Salz, Daniel and Mullins, Ryan and Raghuram Panyam, Sindhu and Smoot, Sara and Naim, Iftekhar and Zou, Joe and Chen, Feiyang and Cer, Daniel and Lisak, Alice and Choi, Min and Gonzalez, Lucas and Sanseviero, Omar and Cameron, Glenn and Ballantyne, Ian and Black, Kat and Chen, Kaifeng and Wang, Weiyi and Li, Zhe and Martins, Gus and Lee, Jinhyuk and Sherwood, Mark and Ji, Juyeong and Wu, Renjie and Zheng, Jingxiao and Singh, Jyotinder and Sharma, Abheesht and Sreepat, Divya and Jain, Aashi and Elarabawy, Adham and Co, AJ and Doumanoglou, Andreas and Samari, Babak and Hora, Ben and Potetz, Brian and Kim, Dahun and Alfonseca, Enrique and Moiseev, Fedor and Han, Feng and Palma Gomez, Frank and Hernández Ábrego, Gustavo and Zhang, Hesen and Hui, Hui and Han, Jay and Gill, Karan and Chen, Ke and Chen, Koert and Shanbhogue, Madhuri and Boratko, Michael and Suganthan, Paul and Duddu, Sai Meher Karthik and Mariserla, Sandeep and Ariafar, Setareh and Zhang, Shanfeng and Zhang, Shijie and Baumgartner, Simon and Goenka, Sonam and Qiu, Steve and Dabral, Tanmaya and Walker, Trevor and Rao, Vikram and Khawaja, Waleed and Zhou, Wenlei and Ren, Xiaoqi and Xia, Ye and Chen, Yichang and Chen, Yi-Ting and Dong, Zhe and Ding, Zhongli and Visin, Francesco and Liu, Gaël and Zhang, Jiageng and Kenealy, Kathleen and Casbon, Michelle and Kumar, Ravin and Mesnard, Thomas and Gleicher, Zach and Brick, Cormac and Lacombe, Olivier and Roberts, Adam and Sung, Yunhsuan and Hoffmann, Raphael and Warkentin, Tris and Joulin, Armand and Duerig, Tom and Seyedhosseini, Mojtaba},
4 publisher={Google DeepMind},
5 year={2025},
6 url={https://arxiv.org/abs/2509.20354}
7}pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("google/embeddinggemma-300m")
5
6# Run inference with queries and documents
7query = "Which planet is known as the Red Planet?"
8documents = [
9 "Venus is often called Earth's twin because of its similar size and proximity.",
10 "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
11 "Jupiter, the largest planet in our solar system, has a prominent red spot.",
12 "Saturn, famous for its rings, is sometimes mistaken for the Red Planet."
13]
14query_embeddings = model.encode_query(query)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# (768,) (4, 768)
18
19# Compute similarities to determine a ranking
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.3011, 0.6359, 0.4930, 0.4889]])float16. Please use float32 or bfloat16 as appropriate for your hardware.| MTEB (Multilingual, v2) | ||
|---|---|---|
| Dimensionality | Mean (Task) | Mean (TaskType) |
| 768d | 61.15 | 54.31 |
| 512d | 60.71 | 53.89 |
| 256d | 59.68 | 53.01 |
| 128d | 58.23 | 51.77 |
| MTEB (English, v2) | ||
|---|---|---|
| Dimensionality | Mean (Task) | Mean (TaskType) |
| 768d | 69.67 | 65.11 |
| 512d | 69.18 | 64.59 |
| 256d | 68.37 | 64.02 |
| 128d | 66.66 | 62.70 |
| MTEB (Code, v1) | ||
|---|---|---|
| Dimensionality | Mean (Task) | Mean (TaskType) |
| 768d | 68.76 | 68.76 |
| 512d | 68.48 | 68.48 |
| 256d | 66.74 | 66.74 |
| 128d | 62.96 | 62.96 |
| MTEB (Multilingual, v2) | ||
|---|---|---|
| Quant config (dimensionality) | Mean (Task) | Mean (TaskType) |
| Q4_0 (768d) | 60.62 | 53.61 |
| Q8_0 (768d) | 60.93 | 53.95 |
| Mixed Precision* (768d) | 60.69 | 53.82 |
| MTEB (English, v2) | ||
|---|---|---|
| Quant config (dimensionality) | Mean (Task) | Mean (TaskType) |
| Q4_0 (768d) | 69.31 | 64.65 |
| Q8_0 (768d) | 69.49 | 64.84 |
| Mixed Precision* (768d) | 69.32 | 64.82 |
| MTEB (Code, v1) | ||
|---|---|---|
| Quant config (dimensionality) | Mean (Task) | Mean (TaskType) |
| Q4_0 (768d) | 67.99 | 67.99 |
| Q8_0 (768d) | 68.70 | 68.70 |
| Mixed Precision* (768d) | 68.03 | 68.03 |
task: {task description} | query: where the task description varies by the use case, with the default task description being search result. Document-style prompts follow the form title: {title | "none"} | text: where the title is either none (the default) or the actual title of the document. Note that providing a title, if available, will improve model performance for document prompts but may require manual formatting.Use Case (task type enum) | Descriptions | Recommended Prompt |
|---|---|---|
Retrieval (Query) | Used to generate embeddings that are optimized for document search or information retrieval | task: search result | query: {content} |
Retrieval (Document) | title: {title | "none"} | text: {content} | |
Question Answering | task: question answering | query: {content} | |
Fact Verification | task: fact checking | query: {content} | |
Classification | Used to generate embeddings that are optimized to classify texts according to preset labels | task: classification | query: {content} |
Clustering | Used to generate embeddings that are optimized to cluster texts based on their similarities | task: clustering | query: {content} |
Semantic Similarity | Used to generate embeddings that are optimized to assess text similarity. This is not intended for retrieval use cases. | task: sentence similarity | query: {content} |
Code Retrieval | Used to retrieve a code block based on a natural language query, such as sort an array or reverse a linked list. Embeddings of the code blocks are computed using retrieval_document. | task: code retrieval | query: {content} |