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
model = "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.2.6.tar.gz
(755.4 kB
view hashes)
Built Distribution
totokenizers-1.2.6-py3-none-any.whl
(765.9 kB
view hashes)
Close
Hashes for totokenizers-1.2.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82446143329d2b48f3318ecdff6143baa73613ee91791dda70977ed9ca44f65b |
|
MD5 | 30c08b47a93fdad3a18f812b1cd1e509 |
|
BLAKE2b-256 | ec6bac27f9163b93f702f57d6c2a6532bad8aeb6e038ecc81900dd2644195242 |