High-Performance Implementation of OpenAI's TikToken - 2x Throughput, 4x Faster Code Tokenization
Project description
TokenDagger: High-Performance Implementation of OpenAI's TikToken
A fast implementation of OpenAI's TikToken, designed for large-scale text processing. 2x Throughput and 4x faster on code sample tokenization.
Benchmarks
Performed on an AMD EPYC 4584PX - 16c/32t - 4.2 GHz.
- Fast Regex Parsing: Optimized PCRE2 regex engine for efficient token pattern matching
- Simplified BPE: Simplied algorithm to reduce performance impact of large special token vocabulary.
- OpenAI Compatible: Full compatibility with OpenAI's TikToken tokenizer
Run Tests
make clean && make
pip3 install tiktoken
python3 tests/test_tokendagger_vs_tiktoken.py --tokenizer llama
python3 tests/test_tokendagger_vs_tiktoken.py --tokenizer mistral
python3 tests/performance_benchmark.py --tokenizer llama
python3 tests/performance_benchmark.py --tokenizer mistral
python3 tests/code_performance_benchmark.py --tokenizer llama
================================================================================
🎉 CONCLUSION: TokenDagger is 4.02x faster on code tokenization!
================================================================================
📦 Installation
From PyPI (Recommended)
pip install tokendagger
🛠️ Dev Install
git clone git@github.com:M4THYOU/TokenDagger.git
sudo apt install libpcre2-dev
git submodule update --init --recursive
sudo apt update && sudo apt install -y python3-dev
And optionally for running the tests:
pip3 install tiktoken
Dependencies
- PCRE2: Perl Compatible Regular Expressions - GitHub
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
tokendagger-0.1.0.tar.gz
(3.0 MB
view details)
File details
Details for the file tokendagger-0.1.0.tar.gz.
File metadata
- Download URL: tokendagger-0.1.0.tar.gz
- Upload date:
- Size: 3.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b2042286ee7f3a54b5fab39328072ff76a4dc83483a0d03aa7fce83948fd3c
|
|
| MD5 |
ae52120682a8653a7ba2922e965adc3d
|
|
| BLAKE2b-256 |
0e79b3f11f0a9990d40302a5a178a20b42a9aaf104b58f13dff553b6df30b69f
|