ztok, a fast multithreaded tokenizer in Zig that loads tiktoken / HF / SentencePiece and is 2–5× faster

“`html A British AI enthusiast named FaustAg has developed a library called ztok, which is a fast multithreaded tokenizer in the Zig…

By Vane May 22, 2026 1 min read
ztok, a fast multithreaded tokenizer in Zig that loads tiktoken / HF / SentencePiece and is 2–5× faster

“`html

  • A British AI enthusiast named FaustAg has developed a library called ztok, which is a fast multithreaded tokenizer in the Zig programming language.
  • Ztok supports various tokenization formats such as .tiktoken, HF tokenizer.json, and SentencePiece .model files. It automatically detects and loads these different formats, making it an easy drop-in replacement for existing systems without requiring re-implementation.
  • The library is particularly notable for its speed improvements-up to 5.5 times faster in batched mode compared to the original implementations like tiktoken and SentencePiece. This makes it suitable for applications such as RAG chunking with token-cap windows and direct dataset tokenization for training.
  • Ztok supports multiple programming languages through a single C ABI, including Python, Node.js, Ruby, Go, Rust, .NET, Java, and Swift, making it versatile for different development environments and workflows.
  • The library is open-source under the AGPL-3.0 license and has undergone extensive testing to ensure its reliability and performance in real-world scenarios.

“`

Scroll to Top