Qwen Tokenizer
Introduction
Qwen Tokenizer is a lightweight tokenization library that does not require the transformers package. It uses tiktoken as its only runtime dependency.
Version 0.3.0 adds the tokenizer shared by the official Qwen/Qwen3.5-* and Qwen/Qwen3.6-* models, including Qwen/Qwen3.6-27B. Earlier Qwen models continue to use the legacy tokenizer, so selecting a Qwen3.5 or Qwen3.6 model does not change tokenization for Qwen2.5 applications.
Installation
To install Qwen Tokenizer, use the following command:
pip install qwen_tokenizer
Basic Usage
Below is a simple example demonstrating how to use the Qwen3.6 tokenizer:
from qwen_tokenizer import get_tokenizer
qwen_tokenizer = get_tokenizer("qwen3.6-27b")
text = "Hello! 毕老师!1 + 1 = 2 ĠÑĤвÑĬÑĢ"
result = qwen_tokenizer.encode(text)
print(result)
Output
[9419, 0, 220, 97169, 97621, 6115, 16, 478, 220, 16, 283, 220, 17, 9551, 254, 68933, 128, 97, 91914, 28495, 68933, 128, 105, 68933, 128, 95]
Hugging Face-style model IDs are also accepted:
qwen_tokenizer = get_tokenizer("Qwen/Qwen3.6-27B")
Qwen3.5 and Qwen3.6 use a 248,044-token base vocabulary plus 33 added tokens. For example, <|im_start|>, <think>, and </think> map to IDs 248045, 248068, and 248069 respectively.
License
This project is licensed under the MIT License.
Metadata
Release files for qwen-tokenizer 0.3.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 | |
|---|---|---|---|
| qwen_tokenizer-0.3.0.tar.gz | 3.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qwen_tokenizer-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 MB
Release files / qwen_tokenizer-0.3.0.tar.gz
| Download URL | qwen_tokenizer-0.3.0.tar.gz |
|---|---|
| Size | 3.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f6ae00b1297dd857c502732b30ba511481bf41cfe2a4ee021431fbb89029c8f
|
|
BLAKE2b-256 checksum How to use checksums |
bc036e0507f5a0b439d19849140184b4b597f0beb784905c75897fe4e1895f46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 11, 2026.
Transparency logRelease files / qwen_tokenizer-0.3.0-py3-none-any.whl
| Download URL | qwen_tokenizer-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfcd0f49459aeba14f9eab32cd4eff487c4871de41ecfd5d6f783db343afca90
|
|
BLAKE2b-256 checksum How to use checksums |
57a18b18cdba867a2fdf686463eeef134a0003838322717c23bacaa9b2459a37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 11, 2026.
Transparency log