Skip to main content

A bitty BPE tokenizer library

Project description

tokenizer.png

Bitty, clean code for the (byte-level) Byte Pair Encoding (BPE) algorithm commonly used in LLM tokenization. The BPE algorithm is "byte-level" because it runs on UTF-8 encoded strings.

This algorithm was popularized for LLMs by the GPT-2 paper and the associated GPT-2 code release from OpenAI. Sennrich et al. 2015 is cited as the original reference for the use of BPE in NLP applications. Today, all modern LLMs (e.g. GPT, Llama, Mistral) use this algorithm to train their tokenizers.

Tokenizers are the reason why Language models work so well, hallucinates other time, doesnt work well in finance industry, and can make or break a system

Find medium link explaining tokenization here : https://medium.com/@mohitdulani/train-a-tokenizer-from-scratch-4a33450d42ee

To Download the data use these commands :

mkdir -p data
cd data

wget https://huggingface.co/datasets/roneneldan/TinyStories/resolve/main/TinyStoriesV2-GPT4-train.txt
wget https://huggingface.co/datasets/roneneldan/TinyStories/resolve/main/TinyStoriesV2-GPT4-valid.txt

or simply run the download.sh script (works on Linux, Mac, or Windows with WSL/Git Bash):

bash data_download.sh

Lecture

For more indepth video lecture refer to :

Andrej Karpathy on Tokenizer

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

bitty_tokenizer-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitty_tokenizer-0.1.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file bitty_tokenizer-0.1.2.tar.gz.

File metadata

  • Download URL: bitty_tokenizer-0.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for bitty_tokenizer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1c422a59ec270e0ad7f7ab32d44a4b9901c3ae773a324c9f8e14a39c7ad1b011
MD5 0b934c71f2a6caa315e25e528ba0bed3
BLAKE2b-256 490c4eafcce72ba14e09ac20997e183bb8b5ea8f2b4eb6add1384ed6185db3c1

See more details on using hashes here.

File details

Details for the file bitty_tokenizer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e4a24cafa37716c6c5987dc02374b9e0c2a29d4bf9c36b471357ed8aa636e63
MD5 0374a43bbff8a036e75c2045c641d59b
BLAKE2b-256 924d33baea220f3b40595a55b9b147aac84f28db9f07e7201ff7da3a4c741c32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page