![]() |
VOOZH | about |
dotnet add package ElBruno.LocalEmbeddings.Npu --version 1.5.0
NuGet\Install-Package ElBruno.LocalEmbeddings.Npu -Version 1.5.0
<PackageReference Include="ElBruno.LocalEmbeddings.Npu" Version="1.5.0" />
<PackageVersion Include="ElBruno.LocalEmbeddings.Npu" Version="1.5.0" />Directory.Packages.props
<PackageReference Include="ElBruno.LocalEmbeddings.Npu" />Project file
paket add ElBruno.LocalEmbeddings.Npu --version 1.5.0
#r "nuget: ElBruno.LocalEmbeddings.Npu, 1.5.0"
#:package ElBruno.LocalEmbeddings.Npu@1.5.0
#addin nuget:?package=ElBruno.LocalEmbeddings.Npu&version=1.5.0Install as a Cake Addin
#tool nuget:?package=ElBruno.LocalEmbeddings.Npu&version=1.5.0Install as a Cake Tool
๐ NuGet
๐ NuGet Downloads
๐ Build Status
๐ GitHub stars
๐ Twitter Follow
A .NET library for generating text embeddings locally using ONNX Runtime and Microsoft.Extensions.AI abstractions โ no external API calls required.
New to local embeddings? Watch this 5-minute video explaining the main goal of the library.
Want to build RAG applications? Read this blog post about 3 RAG approaches in .NET with local embeddings and zero cloud calls.
Interested in image embeddings? Check out the YouTube video and blog post about local image embeddings with CLIP and ONNX.
IEmbeddingGenerator<string, Embedding<float>>ElBruno.LocalEmbeddings.HarrierElBruno.LocalEmbeddings.KernelMemory provides a native ITextEmbeddingGenerator adapter for Microsoft Kernel MemoryElBruno.LocalEmbeddings.VectorData adds DI helpers for Microsoft.Extensions.VectorData (VectorStore and typed collections)ElBruno.LocalEmbeddings.VectorData includes InMemoryVectorStore (no Semantic Kernel connector dependency required)IServiceCollection integrationGenerateAsync("text") and GenerateEmbeddingAsync("text") โ no array wrapping neededSimilarity(...) matrix, and one-line FindClosestAsync(...) semantic search| Package | Version | Downloads | Description |
|---|---|---|---|
| ElBruno.LocalEmbeddings | ๐ NuGet |
๐ Downloads |
Core library โ ONNX Runtime + Microsoft.Extensions.AI |
| ElBruno.LocalEmbeddings.Harrier | ๐ NuGet |
๐ Downloads |
Microsoft Harrier-OSS-v1 (270M, 640-dim, 94+ languages) |
| ElBruno.LocalEmbeddings.ImageEmbeddings | ๐ NuGet |
๐ Downloads |
CLIP-based image embeddings for multimodal search |
| ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader | ๐ NuGet |
๐ Downloads |
Model downloader for image embeddings |
| ElBruno.LocalEmbeddings.KernelMemory | ๐ NuGet |
๐ Downloads |
Microsoft Kernel Memory adapter |
| ElBruno.LocalEmbeddings.VectorData | ๐ NuGet |
๐ Downloads |
Microsoft.Extensions.VectorData + InMemoryVectorStore |
| ElBruno.LocalEmbeddings.Npu | ๐ NuGet |
๐ Downloads |
NPU-accelerated embeddings via DirectML |
| ElBruno.LocalEmbeddings.Npu.Intel | ๐ NuGet |
๐ Downloads |
Intel Core Ultra NPU via OpenVINO |
| ElBruno.LocalEmbeddings.Npu.Qualcomm | ๐ NuGet |
๐ Downloads |
Qualcomm Snapdragon X NPU via QNN |
dotnet add package ElBruno.LocalEmbeddings
For Harrier model support, install the companion package:
dotnet add package ElBruno.LocalEmbeddings.Harrier
For Kernel Memory integration, also install:
dotnet add package ElBruno.LocalEmbeddings.KernelMemory
For VectorData integration, install:
dotnet add package ElBruno.LocalEmbeddings.VectorData
using ElBruno.LocalEmbeddings;
await using var generator = await LocalEmbeddingGenerator.CreateAsync();
var embedding = await generator.GenerateEmbeddingAsync("Hello, world!");
Console.WriteLine(embedding.Vector.Length); // 384
var inputs = new[] { "first text", "second text", "third text" };
var embeddings = await generator.GenerateAsync(inputs);
Console.WriteLine(embeddings.Count); // 3
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);
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}");
using ElBruno.LocalEmbeddings.Harrier;
var generator = await HarrierEmbeddingGenerator.CreateAsync();
var embedding = await generator.GenerateEmbeddingAsync("Hello, world!");
Console.WriteLine($"Dimensions: {embedding.Vector.Length}"); // 640
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 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 .
All sample applications are located in src/Samples/. See the for prerequisites and run instructions.
| Sample | What It Shows |
|---|---|
Minimal hello world with sentence-transformers/all-MiniLM-L12-v2 |
|
| All the basics: single/batch embeddings, similarity, semantic search, DI | |
| Harrier embedding model usage and similarity search | |
Embedding-only semantic search Q&A using shared VectorData InMemoryVectorStore (no LLM needed) |
|
| Full RAG with Ollama + phi4-mini + Kernel Memory | |
| Full RAG with Foundry Local + phi4-mini | |
| Minimal image RAG: index images โ search by text | |
| Interactive image RAG chat with text and image-to-image search |
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 for supported models, local model paths, and cache locations.
Estimated download sizes below are approximate and can vary by ONNX variant (fp32/int8) and tokenizer assets.
sentence-transformers/all-MiniLM-L6-v2 (default, ~90โ100 MB)sentence-transformers/all-MiniLM-L12-v2 (~130โ140 MB)sentence-transformers/paraphrase-MiniLM-L6-v2 (~90โ100 MB)BAAI/bge-large-en-v1.5 (large, ~1.3 GB)intfloat/e5-large-v2 (large, ~1.3 GB)| Topic | Description |
|---|---|
| Step-by-step guide from hello world to RAG | |
| Classes, methods, and extension methods | |
| Options, supported models, cache locations | |
| Non-default free models, local download workflow, and license notes | |
All DI overloads and IConfiguration binding |
|
| Microsoft Harrier-OSS-v1 local embedding model | |
| Using local embeddings with Microsoft Kernel Memory | |
| Using local embeddings with Microsoft.Extensions.VectorData abstractions | |
| Build from source, repo structure, guidelines | |
| Planned and completed features/samples with priorities | |
| NuGet publishing with GitHub Actions + Trusted Publishing | |
| Versioned summary of notable changes |
Have an idea for a new feature or sample? Please open an issue and share your suggestion.
git clone https://github.com/elbruno/elbruno.localembeddings.git
cd elbruno.localembeddings
dotnet build
dotnet test
Hi! I'm ElBruno ๐งก, a passionate developer and content creator exploring AI, .NET, and modern development practices.
Made with โค๏ธ by ElBruno
If you like this project, consider following my work across platforms:
This project is licensed under the MIT License โ see the file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.