dotnet-ai-embeddings

Integrate and benchmark .NET embedding models across local GGUF, ONNX, and OpenAI-compatible backends.

2|Updated Aug 2, 2026
One-click install
npx skills add https://github.com/Arasz/ai-raccoon --skill dotnet-ai-embeddings-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-ai-embeddings
Source: https://github.com/Arasz/ai-raccoon/tree/main/.ai-badger/skills/learned/uncategorized/dotnet-ai-embeddings
Command: npx skills add https://github.com/Arasz/ai-raccoon --skill dotnet-ai-embeddings-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Integrating embedding models into a .NET application involves undocumented API traps, broken library paths, and benchmarks that fail to discriminate between models. This Skill captures verified, end-to-end-tested knowledge for wiring LLamaSharp, LM Studio, and ONNX Runtime behind Microsoft.Extensions.AI's IEmbeddingGenerator, plus how to build retrieval benchmarks that actually rank models. ## Core Features & Use Cases - Backend integration recipes: Working code paths for local GGUF via LLamaSharp (including the 0.27 embedder bug workaround), LM Studio via the plain OpenAI SDK, and an in-process ONNX Runtime MiniLM engine with mean-pooling and L2 normalization. - Retrieval benchmarking methodology: Guidance on building real-world corpora with honest ground truth, computing Recall@k, MRR, and nDCG, and avoiding synthetic-corpus metric ceilings. - Storage and tokenization: sqlite-vec vec0 blob formats and trigger sync, FTS5 hybrid search, and Microsoft.ML.Tokenizers 2.0 token counting for RAG chunking. - Use Case: You need to decide whether a small local embedding model is good enough for your .NET memory store. Use this Skill to wire three backends behind one interface, run a real-world benchmark, and present a size/quality/speed verdict. ## Quick Start Use the dotnet-ai-embeddings skill to wire a local ONNX MiniLM embedding engine behind IEmbeddingGenerator and benchmark it against an LM Studio model.

Frequently Asked Questions about dotnet-ai-embeddings

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate embedding models into a .NET application?

Use Microsoft.Extensions.AI's IEmbeddingGenerator<string, Embedding<float>> as the common seam for every backend. Wire LLamaSharp for local GGUF files, the OpenAI SDK with a custom endpoint for LM Studio, or ONNX Runtime for an in-process MiniLM engine.

How do I benchmark embedding model retrieval quality in .NET?

Build a real-world corpus from actual project documents with verified relevance judgments, then compute Recall@k, MRR, and nDCG with a hand-rolled evaluator. Synthetic corpora hit metric ceilings and cannot discriminate between models.

Why does LLamaSharp GenerateAsync throw ObjectDisposedException?

LLamaSharp 0.27's IEmbeddingGenerator implementation reads a disposed context handle on the first call. The workaround is calling LLamaEmbedder.GetEmbeddings directly with PoolingType.Mean and wrapping it in a small adapter class.

Can I use LM Studio as an embedding backend with the OpenAI SDK?

Yes, use the plain OpenAI package with OpenAIClientOptions.Endpoint pointing at your LM Studio /v1 URL and any placeholder API key. The Azure.AI.OpenAI client returned zero embeddings against LM Studio, so avoid it.

Does Microsoft.Extensions.AI.Evaluation work for retrieval benchmarking?

No, those libraries are LLM-as-judge text-quality evaluators for chat responses and compute no Recall@k, MRR, or nDCG. For ranked retrieval benchmarks, implement the standard IR metrics yourself for deterministic, CI-friendly results.

How do I store embedding vectors in SQLite with sqlite-vec?

Serialize floats as little-endian float32 blobs matching the declared vec0 dimension, and keep the vec0 table in sync with your entries table using delete-then-insert triggers since vec0 has no triggers of its own.