toklen
Count tokens with a model's real Hugging Face tokenizer. Prints an integer.
npx toklen openai-community/gpt2 "hello world" # 2
uvx toklen openai-community/gpt2 "hello world" # 2
Both commands always print the same number. Node uses
@huggingface/tokenizers,
Python uses the Rust tokenizers bindings. One
dependency each, no transformers, no PyTorch.
toklen Qwen/Qwen3-8B < README.md # stdin
git diff | toklen openai-community/gpt2
toklen -s google-bert/bert-base-uncased "hello world" # 4, with [CLS] and [SEP]
toklen --help covers the flags. docs/usage.md has the library API and
the counting rules. npm ·
PyPI · MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toklen-0.1.1.tar.gz.
File metadata
- Download URL: toklen-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb0ae687a0b85c1da8449f9b29d502c3ba73f3b12feffed6a1ab6fc4cdc3134
|
|
| MD5 |
bbbba56943cc7ce2fa2f0c0e372d7c03
|
|
| BLAKE2b-256 |
9aa4fcf23e1ea42fd37f6f5dee841a724fe5265d6fd877ccdd5334e5cc1b4aa7
|
File details
Details for the file toklen-0.1.1-py3-none-any.whl.
File metadata
- Download URL: toklen-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ce8ffc33e2e9c0bdefe75f1eb80db0981c2438ced795ec15c01c71d7ad10d67
|
|
| MD5 |
d620ec87ae694562fc8751d866953e13
|
|
| BLAKE2b-256 |
9a1a2a30fb503d059e4fa36146ed4648e3aabf4130a2dbaebc69bab400d1e9fa
|