embeddinggemma-2
Google DeepMind's embedder built on Gemma 4. The default embedding model in LM-Kit.
EmbeddingGemma 2 embeds text, code and images into one vector space, on your hardware. A sentence finds a photo; a photo finds a passage.
embeddinggemma-2Google DeepMind's embedder built on Gemma 4. The default embedding model in LM-Kit.
Every input lands in the same space, so any one can retrieve any other.
The same vector stores used by text RAG.
One model indexes your images and your documents. No captioning step, no second embedder to keep aligned.
01
Index photos, query with a sentence in any of 100+ languages. Matches come from meaning, not file names.
02
Find visually similar images at scale: near-duplicates, edited variants, products that look alike.
03
Passages, code and images share one index. A text question retrieves the diagram that answers it.
04
The Embedder class takes strings and images alike. One model loaded, one inference engine.
Three common jobs, one loaded model. Each vector is comparable with every other, whatever its source.
Embed a folder of photos once, then rank them against a plain-language query.
using LMKit.Model;
using LMKit.Embeddings;
using LMKit.Media.Image;
// One model, one vector space for text and images.
using LM model = LM.LoadFromModelID("embeddinggemma-2");
var embedder = new Embedder(model);
// Embed every photo once and keep the vectors.
var index = new List<(string Path, float[] Vector)>();
foreach (string path in Directory.EnumerateFiles("./photos", "*.jpg"))
{
using var image = ImageBuffer.LoadAsRGB(path);
index.Add((path, embedder.GetEmbeddings(image)));
}
// Query with a sentence, in any of 100+ languages.
float[] query = embedder.GetEmbeddings("forklift on a warehouse floor");
foreach (var hit in index
.OrderByDescending(e => Embedder.GetCosineSimilarity(query, e.Vector))
.Take(5))
{
Console.WriteLine(hit.Path);
}
Compare a new upload against the same index to surface near-duplicates and edited variants.
// Embed the new upload with the same model.
using var upload = ImageBuffer.LoadAsRGB("upload.jpg");
float[] probe = embedder.GetEmbeddings(upload);
// The closest vectors are the closest images.
var closest = index
.Select(e => (e.Path, Score: Embedder.GetCosineSimilarity(probe, e.Vector)))
.OrderByDescending(m => m.Score)
.Take(3);
foreach (var (path, score) in closest)
Console.WriteLine($"{score:F3} {path}");
Matryoshka training makes the first 512, 256 or 128 dimensions a valid embedding. Truncate, re-normalize, store less.
float[] full = embedder.GetEmbeddings(image); // 768 dimensions
float[] small = Normalize(full[..256]); // 3x smaller index
// Compare truncated vectors only with vectors truncated to the same size.
static float[] Normalize(float[] v)
{
float norm = MathF.Sqrt(v.Sum(x => x * x));
return v.Select(x => x / norm).ToArray();
}
Downloaded once from the model catalog, then runs offline on CPU or GPU.
embeddinggemma-2, Apache 2.0 licenseConfiguration.DefaultImageDetailAnywhere a library of pictures needs to be searched, grouped or checked against itself.
Product catalogs, stock photos, property listings. Text or image query, same index.
Consolidate media libraries. Spot re-uploads, copyright reuse and lightly edited variants.
Diagrams, scans and figures become retrieval targets beside the text around them.
Group large image sets without labels; cluster centroids become discovered categories.
Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.
Console demo: index a folder of images, query by image, rank by similarity.
Open on GitHub → SampleStep-by-step doc page: prerequisites, setup, code path, expected output.
Read on docs → How-to guideText-to-image and image-to-image retrieval, step by step.
Read the guide → How-to guideFoundational guide; image vectors plug into the same store.
Read the guide → API referenceAPI reference for the unified text and image embedder.
Open the reference →The seven pillars of LM-Kit.NET, plus the local runtime they share. Highlighted card is where you are now.
01 · AI Agents
ReAct planning, supervisors, parallel and pipeline orchestrators, persistent memory, MCP clients, custom tools.
AI Agents02 · Document Intelligence
PDF text and table extraction, on-device OCR with layout and table recovery, structured field extraction with grammar-constrained generation.
Document Intelligence03 · Vision & Multimodal
Image understanding, classification, labeling, multimodal chat, image embeddings, VLM-OCR, background removal. Same conversation surface as LLMs.
Vision & Multimodal04 · RAG & Knowledge
Built-in vector store, Qdrant and pgvector connectors, embeddings, hybrid retrieval, document chunking, source citations.
RAG & Knowledge05 · Text Analysis
Built-in classifiers and an extractor that emits typed C# objects via grammar-constrained sampling. Sentiment, keywords, language detection.
Text Analysis06 · Speech & Audio
A growing local speech-to-text stack: hallucination suppression, Voice Activity Detection, real-time translation, streaming output, 100+ languages.
Speech & Audio07 · Text Generation
Single-turn, multi-turn, and stateless conversation primitives. Translate, correct, rewrite, summarise. Prompt templates, streaming, grammar-constrained outputs.
Text GenerationThe foundation
Every capability above runs on this runtime.
Foundation
The runtime all seven pillars sit on. The LM-Kit.NET NuGet ships the complete inference system: open-weight LLMs, vision-language models, embeddings, on-device speech-to-text, OCR and classifiers, accelerated on CPU, AVX2, CUDA 12/13, Vulkan or Metal. One package, zero cloud calls, predictable latency, full data and technology sovereignty.