Stochasticity in Tokenisation Improves Robustness
This paper demonstrates that training large language models with uniformly sampled stochastic tokenisations significantly enhances their robustness against adversarial and random perturbations while preserving accuracy and inference efficiency.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a very smart, well-read librarian (the AI model) who answers your questions. But there's a catch: this librarian only understands words if they are written in a very specific, rigid way.
In the world of Large Language Models (LLMs), this "writing style" is called tokenization. It's the process of chopping a sentence into small chunks (tokens) that the computer can read. Usually, this is done in one single, deterministic way. For example, the word "revolution" might always be chopped into one single chunk: revolution.
The Problem: The "Brittle" Librarian
The paper argues that if you train your librarian to only ever see the word "revolution" as one single chunk, they become brittle.
If someone sneaks into the library and changes the way the word is chopped—say, splitting it into re, vol, and ution—the librarian panics. They might think it's a completely different word or get confused, leading to a wrong answer. The paper calls this a "non-canonical tokenization." It's like if you told the librarian, "I'm asking about 'rev-ol-u-tion' today," and they suddenly forgot how to read "revolution."
The researchers found that these models are surprisingly fragile. A tiny, harmless change in how a word is split can cause the AI to fail completely, even if the meaning of the sentence hasn't changed at all.
The Solution: The "Flexible" Librarian
The paper proposes a simple but powerful fix: Stochastic Tokenization.
Instead of training the librarian to see "revolution" only as revolution, you train them to see it in many different ways randomly. Sometimes it's revolution, sometimes re-vol-ution, sometimes rev-o-lution.
Think of it like teaching a child to recognize a dog.
- The Old Way (Deterministic): You only show the child a Golden Retriever. If they see a Poodle, they don't recognize it.
- The New Way (Stochastic): You show the child a Golden Retriever, a Poodle, a Chihuahua, and a Great Dane. You teach them that "dog" can look many different ways.
By training the AI with this "randomness" (stochasticity), the model learns the essence of the word rather than just the specific way it was chopped up. It becomes robust.
The Experiments: What Happened?
The researchers tested this idea in three different "training camps":
- Pre-training (The Foundation): They trained a small model from scratch using random chopping.
- Result: The model got better at understanding the tiny details of words, but it wasn't a miracle cure on its own.
- Fine-tuning (The Specialization): They took a big, powerful model (like Llama) and gave it a "boot camp" where it had to solve puzzles using randomly chopped words.
- Result: Huge success! The model became incredibly tough. When they tried to trick it with weirdly chopped words later, it didn't even flinch. It kept its accuracy high, even when the input was messy.
- In-Context Learning (The Quick Lesson): They tried to teach the model on the fly by showing it examples in the chat prompt.
- Result: It helped a little, but not as much as actually training the model.
The Secret Sauce: Uniformity
The paper also discovered that not all "randomness" is created equal.
- The Flawed Method (STOCHASTOK): The previous method of random chopping was biased. It was like rolling a weighted die; some splits happened way more often than others.
- The Better Method (Uniform Sampling): The researchers created new methods to ensure every possible way of chopping a word had an equal chance of being used.
- Analogy: Imagine a lottery. The old method had some numbers that were drawn way more often. The new method ensures every number has an equal shot. This "fairness" made the model even stronger against malicious attacks (adversarial attacks) designed to trick it.
The Big Takeaway
The paper concludes that randomness is a superpower for AI safety.
By intentionally training AI models to handle messy, inconsistent, and random ways of breaking down words, we make them:
- Stronger: They don't break when someone tries to trick them with weird formatting.
- Smarter: They understand the actual meaning of words, not just the specific code they were given.
- Cheaper: You don't need more computer power to run them; you just need to change how you train them.
In short: If you want an AI that can't be easily fooled by a simple typo or a weird font, stop teaching it to be rigid. Teach it to be flexible, random, and adaptable. That's the key to a robust AI.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.