MarkZither.Rag.Chunking 0.0.1-alpha.1

This is a prerelease version of MarkZither.Rag.Chunking.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MarkZither.Rag.Chunking --version 0.0.1-alpha.1
                    
NuGet\Install-Package MarkZither.Rag.Chunking -Version 0.0.1-alpha.1
                    
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="MarkZither.Rag.Chunking" Version="0.0.1-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkZither.Rag.Chunking" Version="0.0.1-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="MarkZither.Rag.Chunking" />
                    
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 MarkZither.Rag.Chunking --version 0.0.1-alpha.1
                    
#r "nuget: MarkZither.Rag.Chunking, 0.0.1-alpha.1"
                    
#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 MarkZither.Rag.Chunking@0.0.1-alpha.1
                    
#: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=MarkZither.Rag.Chunking&version=0.0.1-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MarkZither.Rag.Chunking&version=0.0.1-alpha.1&prerelease
                    
Install as a Cake Tool

MarkZither.Rag.Chunking

NuGet License: MIT

Token-aware sliding-window chunking primitives for retrieval-augmented generation (RAG) pipelines in .NET.

Splits long documents into overlapping token-bounded chunks ready for embedding, with optional HTML stripping. No HtmlAgilityPack dependency.

Installation

dotnet add package MarkZither.Rag.Chunking --version 0.0.1-alpha.1

Quick Start

// Register via DI
services.AddChunking();

// Or resolve manually
ITokenEncoder encoder = new TiktokenEncoder();
IChunkingService chunker = new SlideWindowChunkingService(encoder);

var options = new ChunkOptions
{
    ChunkSize = 512,        // tokens per chunk
    ChunkOverlap = 128,     // overlap tokens between chunks
    MaxChunksPerDocument = 200,
    StripHtml = true        // strip HTML before chunking
};

IReadOnlyList<TextChunk> chunks = await chunker.ChunkAsync(text, options, ct);

foreach (var chunk in chunks)
{
    Console.WriteLine($"[{chunk.ChunkIndex + 1}/{chunk.TotalChunks}] {chunk.TokenCount} tokens: {chunk.Text[..Math.Min(80, chunk.Text.Length)]}...");
}

API

IChunkingService

Task<IReadOnlyList<TextChunk>> ChunkAsync(string text, ChunkOptions options, CancellationToken cancellationToken = default);

ChunkOptions

Property Default Description
ChunkSize 512 Maximum tokens per chunk
ChunkOverlap 128 Token overlap between consecutive chunks
MaxChunksPerDocument 200 Hard cap on chunks produced per document
StripHtml true Strip HTML tags before chunking

TextChunk

record TextChunk(string Text, int ChunkIndex, int TotalChunks, int TokenCount);

ITokenEncoder

Abstraction over the tokenizer. Default implementation is TiktokenEncoder using cl100k_base encoding (compatible with nomic-embed-text, text-embedding-ada-002, and similar models).

DI Registration

// Registers TiktokenEncoder as ITokenEncoder and SlideWindowChunkingService as IChunkingService
services.AddChunking();

Supported Frameworks

  • net9.0
  • net10.0

Versioning

This package follows SemVer 2.0. While the version is 0.*, minor bumps may include breaking changes. See ADR-0021 for the full versioning policy.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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 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
0.0.1-alpha.2 32 5/22/2026
0.0.1-alpha.1 174 5/20/2026

Initial alpha release. API surface is unstable until v1.0.0.