LocalReranker 0.3.0

Suggested Alternatives

LMSupply.Reranker

Additional Details

Moved

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

LocalReranker

⚠️ ARCHIVED: This project has been archived and is no longer actively maintained.

Successor: This project has been superseded by LocalAI.Reranker, which offers improved features and is actively maintained.

Existing users are encouraged to migrate to LocalAI.Reranker for continued support and updates.


NuGet License: MIT

A lightweight, zero-configuration semantic reranker for .NET. No API keys, no cloud dependencies—just install and use.

Features

  • Zero Configuration - Works out of the box with sensible defaults
  • Auto Model Download - Models are downloaded and cached automatically from HuggingFace Hub
  • Offline First - Fully local inference, no internet required after initial download
  • Minimal Dependencies - Only 2 packages: ONNX Runtime + ML.Tokenizers
  • Cross-Platform - Windows, Linux, macOS
  • Thread-Safe - Single instance can be shared across multiple threads

Installation

dotnet add package LocalReranker

Quick Start

using LocalReranker;

await using var reranker = new Reranker();

var query = "What is machine learning?";
var documents = new[]
{
    "Machine learning is a subset of artificial intelligence.",
    "The weather today is sunny.",
    "Deep learning uses neural networks with many layers."
};

var results = await reranker.RerankAsync(query, documents, topK: 5);

foreach (var result in results)
{
    Console.WriteLine($"[{result.Score:F4}] {result.Document}");
}

Configuration

var reranker = new Reranker(new RerankerOptions
{
    ModelId = "quality",              // Use alias or full HuggingFace ID
    MaxSequenceLength = 512,
    CacheDirectory = "/path/to/models",
    UseGpu = true,
    BatchSize = 64
});

Supported Models (v0.1.0)

Alias Model Size Use Case
default ms-marco-MiniLM-L-6-v2 90MB ✅ Balanced speed/quality (recommended)
quality ms-marco-MiniLM-L-12-v2 134MB ✅ Higher accuracy
fast ms-marco-TinyBERT-L-2-v2 17MB ✅ Fastest inference

Coming in v0.2.0

Alias Model Size Use Case
bge-base BAAI/bge-reranker-base 440MB 🔜 Multilingual support
multilingual BAAI/bge-reranker-v2-m3 1.1GB 🔜 Best quality, 8K context

Note: BGE models require SentencePiece tokenizer support, which is planned for v0.2.0.

ASP.NET Core Integration

// Program.cs - Register as singleton (recommended)
builder.Services.AddSingleton<IReranker>(sp =>
{
    var reranker = new Reranker(new RerankerOptions
    {
        ModelId = "default",
        BatchSize = 32
    });
    reranker.WarmupAsync().Wait(); // Pre-load model at startup
    return reranker;
});
// SearchService.cs
public class SearchService(IReranker reranker)
{
    public async Task<List<Document>> SearchAsync(string query, List<Document> candidates)
    {
        var texts = candidates.Select(d => d.Content).ToArray();
        var ranked = await reranker.RerankAsync(query, texts, topK: 10);
        return ranked.Select(r => candidates[r.OriginalIndex]).ToList();
    }
}

Performance Tips

  1. Reuse instances - Create one Reranker and reuse it (thread-safe)
  2. Use WarmupAsync() - Pre-load model during app startup
  3. Adjust BatchSize - Larger batches are faster but use more memory
  4. Use topK - Return only the results you need

Requirements

  • .NET 10.0+
  • ~90MB disk space (default model)
  • ~200MB RAM (model loaded)

Documentation

License

MIT - See LICENSE for details.

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

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

Initial release with support for cross-encoder reranking models.