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.4.tar.gz (6.4 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.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitty_tokenizer-0.1.4.tar.gz
  • Upload date:
  • Size: 6.4 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.4.tar.gz
Algorithm Hash digest
SHA256 ba5f0edba801770b6d7d725fe0da375bbaedf58d076932a2149a1c3f36f4d73b
MD5 5265c6e63782561dac1c8c0409364130
BLAKE2b-256 e4ee3c743e41397d122c4e0fffcd00e7ee6857672ac914fe9495177f2e1a5ac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 143a412ab1561929e9276f585372a3c68a912a70e67281ce92f8e717a755e793
MD5 1e7187bd1249717b6ac36fe153d87841
BLAKE2b-256 39d145e968a88787b266009bca50df1a7cf3a0b3cb808166bb2d0adb076950c5

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