EmbeddingGemma 2 是 Google DeepMind 在 2026 年 10 月 6 日发布的一个开源多模态嵌入(embedding)模型,Apache 2.0 许可。它把文本、代码、图像、视频、音频,以及几样混在一起的内容,统一映射到同一个 768 维向量空间里,总共 7.4 亿参数,目标是在手机、笔记本这类普通设备上直接跑。官方模型卡在 Hugging Face: https://huggingface.co/google/embeddinggemma-2 [1],发布博客见 [2],文档见 [3]。
它的上一代 EmbeddingGemma 是 2025 年发布的纯文本版本,据官方说下载量已经超过 2000 万次 [5]。这一代在文本之外补上了图像、视频和音频,代码任务的成绩也提了一截。
嵌入模型干的活儿和 ChatGPT 那种对话模型不一样,它负责把一段内容变成一串数字(向量),语义相近的内容,向量在空间里也靠得近。有了这个,就能做语义搜索、RAG 检索、分类、聚类、去重、事实核查这些事:判断两段话像不像、把一堆文档按主题分堆、拿一句话去海量语料里找最接近的段落。EmbeddingGemma 2 的新意在于,这串向量不只对应文字,也能对应图片、视频和声音,而且都落在同一个空间里,所以可以拿一段文字去搜视频片段,也可以拿一张图去搜相似的音频。
它长什么样
整个模型由几块拼起来,一个 270M 的文本主干(130M 的 Transformer 加 140M 的嵌入器),加上可选的视觉编码器 170M 和音频编码器 300M,全开是 740M。它是基于 Gemma 4 做的,和 Gemma 4 共用同一套文本分词器和音频编码器,所以两个模型可以拼在一个端侧流水线里跑,合起来的内存占用更省 [1][2]。

图 1 文本、图像、视频、音频分别编码后,对齐到同一个 768 维向量空间。
表 1 模型结构(来自官方模型卡)
| 项目 | 数值 |
|---|---|
| 总参数 | 740M |
| 文本主干 | 130M |
| 嵌入器(embedder) | 140M |
| 视觉编码器 | 170M |
| 音频编码器 | 300M |
| 层数 | 24 |
| 模型维度 | 512 |
| 隐层维度 | 2048 |
| 滑动窗口 | 1024 token |
| 词表大小 | 262,144 |
| 注意力 | GQA/MQA,4 头,KV 头 2/1,局部与全局比 5:1 |
| 池化 | 均值池化 |
| 投影 | 512 → 768 |
| 上下文窗口 | 8192 token |
| 原生输出维度 | 768 |
编码器可以按需加载,只用文本的时候把视觉和音频关掉,加载量就降到 270M:

图 2 只用文本、文本加图像、文本加音频、全模态四种配置下的有效参数量。
成绩怎么样
官方在文本、代码、图像、视觉文档、视频、音频几类基准上都给了分,见表 2 [1]。
表 2 各模态基准成绩(768 维)
| 模态 | 基准 | 指标 | EmbeddingGemma 1 | EmbeddingGemma 2 |
|---|---|---|---|---|
| 文本 | MTEB 多语言 v2 | Mean(Task) | 61.15 | 61.36 |
| 代码 | MTEB 代码 v1 | NDCG@10 | 68.76 | 78.68 |
| 图像 | MIEB lite | Mean(TaskType) | — | 64.64 |
| 图像 | MMEB v2 图像 | Hit@1 | — | 57.28 |
| 图像 | MMEB v2 视觉文档 | NDCG@5 | — | 67.84 |
| 视频 | MMEB v2 视频 | Hit@1 | — | 50.67 |
| 音频 | MSEB 检索 | MRR@10 | — | 69.54 |
| 音频 | MAEB | Mean(Task) | — | 49.39 |

