Abstract

How does a language model turn a string of text into something it can compute with, and what follows from the way it does it? A tokenizer cuts text into units from a fixed vocabulary, usually subwords learned by byte-pair encoding, WordPiece or a unigram language model, and an embedding maps each unit, or a whole passage, to a vector. Worked merge and cosine-similarity examples can be checked by hand. Measured effects: chunking digits left to right cut one model’s addition accuracy by 22 points, one 2023 tokenizer needed up to 15 times more tokens for the same text in some languages, and on character-position tasks accuracy was negatively correlated with the length of the token holding the character, while on counting tasks tokenization measures were only weakly associated with correctness. Byte-versus-subword comparisons turn on what is held equal: at matched training FLOPs, the subword models in one 2026 study reached lower validation loss. On security, a 2023 attack recovered most 32-token texts exactly from two embedders it could query, so stored embeddings should be handled according to the sensitivity of their source text; in published tests, tokenizer-level perturbations also evaded some classifiers and safety filters.

Why text has to be cut up

A neural network computes with vectors of numbers. Before a model can read a sentence, something has to decide what the units of that sentence are and give each unit a number, and then a vector. The choice of unit looks like plumbing, but it fixes what the model can see, how long its inputs are, how much each request costs and which inputs it has never been trained on.

The obvious unit is the word. A word vocabulary has two problems. The first is that it is closed: any word not in the list, whether a rare surname, a new product name, a typo or a German compound, has no entry and must be mapped to a catch-all unknown symbol. Sennrich, Haddow and Birch framed this in 2015 for machine translation, where models of the time used a fixed vocabulary “but translation is an open-vocabulary problem”; earlier systems patched the gap by looking unknown words up in a dictionary.1 The second problem is size. Every word in the vocabulary needs its own row of parameters, and a vocabulary large enough to cover a real corpus has a long tail of words seen only a handful of times, whose rows are barely trained.

The other obvious unit is the character, or the byte. A vocabulary of the 256 byte values covers any UTF-8 text, so nothing is ever out of vocabulary; a character vocabulary covers the characters it lists, which removes unknown words but not unknown characters. The cost is length. In a transformer’s full self-attention every position is compared with every other (in a decoder-only model, with every earlier one, under a causal mask), so its cost grows with sequence length,2 and a byte sequence is several times longer than the same text in subwords. The sibling reader on the transformer covers the mechanism. Byte-level models also lagged in quality: the GPT-2 report noted in 2019 that byte-level language models “are not competitive with word-level LMs on large scale datasets” and that OpenAI saw “a similar performance gap” in its own attempts.3

Subword tokenization sits between the two. Frequent words get a single unit, rare words are spelled out from smaller pieces, and the vocabulary stays at a size chosen in advance. The GPT-2 report calls byte-pair encoding “a practical middle ground between character and word level language modeling”.3

Byte-pair encoding

From compression to segmentation

Byte-pair encoding began as a data compression technique. Sennrich and colleagues credit it to Philip Gage in 1994 and describe it as a method that “iteratively replaces the most frequent pair of bytes in a sequence with a single, unused byte”.1 Their adaptation, published at ACL 2016, merges characters and character sequences instead of bytes. Each word in the training corpus starts as a sequence of characters followed by an end-of-word marker. The algorithm counts every adjacent pair of symbols, weighted by how often each word occurs, replaces the most frequent pair with a new symbol, and repeats. Pairs that cross word boundaries are not considered, so the algorithm can run on a word-frequency dictionary instead of the full text. The final vocabulary size equals the size of the initial character set plus the number of merges, and the number of merges is “the only hyperparameter of the algorithm”.1

At test time the learned merges are replayed, in the order they were learned, on any input word. A word that never appeared in training still gets a segmentation, built from the learned pieces, provided its characters were seen in training. On the WMT 2015 translation tasks, their best subword systems improved on a dictionary back-off baseline “by up to 1.1 and 1.3 BLEU” for English to German and English to Russian; the gains varied across the subword configurations they compared.1 The method removes unknown words but not unknown characters: the paper notes that the only symbols unknown at test time are characters never seen in training, or pieces whose every training occurrence was merged into something larger.1 Their English to German systems used 59,500 merge operations with separate source and target encodings and 89,500 with joint BPE, where one set of merges is learned on both languages together.1

A merge example you can check by hand

Take a training corpus with four distinct words and their counts: lower 9 times, newer 8 times, lowest 5 times and wider 3 times. Write _ for the end-of-word marker and split each word into characters.

wordcountsymbols
lower9l o w e r _
newer8n e w e r _
lowest5l o w e s t _
wider3w i d e r _

The starting vocabulary is the eleven distinct symbols: l, o, w, e, r, n, s, t, i, d and _.

Merge 1. Count adjacent pairs, weighting each by the word’s count. The pair w e occurs in lower (9), newer (8) and lowest (5), for 22. The next highest are e r and r _, each 9 + 8 + 3 = 20, then l o and o w at 14. Merge w e into we.

Merge 2. lower is now l o we r _, newer n e we r _, lowest l o we s t _, wider unchanged. The pair e r now survives only in wider (3). The top pair is r _ at 20 (9 + 8 + 3), ahead of we r at 17. Merge r _ into r_.

Merge 3. The pair we r_ occurs in lower and newer: 17. l o and o we are 14. Merge into wer_.

Merge 4. lower is l o wer_, newer n e wer_. The pair l o occurs in lower and lowest: 14. Next are o wer_ (9), n e and e wer_ (8). Merge into lo.

Merge 5. lower is lo wer_, so lo wer_ occurs 9 times; nothing else reaches 9. Merge into lower_.

After five merges the vocabulary has 11 + 5 = 16 symbols, as the formula says. The corpus words now segment as lower_ (one token), n e wer_ (three), lo we s t _ (five) and w i d e r_ (five). The most frequent word became a single token, the shared ending of lower and newer became a unit (wer_, an artefact of this corpus with no linguistic meaning), and the rarer words remain partly spelled out.

Now apply the merges to a word the tokenizer never saw, slower. Start from s l o w e r _. Merge 1 gives s l o we r _, merge 2 s l o we r_, merge 3 s l o wer_, merge 4 s lo wer_, and merge 5 s lower_. The unseen word comes out as two tokens, s and lower_. Nothing was out of vocabulary, and the segmentation reuses the pieces the model has already learned. The example also shows a quirk that matters later: slower and lower now share a token, while lowest is cut into five pieces that do not include low, because in this corpus low was never merged.

The merge loop in code

Sennrich and colleagues printed a minimal Python implementation in the paper.1 A compressed version of the same loop:

import collections

def learn_bpe(word_counts, num_merges):
    # each word becomes a tuple of characters plus an end-of-word marker
    vocab = {tuple(w) + ('_',): c for w, c in word_counts.items()}
    merges = []
    for _ in range(num_merges):
        pairs = collections.Counter()
        for symbols, count in vocab.items():
            for a, b in zip(symbols, symbols[1:]):
                pairs[a, b] += count
        if not pairs:                          # every word is a single symbol
            break
        best = max(pairs, key=pairs.get)       # ties: first pair counted wins
        merges.append(best)
        new_vocab = {}
        for symbols, count in vocab.items():
            out, i = [], 0
            while i < len(symbols):
                if i + 1 < len(symbols) and (symbols[i], symbols[i + 1]) == best:
                    out.append(symbols[i] + symbols[i + 1]); i += 2
                else:
                    out.append(symbols[i]); i += 1
            new_vocab[tuple(out)] = count
        vocab = new_vocab
    return merges

Run on the four-word corpus above with num_merges = 5, it returns the five merges in the order derived by hand. The function expects a dictionary of words with positive counts and stops early if no pairs remain. The example was chosen so that no step has a tie. When there is one, Python’s max returns the first of the equal candidates, so this snippet picks the tied pair it counted first, which depends on the order of the input dictionary. Other implementations use other rules, which is one reason two “BPE” tokenizers trained on the same data need not agree.

