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.2.4.tar.gz
(754.9 kB
view hashes)
Built Distribution
totokenizers-1.2.4-py3-none-any.whl
(765.6 kB
view hashes)
Close
Hashes for totokenizers-1.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b9deaf2c67d88ef2696b3f0d322300a04ae819a3105c4ae5f1469cbff276fe |
|
MD5 | 82c4bb428ed5e1276afcf1950a49e78c |
|
BLAKE2b-256 | e694962b1a38b60be7da0928ed1635b7b0598c3ad4ec09d62688de333c1ed3ac |