Vectantic.Math
1.0.0
dotnet add package Vectantic.Math --version 1.0.0
NuGet\Install-Package Vectantic.Math -Version 1.0.0
<PackageReference Include="Vectantic.Math" Version="1.0.0" />
<PackageVersion Include="Vectantic.Math" Version="1.0.0" />
<PackageReference Include="Vectantic.Math" />
paket add Vectantic.Math --version 1.0.0
#r "nuget: Vectantic.Math, 1.0.0"
#:package Vectantic.Math@1.0.0
#addin nuget:?package=Vectantic.Math&version=1.0.0
#tool nuget:?package=Vectantic.Math&version=1.0.0
π¦ 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
Semantic Search
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 | Versions 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. |
-
net8.0
- System.Numerics.Tensors (>= 10.0.7)
-
net9.0
- System.Numerics.Tensors (>= 10.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Vectantic.Math:
| Package | Downloads |
|---|---|
|
Vectantic.Semantic
Semantic embedding and search module for the Vectantic SDK. Provides local text embeddings via ONNX, semantic search, BERT tokenization, mean and CLS pooling strategies, and built-in support for MiniLM-L6-v2 and BGE-Small-EN-v1.5 models. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 123 | 5/9/2026 |