Byte-level BPE

Sennrich’s BPE starts from characters. For a model meant to accept any text, that is a problem: Unicode has a very large number of code points, and the GPT-2 report notes that a code-point BPE covering all of them “would result in a base vocabulary of over 130,000 before any multi-symbol tokens are added”, against the 32,000 to 64,000 token vocabularies then typical.3 GPT-2’s answer was to run BPE on UTF-8 bytes. The base vocabulary is then only 256 symbols, and any UTF-8 text can be encoded without an unknown token.

Naive byte-level BPE wasted vocabulary. The report observed it learning “many versions of common words like dog since they occur in many variations such as dog. dog! dog?”. The fix was to forbid merges across character categories, so that letters do not merge with punctuation, with “an exception for spaces”.3 GPT-2’s vocabulary was 50,257 tokens and its context 1,024 tokens.3 Because a space may merge with the letters after it, dog at the start of a text and dog after a space can be different tokens, one of many ways in which the same visible word has more than one token form, a point that resurfaces in the section on evasion.

WordPiece, the unigram model and SentencePiece

WordPiece

WordPiece predates the BPE adaptation. Schuster and Nakajima described it in 2012 for Japanese and Korean voice search at Google, where text has few or no spaces and they wanted a segmenter that “depends only on the data” and does not produce out-of-vocabulary words.4 Their procedure starts the inventory with the basic Unicode characters, builds a language model on the training data, and adds the new unit, formed by combining two existing units, “that increases the likelihood on the training data the most”, repeating until a target number of units is reached or the likelihood gain falls below a threshold.4 Kudo later summarised the difference from BPE in a footnote: the WordPiece model “uses a likelihood instead of frequency”.5 Training it by brute force means testing every candidate pair against a rebuilt language model at each step, so the paper describes shortcuts such as only testing pairs that occur in the data.4

BERT used “WordPiece embeddings ... with a 30,000 token vocabulary”.6 Building that vocabulary and applying it are separate steps. In Google’s released BERT code, the WordPiece stage runs after a basic preprocessing tokenizer and applies the vocabulary with “a greedy longest-match-first algorithm”: from the start of each word it takes the longest piece in the vocabulary and marks later pieces with a ## prefix (its example splits unaffable into un, ##aff, ##able). It replaces the whole word with an unknown token in two cases: the word is longer than a length cap (200 characters by default), or some position matches nothing.7 The Transformer paper used “a 32000 word-piece vocabulary” for English to French and byte-pair encoding with about 37,000 shared tokens for English to German.2

The unigram language model

BPE and WordPiece build a vocabulary upward, by merging. Taku Kudo’s unigram language model, published in 2018, works downward.5 It treats a segmentation as a sequence of subwords that each occur independently, so the probability of a segmentation is the product of its pieces’ probabilities, and the best segmentation of a word can be found with the Viterbi algorithm. To learn the vocabulary, it starts from a deliberately large seed vocabulary, fits the piece probabilities with the EM algorithm, computes for each piece how much the corpus likelihood would drop if it were removed, keeps the top share (Kudo gives 80 per cent as an example) and repeats until the vocabulary reaches the target size. Single characters are always kept “to avoid out-of-vocabulary” words; characters absent from the training data remain unknown.5

The unigram model’s advantage is that it defines a probability over every possible segmentation of a word, not just one. Kudo used this for subword regularization: during training the model sees different segmentations of the same sentence, sampled from that distribution, as a form of noise. He reported consistent gains, “especially on low resource and out-of-domain settings”.5 The same difference may bear on a result in the evasion section below, where Unigram-tokenized classifiers resisted an attack that perturbed words.

SentencePiece

Earlier subword tools assumed text had already been split into words by a language-specific pre-tokenizer, which is awkward for Japanese or Chinese and loses information about where spaces were. Kudo and Richardson’s SentencePiece, released in 2018, trains BPE or unigram models “directly from raw sentences”.8 It treats the input as a sequence of Unicode characters, handles whitespace as an ordinary symbol by escaping it to the meta symbol ▁ (U+2581), and so makes tokenization lossless: decoding the tokens and replacing ▁ with a space gives back the normalised input exactly.8 The authors call the result language independent, and their example tokenizes Hello world. as [Hello] [▁wor] [ld] [.].8 LLaMA, for example, used “the bytepair encoding (BPE) algorithm ... using the implementation from SentencePiece”, with two adjustments that matter later: it split “all numbers into individual digits” and fell back “to bytes to decompose unknown UTF-8 characters”.9

The four approaches side by side

BPE (Sennrich 2015)WordPiece (Schuster and Nakajima 2012)Unigram LM (Kudo 2018)Byte-level BPE (GPT-2, 2019)
Builds vocabulary bymerging the most frequent adjacent pairmerging the pair that most raises language-model likelihoodpruning a large seed vocabulary by likelihood lossBPE merges over UTF-8 bytes
Base unitstraining characterstraining characterstraining characters, all kept256 byte values
Segmentation of a worddeterministic replay of mergesin BERT’s released code, greedy longest match with ## continuationsmost probable segmentation, or sampleddeterministic replay of merges
Unknown inputcharacters missing from training, and pieces whose every training occurrence was merged into larger onescharacters missing from training; in BERT’s code, a word over the length cap or with an unmatched positioncharacters missing from trainingnone for UTF-8 text: every byte is in vocabulary
Known users cited hereWMT 2015 systemsBERTsubword regularization; SentencePiece optionGPT-2

Each column cites the paper that introduced or used it.145367

What tokenization does to a model

Spelling and letter counting

A model that reads lower_ as one symbol does not see the letters inside it. It can learn which letters a token contains, since spellings appear in training text, but the information is indirect. The measured picture is task-specific. Uzan and Pinter tested it in 2025 with CharBench, a benchmark of character-level tasks run on seven models including GPT-4o, DeepSeek-V3 and Llama-3.3-70B.10 For counting tasks they found that “tokenization properties are weakly correlated with correctness”, while “the length of the queried word and the actual character count play a more significant part”. For tasks requiring position within a word, performance was negatively correlated with the length of the token containing the queried character, a measure the paper defines for those indexing tasks; the authors offer, as an interpretation, that longer tokens obscure where a character sits.10 The two results are separate associations, one for position tasks and one for counting.

Digits and arithmetic

Numbers show the effect more cleanly. The tokenizer used for GPT-3.5 and GPT-4 has a token for every string of one to three digits and, in Singh and Strouse’s words, defaults “to breaking a long number into 3-digit chunks, left-to-right”.11 So 1234567 is read as 123, 456, 7, while the column arithmetic people learn at school is aligned from the right. Singh and Strouse forced right-to-left chunking by inserting commas every three digits from the right. On 8-shot addition of two numbers of 7 to 9 digits with gpt-3.5-turbo-0301, accuracy rose from 75.6 per cent with the default chunking to 97.8 per cent with commas, a difference of 22.2 percentage points.11 They also found the errors under the default were systematic. Across the other snapshots they tested, the effect stayed strong in later GPT-3.5 versions, was weaker but still present in GPT-4 (most of all in the June 2023 snapshot) and became stronger again in GPT-4 Turbo; the authors’ explanation, that GPT-4’s larger training scale lets it override the bias, rests on model sizes that they state as assumptions.11 A different design avoids multi-digit tokens altogether: LLaMA’s 2023 tokenizer split “all numbers into individual digits”.9

The tokenizer tax on other languages

