Dhara.AI.Inference 0.2.0

dotnet add package Dhara.AI.Inference --version 0.2.0
                    
NuGet\Install-Package Dhara.AI.Inference -Version 0.2.0
                    
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="Dhara.AI.Inference" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dhara.AI.Inference" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Dhara.AI.Inference" />
                    
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 Dhara.AI.Inference --version 0.2.0
                    
#r "nuget: Dhara.AI.Inference, 0.2.0"
                    
#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 Dhara.AI.Inference@0.2.0
                    
#: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=Dhara.AI.Inference&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Dhara.AI.Inference&version=0.2.0
                    
Install as a Cake Tool

Dhara.AI.Inference

Low-level local inference primitives for Dhara.AI packages.

Dhara.AI.Inference is the ONNX and tokenizer layer behind the higher-level embedding APIs. It is useful when you want direct control over model paths, tokenization, ONNX Runtime session options, pooling, and normalization without taking a dependency on the convenience APIs in Dhara.AI.LocalEmbeddings.

What It Provides

  • OnnxTextEmbeddingModel for running BERT-style text embedding models from an ONNX file.
  • OnnxTextEmbeddingOptions for model paths, vocabulary paths, input/output names, pooling, normalization, and ONNX session customization.
  • BertEmbeddingTokenizer for vocabulary-based tokenization into input_ids, attention_mask, and token_type_ids.
  • EmbeddingMath for cosine similarity, mean pooling, and vector normalization.
  • EmbeddingPoolingMode for mean-pooling or CLS-token embedding extraction.

Basic Usage

using Dhara.AI.Inference;

var options = new OnnxTextEmbeddingOptions
{
    ModelPath = "LocalEmbeddingsModel/default/model.onnx",
    VocabularyPath = "LocalEmbeddingsModel/default/vocab.txt",
    ModelId = "default",
    PoolingMode = EmbeddingPoolingMode.Mean,
    NormalizeEmbeddings = true
};

using var model = new OnnxTextEmbeddingModel(options);
var vectors = model.Embed(
[
    "local embeddings for semantic search",
    "native AOT friendly inference in .NET"
]);

var score = EmbeddingMath.CosineSimilarity(vectors[0], vectors[1]);

Model Compatibility

The model is expected to accept BERT-style inputs such as input_ids and attention_mask. If the ONNX graph exposes token_type_ids, the runtime sends them automatically; if it does not, the runtime omits them. This keeps the runtime compatible with many sentence-transformer exports, including models that produce 384-dimensional or 768-dimensional vectors.

The runtime supports output tensors shaped as either:

  • [batch, dimensions] when the model already returns sentence embeddings.
  • [batch, sequence, dimensions] when the runtime should pool token embeddings.

Native AOT

The package is marked as AOT-compatible. Native AOT is validated by publishing an application that consumes the package, because AOT behavior is determined at the application boundary.

Most application code should start with Dhara.AI.LocalEmbeddings, which wraps this runtime with Microsoft.Extensions.AI, model acquisition, compact storage formats, and ranking helpers.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Dhara.AI.Inference:

Package Downloads
Dhara.AI.LocalEmbeddings

Microsoft.Extensions.AI local embedding generator with ONNX inference, compact embedding formats, and ranking helpers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 147 5/12/2026