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.3.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.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitty_tokenizer-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ae89c0caab82aa9c63b34a374d0fc22e5e3fd3f7e0c4b936a60bd82c178ea3fb
MD5 1c3ef21385858dae3c0db8cf67e38ab1
BLAKE2b-256 b7430794bed8504e8ad7b516a2bc36a4b51bad3c99fc9da66fd4cd71380ea100

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d348f35881b7658dcda5166d7b426a8583b7f3b67adb18ab4fd94efdd9c6927f
MD5 ce04462751187b7b69a3ce9c281ec30a
BLAKE2b-256 dc71f76dda128259f24a83dfa89f79bd98a0f3b5443a4051c3b709f167d6c34f

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