A tokenizer’s merges are learned from its training corpus, so how often a language appears there is a plausible contributor to how efficiently it is encoded, alongside its script, how many bytes its characters take in UTF-8, and pre-tokenization rules. Petrov, La Malfa, Torr and Bibi measured this at NeurIPS 2023 on FLORES-200, a dataset of the same sentences translated into some 200 languages.12 For the tokenizer used by ChatGPT and GPT-4, the same content took about 1.6 times as many tokens in Italian as in English, 2.6 times in Bulgarian, 3 times in Arabic and up to 15 times in Shan, a language of Myanmar.12 Their example is one Shan word for “you”: a consonant with three diacritics, four Unicode code points, encoded as nine tokens, where the English you is one.12 Even Portuguese, the closest to parity, needed about 50 per cent more tokens than English. Byte-level representation, which involves no learned merges, still differs by language: the paper finds the byte encoding of the same text “over 4 times longer for Burmese or Tibetan than Chinese”.12

Context limits and per-token pricing

The token is the unit in which model limits and many prices are set. A context window is a number of tokens (1,024 for GPT-23), and many commercial APIs charge per token. Petrov and colleagues counted tokens on parallel text and inferred the pricing consequence: under per-token pricing, their measured premiums “directly map to cost premiums”. With the ChatGPT and GPT-4 tokenizer they measured in 2023, the same text took 1.64 times as many tokens in Italian as in English, so at the same per-token rate its input would be charged about 1.64 times as much; that is an implication for input-token charges, not a measured bill.12 The same premium means less content fits in a fixed token window, and they argue it lengthens processing time, though how much depends on the workload and the serving system.12 A practitioner comparing two models’ context limits or prices should compare them on the language and kind of text the deployment will actually see, since a window of the same nominal token count holds different amounts of text under different tokenizers.

Glitch tokens

A tokenizer is often trained separately from the model that uses it, and one way things go wrong is a mismatch of data: a string frequent in the tokenizer’s corpus earns its own token and then almost never appears in the model’s training data, so the model barely learns it. Land and Bartolo’s “Fishing for Magikarp” (EMNLP 2024) studies such under-trained or glitch tokens; their Figure 1 shows the GPT-2-era example, a token for the string SolidGoldMagikarp preceded by a space, the leading space being part of the token.13 Their method has three steps: analyse the tokenizer, rank candidates with indicators computed from the model’s weights (under-trained tokens’ output embeddings tend to share a direction, so their distance to the embeddings of known unused tokens is informative), and verify the top-ranked 2 per cent with prompts that ask the model to repeat the token, flagging those it assigns under 1 per cent probability. Partial UTF-8 sequences and unreachable tokens are excluded from that verification step.13 The paper separates three kinds of problem token: reachable tokens that are under-trained; unreachable tokens that no input text produces, often intermediate BPE fragments left behind by merges, such as _TheNitrome from the longer GPT-2 token _TheNitromeFan; and single-byte tokens, such as bytes that never occur in valid UTF-8.13 They report such tokens across many models and propose that detection could help protect deployed models “from unwanted inputs, for example through sanitization”; the paper does not evaluate sanitization as a defence.13

Embeddings: meaning as geometry

The distributional idea

Tokenization gives each unit an integer. An embedding replaces the integer with a vector of real numbers. In a language model the embedding is a row looked up by token ID and trained only to help predict text; any similarity structure among the rows is a by-product. Methods such as word2vec, GloVe and the sentence embedders below shape the geometry more directly, so that units used in similar ways end up near each other. The intuition behind that goal is old. It is usually traced to the linguists J. R. Firth, whose line “you shall know a word by the company it keeps” is much quoted, and Zellig Harris; Brunila and LaViolette’s 2022 re-reading argues the two held different and partly conflicting views, Harris focused on the internal structure of language and Firth on wider situational context, and that NLP has flattened them into one slogan.14

Bengio, Ducharme, Vincent and Jauvin turned the idea into a neural model in 2003. Their argument was about the curse of dimensionality: a word sequence seen at test time is likely to differ from every sequence seen in training. Their remedy was “learning a distributed representation for words” jointly with the language model, so that a new sentence could get high probability if its words were similar to words in familiar sentences.15 There the embedding was a by-product of language modelling, the same role the input embedding plays in transformer language models.

word2vec: CBOW and skip-gram

In 2013 Mikolov, Chen, Corrado and Dean stripped the neural language model down to make embeddings cheap to learn at scale.16 Their continuous bag-of-words (CBOW) model removes the hidden layer, averages the vectors of the surrounding words (four before and four after worked best) and trains a log-linear classifier to predict the middle word. The skip-gram model reverses the direction: the current word’s vector is used to predict the words within a window around it, with distant words sampled less often.16 They trained on a Google News corpus of about 6 billion tokens with a vocabulary of the million most frequent words and built a test set of 8,869 semantic and 10,675 syntactic analogy questions.16 In their comparison CBOW did better than skip-gram on the syntactic questions and skip-gram did much better on the semantic ones.16

A second paper the same year added training refinements: negative sampling, which the authors present as a simpler alternative to hierarchical softmax, in which the model learns to tell real context words from randomly drawn ones; subsampling of very frequent words; and a method for learning vectors for phrases such as Air Canada, whose meaning is not the sum of Air and Canada.17

GloVe: ratios of co-occurrence

Pennington, Socher and Manning’s GloVe (EMNLP 2014) started from a global word-by-word co-occurrence count matrix instead of a sliding prediction task.18 Their motivating example compares ice and steam on a 6-billion-token corpus. The probability of seeing solid near ice, divided by the probability of seeing it near steam, is 8.9; for gas the ratio is 0.085; for water, related to both, 1.36; and for fashion, related to neither, 0.96.18 Raw probabilities are noisy, but the ratio picks out the dimension that distinguishes the two words, here thermodynamic phase. GloVe learns two vectors per word, one as the target word and one as a context word, and fits them so that the dot product of a word vector with a context vector, plus bias terms, approximates the log of their co-occurrence count, using a weighted least-squares loss that down-weights rare pairs; the paper notes that zero entries make up 75 to 95 per cent of the matrix.18 It reported 75 per cent accuracy on the word analogy task.18

fastText: vectors for words never seen

word2vec and GloVe give each word one vector and nothing for unseen words, the same closed-vocabulary problem subword tokenizers solve. Bojanowski, Grave, Joulin and Mikolov’s fastText (TACL 2017) represents each word as a “bag of character n-grams” and its vector as the sum of the n-gram vectors, which lets it build vectors for words absent from training and helps morphologically rich languages.19

Analogy arithmetic and its caveats

The result that made word embeddings famous is arithmetic. Mikolov, Yih and Zweig reported at NAACL 2013 that with their recurrent-network word vectors “King - Man + Woman” gives a vector very close to “Queen”,20 and the word2vec paper recounts that result and builds its test set around such offsets.16 The demonstrations depend on an evaluation convention the word2vec paper states in a parenthesis: when searching for the nearest word to the computed vector, “we discard the input question words during this search”.16

Tal Linzen showed in 2016 how much that rule does. Without the exclusion, the nearest neighbour of the computed vector was the third input word itself in 93 per cent of cases.21 He also proposed baselines that ignore the offset entirely. One, which simply returns the nearest neighbour of the third word, reached 70 per cent accuracy on plurals, because cars is usually the nearest word to car anyway.21 The offset method always beat the baselines, but by margins that varied widely across categories.21

Nissim, van Noord and van der Goot carried the point into the debate about bias in “Fair is Better than Sensational: Man is to Doctor as Woman is to Doctor”, published in Computational Linguistics.22 Their Table 2 runs well-known bias queries through three methods. For man : doctor :: woman : X, the constrained 3CosAdd and 3CosMul methods return gynecologist; for he : doctor :: she : X, they return nurse. With the input words allowed as answers, both methods return doctor for both queries, while the method of Bolukbasi and colleagues behaves differently (it returns midwife and nurse constrained).22 Under the usual settings, they write, “it is impossible to obtain man is to doctor as woman is to doctor”.22 Their narrower point is that exclusion rules and the analyst’s choice of query shape what an analogy appears to show; they do not argue that embeddings are free of bias, and they conclude that analogies are a poor instrument for measuring it. What survives is modest and still useful: embedding spaces encode many relations as roughly consistent directions, and the clean four-term demonstrations overstate how consistent.

