EmbeddingGemma.SemanticKernel 1.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package EmbeddingGemma.SemanticKernel --version 1.0.1
                    
NuGet\Install-Package EmbeddingGemma.SemanticKernel -Version 1.0.1
                    
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="EmbeddingGemma.SemanticKernel" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EmbeddingGemma.SemanticKernel" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="EmbeddingGemma.SemanticKernel" />
                    
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 EmbeddingGemma.SemanticKernel --version 1.0.1
                    
#r "nuget: EmbeddingGemma.SemanticKernel, 1.0.1"
                    
#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 EmbeddingGemma.SemanticKernel@1.0.1
                    
#: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=EmbeddingGemma.SemanticKernel&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=EmbeddingGemma.SemanticKernel&version=1.0.1
                    
Install as a Cake Tool

EmbeddingGemma.NET

NuGet Version NuGet Downloads

EmbeddingGemma

EmbeddingGemma.NET provides .NET bindings for Google DeepMind's EmbeddingGemma-300m model, enabling fully local, offline text embedding with no API key, no cloud dependency, and no data egress.

Two NuGet packages are available: one for general .NET applications and one for Microsoft Semantic Kernel.


Why EmbeddingGemma?

No runtime cost Runs on-device, no API calls or external services required
Privacy first All inference is performed locally; no data leaves the machine
Top-class accuracy GemmaEmbedding is the top #1 ranked among open multilingual embedding models under 500M parameters on MTEB
High efficiency Be able to run on low-end devices without GPU and with as little as 4 GB of RAM, making it ideal for a wide range of applications and users
Multilingual Supports 100+ languages out of the box
Task-aware embeddings 15 built-in task types automatically apply the correct prompt prefix


Installation

Package Target scenario
EmbeddingGemma.Core General .NET / ASP.NET Core applications
EmbeddingGemma.SemanticKernel Microsoft Semantic Kernel integration

Model Setup

The ONNX model and tokenizer files must be present on disk before the service can be used. They are hosted at onnx-community/embeddinggemma-300m-ONNX on Hugging Face.

Run the included script once from the repository root. It downloads all required files into a .embedding_resources folder by default; pass -OutputPath to use a different location.

.\Initialize-Embedding-Resources.ps1

Option B — Manual download

Manually download the following files and place them in the same directory:

File Download link Size
model.onnx onnx/model.onnx ~480 KB
model.onnx_data onnx/model.onnx_data ~1.23 GB
tokenizer.json tokenizer.json ~20 MB
tokenizer.model tokenizer.model ~4.7 MB
tokenizer_config.json tokenizer_config.json ~1.2 MB

The resulting directory must have the following structure:

<model-directory>/
├── model.onnx
├── model.onnx_data
├── tokenizer.json
├── tokenizer.model
└── tokenizer_config.json

Usage

Dependency Registration

EmbeddingGemma.Core via IServiceCollection

using EmbeddingGemma.Core;

// Registers IEmbeddingGenerator<string, Embedding<float>> as a singleton.
builder.Services.AddGemmaTextEmbeddingGenerator(options => options.ModelDirectory = @"C:\path\to\model-directory");

EmbeddingGemma.SemanticKernel via IKernelBuilder

using EmbeddingGemma.SemanticKernel;
using Microsoft.SemanticKernel;

var builder = Kernel.CreateBuilder();

builder.AddGemmaTextEmbeddingGenerator(options => options.ModelDirectory = @"C:\path\to\model-directory");

var kernel = builder.Build();

Generating Embeddings

Resolve IEmbeddingGenerator<string, Embedding<float>> from the DI container and call GenerateAsync.

using Microsoft.Extensions.AI;

var generator = serviceProvider.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>();

// Without a task type — no prompt prefix is added.
var embeddings = await generator.GenerateAsync(["Hello, world!"]);

// With a task type — the appropriate prompt prefix is applied automatically.
var options = new EmbeddingGemmaGenerationOptions 
{ 
    TaskType = EmbeddingGemmaTaskType.RetrievalQuery 
};
var queryEmbeddings = await generator.GenerateAsync(["What is semantic search?"], options);

For document embeddings, supply an optional DocumentTitle to improve retrieval quality:

var docOptions = new EmbeddingGemmaGenerationOptions
{
    TaskType = EmbeddingGemmaTaskType.RetrievalDocument,
    DocumentTitle = "Introduction to Semantic Search"
};

var docEmbeddings = await generator.GenerateAsync(["Semantic search ranks results by meaning..."], docOptions);

Task Types

Set EmbeddingGemmaGenerationOptions.TaskType to have the service automatically prepend the correct prompt prefix for your scenario. When TaskType is null, no prefix is added.

EmbeddingGemmaTaskType Intended use
RetrievalQuery User-supplied search queries
RetrievalDocument Documents or passages being indexed
Query / Retrieval General-purpose retrieval
QuestionAnswering Questions in a QA pipeline
FactVerification Claims requiring evidence lookup
Classification / MultilabelClassification Sentiment, spam detection, labelling
Clustering Grouping documents by topic
SentenceSimilarity / PairClassification Direct text-to-text similarity comparison
Summarization Texts intended for summarization
InstructionRetrieval Natural-language-to-code retrieval
Reranking Re-scoring a candidate result set
BitextMining Parallel sentence alignment across languages

For detailed guidance on prompt formatting, refer to:

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 is compatible.  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