ElBruno.LocalEmbeddings.KernelMemory 1.0.11

dotnet add package ElBruno.LocalEmbeddings.KernelMemory --version 1.0.11
                    
NuGet\Install-Package ElBruno.LocalEmbeddings.KernelMemory -Version 1.0.11
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ElBruno.LocalEmbeddings.KernelMemory" Version="1.0.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ElBruno.LocalEmbeddings.KernelMemory" Version="1.0.11" />
                    
Directory.Packages.props
<PackageReference Include="ElBruno.LocalEmbeddings.KernelMemory" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ElBruno.LocalEmbeddings.KernelMemory --version 1.0.11
                    
#r "nuget: ElBruno.LocalEmbeddings.KernelMemory, 1.0.11"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ElBruno.LocalEmbeddings.KernelMemory@1.0.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ElBruno.LocalEmbeddings.KernelMemory&version=1.0.11
                    
Install as a Cake Addin
#tool nuget:?package=ElBruno.LocalEmbeddings.KernelMemory&version=1.0.11
                    
Install as a Cake Tool

LocalEmbeddings

NuGet License: MIT

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.KernelMemory provides a native ITextEmbeddingGenerator adapter for Microsoft Kernel Memory
  • VectorData Integration — Companion package ElBruno.LocalEmbeddings.VectorData adds DI helpers for Microsoft.Extensions.VectorData (VectorStore and typed collections)
  • Built-in In-Memory Vector StoreElBruno.LocalEmbeddings.VectorData includes InMemoryVectorStore (no Semantic Kernel connector dependency required)
  • 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 IServiceCollection integration
  • Single-String Convenience APIGenerateAsync("text") and GenerateEmbeddingAsync("text") — no array wrapping needed
  • Similarity Helpers — Cosine similarity, all-pairs Similarity(...) matrix, and one-line FindClosestAsync(...) 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

1) Generate one embedding

using ElBruno.LocalEmbeddings;

await using var generator = await LocalEmbeddingGenerator.CreateAsync();
var embedding = await generator.GenerateEmbeddingAsync("Hello, world!");
Console.WriteLine(embedding.Vector.Length); // 384

2) Generate embeddings for multiple texts

var inputs = new[] { "first text", "second text", "third text" };
var embeddings = await generator.GenerateAsync(inputs);
Console.WriteLine(embeddings.Count); // 3

3) Compare two texts with cosine similarity

using ElBruno.LocalEmbeddings.Extensions;

var pair = await generator.GenerateAsync(["I love coding", "I enjoy programming"]);
var score = pair[0].CosineSimilarity(pair[1]);
Console.WriteLine(score);

4) Semantic search in one line

var corpus = new[]
{
    "Python for data science",
    "JavaScript for web apps",
    "Swift for iOS development"
};

var corpusEmbeddings = await generator.GenerateAsync(corpus);
var results = await generator.FindClosestAsync(
    "best language for websites",
    corpus,
    corpusEmbeddings,
    topK: 2,
    minScore: 0.2f);

foreach (var result in results)
    Console.WriteLine($"{result.Score:F3} - {result.Text}");

For custom models and runtime behavior, use the options-based constructor: new LocalEmbeddingGenerator(new LocalEmbeddingsOptions { ... }).

Note: The synchronous constructor remains available for backward compatibility, but performs blocking initialization when downloads are needed.

Want to go further? Read the Getting Started guide and the other docs in this repo for DI, configuration, VectorData, Kernel Memory, and full RAG examples.

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 using shared VectorData InMemoryVectorStore (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.

Common model options (with model cards)

Estimated download sizes below are approximate and can vary by ONNX variant (fp32/int8) and tokenizer assets.

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
Roadmap Planned and completed features/samples with priorities
Publishing NuGet publishing with GitHub Actions + Trusted Publishing
Changelog Versioned summary of notable changes

Have an idea for a new feature or sample? Please open an issue and share your suggestion.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.11 23 2/14/2026
1.0.10 29 2/14/2026
1.0.9-preview 29 2/14/2026