LexiSharp 0.10.0

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

LexiSharp

CI NuGet Docs License: MIT

Search and retrieval for .NET โ€” BM25, rank fusion and reranking in composable pipelines.

In-memory inverted index, four ranking strategies and their BM25 variants, rank fusion, reranking, IR metrics and end-to-end search traces. The core references no NuGet package at all (BCL only). PostgreSQL, ASP.NET Core and MessagePack are separate, optional packages, and your models stay in your application behind a seam you implement.

  • Nothing to host. No vector database, no embedding API, no native library.
  • Explainable ranking. Every stage writes a SearchTrace (score in/out); Explain breaks a scorer down to its per-term contributions.
  • Composition, not configuration. Index, scorer and engine are separate interfaces; hybrid retrieval and reranking are decorators over the same ITextSearchEngine.
  • Measured, not asserted. The plain BM25 scorer is checked against published BEIR figures and re-checked by a workflow on every relevant push and weekly.

๐Ÿ“– Documentation โ†’ โ€” guide, reference, and every measurement with the command that reproduces it.

Quick start

dotnet add package LexiSharp
using LexiSharp.Core;
using LexiSharp.Indexing;
using LexiSharp.Ranking;

ITextSearchEngine engine = new RankedTextSearchEngine(
    new InMemoryTextIndex(), new Bm25Scorer());

engine.Index(new[]
{
    new SearchDocument("1", "The search engine uses BM25 to rank the results"),
    new SearchDocument("2", "TF-IDF is a classic method of textual search"),
    new SearchDocument("3", "Italian cuisine is renowned in Rome"),
});

foreach (var r in engine.Search("textual search"))
    Console.WriteLine($"{r.DocumentId} - {r.Score:0.###}: {r.Document.Text}");

Hybrid retrieval and reranking are stages wrapping each other โ€” see pipelines and getting started.

Does it work?

nDCG@10 on three public BEIR corpora, with analysis, BM25 parameters and metric convention aligned to the published figures:

Corpus LexiSharp Published
NFCorpus 0.3218 0.3218
SciFact 0.6789 0.6789
ArguAna 0.4005 0.3970

Point estimates; the harness also reports paired-bootstrap 95 % CIs. Under the library's own default analysis and parameters the same scorer reads 0.308 / 0.662 / 0.320 โ€” the difference is configuration, not ranking. Corpora are md5-verified; numbers are pinned and re-checked by the Pinned reference workflow.

Full tables, CIs, backends and reproducibility: evaluation โ†’.

See it running

dotnet run --project samples/LexiSharp.Demo    # โ†’ http://localhost:5000

Five retrieval strategies over one corpus, compared live โ€” BM25, corpus-derived semantic expansion, dense hashing embeddings, RRF fusion and a term-overlap rerank โ€” with per-lane latency, highlighting and a click-through "why did this rank here?" panel. No model, no external service.

Demo screenshot

--corpus nfcorpus|scifact|arguana runs the same lanes over a BEIR corpus. Details: getting started โ†’.

Packages

Package What it adds
LexiSharp Core: index, scorers, fusion, reranking, metrics, traces โ€” no dependencies
LexiSharp.Postgres tsvector ยท pgvector ยท sparsevec ยท pg_trgm ยท pg_search (Tantivy) BM25
LexiSharp.Onnx Local ONNX embeddings and cross-encoder reranking (no model shipped)
LexiSharp.MessagePack Binary persistence for the in-memory index
LexiSharp.AspNetCore GET /search minimal-API endpoint over LexiSharpIndex<T>
LexiSharp.Cli dotnet tool: search a directory, build a store, benchmark a config

Text analysis (lexical similarity, keyword extraction, Naive Bayes, decision tree, ensemble, linear classifier): text analysis โ†’.

Limits (short version)

  • net10.0, 0.9.0: the public API may still change between minor versions; pin a version and read the changelog. 0.9.0 breaks binary compatibility for ITextSearchEngine implementations, write-capable engine constructors and SearchResult.
  • ArguAna reads 0.4005 against 0.3970 published (0.0035 short; cause not established). An earlier ArguAna figure was withdrawn and is not reproducible by any code path.
  • Not every engine/scorer/reranker/merger combination is tested; treat unusual pairings as supported but unproven until tested on your data.
  • SQL backends are measured on ranking for the engines that rank on their own; sparse and fuzzy engines are covered by integration tests only.

Full list with measurements: scope and limits โ†’.

Development

dotnet build LexiSharp.slnx
dotnet test tests/LexiSharp.Tests
dotnet run --project bench/LexiSharp.Eval -c Release -- --verify-reference   # quality gate

The retrieval quality gate replays every pinned configuration on the three BEIR corpora and exits non-zero on drift (downloads corpora on first run). Benchmarks and the behavioural gate: reference โ†’, benchmarks โ†’.

License

MIT โ€” see LICENSE. The ParadeDB pg_search extension used by the BM25 backend is licensed separately, under AGPL-3.

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.
  • net10.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on LexiSharp:

Package Downloads
LexiSharp.AspNetCore

ASP.NET Core integration for LexiSharp: a minimal-API search endpoint on top of LexiSharpIndex<T>.

LexiSharp.MessagePack

MessagePack persistence for the LexiSharp in-memory text index: save and reload a full corpus as compact binary.

LexiSharp.Postgres

PostgreSQL backends for LexiSharp: lexical full-text search on tsvector, ANN on pgvector, sparse retrieval, fuzzy search on pg_trgm, and true Okapi BM25 on the ParadeDB pg_search (Tantivy) extension.

LexiSharp.Onnx

ONNX Runtime plumbing for LexiSharp: a dense text encoder implementing IEmbeddingProvider and a pairwise cross-encoder implementing ICrossEncoderScorer, with BERT/WordPiece and SentencePiece tokenizers. No model ships; the caller supplies the .onnx file and the tensor names.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.0 0 11/5/2026
0.9.0 114 11/2/2026
0.8.0 147 10/6/2026
0.7.0 142 9/29/2026
0.6.0 131 9/28/2026
0.5.0 141 9/27/2026
0.4.0 136 9/23/2026
0.3.0 130 9/23/2026
0.2.0 114 9/23/2026
0.1.0 136 9/19/2026