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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bitty_tokenizer-0.1.5.tar.gz
Algorithm Hash digest
SHA256 28167ffab6b17862bb62f84038dffe16152ee46bba2781e10bd1d491703c7496
MD5 d1a0a281c6565fa95b775083e26b5400
BLAKE2b-256 b9324ebd74ce535f4c0791a4807b3c437986a426e1665ed6cc26ee44d52e08d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bitty_tokenizer-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe41d0e6411e30646994f116db5a4797a3820dafd7d2896d1113ef0902650f9
MD5 23ed2495298b91b2a6cfc18a1006bc19
BLAKE2b-256 35e2063decf7257ca479dfc5c2fd12e711bb0651f418a7222afec2d7a17f45e7

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