{"id":44486859,"url":"https://github.com/elbruno/elbruno.localembeddings","last_synced_at":"2026-05-23T14:01:10.371Z","repository":{"id":338103701,"uuid":"1156600195","full_name":"elbruno/elbruno.localembeddings","owner":"elbruno","description":".NET library for local embedding generation using ONNX and Microsoft.Extensions.AI","archived":false,"fork":false,"pushed_at":"2026-05-20T15:46:24.000Z","size":62334,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-20T20:58:25.377Z","etag":null,"topics":["cosine-similarity","csharp","dependency-injection","dotnet","embeddings","huggingface","kernel-memory","local-ai","machine-learning","microsoft-extensions-ai","nuget","onnx","onnx-runtime","rag","semantic-search","text-embeddings","vector-embeddings"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elbruno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY_AUDIT_PHASE1.md","support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-12T20:46:25.000Z","updated_at":"2026-05-20T15:46:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbba7f2a-174c-48c1-a946-33378dfa41e2","html_url":"https://github.com/elbruno/elbruno.localembeddings","commit_stats":null,"previous_names":["elbruno/-elbruno.localembeddings"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/elbruno/elbruno.localembeddings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbruno%2Felbruno.localembeddings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbruno%2Felbruno.localembeddings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbruno%2Felbruno.localembeddings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbruno%2Felbruno.localembeddings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elbruno","download_url":"https://codeload.github.com/elbruno/elbruno.localembeddings/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbruno%2Felbruno.localembeddings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33398391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cosine-similarity","csharp","dependency-injection","dotnet","embeddings","huggingface","kernel-memory","local-ai","machine-learning","microsoft-extensions-ai","nuget","onnx","onnx-runtime","rag","semantic-search","text-embeddings","vector-embeddings"],"created_at":"2026-02-13T02:05:04.344Z","updated_at":"2026-05-23T14:01:10.332Z","avatar_url":"https://github.com/elbruno.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LocalEmbeddings\r\n\r\n[![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.svg?style=flat-square\u0026logo=nuget)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings)\r\n[![NuGet Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.svg?style=flat-square\u0026logo=nuget)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings)\r\n[![Build Status](https://github.com/elbruno/elbruno.localembeddings/actions/workflows/publish.yml/badge.svg)](https://github.com/elbruno/elbruno.localembeddings/actions/workflows/publish.yml)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)\r\n[![GitHub stars](https://img.shields.io/github/stars/elbruno/elbruno.localembeddings?style=social)](https://github.com/elbruno/elbruno.localembeddings)\r\n[![Twitter Follow](https://img.shields.io/twitter/follow/elbruno?style=social)](https://twitter.com/elbruno)\r\n\r\nA .NET library for generating text embeddings locally using ONNX Runtime and Microsoft.Extensions.AI abstractions — no external API calls required.\r\n\r\n## 🎥 Quick Overview\r\n\r\nNew to local embeddings? Watch this **[5-minute video](https://www.youtube.com/watch?v=0rRgSQWlVm8)** explaining the main goal of the library.\r\n\r\nWant to build RAG applications? Read this **[blog post about 3 RAG approaches in .NET](https://elbruno.com/2026/02/14/%f0%9f%a4%96-building-rag-in-net-with-local-embeddings-3-approaches-zero-cloud-calls/)** with local embeddings and zero cloud calls.\r\n\r\nInterested in **image embeddings**? Check out the **[YouTube video](https://www.youtube.com/watch?v=nVTropZJC88)** and **[blog post](https://elbruno.com/2026/02/16/%f0%9f%96%bc%ef%b8%8f-local-image-embeddings-in-net-clip-onnx/)** about local image embeddings with CLIP and ONNX.\r\n\r\n## Features\r\n\r\n- **Local Embedding Generation** — Run inference entirely on your machine using ONNX Runtime\r\n- **Microsoft.Extensions.AI Integration** — Implements `IEmbeddingGenerator\u003cstring, Embedding\u003cfloat\u003e\u003e`\r\n- **🦅 Harrier model support** — Microsoft Harrier-OSS-v1 (270M, 640-dim, 94+ languages, instruction-tuned) via `ElBruno.LocalEmbeddings.Harrier`\r\n- **Kernel Memory Integration** — Companion package `ElBruno.LocalEmbeddings.KernelMemory` provides a native `ITextEmbeddingGenerator` adapter for [Microsoft Kernel Memory](https://github.com/microsoft/kernel-memory)\r\n- **VectorData Integration** — Companion package `ElBruno.LocalEmbeddings.VectorData` adds DI helpers for `Microsoft.Extensions.VectorData` (`VectorStore` and typed collections)\r\n- **Built-in In-Memory Vector Store** — `ElBruno.LocalEmbeddings.VectorData` includes `InMemoryVectorStore` (no Semantic Kernel connector dependency required)\r\n- **HuggingFace Model Support** — Use popular sentence transformer models from HuggingFace Hub\r\n- **Automatic Model Caching** — Models are downloaded once and cached locally\r\n- **Dependency Injection Support** — First-class `IServiceCollection` integration\r\n- **Single-String Convenience API** — `GenerateAsync(\"text\")` and `GenerateEmbeddingAsync(\"text\")` — no array wrapping needed\r\n- **Similarity Helpers** — Cosine similarity, all-pairs `Similarity(...)` matrix, and one-line `FindClosestAsync(...)` semantic search\r\n- **Thread-Safe \u0026 Batched** — Concurrent generation and efficient multi-text processing\r\n\r\n## 📦 NuGet Packages\r\n\r\n| Package | Version | Downloads | Description |\r\n|---------|---------|-----------|-------------|\r\n| [ElBruno.LocalEmbeddings](https://www.nuget.org/packages/ElBruno.LocalEmbeddings) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings) | Core library — ONNX Runtime + Microsoft.Extensions.AI |\r\n| [ElBruno.LocalEmbeddings.Harrier](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Harrier) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.Harrier.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Harrier) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.Harrier.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Harrier) | Microsoft Harrier-OSS-v1 (270M, 640-dim, 94+ languages) |\r\n| [ElBruno.LocalEmbeddings.ImageEmbeddings](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.ImageEmbeddings.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.ImageEmbeddings.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings) | CLIP-based image embeddings for multimodal search |\r\n| [ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.ImageEmbeddings.Downloader) | Model downloader for image embeddings |\r\n| [ElBruno.LocalEmbeddings.KernelMemory](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.KernelMemory) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.KernelMemory.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.KernelMemory) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.KernelMemory.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.KernelMemory) | Microsoft Kernel Memory adapter |\r\n| [ElBruno.LocalEmbeddings.VectorData](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.VectorData) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.VectorData.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.VectorData) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.VectorData.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.VectorData) | Microsoft.Extensions.VectorData + InMemoryVectorStore |\r\n| [ElBruno.LocalEmbeddings.Npu](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.Npu.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.Npu.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu) | NPU-accelerated embeddings via DirectML |\r\n| [ElBruno.LocalEmbeddings.Npu.Intel](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Intel) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.Npu.Intel.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Intel) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.Npu.Intel.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Intel) | Intel Core Ultra NPU via OpenVINO |\r\n| [ElBruno.LocalEmbeddings.Npu.Qualcomm](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Qualcomm) | [![NuGet](https://img.shields.io/nuget/v/ElBruno.LocalEmbeddings.Npu.Qualcomm.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Qualcomm) | [![Downloads](https://img.shields.io/nuget/dt/ElBruno.LocalEmbeddings.Npu.Qualcomm.svg?style=flat-square)](https://www.nuget.org/packages/ElBruno.LocalEmbeddings.Npu.Qualcomm) | Qualcomm Snapdragon X NPU via QNN |\r\n\r\n## Installation\r\n\r\n```bash\r\ndotnet add package ElBruno.LocalEmbeddings\r\n```\r\n\r\nFor **Harrier model support**, install the companion package:\r\n\r\n```bash\r\ndotnet add package ElBruno.LocalEmbeddings.Harrier\r\n```\r\n\r\nFor **Kernel Memory** integration, also install:\r\n\r\n```bash\r\ndotnet add package ElBruno.LocalEmbeddings.KernelMemory\r\n```\r\n\r\nFor **VectorData** integration, install:\r\n\r\n```bash\r\ndotnet add package ElBruno.LocalEmbeddings.VectorData\r\n```\r\n\r\n## Quick Start\r\n\r\n### 1) Generate one embedding\r\n\r\n```csharp\r\nusing ElBruno.LocalEmbeddings;\r\n\r\nawait using var generator = await LocalEmbeddingGenerator.CreateAsync();\r\nvar embedding = await generator.GenerateEmbeddingAsync(\"Hello, world!\");\r\nConsole.WriteLine(embedding.Vector.Length); // 384\r\n```\r\n\r\n### 2) Generate embeddings for multiple texts\r\n\r\n```csharp\r\nvar inputs = new[] { \"first text\", \"second text\", \"third text\" };\r\nvar embeddings = await generator.GenerateAsync(inputs);\r\nConsole.WriteLine(embeddings.Count); // 3\r\n```\r\n\r\n### 3) Compare two texts with cosine similarity\r\n\r\n```csharp\r\nusing ElBruno.LocalEmbeddings.Extensions;\r\n\r\nvar pair = await generator.GenerateAsync([\"I love coding\", \"I enjoy programming\"]);\r\nvar score = pair[0].CosineSimilarity(pair[1]);\r\nConsole.WriteLine(score);\r\n```\r\n\r\n### 4) Semantic search in one line\r\n\r\n```csharp\r\nvar corpus = new[]\r\n{\r\n    \"Python for data science\",\r\n    \"JavaScript for web apps\",\r\n    \"Swift for iOS development\"\r\n};\r\n\r\nvar corpusEmbeddings = await generator.GenerateAsync(corpus);\r\nvar results = await generator.FindClosestAsync(\r\n    \"best language for websites\",\r\n    corpus,\r\n    corpusEmbeddings,\r\n    topK: 2,\r\n    minScore: 0.2f);\r\n\r\nforeach (var result in results)\r\n    Console.WriteLine($\"{result.Score:F3} - {result.Text}\");\r\n```\r\n\r\n### 5) Using Harrier model (higher quality, multilingual)\r\n\r\n```csharp\r\nusing ElBruno.LocalEmbeddings.Harrier;\r\n\r\nvar generator = await HarrierEmbeddingGenerator.CreateAsync();\r\nvar embedding = await generator.GenerateEmbeddingAsync(\"Hello, world!\");\r\nConsole.WriteLine($\"Dimensions: {embedding.Vector.Length}\"); // 640\r\n```\r\n\r\nFor custom models and runtime behavior, use the options-based constructor:\r\n`new LocalEmbeddingGenerator(new LocalEmbeddingsOptions { ... })`.\r\n\r\n\u003e **Note:** The synchronous constructor remains available for backward compatibility, but performs blocking initialization when downloads are needed.\r\n\r\nWant to go further? Read the [Getting Started guide](docs/getting-started.md) and the other docs in this repo for DI, configuration, VectorData, Kernel Memory, and full RAG examples.\r\n\r\nPrefer a containerized dev environment? See the Dev Container section in the [Contributing guide](docs/contributing.md#dev-container-vs-code).\r\n\r\n## Samples\r\n\r\nAll sample applications are located in `src/Samples/`. See the [samples README](src/Samples/README.md) for prerequisites and run instructions.\r\n\r\n| Sample | What It Shows |\r\n| ------ | ------------- |\r\n| [HelloWorldAltModel](src/Samples/HelloWorldAltModel) | Minimal hello world with `sentence-transformers/all-MiniLM-L12-v2` |\r\n| [ConsoleApp](src/Samples/ConsoleApp) | All the basics: single/batch embeddings, similarity, semantic search, DI |\r\n| [HarrierConsoleApp](src/Samples/HarrierConsoleApp) | Harrier embedding model usage and similarity search |\r\n| [RagChat](src/Samples/RagChat) | Embedding-only semantic search Q\u0026A using shared VectorData `InMemoryVectorStore` (no LLM needed) |\r\n| [RagOllama](src/Samples/RagOllama) | Full RAG with Ollama + phi4-mini + Kernel Memory |\r\n| [RagFoundryLocal](src/Samples/RagFoundryLocal) | Full RAG with Foundry Local + phi4-mini |\r\n| [ImageRagSimple](src/Samples/ImageRagSimple) | Minimal image RAG: index images → search by text |\r\n| [ImageRagChat](src/Samples/ImageRagChat) | Interactive image RAG chat with text and image-to-image search |\r\n\r\n## Configuration\r\n\r\n```csharp\r\nvar options = new LocalEmbeddingsOptions\r\n{\r\n    ModelName = \"sentence-transformers/all-MiniLM-L6-v2\",  // HuggingFace model\r\n    MaxSequenceLength = 512,                                // Max tokens\r\n    CacheDirectory = null,                                  // Auto-detect per platform\r\n    EnsureModelDownloaded = true,                           // Download if missing\r\n    NormalizeEmbeddings = false                              // L2 normalize vectors\r\n};\r\n```\r\n\r\nSee [Configuration docs](docs/configuration.md) for supported models, local model paths, and cache locations.\r\n\r\n### Common model options (with model cards)\r\n\r\nEstimated download sizes below are approximate and can vary by ONNX variant (fp32/int8) and tokenizer assets.\r\n\r\n- [`sentence-transformers/all-MiniLM-L6-v2` (default, ~90–100 MB)](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)\r\n- [`sentence-transformers/all-MiniLM-L12-v2` (~130–140 MB)](https://huggingface.co/sentence-transformers/all-MiniLM-L12-v2)\r\n- [`sentence-transformers/paraphrase-MiniLM-L6-v2` (~90–100 MB)](https://huggingface.co/sentence-transformers/paraphrase-MiniLM-L6-v2)\r\n- [`BAAI/bge-large-en-v1.5` (large, ~1.3 GB)](https://huggingface.co/BAAI/bge-large-en-v1.5)\r\n- [`intfloat/e5-large-v2` (large, ~1.3 GB)](https://huggingface.co/intfloat/e5-large-v2)\r\n\r\n## Documentation\r\n\r\n| Topic | Description |\r\n| ----- | ----------- |\r\n| [Getting Started](docs/getting-started.md) | Step-by-step guide from hello world to RAG |\r\n| [API Reference](docs/api-reference.md) | Classes, methods, and extension methods |\r\n| [Configuration](docs/configuration.md) | Options, supported models, cache locations |\r\n| [Alternative Models](docs/alternative-models.md) | Non-default free models, local download workflow, and license notes |\r\n| [Dependency Injection](docs/dependency-injection.md) | All DI overloads and `IConfiguration` binding |\r\n| [Harrier Integration](docs/harrier-integration.md) | Microsoft Harrier-OSS-v1 local embedding model |\r\n| [Kernel Memory Integration](docs/kernel-memory-integration.md) | Using local embeddings with Microsoft Kernel Memory |\r\n| [VectorData Integration](docs/vector-data-integration.md) | Using local embeddings with Microsoft.Extensions.VectorData abstractions |\r\n| [Contributing](docs/contributing.md) | Build from source, repo structure, guidelines |\r\n| [Roadmap](docs/plans/roadmap_260213_0803.md) | Planned and completed features/samples with priorities |\r\n| [Publishing](docs/publishing.md) | NuGet publishing with GitHub Actions + Trusted Publishing |\r\n| [Changelog](docs/changelog.md) | Versioned summary of notable changes |\r\n\r\nHave an idea for a new feature or sample? Please open an issue and share your suggestion.\r\n\r\n## Building from Source\r\n\r\n```bash\r\ngit clone https://github.com/elbruno/elbruno.localembeddings.git\r\ncd elbruno.localembeddings\r\ndotnet build\r\ndotnet test\r\n```\r\n\r\n## Requirements\r\n\r\n- .NET 10.0 SDK or later\r\n- ONNX Runtime compatible platform (Windows, Linux, macOS)\r\n\r\n## 👋 About the Author\r\n\r\nHi! I'm **ElBruno** 🧡, a passionate developer and content creator exploring AI, .NET, and modern development practices.\r\n\r\n**Made with ❤️ by [ElBruno](https://github.com/elbruno)**\r\n\r\nIf you like this project, consider following my work across platforms:\r\n\r\n- 📻 **Podcast**: [No Tienen Nombre](https://notienenombre.com) — Spanish-language episodes on AI, development, and tech culture\r\n- 💻 **Blog**: [ElBruno.com](https://elbruno.com) — Deep dives on embeddings, RAG, .NET, and local AI\r\n- 📺 **YouTube**: [youtube.com/elbruno](https://www.youtube.com/elbruno) — Demos, tutorials, and live coding\r\n- 🔗 **LinkedIn**: [@elbruno](https://www.linkedin.com/in/elbruno/) — Professional updates and insights\r\n- 𝕏 **Twitter**: [@elbruno](https://www.x.com/in/elbruno/) — Quick tips, releases, and tech news\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbruno%2Felbruno.localembeddings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felbruno%2Felbruno.localembeddings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbruno%2Felbruno.localembeddings/lists"}