net10.0
A lightweight, zero-configuration semantic reranker for .NET. Supports multiple cross-encoder models with automatic download, GPU acceleration, and HuggingFace caching.
Published
Mar 9, 2026
7mo ago
Total Downloads
24.4K
24,402
Install
dotnet add package LMSupply.Reranker --version 0.22.2
| Product | Versions |
|---|---|
| .NET |
README
LMSupply.Reranker
Local semantic reranking for .NET with cross-encoder models.
Features
- Zero-config: Models download automatically from HuggingFace
- GPU Acceleration: CUDA, DirectML (Windows), CoreML (macOS)
- Cross-platform: Windows, Linux, macOS
- RAG Integration: Perfect for improving retrieval quality
- Multi-Tokenizer Support: Automatic detection of WordPiece, Unigram, BPE tokenizers
Quick Start
using LMSupply.Reranker;
// Load the default model
await using var reranker = await LocalReranker.LoadAsync("default");
// Rerank documents
var results = await reranker.RerankAsync(
query: "What is machine learning?",
documents: ["ML is a branch of AI...", "The weather is nice..."],
topK: 5);
foreach (var result in results)
Console.WriteLine($"{result.Index}: {result.Score:F3}");
Available Models
| Alias | Model | Size | Tokenizer | Description |
|---|---|---|---|---|
default |
MS MARCO MiniLM L6 | ~90MB | WordPiece | Best speed/quality balance |
fast |
MS MARCO TinyBERT | ~18MB | WordPiece | Ultra-fast, latency-critical |
quality |
BGE Reranker Base | ~440MB | Unigram | Higher accuracy, multilingual |
large |
BGE Reranker Large | ~1.1GB | Unigram | Highest accuracy |
multilingual |
BGE Reranker v2-m3 | ~1.1GB | Unigram | 8K context, 100+ languages |
Tokenizer Auto-Detection
The reranker automatically detects the correct tokenizer type:
| Type | Detection | Example Models |
|---|---|---|
| WordPiece | vocab.txt |
MS MARCO MiniLM, TinyBERT |
| Unigram | tokenizer.json (type: Unigram) |
bge-reranker-base, XLM-RoBERTa |
| BPE | tokenizer.json (type: BPE) |
Some multilingual models |
This ensures compatibility with virtually any cross-encoder model from HuggingFace.
GPU Acceleration
# NVIDIA GPU
dotnet add package Microsoft.ML.OnnxRuntime.Gpu
# Windows (AMD/Intel/NVIDIA)
dotnet add package Microsoft.ML.OnnxRuntime.DirectML
Configuration
var options = new RerankerOptions
{
Provider = ExecutionProvider.Auto, // GPU auto-detection
MaxSequenceLength = 512,
BatchSize = 32
};
var reranker = await LocalReranker.LoadAsync("default", options);
Version History
v0.8.9
- Fixed JSON parsing error for Unigram vocab Array format (tuple-like arrays
["token", score])
v0.8.7
- Added automatic tokenizer type detection (WordPiece, Unigram, BPE)
- Fixed compatibility with bge-reranker-base and other Unigram-based models
v0.8.6
- Fixed vocab parsing for Array vs Object format
Changes from Previous Version
No structural changes between v0.22.1 and v0.22.2.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.