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.1.tar.gz (6.0 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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bitty_tokenizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a2abec03b2346fd939cfbc361bc7e144b7a4e0e20c7ac91ce720d35b8b613c41
MD5 44f19ca807f05f47c88450187473d7c6
BLAKE2b-256 4bb0de31e47dac11326ff2b0fc1aec6ab77060d4795580bf4129d0b41e080f55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98142b1898e9e3dd1638ebfa92315c206ef9245d4b37edae679bf0f5c8254d06
MD5 0ebf2edc522c0887320057228dab7831
BLAKE2b-256 a0ae5341ebb811cd1bf3748cdeed8620e657e1989f1494588cb4906b60d98a59

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