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
- Playlist of the whole Zero to Hero series so far:
- our Discord channel:
- my Twitter:
Supplementary links:
- tiktokenizer
- tiktoken from OpenAI:
- sentencepiece from Google
1 view
126
28
2 months ago 00:35:46 1
Boeing: The perfect story of what’s wrong with America’s economy? | Gautam Mukunda
2 months ago 00:00:36 1
Доприседалась курица#shorts
2 months ago 00:03:51 1
Awaken Now | Melodic Techno
2 months ago 00:10:49 1
As sales fall in China VW group forced to shut down 2 more factories
2 months ago 00:05:45 1
Peter Gabriel - Sledgehammer (HD version)
2 months ago 00:05:24 1
twenty one pilots - Chlorine (Official Video)
2 months ago 00:14:36 1
Taiwan Driver-Car Racing & Sim Android Gameplay
2 months ago 00:04:10 1
Tina Turner - The Best (Official Music Video)
2 months ago 00:29:08 1
How To Build A Better You | The Bedros Keuilian Show E005
2 months ago 01:10:58 1
Johnny M - Let’s Go Deeper | Deep House Set
2 months ago 00:04:44 1
100+ ITEMS! THE SIMS 4 CC FOLDER CHILD GIRLS SIM DUMP
2 months ago 00:03:35 1
Darren Hayes of Savage Garden - So Beautiful (Video)
2 months ago 00:03:39 1
Project T | A First Look
2 months ago 01:05:44 1
Сборник шедевров!!! Самая красивая музыка для души! FOR THE HEART 2024 !
2 months ago 00:03:50 1
Eric Clapton - It Hurts Me Too (The Prince’s Trust Masters Of Music 1996)
2 months ago 00:09:19 1
This Cooler Blew My Mind! (Peerless Assassin 90 SE Review)
2 months ago 00:21:05 1
Chosen Ones, 8 Things You MUST LOSE Before Your Breakthrough!
2 months ago 00:10:58 1
English Speaking Practice Session - How To Give Compliments - Advanced English Conversation
2 months ago 00:32:32 5
I’m remastering Bloodborne (kinda). Let’s talk about it.
2 months ago 00:16:43 1
“We can’t take this anymore“ IT HAS TO STOP!!
2 months ago 00:15:53 1
What does it take to BEAT Shiyu Defense? Guide and Showcase - Zenless Zone Zero
2 months ago 00:08:10 4
Katarina’s Daggers (League of Legends) - MAN AT ARMS: REFORGED
2 months ago 00:13:18 1
Tips for Building Glutes 🍑
2 months ago 00:03:19 1
Believer - Imagine Dragons (violin/cello/bass cover) - Simply Three