LLM Token Pollution: Why Special Tokens Fail to Stay Special

    This article examines a token pollution issue in large language models where user input that resembles a control token, such as an unclosed thinking-mode marker, triggers structured reasoning output. It explains the root cause in tokenization and training data preprocessing, presents supporting evidence and boundaries, and outlines fixes spanning tokenizer consistency checks, input-side constraints, targeted alignment data, and ongoing evaluation and monitoring.

    1. The Symptom: Control-Like Input Triggers Abnormal Output

    While using large language models, some developers have noticed that typing an unclosed thinking-mode marker into the input box—for example, just an angle bracket followed by the prefix think—does not produce the expected “input is empty” or “incomplete format” response. Instead, the model outputs a long, well-structured block of reasoning, as if continuing a conversation that never existed.

    This naturally raises suspicions of serious issues such as server-side cache mix-ups or accidentally hitting another user’s session. Reproducible experiments rule out these guesses one by one: loading public weights in a local inference environment, disabling prefix caching, injecting no system prompt, and using an independent context for every request, the behavior still reproduces consistently across more than ten runs. Cache and multi-tenant isolation issues are therefore excluded, leaving only the model weights and tokenization behavior as the explanation.

    2. Root Cause: Special Tokens Are Not Treated as Special

    Understanding this problem requires one basic fact: the model sees a sequence of tokens, not characters.

    Control markers injected on the system side (such as the session-start marker or the thinking-mode-on marker) each map to an independent ID in the vocabulary and are a single token. The identical-looking string typed by a user should, in theory, be split by the tokenizer into multiple ordinary tokens. Their IDs differ, so the model can naturally tell “who is speaking.”

    The difference can be expressed schematically:

    1. System injection: <think> -> [114514] # reserved single token in the vocabulary
    2. User input: "<think" -> [1919, 810] # split into multiple ordinary tokens

    The problem occurs when training corpus data enters tokenization: if the string describing thinking mode is not correctly mapped to the reserved token during preprocessing but is instead split as ordinary text, then in the training data the “system control marker” and “user-inputable text” become completely identical at the token-stream level.

    The consequences are chained:

    • The “thinking mode on” signal the model sees during training is actually a token sequence a user can construct;
    • At inference time, when a user inputs that sequence, the model cannot determine the source of the instruction, and the permission boundary fails;
    • The model tends to continue generating along this signal that “looks like a system instruction,” and starts “reciting answers”—splicing together fragments of reasoning passages learned during training, which appear as content resembling someone else’s conversation.

    This is a typical case of token pollution, sharing the same origin as marker injection/escape attacks in traditional parsers: as long as control markers and data travel in the same channel without escaping, injection succeeds.

    First, overfitting is the direct driver. The model is not actually “reading” any external session; it is performing high-confidence pattern completion. The content looks coherent because in the training distribution this token sequence is almost always followed by complete reasoning text.

    Second, mishandling empty input is a concurrent symptom. A well-behaved model should ask for clarification or refuse when it recognizes that the effective input is empty; a polluted model instead forces entry into thinking mode and generates content, indicating that the alignment stage lacks negative samples for boundary inputs.

    Third, the problem is not limited to a single control marker. Reserved markers such as the session-start marker and the sequence-start marker can exhibit the same type of pollution, differing only in trigger conditions and intensity. This also explains why the issue can be reproduced across models from different vendors and of different sizes—it is a data engineering problem, not a defect unique to one product.

    To clarify, “outputting what appears to be other conversations” is an anthropomorphic description by an outside observer; there is no evidence that the model accessed other users’ data. Mechanically, it is simply a controlled generation shift caused by identical token streams.

    4. Fixes: From Tokenizer Consistency to Alignment Fallback

    The core principle of the fix is a single sentence: system control markers must be single tokens that users cannot construct, and user input can only be a token stream.

    1. Tokenizer and preprocessing consistency checks. Unify template rendering logic before corpus ingestion to ensure all system-side control markers go through reserved-token mapping; build automated checks that scan the full corpus for identical strings that “should have been mapped but were not.”

    2. Hard input-side constraints for reserved tokens. Detect user text at the inference entry point, and escape or reject it when it matches the identical prefix of a reserved token, ensuring it can only enter the model as multiple tokens.

    3. Data re-washing and targeted alignment. Clean the polluted samples and add on the order of a hundred high-quality alignment samples covering scenarios where “user input resembles a control marker,” demonstrating correct behavior: recognizing empty or incomplete format, requesting clarification, and not entering thinking mode.

    4. Normalization of evaluation and monitoring. Build an injection test set and incorporate it into regression testing; online, use logging services and monitoring alerts to track the abnormal trigger rate and prevent data iterations from reintroducing pollution.

    5. Practical Conclusion

    This type of problem does not require overturning model capabilities or complex architectural changes; it is essentially missing escaping in the data pipeline. The most valuable lesson for teams to solidify is to apply the principle that “the control channel and the data channel must be isolated” across four areas: tokenization, corpus rendering, the inference entry point, and evaluation. Hosting inference services on a cloud container platform, managing corpus versions with object storage, and tracking abnormal rates with a logging and monitoring system can more reliably keep the fix from regressing over the long term.