Text tokenizers.
Project description
totokenizers
A model-agnostic library to encode text into tokens and couting them using different tokenizers.
install
pip install totokenizers
usage
from totokenizers.factories import TotoModelInfo, Totokenizer
mdoel = "openai/gpt-3.5-turbo-0613"
desired_max_tokens = 250
tokenizer = Totokenizer.from_model(model)
model_info = TotoModelInfo.from_model(model)
thread_length = tokenizer.count_chatml_tokens(thread, functions)
if thread_length + desired_max_tokens > model_info.max_tokens:
raise YourException(thread_length, desired_max_tokens, model_info.max_tokens)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
totokenizers-1.0.3.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for totokenizers-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e744fc9e23b38ebcdfb165016458c8b993dd4e56b6ab1a9c17e731e6f8c13a6 |
|
MD5 | cdf93537028cbf09b58513fd82a4399c |
|
BLAKE2b-256 | 43e5ac567c2f6ee9141761e35da8da5996ffeebc1db1de181e9c2edb9725989d |