EmbeddingGemma 2
is Google DeepMind's 740M-parameter
embedding model. It maps text in 100+ languages, code, images, video and audio, alone or mixed in one input,
into a single 768-dimensional space. Here the text encoder and the vision and audio towers are packaged as
one
CMF
file. It runs with
cortiq
, a Rust inference engine with no
Python and no ML framework, on Apple silicon (Metal) and on any CPU, from the command line or behind an
OpenAI-compatible
/v1/embeddings
server.
cargo install cortiq-cli
hf download infosave/EmbeddingGemma-2-cmf embeddinggemma-2-q8_2f.cmf --local-dir .
cortiq embed --model embeddinggemma-2-q8_2f.cmf --task SearchQuery "a red fox in the snow" --image fox.jpg
It prints the start of each unit-length vector and the cosine similarities between the inputs. Use cortiq
0.8.15 or later; prebuilt binaries for Linux, macOS and Windows are on the
releases page
. For a smaller download take
embeddinggemma-2-q4tp.cmf
(647 MB: text vectors identical to q8_2f, media slightly less exact), for the
original weights
embeddinggemma-2-bf16.cmf
(1.52 GB); see
Files
.
As a server:
cortiq serve embeddinggemma-2-q8_2f.cmf --host 127.0.0.1 --port 8080
# text with a task prompt, 256-dimension vectors
curl http://127.0.0.1:8080/v1/embeddings -H "Content-Type: application/json" \
-d '{"input": ["What causes the northern lights?"], "prompt_name": "SearchQuery", "dimensions": 256}'# an image and a spoken question
curl http://127.0.0.1:8080/v1/embeddings -H "Content-Type: application/json" -d @- <<EOF{"input": [{"image": "$PWD/fox.jpg"}, {"audio": "$PWD/question.wav"}], "dimensions": 256}EOF
A server bound to 127.0.0.1 reads local file paths. On any other address (the default is 0.0.0.0) media go as
data:
or
http(s)://
URLs.
Examples
Real output of
embeddinggemma-2-q8_2f.cmf
. The inputs are in the
examples/
folder of this repo, one JSONL file
per example: the queries first, then the candidates. Run from the folder that holds
examples/
:
cortiq embed
prints the cosine matrix of all inputs (up to 8); the tables show the query rows. Queries use the
prompts named below, documents and captions use
Document
, images and audio take no prompt. The pictures were
generated with cortiq (Qwen-Image-2.1, LTX-2.5), the speech synthesized with
piper
.
1. Multilingual search
(
search.jsonl
). Query
почему светится полярное сияние
("why
do the northern lights glow"),
SearchQuery
:
#
document
language
cosine
1
Northern lights: solar-wind particles make oxygen and nitrogen glow
en
0.761
2
Где увидеть северное сияние (where and when to see it)
ru
0.729
3
Sonnenzyklus und Polarlichter (auroras and the solar cycle)
de
0.668
4
Light and the body clock
en
0.656
5
La photosynthèse
fr
0.570
6
蓝鲸 (the blue whale)
zh
0.555
7
quicksort.py
code
0.526
2. Code search
(
code.jsonl
). Two queries,
CodeRetrieval
; the snippets carry their
file names as titles:
snippet
"wait until the user stops typing before calling a function"
audio: 10 clips, 0.3–35 s, 8–48 kHz, mono and stereo
0.99975
0.99566
0.9999992
text + image + audio in one input
0.99985
0.99910
1.000000
The video row compares the same decoded frames. Decoding the mp4 with ffmpeg instead of PyAV changes the pixels
slightly, which gives 0.9991 (q8_2f), 0.9981 (q4tp) and 0.9993 (bf16).
On the demo Space corpus
q4tp
returns the same first result as
bf16
for all 41 text queries, 31 captions of
images, videos and audio clips and 8 spoken questions at 768 dimensions, and for 7 of the 8 spoken questions at 256.
Speech moves the most: two spoken questions drop to 0.968 and 0.984 cosine against
bf16
(the first is
ru_baikal.wav
from the examples) and still find the same document. Plain
--quant q4tp
builds a different
file, with the text encoder at 4 bits (worst text cosine 0.969); this one was built with:
Text inputs take a short prefix that tells the model what the vector is for. Pass it by name:
--task
on the
command line,
prompt_name
in the API.
prompt_name
prefix
use for
SearchQuery
task: search result | query:
search queries
QuestionAnswering
task: question answering | query:
questions
FactChecking
task: fact checking | query:
claims to verify
CodeRetrieval
task: code retrieval | query:
natural-language queries for code
Document
title: none | text:
everything that is searched (
--title
/
"title"
fills in the title)
Classification
task: classification | query:
texts to classify
Clustering
task: clustering | query:
texts to cluster
SentenceSimilarity
task: sentence similarity | query:
pairwise similarity
The four query prompts pair with
Document
on the corpus side. The last three are symmetric: give every text
the same one.
cortiq embed --list-prompts
also shows the sentence-transformers aliases (
Retrieval-query
,
STS
, …). Images, video and audio take no prefix. A request-level prompt applies to text-only inputs, and an
input with media uses only a prompt given inside it.
Matryoshka dimensions
The first 512, 256 or 128 numbers of a vector are an embedding by themselves.
--dim
(CLI) or
dimensions
(API) returns the prefix, re-normalized to unit length:
dimensions
bytes per vector (float32)
MTEB multilingual
MMEB (image, video, documents)
768
3072
61.36
59.01
512
2048
61.17
58.38
256
1024
60.41
56.24
128
512
57.89
45.65
Scores are Google's, for the full-precision model. Queries and documents must use the same size. 128 is best
kept for text-only workloads.
--interleave
makes one vector of the text and its media: each
<|image|>
,
<|video|>
or
<|audio|>
takes
the next file of that kind. Every vector, whatever went in, is comparable with every other. A text query finds
images, a spoken question finds the documents that answer it, a photo finds its caption.
--jsonl inputs.jsonl
embeds many inputs in one run, each line a string or an object:
{"text":"What causes the northern lights?","prompt_name":"SearchQuery"}{"text":"Aurora borealis","prompt_name":"Document","title":"Northern lights"}{"image":"aurora.jpg","image_tokens":560}{"text":"Photo: <|image|> Narration: <|audio|>","image":"aurora.jpg","audio":"tour.wav"}
Add
--json
for OpenAI-style output or
--npy out.npy
for a float32 matrix.
In the API, an input is a string, an object like the JSONL lines above, or a list of OpenAI content parts. Media
go as
data:
URLs,
http(s)://
URLs or, when the server listens on localhost, file paths:
GET /v1/embeddings/prompts
lists the prompts and limits.
encoding_format: "base64"
is supported, so the
OpenAI SDKs work unchanged.
Formats.
Images: PNG, JPEG, WebP, GIF. Audio: WAV natively, anything else through
ffmpeg
; any sample rate
or channel count is mixed to mono 16 kHz. Video: anything
ffmpeg
decodes (it must be on
PATH
), a
.y4m
file, or a directory of frames.
Performance
embeddinggemma-2-q8_2f.cmf
, cortiq 0.8.15,
cortiq embed --repeat
, median of in-process runs:
hardware
backend
one query, ms
short texts, texts/s
long documents, tok/s
image (280 tokens), s
video (4 frames), s
audio (30 s), s
Mac mini M4 (24 GB)
Metal
15
232
3600
0.84
1.54
0.71
Mac mini M4 (24 GB)
CPU, 10 cores
28
128
2300
1.46
2.06
1.02
AMD EPYC 7H12, Linux (shared host)
CPU, 30 threads
51
43
1170
3.2
5.1
4.2
Texts go without a task prompt: one query is 8 tokens, short texts are 256 texts of 32 tokens in one call, long
documents 64 of 512 tokens. The image is 512×512, the video has 4 frames at 140 tokens each, and the audio
clip is 35 s long, cut at 30 s. The
bf16
file runs at about the same speed, except batches of text on the CPU,
which take about 1.3× longer. Memory: about 3.3 GB with all three towers loaded.
cortiq serve
batches concurrent requests into shared forward passes. On the M4 (Metal) it answers 59
single-text requests per second to one client and 185 to 64 concurrent clients; one request with 256 texts runs
at 233 texts per second. On the EPYC host (CPU) one request with 256 texts runs at 38 texts per second, and a
single text takes about 80 ms.
On Apple silicon the text and image encoders run on the GPU by default and the audio encoder on the CPU;
CMF_EGEMMA2_GPU=0
keeps everything on the CPU. On Linux and Windows everything runs on the CPU, except the
vision attention of images with 4096 or more patches (
--image-tokens
560 and 1120), which runs on the GPU when
one is present. The CPU path uses all cores but one (at most 32);
CMF_THREADS=N
sets the thread count.
Limits
One input holds at most 8192 tokens, shared by everything in it. Text is cut at that point; an input whose
media do not fit is rejected.
Each audio clip is cut at 30 seconds (750 tokens), as in the reference processor. For a longer recording,
pass 30-second pieces as several
<|audio|>
clips of one input.
Video uses the frames only: 1 per second, at most 32, spread evenly over longer clips. To include the
soundtrack, add it as audio to the same input.
cortiq convert
builds
bf16
,
f32
,
q8_2f
and
q4tp
files from the original checkpoint. It refuses
f16
, because the model's activations overflow half precision.
Verify the download
sha256sum -c embeddinggemma-2-q8_2f.cmf.sha256
cortiq verify embeddinggemma-2-q8_2f.cmf
cortiq info embeddinggemma-2-q8_2f.cmf
EmbeddingGemma 2
— модель эмбеддингов Google DeepMind на 740M
параметров. Она переводит текст на 100+ языках, код, изображения, видео и аудио, по отдельности или вперемешку в
одном входе, в общее пространство размерности 768. Здесь текстовый энкодер и башни зрения и звука собраны в один
файл
CMF
. Его запускает
cortiq
, движок на Rust без Python и
ML-фреймворков, на Apple silicon (Metal) и на любом CPU, из командной строки или как сервер с
OpenAI-совместимым
/v1/embeddings
.
Нужен cortiq 0.8.15 или новее; готовые сборки — на
странице релизов
. Сервер на 127.0.0.1 читает локальные файлы; на
другом адресе (по умолчанию 0.0.0.0) медиа передаются как
data:
- или
http(s)://
-URL. Файл поменьше —
embeddinggemma-2-q4tp.cmf
(647 МБ: текстовые векторы те же, что у q8_2f, медиа чуть менее точные), исходные
веса —
embeddinggemma-2-bf16.cmf
(1.52 ГБ); см.
Файлы
.
Примеры
Настоящий вывод
embeddinggemma-2-q8_2f.cmf
на файлах из папки
examples/
этого репозитория (подробные таблицы — в
английском разделе
):
матрицы 8 бит; нормы, проекционная голова и свёртки аудио точные
798 МБ
ec4192bf6cac…
0.99975
по умолчанию
embeddinggemma-2-q4tp.cmf
как q8_2f, но MLP зрения и feed-forward аудио 4 бита
647 МБ
714ac411236e…
0.99566
загрузка поменьше; текстовые векторы те же, что у q8_2f
embeddinggemma-2-bf16.cmf
исходные веса bf16 байт в байт
1.52 ГБ
96b481acd2cc…
0.9999992
точная копия
Худшее косинусное сходство с
google/embeddinggemma-2
в float32: q8_2f — текст 0.99978, изображения 0.99975,
видео 0.99982, аудио 0.99975, текст + изображение + аудио 0.99985; q4tp — 0.99978, 0.99741, 0.99862, 0.99566,
0.99910; bf16 — 1.000000 (аудио 0.9999992).
На корпусе демо-Space
q4tp
даёт тот же первый результат, что
bf16
, для всех 41 текстового запроса, 31 подписи к
картинкам, видео и аудио и 8 голосовых вопросов при 768 измерениях и для 7 из 8 голосовых вопросов при 256. Сильнее
всего сдвигается речь: у двух голосовых вопросов косинус с
bf16
падает до 0.968 и 0.984 (первый —
ru_baikal.wav
из примеров), но документ находится тот же. Простой
--quant q4tp
собирает другой файл, с 4-битным текстовым
энкодером (худший косинус текста 0.969); этот собран так:
Текст получает короткий префикс, который говорит модели, для чего вектор:
--task
в CLI,
prompt_name
в API.
Запросы:
SearchQuery
,
QuestionAnswering
,
FactChecking
,
CodeRetrieval
, а то, по чему ищут, —
Document
(
--title
/
"title"
подставляет заголовок). Симметричные задачи:
Classification
,
Clustering
,
SentenceSimilarity
, один и тот же промпт для всех текстов. Изображения, видео и аудио идут без префикса.
cortiq embed --list-prompts
показывает все имена.
Матрёшка
Первые 512, 256 или 128 чисел вектора — самостоятельный эмбеддинг:
--dim
/
dimensions
возвращает префикс,
заново нормированный. По данным Google, MTEB multilingual 61.36 / 61.17 / 60.41 / 57.89 и MMEB 59.01 / 58.38 /
56.24 / 45.65 при 768 / 512 / 256 / 128. 128 лучше оставлять для чисто текстовых задач.
Изображения, видео, аудио и смешанные входы
F=embeddinggemma-2-q8_2f.cmf
cortiq embed --model $F --image photo.jpg --image-tokens 560 # 70 | 140 | 280 | 560 | 1120
cortiq embed --model $F --video clip.mp4 # 1 кадр в секунду, не больше 32
cortiq embed --model $F --audio vopros.wav # речь или звуки
cortiq embed --model $F --interleave --image shoe.jpg "Кроссовки для бега: <|image|>"
--interleave
делает один вектор из текста и медиа: каждый
<|image|>
,
<|video|>
,
<|audio|>
берёт
следующий файл своего типа. Все векторы сравнимы между собой: текстовый запрос находит картинки, вопрос голосом —
документы с ответом. В API медиа передаются как
data:
-URL,
http(s)://
-URL или путь к файлу (если сервер слушает
localhost);
--jsonl
принимает пакет входов. Для видео и не-WAV аудио нужен
ffmpeg
в
PATH
.
Тексты без промпта задачи: запрос — 8 токенов, короткие тексты — 256 текстов по 32 токена одним вызовом, длинные —
64 по 512 токенов; изображение 512×512, видео из 4 кадров по 140 токенов, аудиоклип 35 с, обрезанный до 30 с.
Файл
bf16
работает примерно с той же скоростью, кроме пакетов текста на CPU: они в 1.3 раза медленнее. Памяти нужно около 3.3 ГБ со
всеми тремя башнями. Сервер объединяет параллельные запросы в общие проходы: на M4 (Metal) это 59 запросов по
одному тексту в секунду от одного клиента и 185 от 64 клиентов; один запрос с 256 текстами — 233 текста в секунду.
На хосте EPYC (CPU) один запрос с 256 текстами идёт со скоростью 38 текстов в секунду, один текст — около 80 мс.
На Apple silicon текстовый энкодер и зрение по умолчанию работают на GPU, аудио — на CPU;
CMF_EGEMMA2_GPU=0
оставляет всё на процессоре. На Linux и Windows всё считается на CPU, кроме внимания зрения для изображений с 4096
и более патчами (
--image-tokens
560 и 1120): оно идёт на видеокарте, если она есть. На CPU по
умолчанию заняты все ядра, кроме одного (не больше 32),
CMF_THREADS=N
задаёт число потоков.
Ограничения
Один вход — не больше 8192 токенов на всё содержимое. Текст обрезается, вход с медиа сверх лимита отклоняется.
Аудиоклип обрезается до 30 секунд, как в эталонном процессоре; длинную запись подавайте кусками по 30 с
несколькими
<|audio|>
в одном входе.
Видео — только кадры (1 в секунду, не больше 32); звуковую дорожку добавляйте в тот же вход как аудио.
cortiq convert
собирает
bf16
,
f32
,
q8_2f
и
q4tp
, но не
f16
: активации модели выходят за его диапазон.
EmbeddingGemma-2-cmf huggingface.co is an AI model on huggingface.co that provides EmbeddingGemma-2-cmf's model effect (), which can be used instantly with this infosave EmbeddingGemma-2-cmf model. huggingface.co supports a free trial of the EmbeddingGemma-2-cmf model, and also provides paid use of the EmbeddingGemma-2-cmf. Support call EmbeddingGemma-2-cmf model through api, including Node.js, Python, http.
EmbeddingGemma-2-cmf huggingface.co is an online trial and call api platform, which integrates EmbeddingGemma-2-cmf's modeling effects, including api services, and provides a free online trial of EmbeddingGemma-2-cmf, you can try EmbeddingGemma-2-cmf online for free by clicking the link below.
infosave EmbeddingGemma-2-cmf online free url in huggingface.co:
EmbeddingGemma-2-cmf is an open source model from GitHub that offers a free installation service, and any user can find EmbeddingGemma-2-cmf on GitHub to install. At the same time, huggingface.co provides the effect of EmbeddingGemma-2-cmf install, users can directly use EmbeddingGemma-2-cmf installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
EmbeddingGemma-2-cmf install url in huggingface.co: