ElBruno.LocalEmbeddings
1.0.8
See the version list below for details.
dotnet add package ElBruno.LocalEmbeddings --version 1.0.8
NuGet\Install-Package ElBruno.LocalEmbeddings -Version 1.0.8
<PackageReference Include="ElBruno.LocalEmbeddings" Version="1.0.8" />
<PackageVersion Include="ElBruno.LocalEmbeddings" Version="1.0.8" />
<PackageReference Include="ElBruno.LocalEmbeddings" />
paket add ElBruno.LocalEmbeddings --version 1.0.8
#r "nuget: ElBruno.LocalEmbeddings, 1.0.8"
#:package ElBruno.LocalEmbeddings@1.0.8
#addin nuget:?package=ElBruno.LocalEmbeddings&version=1.0.8
#tool nuget:?package=ElBruno.LocalEmbeddings&version=1.0.8
LocalEmbeddings
A .NET library for generating text embeddings locally using ONNX Runtime and Microsoft.Extensions.AI abstractions — no external API calls required.
Features
- Local Embedding Generation — Run inference entirely on your machine using ONNX Runtime
- Microsoft.Extensions.AI Integration — Implements
IEmbeddingGenerator<string, Embedding<float>> - Kernel Memory Integration — Companion package
ElBruno.LocalEmbeddings.KernelMemoryprovides a nativeITextEmbeddingGeneratoradapter for Microsoft Kernel Memory - VectorData Integration — Companion package
ElBruno.LocalEmbeddings.VectorDataadds DI helpers forMicrosoft.Extensions.VectorData(VectorStoreand typed collections) - HuggingFace Model Support — Use popular sentence transformer models from HuggingFace Hub
- Automatic Model Caching — Models are downloaded once and cached locally
- Dependency Injection Support — First-class
IServiceCollectionintegration - Single-String Convenience API —
GenerateAsync("text")andGenerateEmbeddingAsync("text")— no array wrapping needed - Similarity Helpers — Cosine similarity, all-pairs
Similarity(...)matrix, andFindClosest(...)for semantic search - Thread-Safe & Batched — Concurrent generation and efficient multi-text processing
Installation
dotnet add package ElBruno.LocalEmbeddings
For Kernel Memory integration, also install the companion package:
dotnet add package ElBruno.LocalEmbeddings.KernelMemory
For VectorData integration, install:
dotnet add package ElBruno.LocalEmbeddings.VectorData
Quick Start
using ElBruno.LocalEmbeddings;
// Create the generator (downloads model automatically on first run)
using var generator = new LocalEmbeddingGenerator();
// Generate a single embedding — no array wrapping needed
var embedding = await generator.GenerateEmbeddingAsync("Hello, world!");
Console.WriteLine($"Dimensions: {embedding.Vector.Length}"); // 384
// Or get the full result collection
var result = await generator.GenerateAsync("Hello, world!");
Console.WriteLine($"Embedding: [{string.Join(", ", result[0].Vector.ToArray().Take(3))}...]");
For custom models and runtime behavior, use the options-based constructor:
new LocalEmbeddingGenerator(new LocalEmbeddingsOptions { ... }).
Want to go further? See the Getting Started guide for a step-by-step walkthrough — from cosine similarity to semantic search, dependency injection, and full RAG with a local LLM.
Prefer a containerized dev environment? See the Dev Container section in the Contributing guide.
Samples
See the samples README for prerequisites and run instructions.
| Sample | What It Shows |
|---|---|
| HelloWorldAltModel | Minimal hello world with sentence-transformers/all-MiniLM-L12-v2 |
| ConsoleApp | All the basics: single/batch embeddings, similarity, semantic search, DI |
| RagChat | Embedding-only semantic search Q&A (no LLM needed) |
| RagOllama | Full RAG with Ollama + phi4-mini + Kernel Memory |
| RagFoundryLocal | Full RAG with Foundry Local + phi4-mini |
Configuration
var options = new LocalEmbeddingsOptions
{
ModelName = "sentence-transformers/all-MiniLM-L6-v2", // HuggingFace model
MaxSequenceLength = 512, // Max tokens
CacheDirectory = null, // Auto-detect per platform
EnsureModelDownloaded = true, // Download if missing
NormalizeEmbeddings = false // L2 normalize vectors
};
See Configuration docs for supported models, local model paths, and cache locations.
Documentation
| Topic | Description |
|---|---|
| Getting Started | Step-by-step guide from hello world to RAG |
| API Reference | Classes, methods, and extension methods |
| Configuration | Options, supported models, cache locations |
| Alternative Models | Non-default free models, local download workflow, and license notes |
| Dependency Injection | All DI overloads and IConfiguration binding |
| Kernel Memory Integration | Using local embeddings with Microsoft Kernel Memory |
| VectorData Integration | Using local embeddings with Microsoft.Extensions.VectorData abstractions |
| Contributing | Build from source, repo structure, guidelines |
| Publishing | NuGet publishing with GitHub Actions + Trusted Publishing |
Building from Source
git clone https://github.com/elbruno/elbruno.localembeddings.git
cd elbruno.localembeddings
dotnet build
dotnet test
Requirements
- .NET 10.0 SDK or later
- ONNX Runtime compatible platform (Windows, Linux, macOS)
License
This project is licensed under the MIT License — see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.AI.Abstractions (>= 10.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- Microsoft.ML.OnnxRuntime (>= 1.24.1)
- Microsoft.ML.Tokenizers (>= 2.0.0)
- System.Numerics.Tensors (>= 9.0.3)
-
net8.0
- Microsoft.Extensions.AI.Abstractions (>= 10.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.3)
- Microsoft.ML.OnnxRuntime (>= 1.24.1)
- Microsoft.ML.Tokenizers (>= 2.0.0)
- System.Numerics.Tensors (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.9-preview | 0 | 2/14/2026 |
| 1.0.8 | 0 | 2/14/2026 |
| 1.0.7 | 21 | 2/13/2026 |
| 1.0.6 | 25 | 2/13/2026 |
| 1.0.5 | 34 | 2/13/2026 |
| 1.0.4 | 32 | 2/13/2026 |
| 1.0.2 | 30 | 2/13/2026 |
| 1.0.1 | 29 | 2/13/2026 |
| 1.0.0 | 31 | 2/12/2026 |
| 0.5.0-preview | 29 | 2/12/2026 |