How Token IDs Are Generated

When text is processed by a language model, the tokenizer converts the input text into a sequence of numerical IDs. Each token corresponds to a unique ID from the tokenizer's vocabulary. Here's how this process works:


Steps in Generating Token IDs

1. Vocabulary Creation

2. Tokenization

Example: "Tokenization is a foundational aspect." - Tokens: ["Token", "ization", "is", "a", "foundational", "aspect", "."]

3. Mapping Tokens to IDs

Example mapping: - "Token" → 1234 - "ization" → 5678 - "is" → 45 - "a" → 46 - "foundational" → 8910 - "aspect" → 1122 - "." → 5

So, the text: "Tokenization is a foundational aspect." Converts to: [1234, 5678, 45, 46, 8910, 1122, 5]

4. Special Tokens

For instance, the sequence might become: [101, 1234, 5678, 45, 46, 8910, 1122, 5, 102] Where: - [CLS] → 101 - [SEP] → 102


Why Subword Tokenization is Important for IDs


How IDs Are Used by Models


Tools to Explore Token IDs


Summary