Python bindings for the tokie 0.2 tokenizer. encode, encode_plus, and batch release the GIL and return NumPy arrays. There is no Encoding object and no .ids attribute; use .tolist().
Installation
pip install tokie
Quick start
import tokie
tokenizer = tokie.Tokenizer.from_pretrained("openai-community/gpt2")
# from_json(path) and from_file(path) are aliases for open(path).
ids = tokenizer.encode("Hello world") # uint32 array, template off
print(ids.tolist())
print(tokenizer.decode(ids.tolist()))
print(tokenizer.decode_bytes(ids.tolist())) # raw bytes
# The single-sequence template. GPT-2 has none, so this matches encode.
print(tokenizer.encode_plus("Hello world").tolist())
flat, ends = tokenizer.batch(["Hello world", "a12b"]) # ends are cumulative
print(tokenizer.count_tokens("Hello world")) # template off
print(tokenizer.count_tokens_batch(["Hello world", "a12b"]))
print(tokenizer.vocab_size) # highest id + 1
print(tokenizer.pad_token_id) # [PAD] then <pad>
print(tokenizer.num_special_tokens_to_add(is_pair=False))
tokenizer.save("gpt2.tokie")
encode leaves the template off. encode_plus applies it and accepts pair, truncate, and pad; truncation is from the right, longest sequence first, and padding is fixed on the right. One max_len covers both and counts the template ids.
from_pretrained opens exactly one .tokie file from the repo, whatever its name. A repo with no .tokie file is parsed from tokenizer.json; several .tokie files is an error. There is no runtime .tkz fallback: a genuine legacy TOKI image is refused by magic, not by extension, while a JSON file merely named .tkz is parsed as JSON. open reads either file from disk by its magic, from_json(path) and from_file(path) are path aliases for open, and json(text) parses JSON text.
decode returns str (lossy only where needed). decode_bytes returns raw bytes. Both keep specials by default; skip=True omits them. get_vocab() returns raw token strings and may have fewer entries than vocab_size.
Benchmark
bench.py times Tokenizer.encode on one file against the tokie bench command, which is the Rust path.
License
MIT OR Apache-2.0
Metadata
Release files for tokie 0.2.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 |
|---|---|---|---|---|
| tokie-0.2.0.tar.gz | 365.6 kB | Without provenance | Details for tokie-0.2.0.tar.gz |
Built distributions (wheels)
Total release size: 55.4 MB
Release files / tokie-0.2.0.tar.gz
| Download URL | tokie-0.2.0.tar.gz |
|---|---|
| Size | 365.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
649a03364dd878e20bbb67a6bbeeb36fe669dd27987ef0015fa91bd94cd90935
|
|
BLAKE2b-256 checksum How to use checksums |
85ce7f5a59bb1ce4e9d0ef76d3089956d874b944c4048f45554d231418e2efad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-win_amd64.whl
| Download URL | tokie-0.2.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9a9c9070cb4a62c955518eed9c0f241b3f2183c4f63b2f9dd60ab232f3eaf365
|
|
BLAKE2b-256 checksum How to use checksums |
6bd6160b5f7d306f5e853b722d50bdbb26e2856c00e855c73e6f0cecbf8835d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl
| Download URL | tokie-0.2.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl |
|---|---|
| Size | 511.4 kB |
| Tags | CPython 3.14 PyEmscripten 2026.0+ WebAssembly |
|
SHA-256 checksum How to use checksums |
3c06283f598742cad0048e66df9bc28ac3f3b630bd6e2f42a2489dfd840e8586
|
|
BLAKE2b-256 checksum How to use checksums |
62f81fa94ca86444288e3ac8c4d3994be802092a4e245d0cab70efcb8346c8cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-manylinux_2_28_aarch64.whl
| Download URL | tokie-0.2.0-cp314-cp314-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
0f9dff43c0876d6bfc01b1d54781a0a7385c652066f3af1bd08fb0895172d244
|
|
BLAKE2b-256 checksum How to use checksums |
600880d644fc689a49a7ea7f0f991419b5ceb12cd88ee98ee75a5dffc57452da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokie-0.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7d8085b9ed622b0f991c038d2ca0dfab53d3d80cafc4a53e5345955599c0b9dd
|
|
BLAKE2b-256 checksum How to use checksums |
7972afcff838e17e21363aa6e3e8a4b1c9e7ffd8f9626b62b373431e474757d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | tokie-0.2.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
52969498f1a5efc448e7f44f729c96e261166b29cdd52613e498527130ee42e3
|
|
BLAKE2b-256 checksum How to use checksums |
ac9753c291f412f35baaa1ac02afdc14a99f84f32a88a292521946dd90b9a3eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp314-cp314-macosx_10_12_x86_64.whl
| Download URL | tokie-0.2.0-cp314-cp314-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.14 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3e60bd38a2674638b44e7af2744ff4a282749dbbd548bedf7e574a1bc62a0595
|
|
BLAKE2b-256 checksum How to use checksums |
d043922d085d5893a6a6637bdc3cd395f7655775c1b98cbe9996806ff43afcf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp313-cp313-win_amd64.whl
| Download URL | tokie-0.2.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
140ab3aec6be74efe17c7e6895eefd3922d4ef7fb9fa83b8718704f4a560a11d
|
|
BLAKE2b-256 checksum How to use checksums |
d96531e4cb6fb0900137b3634fd1b274d925146ed35482ee9c080b2c285fefa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp313-cp313-manylinux_2_28_aarch64.whl
| Download URL | tokie-0.2.0-cp313-cp313-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
3aa92168bc3535e9a0f1278a760eb1b6b497ec6c22aec6749523b978f1c06200
|
|
BLAKE2b-256 checksum How to use checksums |
31051185e674e64ac8da6a2d4f24f5d0f792c6e55d3a5fa17e365bcb782bbeba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokie-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
db207e62f1099286a994027d8e4c0df4965772db5a2fbba40ce7f445a8c76bfc
|
|
BLAKE2b-256 checksum How to use checksums |
9ff8d4df98127a83ad187295179625a01558386b37e6196ebcc7692d2f708fc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | tokie-0.2.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6177829ebac5f567901c01f2d797ea517b49c9a86ac472d12ab20e4445017f46
|
|
BLAKE2b-256 checksum How to use checksums |
d00cdcda434c11f4dc8f519184349cb7270f5d255251c76c783bc30328bb8e2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | tokie-0.2.0-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c4b99955f6cd2782dcd4457836bb6099c8cd5b8e8a866cb44fcb1ea516cac439
|
|
BLAKE2b-256 checksum How to use checksums |
3aa8b13d8904cad45b801da44a04e29c3ff24c1f17a835257b0fb62788dacc9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | tokie-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f7948f96630625f4366321b78954342fc6d372026afd1e7794351c365af1ba5e
|
|
BLAKE2b-256 checksum How to use checksums |
ab5d85e7b68164c4d4d2c702df827c6416e249a5defba72d509ada460fe10d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl
| Download URL | tokie-0.2.0-cp312-cp312-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
0154b289bf57e5700f13f0b9c33624f84e98dbcedeb6f8e8d3eb56910c8e154e
|
|
BLAKE2b-256 checksum How to use checksums |
fc19a9e83729634c4886e5c6dfc3226c9c422a85d6e7ebe2663ce89abf55b2fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokie-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5c28027c24eb418fb9bcc9733c31ad4a6956d6129685b101e996e024669b6df7
|
|
BLAKE2b-256 checksum How to use checksums |
2301a6004638d5ecf8646d54d454c1de2807e853bc0e8afda352a9907cf9100c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | tokie-0.2.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9ed5d4933166fc3b694d6b14e4a1b4b7614e428cd301ca640e51aaedeb85ef8b
|
|
BLAKE2b-256 checksum How to use checksums |
412350e8594fc9f3d76fbb44f81958254fe3b70b0e720ce76f1e59b173ee9efa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | tokie-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
625ff60144ecb2c8c7fba5717fa5873f51bc3b6267f0f93a4889895e8f03f321
|
|
BLAKE2b-256 checksum How to use checksums |
bb38791ba5d5fac4960d7d1edd02191b5305620e834c502859bc3c18a7cee625
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp311-cp311-win_amd64.whl
| Download URL | tokie-0.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ae2ee7376116707e52857f876cfe87485f4f477498aef0390a42dc11fe2f097d
|
|
BLAKE2b-256 checksum How to use checksums |
c4bab6502adb093dc58ef9b907ae0b06b2d15a9436d1791824c0597fdefc7f5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl
| Download URL | tokie-0.2.0-cp311-cp311-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
0990c643df7b122f712a050baff3887cd6653a7273a3a2abfa537367f5791f6d
|
|
BLAKE2b-256 checksum How to use checksums |
20cbd59ce1f0663e633e897e7d6bc3fe01328f5a1a2d9d78685ca2fa34d76483
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokie-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
dac48161a371b866c0902f1b32c171edcd6cc52d9e7985ed1e54e73aa3f0670f
|
|
BLAKE2b-256 checksum How to use checksums |
efbca067692b0025fdad943f7fc8b527d415524257459b58f8cf3401d8fe8c1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | tokie-0.2.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a1d25583ceeff9dbda95a6355672c7e4ae10c046b849c07bd1d98e683544dd37
|
|
BLAKE2b-256 checksum How to use checksums |
50ce3e35226ed540f11bfac015b3ab663303105297ce4434e4a191c1283cf946
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | tokie-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c344a8e32542879a9f10985201c7464aca984bd3632b45b614b1a3e4056a6838
|
|
BLAKE2b-256 checksum How to use checksums |
1766a78d9b7c81de1912e07c966a2c2a41d1feecc6225d3bf1b9b64b1838f907
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp310-cp310-win_amd64.whl
| Download URL | tokie-0.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b375324ef0e47cb9a9a24621c0ab4258aaa107b452681561181d38dc280e58e4
|
|
BLAKE2b-256 checksum How to use checksums |
351cd473a3e4148251eb2ee58a656fc20d3bf28c4c1c79d0baba7d2f70426c99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp310-cp310-manylinux_2_28_aarch64.whl
| Download URL | tokie-0.2.0-cp310-cp310-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
385f65dc67e20f54a2d50798c3ec829dbfa84b62e98b8f6ffbc9bf8cd89671db
|
|
BLAKE2b-256 checksum How to use checksums |
e101ef856866eb5c235eb9c099553a89ecaf7322677b36f4851b82f5e3b0bed7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | tokie-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fa0e905aff9407d792c91ba0f2735129af318c25d57b9761b428e4e43632d445
|
|
BLAKE2b-256 checksum How to use checksums |
485fb269baecadde8e34967e9d4a64150d19e8719f9796765eb16eb450ebc986
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | tokie-0.2.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dcaa8b6e9e373861e4a50f82c23e6676b910c0b397bea2eb2f3deaebe2208aee
|
|
BLAKE2b-256 checksum How to use checksums |
6c1c8a08f40313d415a32e31bd7be9f8f399cafe06cd0b694a3a15c8129c51ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tokie-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | tokie-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
4727c60a3dad50d2e79867763c372abc319237150e3d6d00d78fffadf353e0ef
|
|
BLAKE2b-256 checksum How to use checksums |
f98938f3fa6fffd659469f3adebf4ea0014e495678a524bf0d3c4437f659724a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for tokie 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.