DeepSeek Tokenizer
English | 中文
Introduction
DeepSeek Tokenizer is an efficient and lightweight tokenization library with no third-party runtime dependencies, making it a streamlined and efficient choice for tokenization tasks.
This release uses the DeepSeek-V4 series tokenizer shared by deepseek-ai/DeepSeek-V4-Pro and deepseek-ai/DeepSeek-V4-Flash. The bundled tokenizer supports the V4 special tokens, including thinking, DSML, quick-instruction, and multimodal placeholder tokens, with a model_max_length of 1,048,576 tokens.
Installation
To install DeepSeek Tokenizer, use the following command:
pip install deepseek_tokenizer
Basic Usage
Below is a simple example demonstrating how to use DeepSeek Tokenizer to encode text:
from deepseek_tokenizer import ds_token
# Sample text
text = "Hello! 毕老师!1 + 1 = 2 ĠÑĤвÑĬÑĢ"
# Encode text
result = ds_token.encode(text)
# Print result
print(result)
Output
[19923, 3, 223, 5464, 5008, 1175, 19, 940, 223, 19, 438, 223, 20, 6113, 257, 76589, 131, 100, 76032, 1628, 76589, 131, 108, 76589, 131, 98]
DeepSeek-V4 Tokens
from deepseek_tokenizer import ds_token
print(ds_token.model_max_length)
print(ds_token.convert_tokens_to_ids("<think>"))
print(ds_token.convert_tokens_to_ids("</think>"))
print(ds_token.convert_tokens_to_ids("|DSML|"))
print(ds_token.convert_tokens_to_ids("<|latest_reminder|>"))
Output
1048576
128821
128822
128825
128828
License
This project is licensed under the MIT License.
Metadata
Release files for deepseek-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 | |
|---|---|---|---|
| deepseek_tokenizer-0.3.0.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deepseek_tokenizer-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.8 MB
Release files / deepseek_tokenizer-0.3.0.tar.gz
| Download URL | deepseek_tokenizer-0.3.0.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eda5e8cb98776bd72065841d4c51b6749deec1e19f4c6f1c569e6daeed3d5b56
|
|
BLAKE2b-256 checksum How to use checksums |
297be1563c3d0208cf09c6c68cd5c5161df6f7513329148e0197e6fbdba3cade
|
| 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 Jun 28, 2026.
Transparency logRelease files / deepseek_tokenizer-0.3.0-py3-none-any.whl
| Download URL | deepseek_tokenizer-0.3.0-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6617d0b92aabaebe71a7be23244b5c602a5b0c1bd2dcdc6fa0dfdaf735f9e88
|
|
BLAKE2b-256 checksum How to use checksums |
63a2482cd79283a943740e2da16d0e2a0f6c6d00cf8587cd0b35ce17956fdc13
|
| 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 Jun 28, 2026.
Transparency log