POST 1 of 5 MorningAI/MLConcept
Tokens are not words
📅 Day 50. Halfway through the sprint. Welcome to NLP and transformers week. 📝 Let's start with the layer no one talks about but everyone uses — tokenisation. A tokenizer turns text into a list of integer IDs that the model can process. Modern tokenizers (BPE, WordPiece, SentencePiece) split text into subword units, NOT whole words. 🔤 Examples: → 'tokenization' might be ['token', 'ization'] — two tokens. → 'unbelievable' might be ['un', 'bel', 'ievable'] — three tokens. → 'hello world' is usually ['hello', ' world'] (the leading space is part of the token). → Numbers and punctuation each become tokens. → Emojis often become 2-4 tokens because they're encoded in multi-byte Unicode. 💰 Why this matters in practice — APIs charge by token, not by word. A 1000-word English blog post is roughly 1300 tokens. A 1000-character code snippet is roughly 250-400 tokens (code is denser). A page of dense math symbols is hundreds of tokens for a few lines. GPT-4-class models cost a few dollars per million tokens. For high-volume apps, token efficiency matters. 🌐 Tokenization is also language-dependent. English averages ~1.3 tokens per word. Chinese, Japanese, Korean often hit 1-2 tokens per character (much higher per equivalent meaning). Multi-lingual apps need to budget for this. 🎯 The takeaway: → Tokens ≠ words. The mental model 'each word is one token' is wrong. → Token counts are language-specific and content-specific. → Always count tokens before sending to APIs to estimate cost and check context limits. 💡 We'll write code to count tokens later in the day. For now — internalise that 'token' is the model's unit, not the human's.
#NLP#Transformers#LLM#AI#100DaysOfCode#Tokenization