tokforge
Fast BPE tokenization for Python, backed by a Rust engine.
GPT-2, GPT-4 (cl100k_base), GPT-4o (o200k_base) and Qwen2-style tokenizers run on a
byte-level BPE core written from scratch, checked against tiktoken and Hugging Face tokenizers
by differential tests and long soak runs without a mismatch. On the project's benchmark it is
1.4x to 4.6x as fast as tiktoken with identical output. Any other Hugging Face tokenizer.json
(BERT, XLM-R, ...) loads too and runs on the Hugging Face backend.
import tokforge
tok = tokforge.Tokenizer.from_file("tokenizer.json")
tok.encode("hello world") # [31373, 995]
tok.count("hello world") # 2
tok.decode([31373, 995]) # "hello world"
tok.encode_batch(["a", "b", "c"]) # parallel, releases the GIL
tok.truncate(long_text, 512) # a prefix of long_text within 512 tokens
tok.chunk(long_text, 512) # slices that join back to long_text
Options, all keyword-only:
special_tokens="literal"(default) treats spellings like<|endoftext|>in the input as plain text;"recognize"matches them as special tokens.add_special_tokens=False(default);Trueadds the model's BOS/EOS tokens.core="auto"(default) uses the custom core where it applies;"backend"forces the Hugging Face path;"verify"runs both and raises if they ever disagree.
Errors raise ValueError (bad options, unknown ids, invalid input) or OSError (file).
License: MIT OR Apache-2.0.
Metadata
Release files for tokforge 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tokforge-0.1.0.tar.gz | 386.5 kB | With provenance | Details for tokforge-0.1.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| tokforge-0.1.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for tokforge-0.1.0-cp39-abi3-win_amd64.whl |
| tokforge-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for tokforge-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| tokforge-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for tokforge-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| tokforge-0.1.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for tokforge-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
| tokforge-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for tokforge-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 9.8 MB
Release files / tokforge-0.1.0.tar.gz
| Download URL | tokforge-0.1.0.tar.gz |
|---|---|
| Size | 386.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ce65d0249a4fceb080d236472e2f65309e04f7441b09d5feb9d0c7a47f9e07c
|
|
BLAKE2b-256 checksum How to use checksums |
fb7b5954484e43ce6876cf503c6f04063ed3c09a1d47892d1f464f91f8ef5f6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tokforge-0.1.0-cp39-abi3-win_amd64.whl
| Download URL | tokforge-0.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
614dadbd61a09bc7752a911cc4b43a6d4fb3891821feaa725e862a3ae9f77d9d
|
|
BLAKE2b-256 checksum How to use checksums |
e44b7fce63bef84dc3cf59856ea841f471ed6fe602c230096649997148717d6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tokforge-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokforge-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0833b822ed3db601b0649b8064645aa12db91c8fa8ac4a7136318e46a13bb99c
|
|
BLAKE2b-256 checksum How to use checksums |
0a775f931d04bb923e72182c433c6f40e9c8866478f5ba5f455dd0a10db8bb10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tokforge-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | tokforge-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
5ba11cae735a8bf5ff0a9133a074393d499e877fa39779e5b8a219188828d3d3
|
|
BLAKE2b-256 checksum How to use checksums |
1528b815b4d46684d827638247180a7e85c15daccc66501880afab96378fd4a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tokforge-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | tokforge-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f3fce01c275ace1c62678d0db100c53c066ea00b3bde58efa62e2b47e12d1fb7
|
|
BLAKE2b-256 checksum How to use checksums |
8d7a4ae3d9e89a4e54dff818d7ebe84f52af3e18a01481a26a68f685f03e20be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / tokforge-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | tokforge-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
67eaa284d918d68d54488b8ae16b2af3caeebdb55d5537539564378cf707ac25
|
|
BLAKE2b-256 checksum How to use checksums |
fbe54f009aba5335bf7cdbef4cad3b189f46da9737629b4c5e3aa66fdcbeb00a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logSecurity for tokforge 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for tokforge-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.