Skip to main content

A simple token counter for Qwen model series

Project description

Qwen Token Counter

一个简单的Qwen模型系列token计数工具。

安装

pip install qwen-token-counter

使用方法

有两种使用方式:

  1. 快速单次使用:
from qwen_token_counter import get_token_count

text = "你好,世界!"
count = get_token_count(text)
print(f"Token数量: {count}")
  1. 多次使用(推荐):
from qwen_token_counter import TokenCounter

counter = TokenCounter()
text1 = "你好,世界!"
text2 = "Hello, World!"

count1 = counter.count_tokens(text1)
count2 = counter.count_tokens(text2)

print(f"文本1的Token数量: {count1}")
print(f"文本2的Token数量: {count2}")

特点

  • 轻量级:只包含必要的tokenizer文件
  • 易用:简单的API设计
  • 高效:支持批量文本处理
  • 准确:使用官方Qwen tokenizer

依赖

  • Python >= 3.7
  • transformers >= 4.51.0

License

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

qwen_token_counter-0.2.1.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

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

qwen_token_counter-0.2.1-py3-none-any.whl (4.0 MB view details)

Uploaded Python 3

File details

Details for the file qwen_token_counter-0.2.1.tar.gz.

File metadata

  • Download URL: qwen_token_counter-0.2.1.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for qwen_token_counter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 531c5c07661a1db9304fab24b6a59a9cf1a8f838080266004d253e8dd08ac5e1
MD5 8419cf53836b99586ab614a1dd3b3ad6
BLAKE2b-256 0d9c373f7bdbccd134afbb4a489c13ccbd8f1b1af2de7f39edba123c299fe1ce

See more details on using hashes here.

File details

Details for the file qwen_token_counter-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for qwen_token_counter-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af125ed4d285c381db882982d538e117306653ad2e150c7ded655ddc56e0f34c
MD5 3e70ded6ba48b00c162a4f8cc25598a4
BLAKE2b-256 2aa921439d13d4baabc6e0beb262f30fcbed5828d1039bc42dae0510cc57abca

See more details on using hashes here.

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