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.1.1.tar.gz (3.6 kB 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.1.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qwen_token_counter-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • 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.1.1.tar.gz
Algorithm Hash digest
SHA256 39a55029df667ea09b78ac4c4d95270770b49cd6268b4b3b08acae2f99e6d64a
MD5 4dcfb34ce85f66157e104564371757c7
BLAKE2b-256 530a7165df8098bdc6977d7326e9d9ee09064f2ff2f4a3bc384ce45295f9e02d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qwen_token_counter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88c864feb3bd6a1df861335f2c08074adac27d7cadedcaad9df1e63384d003f3
MD5 27fc44120e5e88dee1c054a3d7d5a106
BLAKE2b-256 2ceac3d73d6cc37fdf52bcdb48d6a51955d8873b2dc14a05b57ccd8b4881d9d4

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