Embeddings inside a transformer

A transformer language model begins with an embedding matrix of shape vocabulary size by model width. Token number 4,711 selects row 4,711. That row is the token’s input embedding, learned by gradient descent along with every other weight. In an autoregressive language model, the final layer produces a vector of the same width at each position, and a matrix of the same shape turns it into one score per vocabulary entry, from which the next-token probabilities are computed.

Press and Wolf argued in 2016 that the output matrix is itself a usable word embedding and recommended tying the two, using one matrix for both input and output; on translation models, they reported, tying cut model size to “less than half” without hurting performance.23 The original Transformer adopted it: “we share the same weight matrix between the two embedding layers and the pre-softmax linear transformation”.2 Tying is not universal in later models; Land and Bartolo’s glitch-token indicators, for instance, are computed differently for models with and without tied embeddings.13

The token ID for bank selects the same input row whatever the sentence. The layers above mix in information from other positions through attention, so the vector at that position after a few layers depends on the context: in a causal decoder, on the preceding text only; in a bidirectional encoder such as BERT, on both sides. These are contextual embeddings. ELMo (Peters and colleagues, NAACL 2018) made them a product: each token is assigned a representation that is “a function of the entire input sentence”, computed from the internal states of a bidirectional language model.24 BERT followed with a bidirectional transformer whose per-token outputs are contextual representations of the same kind.6 How the layers of a transformer build these representations, and how they feed next-token prediction, is the subject of the sibling reader.

Sentence and retrieval embeddings

One vector per passage

Search, clustering and retrieval-augmented generation are often built on a dense bi-encoder: each passage is encoded independently, once, as one vector, and a query’s vector is scored against stored vectors by a single similarity number; which stored vectors get scored is a matter of search strategy, covered below. The obvious ways to get such vectors from BERT work badly. Reimers and Gurevych found in 2019 that averaging BERT’s output vectors, or taking the output for its special first token, “yields rather bad sentence embeddings, often worse than averaging GloVe embeddings”; across seven semantic textual similarity benchmarks (STS12 to STS16, STSb and SICK-R), the first-token approach scored a mean Spearman correlation of 29.19 on the conventional 0 to 100 scale.25 Using BERT as a cross-encoder that reads both sentences together is accurate but slow: by the authors’ estimate, finding the most similar pair in 10,000 sentences takes about 50 million inference passes, roughly 65 hours on a V100 GPU.25

Sentence-BERT fine-tunes BERT in a siamese arrangement: two copies with shared weights each encode one sentence, a pooling step (the mean of the output vectors by default) turns each into a fixed-size vector, and training on labelled sentence pairs pushes the vectors of related sentences together.25 Sentences can then be embedded once and compared with cosine similarity. In the authors’ comparison, embedding the 10,000 sentences takes about 5 seconds and computing the cosine similarities about 0.01 seconds.25 The design that matters is the split between an expensive step done once per document and a cheap comparison done per query.

Contrastive training

Many retrieval embedders since, including the two below, are trained contrastively: the model sees a query with a passage known to match it and many passages that do not, and the loss rewards a higher similarity score for the match. Dense Passage Retrieval (Karpukhin and colleagues, EMNLP 2020) applied a dual encoder of this kind to open-domain question answering and beat a strong BM25 keyword baseline by “9%-19% absolute” in top-20 passage retrieval accuracy.26 E5 (Wang and colleagues, 2022) pre-trained contrastively on a large curated set of weakly related text pairs. Without labelled data, its base model averaged 42.9 nDCG@10 across 15 BEIR datasets against 41.7 for BM25, which the authors describe as the first such result; BM25 still won on several datasets, including Trec-Covid, Touche-2020 and Fever.27

A cosine-similarity example

Cosine similarity of two nonzero vectors is their dot product divided by the product of their lengths. It ranges from 1 (same direction) through 0 (orthogonal) to -1 (opposite). Take a three-dimensional query vector and three document vectors, chosen so that the lengths are whole numbers:

vectorcomponentslength
q(1, 2, 2)3
d1(2, 3, 6)7
d2(6, 2, -3)7
d3(-2, -1, -2)3
  • q · d1 = 2 + 6 + 12 = 20, so cos(q, d1) = 20 / (3 × 7) = 0.952.
  • q · d2 = 6 + 4 - 6 = 4, so cos(q, d2) = 4 / 21 = 0.190.
  • q · d3 = -2 - 2 - 4 = -8, so cos(q, d3) = -8 / 9 = -0.889.

A retrieval system returns d1 first. If the query and every stored vector are scaled to length 1, cosine similarity equals the plain dot product, which is why many systems normalise embeddings and then use dot-product search. Real embeddings have hundreds or thousands of dimensions. A vector index can search exactly, comparing the query with every stored vector, or approximately: the Faiss library, for example, labels its flat indexes “Exact Search” and describes partitioned indexes as a way to speed search up “at the cost of loosing the guarantee to find the nearest neighbor”, with settings that trade speed against accuracy.28

Matryoshka representations

Longer vectors cost storage and search time. Kusupati and colleagues’ Matryoshka Representation Learning (NeurIPS 2022) trains one embedding so that its first m dimensions are themselves a usable embedding, for a set of nested sizes such as 8, 16, 32 and so on up to the full width, by applying the training loss at each size.29 The paper reports up to 14 times smaller embeddings at the same ImageNet-1K classification accuracy and, in retrieval experiments on ImageNet-1K and 4K, up to 14 times wall-clock speedups by shortlisting candidates with the first few dimensions and re-ranking with successively more.29 The technique reached production quickly. OpenAI’s January 2024 embedding models let developers “shorten embeddings (i.e. remove some numbers from the end of the sequence)” through a dimensions parameter, credit Matryoshka Representation Learning in a footnote, and claim that text-embedding-3-large cut from 3,072 to 256 dimensions still beats the older 1,536-dimension text-embedding-ada-002 on MTEB.30

The toy vectors show the idea, though they were not trained to have it. Keep only the first two components: q becomes (1, 2), d1 (2, 3) and d2 (6, 2). Then cos(q, d1) = 8 / (√5 × √13) = 0.992 and cos(q, d2) = 10 / (√5 × √40) = 0.707. The ranking survives truncation here by luck. Matryoshka training makes the chosen prefix widths useful on average; it does not guarantee that any particular ranking survives.

How embedders are compared: MTEB

The Massive Text Embedding Benchmark (Muennighoff, Tazi, Magne and Reimers, 2022) collected, in its original release, 58 datasets across 8 task types (bitext mining, classification, clustering, pair classification, reranking, retrieval, semantic textual similarity and summarization) and 112 languages, with a public leaderboard.31 Its headline finding was that “no particular text embedding method dominates across all tasks”.31 The original paper’s own limitations section is worth reading before trusting an average score. Its longest datasets “have a few hundred words”, so long-document retrieval was barely measured. The average is computed over datasets, so it is biased toward tasks with many datasets, notably retrieval, classification and clustering. Retrieval and clustering were English-only, and there were no code datasets.31 A later multilingual expansion, MMTEB (2025), describes a wider collection of over 500 tasks in more than 250 languages, with task types including code retrieval.32 Neither average says much about a particular corpus; an evaluation on a sample of one’s own queries and documents says more.

Four embedders compared

word2vec (2013)GloVe (2014)Sentence-BERT (2019)E5 (2022)
Unit embeddedwordwordsentence or short passagequery or passage
Training signalCBOW: predict a word from its window; skip-gram: predict the window from the wordfit log co-occurrence counts with word and context vectorslabelled sentence pairs, siamese networkcontrastive pre-training on weakly related pairs, then fine-tuning
Context-dependentnonoyesyes
Unseen wordsno vectorno vectorhandled by the subword tokenizerhandled by the subword tokenizer
Typical comparisoncosine similarity (analogy offsets used as an evaluation)cosine similarity (analogy offsets used as an evaluation)cosine similaritycosine or dot product

