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.0.tar.gz (3.2 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.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qwen_token_counter-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 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.0.tar.gz
Algorithm Hash digest
SHA256 a59f21fdddaf994c11944c6685ccdd5984d44599119f394035989e697bca6fe9
MD5 857c16e6e2bc7da1054a01273d42c91f
BLAKE2b-256 4adf2d5a9994432d99f40db848fa25bb9e70f4818b1b404a3bc3fa98896be7ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qwen_token_counter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27e5d847b4dc5a4bcb02de722391dba22fdba70e9b782d9bca945cf8a8402801
MD5 2dc4afc74f018a91a5ddc96042b31af4
BLAKE2b-256 9a140f2048a82c2ec9fe14256e0bec8bc5227117b701338b59461f1a170d385d

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