lcarrere's picture
Merge the GGUF files (text encoder, Q8_0 and BF16 vision encoders) into the LMK repository
3ea3e57 verified
|
Raw History Blame Contribute Delete
2.85 kB
---
license: apache-2.0
base_model: google/embeddinggemma-2
pipeline_tag: feature-extraction
library_name: lm-kit
tags:
- embedding
- sentence-similarity
- multimodal-embedding
- lmk
- gguf
- lm-kit
language:
- multilingual
---
# EmbeddingGemma 2 (LMK) for LM-Kit.NET
An LM-Kit model archive of [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2), the
open multimodal embedding model from Google DeepMind, packaged for
[LM-Kit.NET](https://lm-kit.com). Text, code and images are embedded into one 768-dimensional vector
space (Matryoshka truncation to 512, 256 or 128 dimensions, re-normalized), with an 8,192-token
context.
| File | Content | Size |
|---|---|---|
| `embeddinggemma-2-Q5_K_M.lmk` | LM-Kit archive: the text encoder (Q5_K_M) and the vision encoder (Q8_0) in one file. This is what `LM.LoadFromModelID("embeddinggemma-2")` loads | 439 MB |
| `embeddinggemma-2-Q5_K_M.gguf` | Text encoder (270M parameters), Q5_K_M | 213 MB |
| `embeddinggemma-2-mmproj-vision-Q8_0.gguf` | Vision encoder (170M parameters), Q8_0, audio tower removed | 226 MB |
| `embeddinggemma-2-mmproj-vision-BF16.gguf` | Vision encoder, BF16 reference (full precision, for re-quantization) | 368 MB |
The archive's vision encoder reads only its header at load: its weights reach memory with the first image, so text-only use costs no vision memory. The GGUF files are the archive's contents, for runtimes that load GGUF directly.
## Usage
```csharp
using LMKit.Model;
using LMKit.Embeddings;
using LMKit.Media.Image;
// Text, code and images, in the same vector space
using LM model = LM.LoadFromModelID("embeddinggemma-2");
var embedder = new Embedder(model);
float[] query = embedder.GetQueryEmbeddings("waterproof running shoes");
float[] document = embedder.GetEmbeddings("Our trail shoe keeps your feet dry on wet rock.");
float[] image = embedder.GetEmbeddings(ImageBuffer.LoadAsRGB("shoe.jpg"));
```
LM-Kit.NET applies the model card's prompts by retrieval role (`task: search result | query: ` for
queries, `title: none | text: ` for documents), frames every input with `<bos>` and `<eos>` as the
publisher's tokenizer does, and sizes images with the model's own processor rule (280 soft tokens
by default, aspect ratio preserved, bicubic resampling).
## Conversion
Converted with LM-Kit's llama.cpp fork (upstream `convert_hf_to_gguf.py`, architecture
`gemma-embedding2`, projector `gemma4v`). Every text tokenizes to exactly the publisher's token
ids, and the vectors match the publisher's own pipeline (sentence-transformers) for text and
images.
## License
Apache 2.0, as the original model. See the
[Gemma 4 license](https://ai.google.dev/gemma/docs/gemma_4_license) and the
[original model card](https://huggingface.co/google/embeddinggemma-2).