图 3 各模态基准得分。
各家榜单的指标口径不一样,不能直接横着比,能看出来的主要是代码这一项,从上一代的 68.76 涨到 78.68,官方博客说提了 9.92 分,约 14% [2]。官方也强调,它是 10 亿参数以下多模态嵌入模型里最强的几档之一,部分项目上还能超过体积两倍多的专用模型。
一个很实用的设计:向量能截短
嵌入向量越短,占的存储越小,检索也越快,但质量会掉。EmbeddingGemma 2 用了 Matryoshka 表示学习(MRL),训练时就保证截断前面若干维仍然可用,支持 768、512、256、128 四档,最短的 128 维能把存储压到 1/6 [1]。
表 3 截断到不同维度的效果
| 输出维度 | 压缩比 | MTEB 多语言 | MTEB 英文 | MTEB 代码 | MIEB | MMEB | MSEB | MAEB |
|---|---|---|---|---|---|---|---|---|
| 768 维 | 1:1 | 61.36 | 68.46 | 78.68 | 64.64 | 59.01 | 69.54 | 49.39 |
| 512 维 | 1:1.5 | 61.17 | 68.41 | 77.24 | 64.32 | 58.38 | 69.18 | 49.21 |
| 256 维 | 1:3 | 60.41 | 67.78 | 76.18 | 63.13 | 56.24 | 66.76 | 48.91 |
| 128 维 | 1:6 | 57.89 | 65.68 | 71.41 | 59.06 | 45.65 | 56.71 | 46.92 |

