Count number of tokens in the text file using toktoken tokenizer from OpenAI.
Project description
Count tokens
Simple tool that have one purpose - count tokens in a text file.
Requirements
This package is using tiktoken library for tokenization.
Installation
For usage from comman line install the package in isolated environement with pipx:
$ pipx install count-tokens
or install it in your current environment with pip.
Usage
Open terminal and run:
$ count-tokens document.txt
You should see something like this:
File: document.txt
Encoding: cl100k_base
Number of tokens: 67
if you want to see just the tokens count run:
$ count-tokens document.txt --quiet
and the output will be:
67
Related Projects
- tiktoken - tokenization library used by this package
Credits
Thanks to the authors of the tiktoken library for open sourcing their work.
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
count_tokens-0.3.0.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for count_tokens-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4f8470367d838469bdfa37529571ee1cc1bd539e20d3583fc17ca33854c68cf |
|
MD5 | 2137e8bc2651c2beee4e0e76476bec5d |
|
BLAKE2b-256 | e26eadd3e21c334142a4581bc8bc35da0387df97ce7e786527f3ce4183b8e967 |