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.9.2.tar.gz
(756.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
totokenizers-1.9.2-py3-none-any.whl
(766.9 kB
view details)
File details
Details for the file totokenizers-1.9.2.tar.gz.
File metadata
- Download URL: totokenizers-1.9.2.tar.gz
- Upload date:
- Size: 756.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c515f6682a87f4decebffefbdc3c4f621d40f5f0727eedd793ebb619d19a33c1
|
|
| MD5 |
f43263ae08744196466c94d1a75f2eba
|
|
| BLAKE2b-256 |
1032299fe659ae663f1a6a91f65122e0597488ae7ff4bedac27232ee49368c38
|
File details
Details for the file totokenizers-1.9.2-py3-none-any.whl.
File metadata
- Download URL: totokenizers-1.9.2-py3-none-any.whl
- Upload date:
- Size: 766.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55e27e45732bc6b2e1610c80d3af34d34fd777efb246fc73e2b9c83e9d7b9904
|
|
| MD5 |
8d590b3dc82835df76c2c87b4f0d4452
|
|
| BLAKE2b-256 |
ee3d75c45a9213ed5e12c2970080c3b063736b742151dceff06fd739b807f5be
|