ZeroTokenizer.Core
1.0.0
dotnet add package ZeroTokenizer.Core --version 1.0.0
NuGet\Install-Package ZeroTokenizer.Core -Version 1.0.0
<PackageReference Include="ZeroTokenizer.Core" Version="1.0.0" />
<PackageVersion Include="ZeroTokenizer.Core" Version="1.0.0" />
<PackageReference Include="ZeroTokenizer.Core" />
paket add ZeroTokenizer.Core --version 1.0.0
#r "nuget: ZeroTokenizer.Core, 1.0.0"
#:package ZeroTokenizer.Core@1.0.0
#addin nuget:?package=ZeroTokenizer.Core&version=1.0.0
#tool nuget:?package=ZeroTokenizer.Core&version=1.0.0
๐ค ZeroTokenizer: Sovereign Pure C# BPE & Tiktoken Engine
ZeroTokenizer is an ultra-fast, zero-allocation Byte-Pair Encoding (BPE), WordPiece, and Tiktoken tokenizer engine engineered in 100% pure C# for .NET. It resides in Tier 3 (Perception & Intelligence) of the ZeroPlatform ecosystem.
โก Key Capabilities
- Zero-Allocation Tokenizer Pipeline:
- Direct span-based encoding:
int Encode(ReadOnlySpan<char> text, Span<int> destinationTokenIds). - Fast token counter:
int CountTokens(ReadOnlySpan<char> text)without allocating integer arrays or string chunks. - Streaming decoding:
int Decode(ReadOnlySpan<int> tokenIds, Span<char> destinationText).
- Direct span-based encoding:
- BPE & Byte-Level Fallback:
- Implements the standard Byte-Pair Encoding algorithm with UTF-8 byte fallback (compatible with GPT-2, GPT-4, LLaMA-3, and Qwen models).
- Tiktoken Engine:
- Pre-configured regex patterns for
cl100k_base(OpenAI GPT-4 / ChatGPT) ando200k_base(GPT-4o).
- Pre-configured regex patterns for
- Context Token Budgeter (
TokenBudgeter):- Greedy Knapsack packing algorithm for LLM prompts, ensuring conversation histories, system instructions, and RAG knowledge fragments never overflow the context window ($128\text{k}$ tokens).
- Zero External Dependencies & Multi-Targeting:
- Compatible with
.NET 8.0+,.NET Framework 4.6.2+, and.NET Standard 2.0.
- Compatible with
๐ Quick Start
1. Count Tokens Without Memory Allocations
using ZeroTokenizer.Core;
var tokenizer = TiktokenTokenizer.CreateCl100kBase();
ReadOnlySpan<char> prompt = "System: Analyze factory vibration telemetry at node 4.";
int tokenCount = tokenizer.CountTokens(prompt);
Console.WriteLine($"Token count: {tokenCount}");
2. Encode and Decode Tokens
using ZeroTokenizer.Core;
var tokenizer = TiktokenTokenizer.CreateCl100kBase();
// Encode into pre-allocated buffer
Span<int> tokenBuffer = stackalloc int[128];
int written = tokenizer.Encode("Hello, ZeroPlatform AI Agent!", tokenBuffer);
// Decode back to string
string reconstructed = tokenizer.Decode(tokenBuffer.Slice(0, written));
3. Context Token Budgeting (Knapsack Packing)
using ZeroTokenizer.Core.Budget;
var budgeter = new TokenBudgeter(tokenizer, maxContextTokens: 4096);
budgeter.AddSystemPrompt("You are an autonomous SCADA diagnostic agent.");
budgeter.AddUserMessage("Why did Motor #3 trigger an over-current fault?");
budgeter.AddKnowledgeItem("Motor #3 Bearing Specification Manual: Max rated current is 45A.", priority: 90);
string packedPrompt = budgeter.BuildPackedPrompt();
๐ License
Architected and developed by Phong Vรต (kzxl). Released under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- ZeroPrimitives.Core (>= 1.7.0)
-
.NETStandard 2.0
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- ZeroPrimitives.Core (>= 1.7.0)
-
net8.0
- ZeroPrimitives.Core (>= 1.7.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ZeroTokenizer.Core:
| Package | Downloads |
|---|---|
|
ZeroLlm.Core
Pure C# in-process Small Language Model (SLM) runtime, GGUF v2/v3 binary parser, Paged KV-Cache allocator, Transformer decoder (RMSNorm, RoPE, SwiGLU, GQA), and token sampling engine for .NET. |
|
|
ZeroAgent.Core
Pure C# enterprise-grade cognitive AI Agent runtime (ReAct loop, tool registry, episodic memory via ZeroVector, and multi-agent swarm) for .NET. |
|
|
ZeroPrompt.Core
Pure C# Prompt Engineering & Grammar-Constrained Token Decoding Engine (Zero-Allocation Templates, JSON Schema Finite Automata, Logit Masking, and Dynamic Few-Shot Exemplars) for .NET. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 34 | 9/30/2026 |