Sources for each column are the papers themselves.16182527

Doing without a tokenizer

Byte Latent Transformer

The tokenizer is a separately trained, frozen component behind many of the problems above. The long-standing alternative, reading raw bytes, costs sequence length. The Byte Latent Transformer (Pagnoni and colleagues, December 2024) attacks the cost directly.33 A small byte-level language model, trained separately, estimates the entropy of the next byte at each position. A new patch starts either where that entropy exceeds a global threshold or, under a second criterion, where it rises sharply relative to the previous byte, so predictable runs of bytes are grouped into long patches and hard-to-predict regions into short ones. A lightweight local encoder turns the bytes of each patch into one vector, a large latent transformer runs once per patch, and a lightweight local decoder turns patch vectors back into bytes.33

The abstract describes a FLOP-controlled scaling study of models up to 8 billion parameters and 4 trillion training bytes, which it calls the first of its kind for byte-level models.33 In the 8B comparison of Table 1, Llama 3 was trained on 1 trillion tokens, BLT with entropy patching on 4.5 trillion bytes and a space-patched variant on 6 trillion bytes; the entropy-patched model averaged 61.1 against Llama 3’s 60.0 across seven tasks, with patches averaging about 4.5 bytes, close to Llama 3’s 4.4 bytes per token.33 Inference savings come separately, from larger patches, which the scaling study ran at averages of 6 and 8 bytes; the conclusion describes BLT as able to “trade minor losses in evaluation metrics for up to 50% reductions in inference flops”.33 On the CUTE benchmark of character-manipulation tasks, BLT outperformed both BPE Llama 3 models it was compared with “by more than 25 points”, and on a noised version of the HellaSwag benchmark it averaged about 8 points better than a Llama 3 model trained on the same data.33 The authors list limits: their implementation may not match tokenizer-based models in wall-clock time, the scaling laws they relied on “were calculated for BPE-level transformers”, and the entropy model is not trained end to end with the rest.33

ByteFlow

ByteFlow (Deng and colleagues, accepted to ICLR 2026) learns its own segmentation of the byte stream.34 It scores each position by how much it adds to a lossy coding rate of the latent representations. In training, the selected set always includes the first (beginning-of-sequence) position plus the K−1 highest-scoring others, a fixed count the authors say “preserves a static computation graph”; selection ranks scores over the whole sequence. The authors state that causal masks ensure predictions never directly access future byte content; because the ranking is over the whole sequence, which earlier positions are selected can still depend on later bytes. The paper does not describe how boundaries are chosen at inference.34 At about 600 million parameters, ByteFlow averaged 50.89 ± 0.89 per cent over six zero-shot tasks against 49.15 ± 0.73 for a BPE LLaMA baseline, over three runs each; at 1.3 billion, 63.19 ± 1.57 against 60.15 ± 1.59. On CUTE its 1.3B model scored 51.2 against 27.5 for the 1-trillion-token Llama 3 baseline taken from the BLT paper, a comparison between models of different architecture, size and training data.34 An appendix ablation is telling: without the architecture’s Canon layers, the 600M ByteFlow model’s average falls to 49.04, below the LLaMA baseline. The March 2026 manuscript says the code release was awaiting a legal review.34

Decoupling the subword advantage

Gigant, Peng and Quesnelle’s “Decoupling the Benefits of Subword Tokenization for Language Model Training via Byte-level Simulation” (April 2026) asks what, exactly, subwords give a model.35 They train a 1.7-billion-parameter LLaMA-3-style model on UTF-8 bytes and simulate one subword effect at a time inside that byte pipeline: more text per training step, a larger vocabulary, and the boundary information that subwords carry.35 Their experiments, in the abstract’s words, “highlight the critical role of increased training throughput”, meaning more text per unit of compute, in why subword models beat raw byte models. Adding n-gram embedding tables to mimic a large vocabulary helped only slightly, and subword boundaries helped when given as explicit priors or inductive biases.35 Results are measured as validation loss in bits per byte. They tested one main scale, on the English-centric FineWeb-Edu dataset; four of the interventions, including the throughput one, ran only for the first 50,000 training steps; and they leave open whether the effects add up.35 They do not test patching models such as BLT, but note that state-of-the-art byte-level models “come with methods to compress the byte sequences and thus increase sample throughput closer to the subword counterpart”.35

What is settled and what is not

Settled: subword tokenization is what the large models discussed here use; it can segment unseen words whenever their pieces are in the vocabulary, and at the byte level covers all UTF-8 characters; and it is associated with measurable effects on digit arithmetic and character-position tasks, and with measurable token-count differences across languages, for the tokenizers studied.101112 Also settled is that byte-level models trained from scratch now reach billions of parameters, and that on CUTE the BLT and ByteFlow models scored more than 20 points above the Llama 3 baselines they were compared with.3334

Not settled: whether byte or tokenizer-free models beat subword models at equal compute in general. The from-scratch comparisons discussed here are at 8 billion parameters or below, come largely from the papers proposing the new architectures, and the answer depends on what is held equal. An October 2026 study by Wang, Luo, Zhang and Wu trained a flat byte-level Transformer, with token-superposition training and hash embeddings, against subword Transformers. Comparing fitted compute-optimal validation loss in bits per byte across their training budgets, with data exposure allowed to vary, they report that “under the same FLOPs budgets, Subword is always better”, while the byte models had lower loss at the same optimal parameter count.36 The decoupling study notes a parallel without testing it: byte models that compress their input raise sample throughput toward subword levels. Whether that recovers the advantage throughput gave in their simulation is a hypothesis.35 A third route avoids training from scratch: a November 2026 preprint converted an already-trained 27-billion-parameter subword model to byte inputs. On four evaluations the paired 95 per cent intervals for the difference from the original model included zero, so no difference was detected in those runs (the intervals reflect question sampling only). Separately, the byte model lost 4 to 6 points on three others. In non-thinking mode its CUTE score rose from 75.2 to 84.0, while some Chinese character-knowledge tasks declined, and on the same GPUs it produced Chinese characters at about a quarter of the original’s rate per second.37 A fair summary in late 2026 is that the tokenizer is no longer obviously necessary, and not yet obviously worse.

Security consequences

Embedding inversion

A common assumption about vector databases is that an embedding is a lossy fingerprint, safe to store or share where the text itself would not be. Morris, Kuleshov, Shmatikov and Rush tested that assumption in “Text Embeddings Reveal (Almost) As Much As Text” (EMNLP 2023).38 Their method, Vec2Text, frames inversion as controlled generation: find text whose embedding is as close as possible to a target embedding. A first model guesses text from the embedding. A correction model then takes the target embedding, the current guess and the guess’s own embedding, obtained by querying the embedding model, and proposes a better guess; the loop “iteratively corrects and re-embeds text”.38

What they recovered, and under what conditions:

  • Short text from an open retrieval model. For 32-token passages from Wikipedia (Natural Questions) embedded with GTR-base, 50 correction steps with a sequence-level beam search recovered 92.0 per cent of inputs exactly, with a BLEU score of 97.3.38
  • A commercial API model. For 32-token passages from MS MARCO embedded with OpenAI’s text-embedding-ada-002, the same setting recovered 60.9 per cent exactly (BLEU 83.4). For passages of up to 128 tokens, exact recovery fell to 8.0 per cent, with BLEU 55.0.38
  • Clinical notes. On a pseudo re-identified version of the MIMIC-III clinical notes, truncated to 32 tokens and embedded with GTR-base, Vec2Text recovered 94 per cent of first names, 95 per cent of last names and 89 per cent of full names, while recovering 26 per cent of notes exactly.38
  • Out of domain. Across 15 BEIR datasets it recovered at least 41 Token F1 on every dataset and 66 per cent of Quora questions exactly.38

