Embedder
One class, one constructor, one method (with overloads).
Turn any text passage, image, or document into a dense vector
that captures meaning. Embedder is the unified API
used by every search, RAG, classification, and clustering
workflow in LM-Kit.NET. Runs entirely on-device with any
embedding model in the catalog.
EmbedderOne class, one constructor, one method (with overloads).
VectorOperationsCosine, dot, Euclidean similarity plus normalisation utilities.
float[] & float[][]Plain arrays. Drop directly into any vector store or do raw vector math.
01 · Unified
embeddinggemma-2 takes strings and images alike; any other catalog embedder loads the same way. Same Embedder constructor, same GetEmbeddings call.
02 · Batched
Overloads accept a single string, an IEnumerable<string>, pre-tokenised arrays, or ImageBuffer sequences for images. Throughput scales linearly with batch size on GPU.
03 · Async-first
GetEmbeddingsAsync + cancellationEvery overload has an async sibling. Pass a CancellationToken, get back a Task. Wire straight into server pipelines without blocking the request thread.
04 · Cross-modal
embeddinggemma-2 embeds text and images into one space. A text query retrieves images, an image query retrieves passages. One vector store, two modalities.
05 · Multilingual
bge-m3bge-m3 embeds across 100+ languages in one model. Index in mixed-language corpora, query in any language, retrieve cross-lingually without per-language pipelines.
06 · Plug-in stores
In-memory, FileSystemVectorStore, Qdrant or pgvector via connector, or a custom IVectorStore implementation. float[] in, similarity hits out. No vendor lock-in.
Single, batch, and cross-modal. Pick a tab for the pattern you need.
The simplest pattern. One model, one call, one vector. The
EmbeddingSize property tells you the dimension
ahead of time so you can size your vector store correctly.
using LMKit.Model; using LMKit.Embeddings; var model = LM.LoadFromModelID("embeddinggemma-2"); var embedder = new Embedder(model); float[] vec = embedder.GetEmbeddings("Machine learning is fascinating."); Console.WriteLine($"dimensions: {vec.Length} (matches embedder.EmbeddingSize = {embedder.EmbeddingSize})");
Batch inputs in one call for throughput. Combine with
VectorOperations.CosineSimilarity for duplicate
detection, semantic deduplication, or clustering.
var texts = new[] { "The cat sat on the mat.", "A feline rested on the rug.", "Stock market closed higher.", }; // One call, three vectors. GPU batches them efficiently. float[][] vecs = embedder.GetEmbeddings(texts); // 0 and 1 are semantically close; 2 is far away. float simCatRug = VectorOperations.CosineSimilarity(vecs[0], vecs[1]); float simCatStock = VectorOperations.CosineSimilarity(vecs[0], vecs[2]); Console.WriteLine($"cat ~ rug: {simCatRug:F3}"); Console.WriteLine($"cat ~ stock: {simCatStock:F3}");
embeddinggemma-2 embeds text and images into one
vector space. Embed once, query both modalities, retrieve
cross-modally without two separate pipelines.
using LMKit.Media.Image; // One model for text and images. var embedder = new Embedder(LM.LoadFromModelID("embeddinggemma-2")); // Index images. var index = new List<(string Path, float[] Vector)>(); foreach (var path in Directory.EnumerateFiles("./photos", "*.jpg")) { using var image = ImageBuffer.LoadAsRGB(path); index.Add((path, embedder.GetEmbeddings(image))); } // Query with TEXT. Retrieves IMAGE results. float[] query = embedder.GetEmbeddings("sunset over the ocean"); var hits = index .OrderByDescending(e => Embedder.GetCosineSimilarity(query, e.Vector)) .Take(5);
Default · Text + vision
embeddinggemma-2Google's embedder on Gemma 4: text, code and images in one 768-d space, 100+ languages, 8K context, Matryoshka truncation.
Text
harrier-oss:0.6bMicrosoft's compact multilingual embedder. 1024-dimensional instruction-aware vectors, 32K context, 90+ languages, in a ~360 MB footprint.
Multilingual
bge-m3100+ languages in one model. Dense AND sparse output (so it can drive lexical-style retrieval too). The default choice for international corpora.
Text
qwen3-embedding:0.6b / 4b / 8bQwen3 embedding family across three sizes. Choose based on accuracy / memory trade-off; same API.
Lightweight vision
nomic-embed-vision + nomic-embed-textA smaller aligned pair: a 97 MB image encoder beside its matching text embedder, for tight memory budgets.
Bring your own
If a model is in GGUF format, LM.LoadFromFile handles it. The Embedder wrapper works the same way.
Generating vectors is half the work. The rest of the stack handles storage, retrieval, expansion, reranking, and grounded generation.
Storage
Built-in FileSystemVectorStore, Qdrant and pgvector connectors, or a custom IVectorStore. Same vectors, four deployment shapes.
Recall
HyDE, MultiQuery, contextualisation. When the user's wording is far from the corpus, these techniques pull it back.
Query expansionPrecision
A second-pass model reorders the top-k from any retriever. Often the difference between mediocre and excellent results.
RerankerGeneration
Wrap the full pipeline into DocumentRag and answer with citations.
Lexical companion
Layout-aware exact / regex / fuzzy search with bounding boxes. Pair lexical and semantic for hybrid workflows.
Document SearchOutside RAG
Same Embedder powers classification, clustering, semantic deduplication, and anomaly detection. The Text Analysis page covers those patterns.
Text Analysis use casesWorking 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: embed a query and corpus, rank by cosine similarity. Minimal embedding pipeline.
Open on GitHub → SampleStep-by-step doc page: prerequisites, setup, code path, expected output.
Read on docs → DemoConsole demo: ingest, embed, retrieve, ground answers with citations.
Open on GitHub → DemoConsole demo: cross-modal embeddings + retrieval with reranking.
Open on GitHub → SampleStep-by-step doc page: prerequisites, setup, code path, expected output.
Read on docs → How-to guideIndex, embed, query by meaning, rerank.
Read the guide → API referenceAPI reference for the unified text + 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.