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.0.tar.gz (5.8 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.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitty_tokenizer-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 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.0.tar.gz
Algorithm Hash digest
SHA256 27393cce58e16d40e53cdcbad1ffeba4160737555af2a6e19e0ed6e27bf96a0d
MD5 22719e0b9ad8bb8ded26959197e4b80c
BLAKE2b-256 a291e179416ccad463b1132858052d9cf92cf338c2b656b0cddf08bc37fad9fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 378775f121f7b8375896a035229208523052bc704505881e372dd6f407d3f257
MD5 a4ca9a891b6510309d589fdb55fd5320
BLAKE2b-256 53e7ced4b2a47151b22bb072f1a573df2a6fe94a8829b08e91c6ec73b60bafe8

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