The threat model matters. In the demonstrated method, the attacker can query the same embedding model that produced the vectors and trains an inversion model for that embedder on a large corpus (5 million Wikipedia passages for GTR).38 The authors list as limitations that they did not test texts longer than 128 tokens, although popular embedders accept inputs “on the order of thousands of tokens”; that their search was capped at 50 rounds and a beam width of 8; and that they did not study adaptive attacks and defences.38

The defence they tested was adding Gaussian noise to each GTR-base embedding. In their Table 7, noise at λ = 0.01 left mean NDCG@10 across BEIR tasks at 0.296 against 0.302 without noise, while reconstruction BLEU fell from 80.4 to 10.3, about 13 per cent of the original; at λ = 0.1 both collapsed (NDCG@10 0.002).38 They add two cautions. An attacker could train the inverter on noisy embeddings, which they did not test, and low reconstruction BLEU “is not necessarily indicative that coarser inferences, such as clinical area or treatment regimen, cannot be made”.38

What this means for a vector store

The paper’s findings are specific: short texts, two embedders, an attacker who can query the embedder and train an inverter for it. A paper by Elaasar and Lopes, posted to arXiv on November 3, 2026, adapted Vec2Text to newer commercial embedders (OpenAI’s text-embedding-3-small and mistral-embed, with GTR-base) on inputs of 60 to 80 characters. With exact match defined case-insensitively and ignoring whitespace, text-embedding-3-small gave the highest exact-match rates, for example 47.4 per cent on health-related instructions and 24.5 per cent on general instructions; the authors caution that the results describe one attack configuration and their datasets.39 How far either result extends to long chunks and other embedders is not established. The defensible practice does not depend on settling that. Embeddings can expose sensitive information about the text they were computed from, so they should be classified and handled according to the sensitivity of that text: access control, encryption, retention and deletion for a vector database indexing HR files, medical notes, source code or customer tickets should match those of the document store, and deleting a document should delete its vectors. Sharing embeddings with a third party, or exposing an endpoint that returns raw vectors, deserves the same review as sharing the source text. Noise injection can be evaluated as an additional layer against the deployment’s own retrieval quality; it is not an anonymisation guarantee.

Retrieval stores also feed text back into models, which makes them a route for indirect prompt injection; that problem is covered in the reader on prompt injection and agents.

Tokenizer quirks in filter evasion

TokenBreak studies text classifiers used to guard language models against prompt injection, toxic input and spam. Both the classifier and the model see tokens, and different tokenizers produce different representations of the same text. Schulz, Yeung and Evans’s TokenBreak (June 2025) found that small character-level edits to the words a classifier relies on can flip its verdict to benign while a human or a downstream language model still reads the intent.40 In their tests, classifiers built on BPE (RoBERTa) and WordPiece (BERT, DistilBERT) models were susceptible, the WordPiece models most so, with a mean of 55.62 per cent of samples successfully manipulated, while none of the Unigram-tokenized models tested (DeBERTa-v2, XLM-RoBERTa) produced false negatives.40 The authors attribute the difference to tokenization strategy; because tokenizer type coincides with model family in these experiments, the comparison does not separate tokenizer from architecture and training. Their proposed defence translates input through a Unigram tokenizer into the classifier’s vocabulary, which cut mean attack success across the BPE and WordPiece models tested from 33.09 to 12.63 per cent.40

Geh, Shao and Van den Broeck’s “Adversarial Tokenization” (ACL 2025) needs no change of characters at all.41 A BPE tokenizer produces one canonical segmentation of a string, but other token sequences can decode to the same string, and their number can grow exponentially with length, depending on which pieces the vocabulary contains.41 The authors find that models still understand non-canonical segmentations close to the canonical one, and that choosing segmentations adversarially raised harmful-compliance scores on the three open models they tested (for Llama 3, a StrongREJECT score of 0.275 against 0.023 for canonical input) and raised the rate at which requests passed the LlamaGuard safety model on one dataset from 33 to 56 per cent.41 Because the attack operates on token sequences, it presupposes an interface that accepts token IDs, such as a locally run open-weight model; a service that only accepts text and tokenizes it canonically is not exposed in the same way (this reader’s inference, not a claim the paper tests).

The practical lessons are narrow. A filter and the model it protects may represent the same text differently, and evaluations of the filter should use the representation the model will actually receive. For the second attack, the control has to sit at the protected model’s input: Geh and colleagues note that retokenizing every input “completely solves the problem if the (de)tokenizer is bijective”, that this “is not true for most deployed LLMs”, and that restricting users to string input also blocks the attack. Canonicalising only what a filter sees leaves the model receiving the original sequence.41 For the first, TokenBreak evaluated one specific defence; generic string normalisation and matched preprocessing between filter and model are hypotheses to validate against the deployment’s own traffic, not established controls.40 These are classifier and safety-filter results, and they say nothing about other ways a model can be talked out of its instructions. The MITRE ATLAS reader places evasion of this kind among the wider catalogue of attacks on machine-learning systems.

Reading list

Tokenization

  • Sennrich, Haddow and Birch, “Neural Machine Translation of Rare Words with Subword Units” (2015, ACL 2016). Adapted byte-pair encoding to word segmentation for translation. Section 3.2 and its code listing are short and runnable; footnote 3 states what remains unknown.1
  • Schuster and Nakajima, “Japanese and Korean Voice Search” (ICASSP 2012). The original WordPiece model, built by likelihood for languages without spaces; BERT later used a WordPiece vocabulary.46
  • Kudo, “Subword Regularization” (ACL 2018). The unigram language model tokenizer and training on sampled segmentations; section 3.2 gives the pruning algorithm.5
  • Kudo and Richardson, “SentencePiece” (2018). Subword training on raw text with whitespace as a symbol; LLaMA used its BPE implementation.89
  • Radford and colleagues, “Language Models are Unsupervised Multitask Learners” (2019). The GPT-2 report; section 2.2 introduces byte-level BPE with category-restricted merges.3
  • Petrov, La Malfa, Torr and Bibi, “Language Model Tokenizers Introduce Unfairness Between Languages” (NeurIPS 2023). Token premiums for specific tokenizers on parallel text (Table 1), byte and character baselines, and the cost argument in section 5. How much of the cross-language quality gap tokenization explains is a separate question.12
  • Singh and Strouse, “Tokenization counts” (2024). Digit-chunking direction and arithmetic accuracy in GPT-3.5 and GPT-4 checkpoints.11
  • Uzan and Pinter, “CharBench” (2025, AAAI-26). Separates counting from position tasks; useful against one-line explanations of letter-counting errors.10
  • Land and Bartolo, “Fishing for Magikarp” (EMNLP 2024). Detection of under-trained and unreachable tokens, with per-model reports.13