图 4 以代码任务为例,向量越短分数越低,到 256 维基本还能接受。
截到 256 维,质量基本没怎么掉,适合省存储;128 维更省,但官方提示多模态任务掉得明显,得拿自己的数据先验一验 [1]。还有一点得留神:单位向量截短之后长度会变,必须重新做 L2 归一化,否则余弦相似度会悄悄算错,还不报错 [1]。
怎么用起来
官方给了 sentence-transformers 的最简例子,几行就能跑 [1]:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("google/embeddinggemma-2")
query = "What causes the northern lights?"
document = "The northern lights are caused by charged particles from the sun."
query_emb = model.encode(query, prompt_name="SearchQuery")
doc_emb = model.encode(document, prompt_name="Document")
print(model.similarity(query_emb, doc_emb))
上手之前有几条约定得先知道,不然分数会悄悄变低。
给文本加任务前缀,能明显提升质量。检索这类非对称任务,查询和文档用不同前缀;分类、聚类、相似度这类对称任务,所有输入用同一个前缀。文档有标题的话按 title: 标题 | text: 正文 拼,没标题就写 title: none [1]。
表 4 常用的任务前缀
| 用途 | 类型 | 前缀名 | 查询前缀 | 文档前缀 |
|---|---|---|---|---|
| 网页/文档搜索 | 非对称 | SearchQuery | task: search result / query: | title: {...} / text: {...} |
| 问答 | 非对称 | QuestionAnswering | task: question answering / query: | title: {...} / text: {...} |
| 事实核查 | 非对称 | FactChecking | task: fact checking / query: | title: {...} / text: {...} |
| 代码搜索 | 非对称 | CodeRetrieval | task: code retrieval / query: | title: {...} / text: {...} |
| 文本分类 | 对称 | Classification | task: classification / query: | 不适用 |
| 聚类 | 对称 | Clustering | task: clustering / query: | 不适用 |
| 相似度 | 对称 | SentenceSimilarity | task: sentence similarity / query: | 不适用 |
按需加载编码器能省内存,在 SentenceTransformer 里通过 config_kwargs 传 [1]:
表 5 打开不同模态时的加载量
| 启用的模态 | config_kwargs | 有效规模 |
|---|---|---|
| 仅文本 | {"vision_config": None, "audio_config": None} | 270M |
| 文本 + 图像 | {"audio_config": None} | 440M |
| 文本 + 音频 | {"vision_config": None} | 570M |
| 全模态 | {} | 740M |
数值精度用 bfloat16 或 float32,别用 float16。官方说这个模型的激活范围超出 float16 的动态范围,用 float16 会返回 NaN 或者悄悄退化的向量,而不是报错,很容易中招 [1]。
多模态也可以混着喂,一段输入里同时放文字、图片、视频、音频,用占位符 <|image|>、<|video|>、<|audio|> 标出位置,共用同一个 8192 token 的上下文 [1]。各模态消耗的 token 见表 6。
表 6 各模态的 token 预算
| 模态 | token 消耗 | 单模态上限 |
|---|---|---|
| 文本 | 1 token / 子词 | 8192 token |
| 图像 | 默认 280 token / 张 | 约 29 张 |
| 视频 | 默认 140 token / 帧 | 约 58 帧 |
| 音频 | 25 token / 秒 | 约 327 秒 |
在哪儿下载
权重在 Hugging Face、Kaggle 都能拿,国内可以在 ModelScope(魔搭社区)上找到同一份,路径是 google/embeddinggemma-2 [4]。推理和部署支持得也全:Ollama、llama.cpp(有 GGUF 量化版)、MLX、vLLM、SGLang、LM Studio 都能跑,向量库用 Qdrant,微调有 Unsloth 的教程 [2][7][8][9][10]。
端侧占用方面,官方给的数据是,在 Google Pixel 11 Pro 上,量化之后纯文本权重占约 191MB 内存,全模态约 567MB [2];想在浏览器里直接跑,可以看 Google AI Edge 的做法 [6]。官方还整理了一份开发者指南,从推理到微调都有 [11]。
局限和注意
EmbeddingGemma 2 属于嵌入模型,本身不生成文字,也没有做对齐和安全微调,安全主要靠预训练阶段的数据过滤。它输出的是向量,风险落在下游怎么用这些向量,检索过滤、公平性测试这些得自己负责,也要遵守 Gemma 的禁止用途政策 [1][12]。
训练数据决定了能力边界,官方也承认,100 多种语言之间的表现并不均衡;复杂、开放式的任务比较吃力;省略任务前缀会拉低质量;隐喻、讽刺这类细微语义也不容易处理 [1]。训练数据截止到 2025 年 1 月 [1]。
许可为 Apache 2.0,可以商用,具体条款见 [13]。
参考资料
[1] google/embeddinggemma-2 模型卡(Hugging Face) https://huggingface.co/google/embeddinggemma-2
[2] EmbeddingGemma 2: an open, lightweight multimodal embedding model(Google 博客,2026-10-06) https://blog.google/innovation-and-ai/technology/developers-tools/embeddinggemma-2
[3] EmbeddingGemma 文档(Google AI) https://ai.google.dev/gemma/docs/embeddinggemma
[4] ModelScope(魔搭)google/embeddinggemma-2 https://modelscope.cn/models/google/embeddinggemma-2
[5] Introducing EmbeddingGemma(v1,Google Developers Blog) https://developers.googleblog.com/en/introducing-embeddinggemma/
[6] Google AI Edge with EmbeddingGemma 2 https://developers.googleblog.com/google-ai-edge-with-embeddinggemma-2
[7] Ollama: embeddinggemma-2 https://ollama.com/library/embeddinggemma-2
[8] llama.cpp GGUF: ggml-org/embeddinggemma-2-GGUF https://huggingface.co/ggml-org/embeddinggemma-2-GGUF
[9] Unsloth: EmbeddingGemma 2 微调 https://unsloth.ai/docs/models/embeddinggemma-2
[10] Qdrant: EmbeddingGemma 2 https://qdrant.tech/blog/embeddinggemma-2/
[11] EmbeddingGemma 2: the developer guide https://developers.googleblog.com/en/embeddinggemma-2-the-developer-guide/
[12] Gemma Prohibited Use Policy https://ai.google.dev/gemma/prohibited_use_policy
[13] Gemma 4 License https://ai.google.dev/gemma/docs/gemma_4_license
以上数据来自 Google 官方模型卡、发布博客与文档,均为 2026 年 10 月的公开信息;模型与接口随时可能更新,请以官方页面为准。数据截至 2026 年 10 月 8 日。