The process of tokenization and embedding occurs before a large language model processes data in the residual stream. Tokenizers convert raw Unicode strings into integer IDs using a fixed vocabulary and pre-learned merge ranks, such as in the Byte-Pair Encoding algorithm.

Variations in tokenization can bypass security filters. For example, replacing a standard ASCII comma with a full-width comma can change the model's output language. This happens because filters and models interpret text differently, leading to a discrepancy in how input is validated versus executed.

Token expansion poses security risks. Adding diacritics can inflate a short string into hundreds of tokens, potentially pushing malicious instructions beyond the truncation limits of lightweight security classifiers while remaining within the context window of the main LLM.

Homoglyph attacks, such as replacing Latin characters with visually identical Cyrillic ones, can deceive human operators and automated systems. Standard Unicode normalization like NFKC does not prevent these attacks, as it treats such characters as distinct, independent letters.

Security strategies should rely on deterministic parsers rather than implicit trust in model behavior. Developers must ensure that security filters and the LLM use consistent tokenization methods to prevent attackers from exploiting the gap between input validation and model processing.