Tokens And Text Representation
PART 2 — Tokens and Text Representation¶
AI models process fixed-length integer arrays, not strings. The conversion is done by a Tokenizer.
Example Trace (Byte Pair Encoding):
Let's tokenize the string: "unfriendliness"
- The tokenizer looks at its dictionary (vocabulary).
- It breaks the string into known chunks:
["un", "friend", "li", "ness"] - It maps these to integer IDs:
SDE Implication: If you change "friend" to a word the tokenizer doesn't know well, it might split it into 5 characters [f, r, i, e, n, d]. This means 1 word suddenly costs 5x more compute and API cost to process!