Embeddings

  • Bengio, Ducharme, Vincent and Jauvin, “A Neural Probabilistic Language Model” (JMLR 2003). An early, influential neural language model that learned word vectors jointly with the model.15
  • Mikolov, Yih and Zweig, “Linguistic Regularities in Continuous Space Word Representations” (NAACL 2013). The vector-offset analogy result.20
  • Mikolov, Chen, Corrado and Dean, “Efficient Estimation of Word Representations in Vector Space” (2013) and Mikolov, Sutskever, Chen, Corrado and Dean, “Distributed Representations of Words and Phrases and their Compositionality” (2013). CBOW, skip-gram and the analogy test set; then negative sampling, subsampling and phrase vectors.1617
  • Pennington, Socher and Manning, “GloVe” (EMNLP 2014). Table 1’s co-occurrence ratios are the clearest motivation for the model.18
  • Bojanowski, Grave, Joulin and Mikolov, “Enriching Word Vectors with Subword Information” (TACL 2017). fastText’s character n-gram vectors.19
  • Linzen, “Issues in evaluating semantic spaces using word analogies” (2016) and Nissim, van Noord and van der Goot, “Fair is Better than Sensational” (Computational Linguistics). Baselines and exclusion rules for analogy evaluation; Nissim et al.’s Table 2 shows the bias queries with and without them.2122
  • Press and Wolf, “Using the Output Embedding to Improve Language Models” (EACL 2017). The case for weight tying.23
  • Peters and colleagues, “Deep contextualized word representations” (NAACL 2018) and Devlin and colleagues, “BERT” (2018). Contextual representations from bidirectional models.246
  • Reimers and Gurevych, “Sentence-BERT” (EMNLP 2019). Siamese fine-tuning for sentence vectors; Table 1 has the STS comparison.25
  • Karpukhin and colleagues, “Dense Passage Retrieval” (EMNLP 2020) and Wang and colleagues, “E5” (2022). Contrastive dual encoders; read E5’s Table 1 for the datasets where BM25 still wins.2627
  • Kusupati and colleagues, “Matryoshka Representation Learning” (NeurIPS 2022). Nested, truncatable embeddings; OpenAI’s 2024 API truncation credits it.2930
  • Muennighoff, Tazi, Magne and Reimers, “MTEB” (2022). The original benchmark; its appendix lists its limitations. MMTEB (2025) is the multilingual expansion.3132

Beyond tokenizers

  • Pagnoni and colleagues, “Byte Latent Transformer: Patches Scale Better Than Tokens” (2024). Entropy patching and FLOP-controlled scaling to 8B; Table 1 gives the training data of each condition.33
  • Deng and colleagues, “ByteFlow” (ICLR 2026). Coding-rate segmentation at 600M and 1.3B; see its Canon-layer ablation.34
  • Gigant, Peng and Quesnelle, “Decoupling the Benefits of Subword Tokenization” (2026). Simulates subword effects inside a byte model to see which matter.35
  • Wang, Luo, Zhang and Wu, “Byte Language Models: Scaling, Emergent Abstractions, and Information Allocation” (2026) and Zhang, Tong, Guan and Li, “One Byte, One Token” (2026). A matched-compute scaling comparison, and a conversion of a trained 27B subword model to bytes.3637

Security

  • Morris, Kuleshov, Shmatikov and Rush, “Text Embeddings Reveal (Almost) As Much As Text” (EMNLP 2023). Vec2Text; Table 1 for reconstruction, the MIMIC case study for clinical notes, Table 7 for the noise defence, and the limitations section for scope.38
  • Elaasar and Lopes, “How Much Do Modern Embeddings Reveal?” (2026). Vec2Text adapted to newer commercial embedders on short inputs.39
  • Schulz, Yeung and Evans, “TokenBreak” (2025) and Geh, Shao and Van den Broeck, “Adversarial Tokenization” (ACL 2025). Classifier and safety-filter evasion through character edits and through non-canonical segmentations.4041

Conclusion

Tokenization and embedding are the two steps that turn text into numbers, and both leave measurable traces downstream. Subword tokenizers segment unseen words into a fixed, frequency-learned list of pieces whenever those pieces are available, and byte-level variants cover every UTF-8 character. The measured effects are specific: left-to-right digit chunking cost one GPT-3.5 checkpoint 22 points on long addition; accuracy on character-position tasks was negatively correlated with the length of the token holding the character, while on counting tasks tokenization measures were only weakly associated with correctness; the 2023 ChatGPT and GPT-4 tokenizer needed from 1.5 to 15 times as many tokens as English for the same text in other languages; and many models carry under-trained or unreachable tokens. Embeddings turned the distributional idea into geometry, first for words and then for whole passages, and the benchmarks used to compare passage embedders list in their own papers what they leave out. Byte-level models that drop the tokenizer have become credible at billions of parameters; whether they beat subwords depends on what is held equal, and at matched training FLOPs the subword models in one 2026 study reached lower validation loss. Two security conclusions hold within the limits of the evidence. Embeddings of short texts from the embedders tested could be inverted by an attacker able to query the embedder, so stored embeddings should be handled according to the sensitivity of their source text. And because a filter and the model it guards can represent the same text differently, filters should be evaluated on what the model actually receives.

