Natural language processing
Segmentation: Sentences, Words, Subwords, and Bytes
Choose and evaluate document, sentence, word, subword, character, and byte segmentation for multilingual NLP tasks.
By the end you can
- Distinguish document, sentence, word, subword, character, and byte boundaries
- Explain why whitespace and punctuation are unreliable universal segmenters
- Match segmentation units to tasks, languages, models, and source constraints
- Evaluate boundary errors and preserve context across segments
Example
Word boundaries scored 98.18; Thai averaged 17.16
Boundary decisions that look trivial in English become explicit engineering choices in real corpora.
Unicode says so in its own specification, rather than leaving implementers to discover it. Annex #29 defines the default boundaries for grapheme clusters, words and sentences, and it warns readers directly: “Word boundaries are not restricted to whitespace and punctuation. Indeed, some languages do not use spaces at all”. It is more specific a line later: “reliable detection of word boundaries in languages such as Thai, Lao, Chinese, or Japanese requires the use of dictionary lookup or other mechanisms”. ICU, the reference implementation, ships precisely that. Its own guide records: “Some languages are written without spaces, and word and line breaking requires more than rules over character sequences. ICU provides dictionary support for word boundaries in Chinese, Japanese, Thai, Lao, Khmer and Burmese”.
How large a gap that leaves has been measured on the record. In the CoNLL 2018 shared task, 26 systems parsed raw text into Universal Dependencies across 82 treebanks in 57 languages. In aggregate, word segmentation looked finished. Uppsala took the best macro-averaged word F1 at 98.18, and even the BASELINE UDPipe 1.2 reached 96.97. Sentence segmentation did not follow. The best score was 83.87, from HIT-SCIR, against a baseline of 83.01. The winning system barely separated itself from the untuned starting point, on the task with far more error left in it.
The aggregate also hides where the failure actually lives. On Thai (th_pud) the best word-segmentation F1 was 69.93, and the cross-system average was 17.16 ± 20.57. On Japanese “Modern” (ja_modern) the best was 75.69, the average 59.40 ± 7.70.
The organisers did not treat this as a surprise. “Not surprisingly, word segmentation is difficult for the low-resource languages and for languages like Chinese, Vietnamese, Japanese and Thai, where spaces do not separate words.”
A tokenizer that splits on spaces is not a simple tokenizer. It is a tokenizer whose headline number is 98.18 and whose Thai number is 17.16. Only one of those two ever appears in a summary table.
- Abbreviations: “Dr. Rao arrived at 16:00 Tuesday” contains periods that do not all end sentences — the period also marks initials, ordinal numbers and ellipses.
- No spaces: Chinese and Thai do not use whitespace as a universal word delimiter, and on Thai (th_pud) the CoNLL 2018 systems averaged 17.16 ± 20.57 word F1.
- Clitics: French “l’homme” and Italian “dell’acqua” can be split differently by linguistic and modeling conventions.
- Social text: hashtags, URLs, emoji sequences, and repeated punctuation mix orthographic and semantic units.
- Speech transcripts: pauses, speaker turns, partial words, and recognition errors replace ordinary punctuation.
Visual
A hierarchy of possible segment boundaries
A pipeline may use several levels at once rather than choosing one forever.
The levels below are not a ladder of increasing correctness. Each one is a policy that somebody had to write down and defend. The same corpus can carry all of them at once: a stable document identifier, a 100-word retrieval block, a sentence split whose accuracy depends on the source, and a 256-value byte alphabet underneath. The sections that follow attach a measured number to three of those choices.
Document or conversation
Defines the broad evidence container and split boundary.
Passage or turn
Creates manageable retrieval and interaction units.
Sentence or clause
Supports local syntax, alignment, and display.
Word or morpheme
Connects linguistic structure to lexical features.
Subword, character, or byte
Provides an open vocabulary for learned models.
Comparison
The same text, up to 15 times the tokens
Different units trade sequence length, linguistic alignment, robustness and vocabulary size. Each side of that trade has been measured, so it can be quoted rather than asserted.
On the subword side the disparity is large, and it falls unevenly across languages. Petrov and colleagues put it in the abstract of their 2023 NeurIPS paper: “The same text translated into different languages can have drastically different tokenization lengths, with differences up to 15 times in some cases.” A second group reproduced the effect independently that year, across 22 typologically diverse languages, and found “some languages requiring 5 times as many tokens than others”. Ahia and colleagues also estimated that a Telugu user could pay 5× more than an English user for equivalent use of the same API. Sequence length is not a neutral property of the encoder. It is an invoice, and it is not addressed to everyone equally.
Dropping to a smaller alphabet does not cancel the effect. The same NeurIPS paper records that “Character-level and byte-level models also exhibit over 4 times the difference in the encoding length for some language pairs.”
ByT5, published in 2022, prices the byte column exactly. It feeds UTF-8 bytes directly, with “a vocabulary of 256 possible byte values” plus 3 reserved IDs. That collapses the vocabulary side of the parameter budget: vocabulary-related parameters fall from 85% of the model in mT5-Small and 16% in mT5-XXL to 0.3% and 0.02%. The bill arrives as time. ByT5 runs 1.5 to 2.6 times slower than mT5 on Dakshina transliteration and 3.7 to 6.4 times slower on GEM-XSum summarization. On XNLI zero-shot classification the paper reports a model that “is 6.4 to 9.5 times slower”. Its own introduction says why: “The main drawback of byte-level models is that byte sequences tend to be significantly longer than token sequences.”
So the four columns below are not four flavours. They are four points on one curve. It runs from 85% of a model spent on a vocabulary down to 0.02%, and from one inference-time unit up to 9.5.
Words
Use lexically meaningful units when boundaries and vocabulary are manageable.
- Shorter sequences
- Natural for lexicons
- Unknown-word problem
- Language-specific tokenization
Subwords
Learn reusable fragments from a corpus.
- Open vocabulary
- Moderate sequence length
- Domain-dependent splits
- Common in Transformers
Characters
Represent written symbols directly.
- No word vocabulary
- Longer sequences
- Handles spelling variation
- Grapheme complexity remains
Bytes
Represent encoded input with a fixed small alphabet.
- Universal raw coverage
- Very long sequences
- Encoding patterns must be learned
- Less linguistic alignment
Case
Rare words split below the word line bought up to 1.3 BLEU
The practical question was settled in 2016 by borrowing a compression algorithm. Encoding rare and unknown words as sequences of subword units, rather than backing off to a dictionary, improved translation on the WMT 15 English-to-German and English-to-Russian tasks — in the words of the abstract, “by up to 1.1 and 1.3 BLEU, respectively”. Sennrich and colleagues presented it at ACL 2016.
The hedge is theirs. The ACL proceedings and the preprint PDF both read up to. Only arXiv’s abstract listing prints the two figures flat. That is one reason to read the artefact rather than the record that points at it.
Their reasoning was linguistic rather than statistical. Names are translatable by character copying or transliteration. Compounds translate compositionally. Cognates and loanwords go through phonological and morphological transformation. A unit below the word is the right size for all three classes.
One hundred words, 21,015,324 passages
Breaking a long document into passages can improve retrieval and fit model limits. But a claim may depend on a definition in an earlier section. Overlap helps at boundaries, and it also creates duplicate evidence and additional cost.
What such a policy looks like in practice is on the record, down to the unit count. For Dense Passage Retrieval, in 2020, Karpukhin and colleagues took the December 20, 2018 English Wikipedia dump and cleaned it of tables, infoboxes, lists and disambiguation pages. Then, in their pre-processing section: “We then split each article into multiple, disjoint text blocks of 100 words as passages, serving as our basic retrieval units, following (Wang et al., 2019), which results in 21,015,324 passages in the end.” Each block was prepended with its article title and an [SEP] token. One round number, chosen once, fixed the unit of evidence 21,015,324 times.
And the choice did not stay inside that paper. The Retrieval-Augmented Generation paper reused the identical split later the same year: “Each Wikipedia article is split into disjoint 100-word chunks, to make a total of 21M documents.” That was the non-parametric knowledge source for every experiment in it. Disjoint means no overlap. Every dependency that crossed one of those 21 million cuts was simply not represented, in both systems, unexamined.
Preserve stable document and position identifiers so passages can be reassembled. Evaluate facts and references that cross chunk boundaries rather than assuming local context is sufficient.
A segment is a computational convenience, not proof that meaning is local.
Analogy
Cutting a map into tiles
Cartographers divide a large map into tiles for storage and navigation. Smaller tiles are easy to load, but a road or river can cross several boundaries, so coordinates and overlap matter.
On a map, adjacency is physical distance and nothing more. Language dependencies are not. A pronoun can depend on a distant sentence, while adjacent paragraphs discuss unrelated topics. A tile boundary at least announces itself on the page. A disjoint 100-word cut does not, and the retrieved passage looks equally complete either way.
Segmentation should preserve location and test the dependencies it may cut.
Key idea
Four gold standards, scored side by side
Linguists, annotators, tokenizers and products can disagree about whether punctuation, contractions, compounds or multiword expressions form one unit. A benchmark boundary reflects its guideline, not a universal natural law.
That proposition was run as an experiment. The First International Chinese Word Segmentation Bakeoff, in 2003, scored systems against four incompatible gold standards at once: Academia Sinica, the Penn Chinese Treebank, Hong Kong CityU and Peking University. The standard, not the system, dominated the scoreboard. “The top performance of any system on any track was S09 on ASc (F=0.961)”, while the best closed-track F on the Chinese Treebank was 0.881 and the worst closed CTB entry scored 0.732. The Treebank's out-of-vocabulary rate was 0.181, against 0.022 for Academia Sinica. Read the column, not the row. The same competition, the same week, and roughly eight hundredths of F separating one guideline from another.
Sproat and Emerson had already said why the guidelines differ, in their introduction: “It has also been observed that different segmentation standards are appropriate for different purposes; that the segmentation standard that one might prefer for information retrieval applications is likely to be different from the one that one would prefer for text-to-speech synthesis”.
Better models did not dissolve the disagreement. Fourteen years on, Chen and colleagues were still training across eight Chinese corpora with “heterogeneous segmentation criteria”, and still had to show PKU's People's Daily and the Penn Chinese Treebank, which “use different segmentation criteria”, cutting the same sentence in different places.
Document the convention and evaluate the downstream effect. An alternative segmentation can be reasonable if the entire pipeline uses it consistently and the task benefits.
Boundary accuracy is meaningful only relative to a declared annotation and product convention.
Steps
1.26% error on newspapers, 62.1% precision on legal text
Use both direct boundary measures and downstream tests. Re-run them whenever the source changes, because a segmenter's published accuracy belongs to the corpus it was published on.
Punkt is the case worth knowing, and it is instructive because it began so well. Kiss and Strunk published it in 2006, “tested extensively on eleven different languages” in their own abstract's words. The mean sentence-boundary error rate across those eleven newspaper corpora was 1.26%. That beat the supervised MxTerminator's 1.77%, even though MxTerminator had been given as many as 34,256 training instances. On the Brown corpus the error rate was 1.02%. On The Works of Edgar Allan Poe, 0.80%. Their introduction explains where the difficulty comes from: “Graphemes often serve more than one purpose in writing systems. The period, which is employed as sentence boundary marker, is no exception. It is also used to mark abbreviations, initials, ordinal numbers, and ellipses.”
Nineteen years later, the same splitter met a different kind of text. A 2025 evaluation ran it over five legal datasets: 25,000+ documents, 197,000+ annotated sentence boundaries. NLTK's Punkt measured 62.1% precision on legal text, against 91.1% for the domain-retrained NUPunkt. That is a 29–32% precision gap, opened by nothing but a change of source. About 1% error on newswire and 62.1% precision on legal documents are the same program, unmodified, under two evaluations.
So step 1 is not a formality, and step 4 is not optional. Sample the sources you will actually run on. Annotate the boundary this product needs. Separate missed boundaries from harmful extra splits. Then check whether those local errors move retrieval, extraction, translation, latency and sequence length at all.
1. Sample difficult sources
Include abbreviations, mixed scripts, OCR, chat, transcripts, and domain notation.
2. Annotate the relevant boundary
Define what counts as a sentence, token, passage, or turn for this product.
3. Measure boundary precision and recall
Separate missed boundaries from harmful extra splits.
4. Test downstream tasks
Compare retrieval, extraction, translation, latency, and sequence length.
5. Inspect cross-boundary failures
Review clipped entities, broken references, duplicated answers, and lost speaker state.
Design two segmentation policies for the same corpus
Take a set of long customer conversations. Create one policy for intent routing and another for evidence retrieval, then justify the document, turn, passage and overlap choices.
Estimate token lengths, duplicated text, cross-boundary references and source reconstruction. The two tasks may need different segmentation even though they use the same raw messages. Write the numbers down the way Dense Passage Retrieval did — 100 words, disjoint, title prepended, 21,015,324 units — so that a later reader can see what was chosen rather than infer it.
Then ask the second question, the one the Retrieval-Augmented Generation paper answers by example. If someone reuses your policy unchanged for a different task, what breaks, and would either of you notice?
Segmentation should be optimized for the downstream obligation, not inherited without inspection.
Key takeaways
- Document, passage, sentence, word, subword, character and byte boundaries solve different problems, and they are not equally solved: over the same 82 CoNLL 2018 treebanks the best macro-averaged word F1 was 98.18 and the best sentence F1 only 83.87.
- Whitespace is a script-dependent signal, not a rule. Unicode Annex #29 states that some languages do not use spaces at all, and on Thai (th_pud) the 26 CoNLL 2018 systems averaged 17.16 ± 20.57 word F1 against a 69.93 best.
- Units carry a price: subword tokenization of the same text differs by up to 15 times across languages, and ByT5's 256-value byte alphabet cuts vocabulary-related parameters to 0.02% while running 6.4 to 9.5 times slower on XNLI.
- Chunking is a policy with a number in it. Dense Passage Retrieval's disjoint 100-word blocks produced 21,015,324 passages, and the Retrieval-Augmented Generation experiments inherited that split unexamined.
- Gold segmentation is a declared convention. The 2003 bakeoff scored systems against Academia Sinica, the Penn Chinese Treebank, Hong Kong CityU and Peking University at once, with a best F of 0.961 on one standard and 0.881 on another.
- A segmenter's accuracy belongs to its corpus. Punkt's 1.26% mean error on eleven newspaper corpora becomes 62.1% precision on legal text, where the domain-retrained NUPunkt reaches 91.1%.