The Tokenizer is a necessary and pervasive component of Large Language Models (LLMs), where it translates between strings and tokens (text chunks). Tokenizers are a completely separate stage of the LLM pipeline: they have their own training sets, training algorithms (Byte Pair Encoding), and after training implement two fundamental functions: encode() from strings to tokens, and decode() back from tokens to strings. In this lecture we build from scratch the Tokenizer used in the GPT series from OpenAI. In the process, we will see that a lot of weird behaviors and problems of LLMs actually trace back to tokenization. We’ll go through a number of these issues, discuss why tokenization is at fault, and why someone out there ideally finds a way to delete this stage entirely.
Chapters:
00:00:00 intro: Tokenization, GPT-2 paper, tokenization-related issues
00:05:50 tokenization by example in a Web UI (tiktokenizer)
00:14:56 strings in Python, Unicode code points
00:18:15 Unicode byte encodings, ASCII, UTF-8, UTF-16, UTF-32
00:22:47 daydreaming: deleting tokenization
00:23:50 Byte Pair Encoding (BPE) algorithm walkthrough
00:27:02 starting the implementation
00:28:35 counting consecutive pairs, finding most common pair
00:30:36 merging the most common pair
00:34:58 training the tokenizer: adding the while loop, compression ratio
00:39:20 tokenizer/LLM diagram: it is a completely separate stage
00:42:47 decoding tokens to strings
00:48:21 encoding strings to tokens
00:57:36 regex patterns to force splits across categories
01:11:38 tiktoken library intro, differences between GPT-2/GPT-4 regex
01:14:59 GPT-2 released by OpenAI walkthrough
01:18:26 special tokens, tiktoken handling of, GPT-2/GPT-4 differences
01:25:28 minbpe exercise time! write your own GPT-4 tokenizer
01:28:42 sentencepiece library intro, used to train Llama 2 vocabulary
01:43:27 how to set vocabulary set? revisiting transformer
01:48:11 training new tokens, example of prompt compression
01:49:58 multimodal [image, video, audio] tokenization with vector quantization
01:51:41 revisiting and explaining the quirks of LLM tokenization
02:10:20 final recommendations
02:12:50 ??? :)
Exercises:
- Advised flow: reference this document and try to implement the steps before I give away the partial solutions in the video. The full solutions if you’re getting stuck are in the minbpe code
Links:
- Google colab for the video:
- GitHub repo for the video: minBPE
Supplementary links:
- tiktokenizer
- tiktoken from OpenAI:
- sentencepiece from Google
37 views
3689
1467
19 hours ago 00:00:23 1
Лень: откуда растут ноги?
19 hours ago 00:00:00 1
НАГИБ на Type 71 в Tanks Blitz
19 hours ago 00:00:29 1
Единственный путь к достойной жизни
2 days ago 00:48:11 1
Техномагия - описание системы от Николая Журавлева
2 days ago 00:57:22 1
Модель с аутизмом покоряет мир: хайп или вдохновляющий путь к успеху? Особенные разговоры #1
2 days ago 00:17:43 1
ДНЕВНИК САМОПРОГРАММИРОВАНИЯ | Как исполнять желания
2 days ago 01:23:48 1
One. Last. Ride.
3 days ago 01:10:37 1
“Я ПРОБОВАЛ ВСЕ ВИДЫ НАРКОТИКОВ“. Исповедь Павла Деревянко
3 days ago 00:21:53 2
Проститутка про восемь мужчин за ночь, первые 100$ и любовницу-лесбиянку | Без лица
3 days ago 00:10:43 1
California Games (NES) Playthrough - NintendoComplete
3 days ago 00:35:42 1
Journey to the Center of the Earth (It Took 8 Days, I Lost 10kg)
3 days ago 00:26:30 1
Почему ПОСТОЯННО НЕТ СИЛ? ? Скрытые причины ХРОНИЧЕСКОЙ УСТАЛОСТИ. Лайфхаки для бодрости
4 days ago 00:13:54 1
Ancient Temple Shows Cell Phone & Wrist Watch? Built with Psychic Powers?
4 days ago 00:35:41 1
🔥 ВОТ ПОЧЕМУ 90% ЛЮДЕЙ НЕ ДОСТИГАЮТ УСПЕХА: ПРАВДА О ЖИЗНЕННЫХ КАЧЕЛЯХ
4 days ago 00:33:30 1
ТЮНИНГ ПИТБАЙКА С WILDBERRIES!КРУТАЯ LED ПОДСВЕТКА!😏
4 days ago 01:18:37 1
«Крошка Цахес» | Путинизм как он есть #21
4 days ago 00:01:31 1
Алматыда трансұлттық ұйымдасқан қылмыстық топ мүшелеріне үкім шықты
4 days ago 00:21:00 1
КАПСУЛА ВРЕМЕНИ – 20 лет. Второй год. Задаю одни и те же вопросы Rukosueva Anna