Footnotes

  1. Rico Sennrich, Barry Haddow and Alexandra Birch, “Neural Machine Translation of Rare Words with Subword Units”, arXiv:1508.07909, first submitted August 31, 2015, revised June 10, 2016 (ACL 2016). https://arxiv.org/abs/1508.07909 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9
  2. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser and Illia Polosukhin, “Attention Is All You Need”, arXiv:1706.03762, June 12, 2017, sections 3.4 and 5.1. https://arxiv.org/abs/1706.03762 (opens in a new tab) ↩1 ↩2 ↩3
  3. Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever, “Language Models are Unsupervised Multitask Learners”, OpenAI technical report, 2019, section 2.2. https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8
  4. Mike Schuster and Kaisuke Nakajima, “Japanese and Korean Voice Search”, IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2012, pp. 5149–5152. https://research.google/pubs/japanese-and-korean-voice-search/ (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5
  5. Taku Kudo, “Subword Regularization: Improving Neural Network Translation Models with Multiple Subword Candidates”, arXiv:1804.10959, April 29, 2018 (ACL 2018). https://arxiv.org/abs/1804.10959 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6
  6. Jacob Devlin, Ming-Wei Chang, Kenton Lee and Kristina Toutanova, “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding”, arXiv:1810.04805, October 11, 2018, revised May 24, 2019. https://arxiv.org/abs/1810.04805 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5
  7. Google Research, tokenization.py in the BERT repository on GitHub, WordpieceTokenizer class. https://github.com/google-research/bert/blob/master/tokenization.py (opens in a new tab) ↩1 ↩2
  8. Taku Kudo and John Richardson, “SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing”, arXiv:1808.06226, August 19, 2018. https://arxiv.org/abs/1808.06226 (opens in a new tab) ↩1 ↩2 ↩3 ↩4
  9. Hugo Touvron, Thibaut Lavril, Gautier Izacard and 11 co-authors, “LLaMA: Open and Efficient Foundation Language Models”, arXiv:2302.13971, February 27, 2023. https://arxiv.org/abs/2302.13971 (opens in a new tab) ↩1 ↩2 ↩3
  10. Omri Uzan and Yuval Pinter, “CharBench: Evaluating the Role of Tokenization in Character-Level Tasks”, arXiv:2508.02591, August 4, 2025 (AAAI-26). https://arxiv.org/abs/2508.02591 (opens in a new tab) ↩1 ↩2 ↩3 ↩4
  11. Aaditya K. Singh and DJ Strouse, “Tokenization counts: the impact of tokenization on arithmetic in frontier LLMs”, arXiv:2402.14903, February 22, 2024. https://arxiv.org/abs/2402.14903 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5
  12. Aleksandar Petrov, Emanuele La Malfa, Philip H. S. Torr and Adel Bibi, “Language Model Tokenizers Introduce Unfairness Between Languages”, arXiv:2305.15425, May 17, 2023, revised October 20, 2023 (NeurIPS 2023). https://arxiv.org/abs/2305.15425 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8
  13. Sander Land and Max Bartolo, “Fishing for Magikarp: Automatically Detecting Under-trained Tokens in Large Language Models”, arXiv:2405.05417, May 8, 2024, revised September 27, 2024 (EMNLP 2024). https://arxiv.org/abs/2405.05417 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6
  14. Mikael Brunila and Jack LaViolette, “What company do words keep? Revisiting the distributional semantics of J.R. Firth & Zellig Harris”, arXiv:2205.07750, May 16, 2022 (NAACL 2022). https://arxiv.org/abs/2205.07750 (opens in a new tab) ↩
  15. Yoshua Bengio, Réjean Ducharme, Pascal Vincent and Christian Jauvin, “A Neural Probabilistic Language Model”, Journal of Machine Learning Research 3:1137–1155, February 2003. https://www.jmlr.org/papers/v3/bengio03a.html (opens in a new tab) ↩1 ↩2
  16. Tomas Mikolov, Kai Chen, Greg Corrado and Jeffrey Dean, “Efficient Estimation of Word Representations in Vector Space”, arXiv:1301.3781, January 16, 2013, revised September 7, 2013. https://arxiv.org/abs/1301.3781 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8
  17. Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg Corrado and Jeffrey Dean, “Distributed Representations of Words and Phrases and their Compositionality”, arXiv:1310.4546, October 16, 2013. https://arxiv.org/abs/1310.4546 (opens in a new tab) ↩1 ↩2
  18. Jeffrey Pennington, Richard Socher and Christopher D. Manning, “GloVe: Global Vectors for Word Representation”, Proceedings of EMNLP 2014, Doha, October 2014, pp. 1532–1543. https://aclanthology.org/D14-1162/ (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6
  19. Piotr Bojanowski, Edouard Grave, Armand Joulin and Tomas Mikolov, “Enriching Word Vectors with Subword Information”, arXiv:1607.04606, July 15, 2016, revised June 19, 2017 (TACL). https://arxiv.org/abs/1607.04606 (opens in a new tab) ↩1 ↩2
  20. Tomas Mikolov, Wen-tau Yih and Geoffrey Zweig, “Linguistic Regularities in Continuous Space Word Representations”, Proceedings of NAACL-HLT 2013, Atlanta, June 2013, pp. 746–751. https://aclanthology.org/N13-1090/ (opens in a new tab) ↩1 ↩2
  21. Tal Linzen, “Issues in evaluating semantic spaces using word analogies”, arXiv:1606.07736, June 24, 2016 (First Workshop on Evaluating Vector Space Representations for NLP). https://arxiv.org/abs/1606.07736 (opens in a new tab) ↩1 ↩2 ↩3 ↩4
  22. Malvina Nissim, Rik van Noord and Rob van der Goot, “Fair is Better than Sensational: Man is to Doctor as Woman is to Doctor”, arXiv:1905.09866, May 23, 2019, revised November 9, 2019 (Computational Linguistics). https://arxiv.org/abs/1905.09866 (opens in a new tab) ↩1 ↩2 ↩3 ↩4
  23. Ofir Press and Lior Wolf, “Using the Output Embedding to Improve Language Models”, arXiv:1608.05859, August 20, 2016, revised February 21, 2017 (EACL 2017). https://arxiv.org/abs/1608.05859 (opens in a new tab) ↩1 ↩2
  24. Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee and Luke Zettlemoyer, “Deep contextualized word representations”, arXiv:1802.05365, February 15, 2018 (NAACL 2018). https://arxiv.org/abs/1802.05365 (opens in a new tab) ↩1 ↩2
  25. Nils Reimers and Iryna Gurevych, “Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks”, arXiv:1908.10084, August 27, 2019 (EMNLP 2019). https://arxiv.org/abs/1908.10084 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6
  26. Vladimir Karpukhin, Barlas Oğuz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, Danqi Chen and Wen-tau Yih, “Dense Passage Retrieval for Open-Domain Question Answering”, arXiv:2004.04906, April 10, 2020, revised September 30, 2020 (EMNLP 2020). https://arxiv.org/abs/2004.04906 (opens in a new tab) ↩1 ↩2
  27. Liang Wang, Nan Yang, Xiaolong Huang, Binxing Jiao, Linjun Yang, Daxin Jiang, Rangan Majumder and Furu Wei, “Text Embeddings by Weakly-Supervised Contrastive Pre-training”, arXiv:2212.03533, December 7, 2022, revised February 22, 2024. https://arxiv.org/abs/2212.03533 (opens in a new tab) ↩1 ↩2 ↩3
  28. Faiss wiki, “Faiss indexes”, facebookresearch/faiss on GitHub. https://github.com/facebookresearch/faiss/wiki/Faiss-indexes (opens in a new tab) ↩
  29. Aditya Kusupati, Gantavya Bhatt, Aniket Rege and 8 co-authors, “Matryoshka Representation Learning”, arXiv:2205.13147, May 26, 2022, revised February 8, 2024 (NeurIPS 2022). https://arxiv.org/abs/2205.13147 (opens in a new tab) ↩1 ↩2 ↩3
  30. OpenAI, “New embedding models and API updates”, January 25, 2024. https://openai.com/index/new-embedding-models-and-api-updates/ (opens in a new tab) ↩1 ↩2
  31. Niklas Muennighoff, Nouamane Tazi, Loïc Magne and Nils Reimers, “MTEB: Massive Text Embedding Benchmark”, arXiv:2210.07316, October 13, 2022, revised March 19, 2023; limitations in the appendix. https://arxiv.org/abs/2210.07316 (opens in a new tab) ↩1 ↩2 ↩3 ↩4
  32. Kenneth Enevoldsen et al., “MMTEB: Massive Multilingual Text Embedding Benchmark”, arXiv:2502.13595, February 19, 2025, revised November 13, 2025. https://arxiv.org/abs/2502.13595 (opens in a new tab) ↩1 ↩2
  33. Artidoro Pagnoni, Ram Pasunuru, Pedro Rodriguez and 11 co-authors, “Byte Latent Transformer: Patches Scale Better Than Tokens”, arXiv:2412.09871, December 13, 2024. https://arxiv.org/abs/2412.09871 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9
  34. Chunyuan Deng, Sanket Lokegaonkar, Colin Lockard, Besnik Fetahu, Nasser Zalmout and Xian Li, “ByteFlow: Language Modeling through Adaptive Byte Compression without a Tokenizer”, arXiv:2603.03583, March 3, 2026 (ICLR 2026). https://arxiv.org/abs/2603.03583 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6
  35. Théo Gigant, Bowen Peng and Jeffrey Quesnelle, “Decoupling the Benefits of Subword Tokenization for Language Model Training via Byte-level Simulation”, arXiv:2604.27263, April 29, 2026, revised May 14, 2026. https://arxiv.org/abs/2604.27263 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7
  36. Jie Wang, Shiwei Luo, Qi Zhang and Yuanbin Wu, “Byte Language Models: Scaling, Emergent Abstractions, and Information Allocation”, arXiv:2610.05978, October 5, 2026, section 2. https://arxiv.org/abs/2610.05978 (opens in a new tab) ↩1 ↩2
  37. Liwei Zhang, ZhiMing Tong, Mochen Guan and Linzhe Li, “One Byte, One Token: Byteifying a 27B Hybrid-Attention LLM with Self-Generated Data”, arXiv:2611.13607, November 10, 2026, revised November 12, 2026 (preprint). https://arxiv.org/abs/2611.13607 (opens in a new tab) ↩1 ↩2
  38. John X. Morris, Volodymyr Kuleshov, Vitaly Shmatikov and Alexander M. Rush, “Text Embeddings Reveal (Almost) As Much As Text”, arXiv:2310.06816, October 10, 2023 (EMNLP 2023). https://arxiv.org/abs/2310.06816 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11
  39. Kareem Elaasar and Cristina Lopes, “How Much Do Modern Embeddings Reveal? Inversion Attacks on Commercial Embedding Models”, arXiv:2611.05716, posted November 3, 2026 (also in the BlackboxNLP 2026 workshop proceedings). https://arxiv.org/abs/2611.05716 (opens in a new tab) ↩1 ↩2
  40. Kasimir Schulz, Kenneth Yeung and Kieran Evans, “TokenBreak: Bypassing Text Classification Models Through Token Manipulation”, arXiv:2506.07948, June 9, 2025. https://arxiv.org/abs/2506.07948 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5
  41. Renato Lui Geh, Zilei Shao and Guy Van den Broeck, “Adversarial Tokenization”, arXiv:2503.02174, March 4, 2025, revised June 5, 2025 (ACL 2025). https://arxiv.org/abs/2503.02174 (opens in a new tab) ↩1 ↩2 ↩3 ↩4 ↩5