Vectantic.Semantic 1.0.0

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

πŸ“¦ Vectantic

A modern, high-performance .NET SDK for local text embeddings and semantic search β€” powered by ONNX, no external APIs required.


πŸš€ Why Vectantic?

Working with embeddings locally in .NET is complex β€” managing ONNX models, tokenization, pooling, and vector math is a lot of boilerplate.

Vectantic provides:

  • Local inference β€” runs entirely on your machine, no API keys, no data leaving your environment
  • Clean abstractions β€” simple IEmbeddingService and ISemanticSearchService interfaces
  • Built-in models β€” MiniLM-L6-v2 and BGE-Small-EN-v1.5 ready to use out of the box
  • Automatic model download β€” models fetched and cached on first use
  • Batching support β€” embed multiple texts in a single inference pass
  • Vector math utilities β€” dot product, cosine similarity, TopK search via Vectantic.Math
  • Modular architecture β€” Core, Semantic, Math as separate NuGet packages

⚑ Quick Start

Installation

dotnet add package Vectantic.Core
dotnet add package Vectantic.Semantic
dotnet add package Vectantic.Math

Registration

var coreOptions = new VectanticOptions {
    AccessToken = "hf_..."  // optional, recommended for better download reliability and necessary for private models
};

var semanticOptions = new SemanticOptions {
    Normalize = true
};

await services
    .AddVectanticSemantic(coreOptions, semanticOptions, VectanticPreset.MiniLML6V2)
    .EnsureModelAsync();

Note: EnsureModelAsync() downloads and caches the model on first run. Subsequent runs load from cache instantly.

Embedding Text

var embedder = provider.GetRequiredService<IEmbeddingService>();

// Single embedding
var embedding = await embedder.EmbedAsync("The quick brown fox");
Console.WriteLine($"Dimensions: {embedding.Dimensions}");
// β†’ Dimensions: 384

// Batch embedding
var embeddings = await embedder.EmbedBatchAsync([
    "The quick brown fox",
    "A lazy dog sat",
    "Neural networks are fascinating"
]);
Console.WriteLine($"Batch count: {embeddings.Count}");
// β†’ Batch count: 3
var search = provider.GetRequiredService<ISemanticSearchService>();

var documents = new List<string> {
    "The Eiffel Tower is located in Paris",
    "Machine learning powers modern AI",
    "The Amazon rainforest covers Brazil",
    "Deep learning uses neural networks",
    "The Louvre museum is in France"
};

var results = await search.SearchAsync(
    query: "artificial intelligence and neural networks",
    docs: documents,
    topK: 2);

foreach (var match in results.Matches)
    Console.WriteLine($"[{match.Score:F4}] {match.Text}");

// β†’ [0.6654] Deep learning uses neural networks
// β†’ [0.5518] Machine learning powers modern AI

Vector Math (Vectantic.Math)

var a = new float[] { 1f, 2f, 3f };
var b = new float[] { 4f, 5f, 6f };

var similarity = EmbeddingMath.CosineSimilarity(a, b);
var dot = EmbeddingMath.Dot(a, b);

EmbeddingMath.Normalize(a.AsSpan());

πŸ“¦ Packages

Package Description
Vectantic.Core Download infrastructure, Configuration, ONNX session, DI wiring
Vectantic.Semantic Embedding service, semantic search, tokenization, pooling, etc
Vectantic.Math Vector math utilities β€” dot product, cosine similarity, TopK

πŸ€– Built-in Models

Preset Model Dimensions Pooling
VectanticPreset.MiniLML6V2 all-MiniLM-L6-v2 384 Mean
VectanticPreset.BgeSmallEnV15 bge-small-en-v1.5 384 Mean

πŸ”§ Custom Presets

var customPreset = new PresetBuilder()
    .WithId("my-model")
    .WithModelUrl("https://huggingface.co/.../model.onnx")
    .WithChecksum("sha256_here")
    .ApplyLowerCase(true)
    .WithTokenTypeIds(true)
    .WithOutputTensorName("last_hidden_state")
    .WithTokenizerFiles([
        "https://huggingface.co/.../tokenizer.json",
        "https://huggingface.co/.../vocab.txt"
    ])
    .WithMaxTokens(512)
    .WithPoolingStrategy(PoolingStrategy.Mean)
    .WithTokenizationType(TokenizationType.WordPiece)
    .Build();

await services
    .AddVectanticSemantic(coreOptions, semanticOptions, customPreset)
    .EnsureModelAsync();

πŸ—ΊοΈ Next Steps

  • Additional built-in models
  • Multi-model support
  • GPU acceleration support
  • Vectantic.Api β€” REST API wrapper for non-.NET consumers (n8n, Python, etc.)
  • Vectantic.Generative β€” local LLM inference

🀝 Contributing

Contributions, issues and feature requests are welcome.


πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ™Œ Credits

Created and maintained by JSebas-11 (Sebastian Delgado) Built for developers who want powerful local AI without cloud dependencies.

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 was computed.  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
1.0.0 107 5/9/2026