# Poster 27677

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/27677

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hi, this is Boo and today I'll talk about tokenization in language models. In particular, I'll describe an algorithm that converts your tokenized language model into a byte-equivalent one.
Tokenization is an encoding process that defines text into smaller pieces known as tokens. Each token has a unique ID within a predefined vocabulary. These IDs are input into the language model which returns a list of next token probabilities. Note that we can also recover back to the original text through a decoding function.
Here is another example for code completion task. You can notice that the language model will never output the correct solution, which is the token A in this case. This can be traced down to tokenization and we call this phenomenon tokenization bias. To better understand tokenization bias, consider this simple language model, which is a Markov chain with two states, A and B.
We introduce tokenization with the following vocabulary. Notice that we have an extra token which is a double A. Here, BBE and MPE stands for byte pair encoding and maximum prefix encoding. They are commonly used in nowadays language models.
The idea is that tokenization change our original two states Markov chain into the following three states Markov chain. Notice that the red arrow were from token A, we can only sample next token as B. This is because tokenization always merges two characters A's into one single double A token.
For BBE and MPE, we can precisely know when this happens. In general, a sequence of token has zero probability if it is different from the encoding of its decoded string, and we refer these encodings as invalid, otherwise it is a valid encoding.
Our solution is to convert tokenize language model into its equivalent byte level one. Note that there is no training required for this algorithm.
You can think of this algorithm as a green box below which repeatedly requires the result from the original tokenized language models. The end result is that we fix the tokenization bias issue and obtain the correct token with high probability. This also allows us to ensemble multiple language models together even when they do not share the same vocabulary.
Here is an illustration of how this can be done. Basically we convert all the type nice language models into the same byte domain. We now introduce the main algorithm. Basically we want to compute the probability that a string starts with a certain prefix, which is x_1 to x_n in this case. The main idea is to find all encodings that covers this prefix.
As an example, consider this vocabulary and we are doing MPE. From this prefix B, we find that there are two valid encodings that contain this prefix shown below. So, any strings whose encoding start with one of these two must also start with the prefix B and vice versa. We formalize this idea here in Step 1 of our algorithm.
In the paper, we refer to these encodings as cover encodings of X, and you can find our paper how to efficiently find these cover encodings. The second and also the last step is basically sum up the probability of all these cover encodings. For a next-byte prediction, we can use base rule to compute the probability.
But doing this naively for every step is very slow, so check the paper on how to do this efficiently. Our algorithm effectively fixed tokenization bias issue. Here we show the performance in film coding task and test our method in several settings. Overall, it outperforms all other heuristic fixes.
For the case of ensemble model, we observe that combining models with similar individual score often boost the performance. This observation holds for complicated reasoning tasks such as coding as well. Thank you for visiting our paper. You can find the code and paper in the following links.
