Skip to main content

Lightweight tokenizer for DeepSeek V4 series

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepseek_tokenizer-0.3.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepseek_tokenizer-0.3.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file deepseek_tokenizer-0.3.0.tar.gz.

File metadata

  • Download URL: deepseek_tokenizer-0.3.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deepseek_tokenizer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eda5e8cb98776bd72065841d4c51b6749deec1e19f4c6f1c569e6daeed3d5b56
MD5 09ea24f6ea31442309ad4363ca4dea0c
BLAKE2b-256 297be1563c3d0208cf09c6c68cd5c5161df6f7513329148e0197e6fbdba3cade

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepseek_tokenizer-0.3.0.tar.gz:

Publisher: release.yml on AndersonBY/deepseek-tokenizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepseek_tokenizer-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deepseek_tokenizer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6617d0b92aabaebe71a7be23244b5c602a5b0c1bd2dcdc6fa0dfdaf735f9e88
MD5 b3341a15a78881a085d1fd4a51ef9569
BLAKE2b-256 63a2482cd79283a943740e2da16d0e2a0f6c6d00cf8587cd0b35ce17956fdc13

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepseek_tokenizer-0.3.0-py3-none-any.whl:

Publisher: release.yml on AndersonBY/deepseek-tokenizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page