A Masked Segmental Language Model for Unsupervised Natural Language Segmentation
Paper · 2022 · C.M. Downey, Fei Xia, Gina-Anne Levow et al.
Summary
Where does one word end and the next begin? In written Chinese, spaces generally leave that question open, and in running speech there are few reliable gaps to read as word boundaries. A system can learn where to split a sequence from examples that people have already marked, but many languages and tasks have little such training material. Downey and colleagues explore a way to learn boundaries from the sequences themselves. Their Masked Segmental Language Model, or MSLM, learns to predict stretches of characters from the text around them. It then uses those predictions to decide which stretches fit together as a division into words. The paper treats boundary discovery as part of the task of building a language model.
The central change is how the system sees its surroundings. An earlier recurrent segmental system tries to generate a candidate stretch from the characters that precede it. The MSLM uses a Transformer encoder that can also draw on characters that follow. For each possible start, an attention mask keeps the encoder from seeing the characters it may be asked to predict. The system can produce these context representations in a shared pass, score candidate stretches of different lengths, and use dynamic programming to combine their scores. During training it gives credit to all permitted ways of dividing the sequence. At decoding time it returns the division with the highest score.
On the Chinese Peking University corpus, the masked system had a median whole-corpus word F1 of 64.1, compared with 58.7 for the recurrent baseline, when both systems were selected by their ability to predict characters on validation data. With human-marked validation boundaries available for selection, the medians rose to 72.6 and 60.2, respectively. A Transformer restricted to left context came close to the masked system in Chinese segmentation, while the masked system had lower test loss in bits per character under both selection rules. On the English Penn Treebank, the recurrent baseline led in both word F1 and test loss. Under unsupervised selection, its median word F1 was 76.2, compared with 71.5 for the masked system.
These experiments establish that a span-masked Transformer can learn useful boundaries through a segmental prediction objective. They also show that predicting characters well and recovering the words in a reference annotation are different accomplishments. On Chinese, choosing a configuration using a small source of boundary supervision changed the segmentation results substantially. On English, the recurrent encoder retained an advantage even with that option. The evidence comes from shallow systems on written corpora, and the proposed benefits of greater depth and applications to speech or more varied languages remain open.
Deep dive: A Masked Segmental Language Model for Unsupervised Natural Language Segmentation
The Masked Segmental Language Model learns word boundaries from unsegmented text by scoring character spans using context on both sides. · about 39 minutes to read
The problem and its context
When a boundary is part of the answer
An unbroken string can admit several plausible divisions. A familiar stretch might be a word in one setting and part of a larger word in another. The problem is especially visible in Chinese orthography, where the input to a word segmenter can be a sequence of characters with no spaces to supply the answer. In running speech, the comparable difficulty is that a listener cannot recover the words simply by dividing the signal at pauses. The task is to discover units whose boundaries depend on the material around them. In natural language processing, this is a problem of tokenization and segmentation.
A benchmark makes the task measurable by supplying a reference division. A supervised system learns from examples with boundaries already marked and is evaluated on its agreement with a reference. The paper describes supervised Chinese word segmentation as highly accurate in settings where sufficient training examples exist. Its motivation comes from settings in which those examples are expensive or scarce. An annotated collection may be particularly hard to obtain when the units of interest lie inside words. A spelling convention that separates words can still leave roots and affixes joined, and a collection of sentences gives no direct record of where those smaller parts begin and end. That makes the availability of training labels a separate question from the availability of raw text or transcribed speech. The smaller units are a concern of morphology.
The kind of unit matters because different applications ask different things of a segmentation. A study of language acquisition may want to see whether recurring stretches resemble the units a child could discover. A speech application may want divisions that make sense when recurring utterances are compared. A language description project may need candidate units that a linguist can inspect and relate to other forms. A system that serves these purposes has to be judged in part by the boundaries it produces. How conveniently it encodes the input is a different criterion.
The paper makes this distinction when it discusses byte-pair encoding. A byte-pair procedure joins commonly adjacent pieces and builds a vocabulary to the desired size. Its pieces can be useful inputs for neural systems even if their divisions are hard for a person to interpret. Where the divisions themselves are the object of study, the desired vocabulary size supplies little guidance about which particular division should count as a word. The authors situate their work alongside this broad use of subword tokenization, including Neural Machine Translation of Rare Words with Subword Units and SentencePiece.
A second issue is that a useful reference reflects an annotation standard. The paper notes that Chinese corpora can divide the same kinds of material at different levels of detail. A method can therefore be good at predicting the divisions in a particular corpus without settling what should count as a word in Chinese generally. This matters even in an unsupervised experiment. The training algorithm can run without boundary labels, while the eventual evaluation still measures agreement with a human convention. The authors use established references to make the comparison reproducible and treat the choice of reference as one of the conditions of the result.
What earlier methods could learn from sequences
One early approach described by the authors looks for points where an ongoing character prediction becomes unexpectedly difficult. If a sequence predictor expects the continuation of a familiar unit, the first symbol of a new unit can produce a jump in surprise. Peaks in surprise can then serve as clues about boundaries. The prediction system supplies a score at each position, and the segmentation procedure interprets the score as evidence about where to cut. The paper traces this line of work to Elman’s recurrent experiments.
A different approach treats segmentation as a form of compression. Reusing the description of a recurring stretch can save space, but there is also a cost to maintaining a collection of such descriptions. A segmentation is attractive when the resulting units support a compact account of the data at a reasonable cost for the inventory itself. The paper identifies this reasoning with minimum description length and gives Morfessor as a familiar example in Unsupervised Discovery of Morphemes.
Bayesian approaches provide another way to weigh competing divisions. In the account the authors give, methods using hierarchical Dirichlet processes or nested Pitman–Yor processes can be strong at recovering word boundaries. The authors also cite the argument that many such systems capture long-distance dependencies less readily than modern neural predictors. This observation helps define the aim of their comparison. They want a system that yields segments and also learns useful character representations and predictive context. They leave the direct comparison with Bayesian segmentation methods to the earlier work they discuss. Two of the sources in that discussion are Hierarchical Dirichlet Processes and Bayesian Unsupervised Word Segmentation.
The paper also draws on neural work that learns structure at more than one timescale. A sequence can contain events or units longer than a character or timestep, and recurrent systems have been designed to represent that hierarchy. The authors place segmental language modeling in this line of research alongside Connectionist Temporal Classification, segmental recurrent networks, and Hierarchical Multiscale Recurrent Neural Networks.
Another precursor is open-vocabulary prediction. A predictor can represent a familiar word as an entry in an inventory and build an unfamiliar word from its characters. The authors describe earlier neural systems that combine these generation routes and learn representations from spelling. Those systems take word divisions as input, which tells them where each character sequence to be represented begins and ends. In a segmental language model, the choice of those sequences is part of the problem. A plausible division should help explain the recorded characters, even though several other divisions can explain exactly the same observations.
What the segmental approach changes
A segmental language model scores an entire way of grouping the input. It can prefer a particular stretch because a decoder can generate it easily as a unit in the given context. It can also prefer a boundary because ending the current stretch and beginning a new one makes the whole sequence easier to account for. This connection between predicting characters and proposing a division is the common ground between the recurrent baseline and the masked system. The learning procedure can use unsegmented strings because the observed characters are the target and the boundaries are treated as unknown.
The paper distinguishes two experimental traditions in earlier segmental work. Sun and Deng used an LSTM-based system with greedy decoding and used validation boundaries to select settings for Chinese segmentation. The authors call this light supervision. Kawakami and colleagues instead selected settings by language-modeling performance. They reported that the plain segmental objective could yield weak divisions and explored ways to guide it, including an inventory of character sequences and a penalty involving expected segment length. Those studies motivate evaluating both selection rules. A system intended for a language with no annotated validation data has to be selected by a criterion available on unsegmented text.
Access to following context also has a precedent. The paper discusses a bidirectional recurrent segmental system that processes the input in both directions and combines information from those directions when making decoding decisions. Downey and colleagues ask how an attention encoder can incorporate both sides directly into a context for each candidate start. They also build a restricted attention encoder that sees only the left. That comparison gives the experiments a way to ask whether a gain follows from the change in encoder or from access to following text. The architectural starting point is the Transformer.
The method, step by step
From the observed string to candidate segments
The input is a sequence of characters or other discrete timesteps. A candidate segmentation divides it into contiguous, nonempty stretches. Every position belongs to a stretch, and concatenating those stretches in order returns the observed input. The system learns from that input even where no particular division is supplied. The fact that several divisions are compatible with the same string is what makes the boundaries latent, or unobserved, during training.
Start with a position where a segment might begin. The system prepares a representation of the surrounding characters. A smaller recurrent network then tries to generate a candidate segment, character by character, from that representation. It also has to emit a special end-of-segment symbol at the proposed boundary. A candidate with an easy-to-predict beginning can still get a low score if its later characters are unlikely under the decoder or if the decoder expects it to continue when the candidate stops.
A complete division is a chain of these candidates. A path through the input starts at the beginning, chooses a first stretch, starts the next stretch where the first ended, and continues to the end. Training aggregates the contributions of these paths. To return a segmentation, the system tracks the strongest path and reads off its cuts. A maximum segment length limits how far any individual stretch can reach. The number of complete paths can still be large, so the procedure shares calculations between paths.
How the masked system scores and segments text
The steps in order.
There are two distinct information flows here. The context encoder provides a summary of characters outside the candidate, according to the particular mask being used. The segment decoder is allowed to see the characters it has already generated within the candidate. A decoder that has generated a prefix can use it to predict the continuation. The restriction on seeing the target applies to the preparation of the external context and to the prediction of characters that have yet to be generated.
What the recurrent version scores
The paper first describes the recurrent segmental system on which the masked version is based. Its notation for half-open intervals means that the start index is included and the end index is excluded. The relationship between the string and its division can be written as follows.
π(y) = x
Here x is the input sequence, y is an ordered sequence of input segments, and π concatenates them. Equality says that this candidate segmentation accounts for the complete observed string in the original order. In the recurrent system, the context encoder reads x from left to right and updates a hidden state at each character.
hᵢ = Encoder(hᵢ₋₁, xᵢ)
The state hᵢ represents the input through position i. The preceding state is hᵢ₋₁, and xᵢ is the input character at position i. Encoder is the recurrent context update. For a segment beginning at i, the state available before seeing its first character is therefore hᵢ₋₁. Using this state connects the new segment to the entire preceding sequence through the encoder.
The context state serves two purposes at the start of decoding. It initializes the decoder’s hidden state and supplies an input to its first prediction. These are learned transformations of the same contextual information.
uᵢ = gₕ(hᵢ₋₁)
Here uᵢ is the initial segment-decoder state for a start at position i. The function gₕ is a feed-forward layer that maps the context encoder state hᵢ₋₁ to that initial state. The subscript h identifies the transformation for the hidden state.
sᵢ = gₛₜₐᵣₜ(hᵢ₋₁)
Here sᵢ is the starting input to the decoder for position i. The feed-forward layer gₛₜₐᵣₜ prepares it from the same preceding context state hᵢ₋₁. The starting input is distinct from the initial hidden state. Together they let the decoder issue its first character distribution before it has generated any character of the segment.
p(yᵢ,₀ | x₀:ᵢ) = Decoder(uᵢ, sᵢ)
In this expression, p denotes a conditional probability, and the bar separates the target from its conditioning input. yᵢ,₀ is the first character of the candidate starting at i, and x₀:ᵢ is the prefix up to, but excluding, that start. Decoder denotes the probability assigned to the specified target by the segment decoder, here using state uᵢ and starting input sᵢ. The decoder produces a distribution, and scoring an observed candidate takes the entry for its actual first character.
p(yᵢ,ⱼ | yᵢ,₀:ⱼ, x₀:ᵢ) = Decoder(dᵢ,ⱼ₋₁, yᵢ,ⱼ₋₁)
Here j is the offset of the next item within the candidate that begins at i. The prefix yᵢ,₀:ⱼ consists of the earlier items in that candidate, and x₀:ᵢ is the same external prefix as before. The state dᵢ,ⱼ₋₁ carries the segment decoder’s running information, and yᵢ,ⱼ₋₁ is the preceding item. The left side makes explicit the information on which the probability p depends. The right side expresses how Decoder accesses that information through its recurrent state and input.
The last item to be scored is a special symbol, written <eoseg> in the training details. Its probability supplies evidence about the proposed end. Consider two candidates with the same beginning, where one stops and the other continues. The first uses the probability of the end symbol immediately after their shared characters. The second uses the probability of another observed character at that point and scores the end symbol later. A single sequence of predictions from a given start can therefore supply distinct scores for the possible stopping points.
S(i,i+ℓ) = p(yᵢ,₀ | x₀:ᵢ) × ∏ⱼ₌₁…ℓ p(yᵢ,ⱼ | yᵢ,₀:ⱼ, x₀:ᵢ)
S(i,i+ℓ) is the recurrent score for the span starting at i and ending just before i+ℓ, where ℓ is its length in observed characters. The first factor is the probability p of the first character yᵢ,₀ given the external prefix x₀:ᵢ. The product sign ∏ multiplies the remaining probabilities as j moves from 1 through ℓ. For j below ℓ, yᵢ,ⱼ is another character of the candidate. At j = ℓ, it is the segment terminator. In every factor, yᵢ,₀:ⱼ is the part already generated. In log space, the score is the sum of the corresponding log probabilities.
This factorization is important even when the encoder is changed. The decoder at a candidate start uses the input characters available to its context encoder, independently of how those surrounding characters might eventually be divided. For the recurrent encoder, the same prefix can have several possible segmentations and still give exactly the same hᵢ₋₁. The model can thus reuse the score for a proposed stretch across paths that reach it through different earlier cuts.
What the span mask makes visible
The masked system replaces the recurrent context encoder with an attention encoder while preserving a recurrent decoder for individual segments. Attention allows a representation at a particular position to draw on other input positions. In this application, unrestricted attention would give the decoder access to the stretch it is supposed to predict. The authors prevent that by pairing a candidate start with a nearby encoder position and blocking that position’s access to the span.
The intended conditioning can be understood first for a span of known length.
p(xₜ:ₜ₊₃ | x<ₜ, x≥ₜ₊₃)
Here p is a conditional distribution, x is the character sequence, and t is the start of the candidate. xₜ:ₜ₊₃ is the span from t up to but excluding t+3, using the paper’s example. x<ₜ is the material before the start, and x≥ₜ₊₃ is the material from the first position after the candidate onward. The bar marks the separation between the characters to be predicted and the characters allowed as context.
The working encoder shares a context among the spans of different lengths that begin at the same place. To see the consequence, imagine a short candidate and a longer candidate extending from that start. The short candidate ends inside the range withheld for the longer one. Some characters that could have supplied following context for the short candidate are thus hidden from its encoder representation as well. This is the cost of deriving all those candidate scores from a single representation per start. The paper expresses the shared prediction target in the following form.
p(xₜ:ₜ₊₁, xₜ:ₜ₊₂, …, xₜ:ₜ₊ₖ | x<ₜ, x≥ₜ₊ₖ)
p again denotes conditional prediction, t is the start, and k is the maximum segment length. The expressions before the bar denote the possible target spans, with … covering the intermediate lengths. The comma-separated targets summarize the predictions obtained from the shared encoder context. The characters visible to that context are x<ₜ on the left and x≥ₜ₊ₖ on the right, with visibility limited to positions that exist in the sequence. The expression describes a common source of context for the candidates. Each candidate still receives its own score from the segment decoder, including its own decision to end.
The encoder position used for a start at t is t−1. This offset puts the representation at a position just before the masked stretch, so the character at the query position belongs to the allowed left context. Each attention row has its own range of forbidden columns. The restriction is added to the attention scores before the weights are normalized.
Aᵢ,ⱼ = −∞ if 0 < j − i ≤ k, and 0 otherwise
Aᵢ,ⱼ is the additive mask value for a query at input position i and a key at position j. The difference j − i measures the offset of that key from the query. A positive offset at most k falls within the withheld stretch. The value −∞ gives such a position zero attention weight, and the additive value 0 leaves the attention score unchanged. At the row with i = t−1, the first hidden character is the character at t. Positions beyond the blocked range are eligible to contribute following context.
The arrangement matters because hiding a target with an ordinary replacement symbol would require different corrupted inputs for different stretches. A pass in which the characters at a particular start have been replaced offers an input for that choice of target. The segmental training objective needs scores across the sequence, including for stretches that overlap. The attention mask handles these different visibility requirements through its rows. Each row reads the permitted positions for its own prediction, while other rows can have different sets of visible characters within the same encoder pass.
The paper places this design in the context of masked prediction. BERT is an example of using context around a withheld token. MASS and BART provide precedents for hiding larger spans, but the segmental objective needs a score for every permitted candidate in a sequence. The distinction is about how prediction is used. A pretraining procedure can learn from selected omissions, while the segmental calculation needs the alternatives that could form each complete path. The earlier approaches include BERT, MASS, and BART.
Preventing information from reaching a hidden span indirectly
The mask controls attention between positions, but a deeper encoder has another route by which a hidden character can affect a prediction. A position visible to the current query might have attended to the hidden character in an earlier layer. If the current query can read that position’s updated representation, the target could enter the calculation indirectly. It is the information inside the visible representation, as well as its location, that determines whether a mask does what it is supposed to do.
In attention, a query represents the position asking for information, a key helps determine whether a source is relevant, and a value carries the information to be combined. In the first encoder layer, the authors derive all of these from the original input embeddings. The shifted query comes from the position before the target begins, so its original character is available to the prediction. Under the segmental mask, the keys and values for positions inside the withheld range receive no attention weight.
For later layers, the query is made from the preceding layer’s representation of the query position. The keys and values are still made directly from the original input embeddings. The updated query can refine what it seeks using the information it has already gathered under its own mask. It still reads original embeddings at the allowed source positions. Using updated keys would let hidden information affect which material appears relevant, and using updated values would let it enter the material being combined. The paper describes a related independently developed approach by Shin and colleagues for single-token prediction. The segmental design adapts the masking problem to stretches that can have different lengths and offsets the query to the position preceding the target.
The Directional MSLM, abbreviated DMSLM, uses a causal attention mask. At the query position before the proposed start, the available information is confined to the prefix. This makes its external conditioning resemble that of the recurrent system, while the way it gathers that information is attention-based. The MSLM and DMSLM use the same style of segment decoder and differ in the context allowed by the encoder. The RSLM, the recurrent baseline, differs in how the encoder processes the prefix. All these systems have recurrence inside the segment decoder, so references to an attention-based alternative concern the context encoder.
Adding position information to the characters
A segmental prediction can depend on the order of the characters in view. The authors add static sinusoidal position representations to the character embeddings and learn how strongly the character component should contribute to the combination. An embedding is a vector used to represent an input item, in this case a character. The position representation is a separate vector associated with its index. Their method first computes a scale from the two vectors together. The underlying representations are examples of embeddings.
g = 1.0 + ReLU(f([e, r]))
Here e is the original character embedding and r is the sinusoidal position vector. The brackets [e, r] denote their concatenation, which is the input to the learned linear map f. ReLU retains a positive input and returns zero for a negative input. The constant 1.0 sets the base value of the scale g. The larger the positive output of f, the more weight the combination can give the character embedding.
e ← g × e + r
The arrow ← replaces the representation e on the left with the expression on the right. The scale g multiplies the original e, and r supplies the additive position vector. The resulting input representation thus carries both the character and its location. The scale is learned as part of the network. The study uses this construction in both attention variants and offers its adequacy as part of the interpretation of the results.
Adding up paths for training and choosing a path for decoding
To learn from an input with missing boundaries, the segmental objective combines the scores of every allowed division. With S standing for the score of an individual segment under the encoder and decoder in use, the paper’s marginalization can be written as follows.
P(x) = ∑ᵧ∈Z(|x|) ∏₍ᵢ,ⱼ₎∈y S(i,j)
P(x) is the score obtained by summing the contributions of the candidate divisions of x. The notation |x| is the length of x, and Z(|x|) denotes the set of segmentations considered for that length. With a maximum span length in force, the allowed divisions contain only spans within the limit. The sum ∑ ranges over those divisions y. The product ∏ ranges over the start and end pairs (i,j) of the spans in a division, and S(i,j) scores the stretch from i up to but excluding j. The sum makes it possible to give a string a training score before the system has settled on a division.
There are exponentially many unrestricted divisions. At each internal gap a boundary can be present or absent, giving the count the authors use to motivate dynamic programming.
2^(|x|−1)
Here 2 is the number of choices at each gap, |x| is the number of characters, and |x|−1 is the number of internal gaps in a nonempty string. The exponent counts the combinations of boundary decisions before the maximum segment length rules out any paths. Calculating the product separately along every path would repeat the same operations on the same prefixes.
The forward calculation stores a total at each endpoint. The starting endpoint represents the empty prefix and has a path contribution of one.
α₀ = 1
Here α₀ is the forward value at the start of the input, position 0. The value 1 is the multiplicative identity for the first segment score. At any later endpoint, every path has a last segment. Paths with the same last segment can be grouped together, since the total for the prefix before that segment is already available.
αⱼ = ∑ᵢ αᵢ × S(i,j), over max(0, j−k) ≤ i < j
αⱼ is the sum of path contributions through endpoint j, and αᵢ is the previously computed sum at a possible start i. The sum ∑ᵢ includes the starts satisfying the range on the right. S(i,j) is the score of the final proposed span, k is the maximum span length, and max(0, j−k) prevents the candidate from beginning before the input or reaching farther back than that limit. The strict inequality i < j makes each span nonempty. The value at the end of the sequence gives the sum needed for training.
When a particular segmentation is required, the procedure uses the same candidate spans and records the best arrival at each position. This is Viterbi decoding. For a given endpoint, it compares the score of the best path to each eligible start followed by the score of the proposed last segment. It records the winning start as a backpointer. Following the pointers from the end back to the beginning recovers the boundaries of the best complete path. The training calculation can benefit from several plausible divisions, while the evaluated output is a single division.
For the recurrent encoder, each segment probability is conditioned on a prefix. In the masked system, the score for a segment can also depend on characters farther along the same input. The lattice calculation still applies because every span’s score is fixed once the input and model parameters are given. It does not depend on which cuts the path used to reach the span or will use after it. This is a property of the scoring and decoding procedure. The two-sided score evaluates a known string with context from that string, so interpreting it as an ordinary left-to-right generation probability would require an additional argument.
How the systems were trained and selected
The experiments use the same basic training procedure across the three encoders. Each network has one encoder layer and one decoder layer, with an embedding size and hidden size of 256. The paper reports 592,381 trainable parameters for the Transformer-based encoder and 592,640 for the LSTM encoder. The Transformer uses 4 attention heads and a feed-forward size of 509. The dimensions were chosen to keep the attention encoder within the parameter count of the recurrent encoder. Dropout, which randomly suppresses part of a representation during training, is set to 0.1 before both the encoder and the decoder and to 0.15 within the Transformer layers.
Initial character embeddings are learned from the training portion of each corpus using continuous bag of words, or CBOW. This gives characters starting representations learned from nearby input before the segmental objective begins updating them. During the 32 epochs of initialization, PKU uses a window of 5 and PTB uses a window of 10. Symbols absent from the ordinary training strings, including the segment terminator, start with random embeddings. The initialized vectors continue to be updated during training. The authors base this stage on Efficient Estimation of Word Representations in Vector Space.
Training uses 8192 optimizer steps. The target mini-batch size is 8192 characters, with some variation because the authors keep sequences intact. They cap the gradient norm at 1.0 and save checkpoints every 128 steps. The Chinese training schedule warms up linearly for 1024 steps and then decays linearly. The English schedule decays linearly from the start. The optimization algorithm is Adam.
The maximum candidate length is 5 characters for PKU and 10 for PTB. This parameter is part of both the search and the training setup. It determines which spans can enter a path and, for the masked encoder, how much following material is held out for each start. A reference word longer than the limit cannot be returned as a single segment. A larger limit would allow longer candidates and would also change the context shared by the candidates in the masked system.
Each architecture is initially swept over six learning rates on one random seed. On PKU, the candidates are 6e-4, 7e-4, 8e-4, 9e-4, 1e-3, and 2e-3. On PTB, the candidates are 6e-4, 8e-4, 1e-3, 3e-3, 5e-3, and 7e-3. The authors retain two selections from each sweep. One is based on agreement with validation boundaries, and the other is based on the lowest validation loss in bits per character. The appendix labels the segmentation selection criterion MCC. The selected configurations are then run with four additional seeds, and the results are reported across 5 random seeds.
The source of supervision is the selection rule. In the lightly supervised setting, a reference division helps determine which configuration is retained. The objective that updates the character encoder and segment decoder still learns from the strings through the segmental calculation. In the unsupervised setting, validation text is available but its word boundaries are unnecessary for selection. This distinction makes it possible to test what happens when the practitioner can afford some human division of validation examples and what happens when only unsegmented material is available.
The authors identify their project repository as the home of the code used for the experiments and the data in the form they used, including the modified PKU tokenization. They obtained their starting corpora and splits from the segmental experiments of Kawakami and colleagues.
Experiments and results
What the corpora and metrics measure
The Chinese benchmark is the Peking University corpus, abbreviated PKU. It has been used for Chinese word segmentation through the SIGHAN Bakeoff. The authors use the training, validation, and test division from the earlier segmental study. They adopt Sun and Deng’s handling of English material, numbers, and punctuation within PKU, and keep whole sequences across punctuation. Doing so keeps the text surrounding punctuation available to the encoder where the sequence permits it. The account of the benchmark comes from the Second International Chinese Word Segmentation Bakeoff.
The English benchmark is the Penn Treebank, abbreviated PTB, in the version used by Kawakami and colleagues and sourced in the paper to Mikolov and colleagues. The corpus statistics count 4.60M characters, 1.04M words, and 49.20k lines, with an average of 4.44 characters per reference word and a character vocabulary of 46. PKU has 1.93M characters, 1.21M words, and 20.78k lines, with an average of 1.59 characters per reference word and a character vocabulary of 4508. The experiments thus present the encoders with very different inventories and typical word lengths. They also use different maximum candidate lengths and training schedules for the corpora.
The main segmentation metric is word F1, reported over the entire corpus using the SIGHAN scoring script. A word counts as recovered when its span matches a word in the reference. Word precision reflects the share of proposed words that match. Word recall reflects the share of reference words recovered. F1 combines those quantities. A misplaced internal boundary can spoil a full-word match even where several neighboring boundaries are correct. Conversely, an individual correct boundary can receive credit in boundary-level analysis while the adjacent word fails to match.
The language-modeling metric is average test loss in bits per character, abbreviated bpc. Lower loss means that the system assigned stronger scores to observed text according to its objective. The bpc results come from the test split and the configuration choices are made on validation data. That split distinction matters for comparisons with the paper’s individual learning-rate example, which quotes validation loss. The word F1 results have their own reporting scope. The authors use the entire corpus for word F1, following the earlier segmental study, so the reported word scores should be read as whole-corpus agreement.
The architecture comparison uses the recurrent RSLM, the left-context attention DMSLM, and the span-masked MSLM. The reported segmentation summaries include the mean, standard deviation, and median across seeds. Since the rates are first chosen on an initial seed and then used for further trials, variation across runs shows how much the resulting division can depend on initialization and training randomness under a fixed selection procedure. It also gives context for comparisons in which the mean and median imply different impressions of the typical outcome.
Chinese word recovery
With unsupervised selection, both attention encoders improve word F1 over the recurrent baseline on PKU. The masked system has the highest median. The means of the attention variants are both 62.9, with standard deviations of 2.6 for the DMSLM and 2.8 for the MSLM. The recurrent baseline has a mean of 59.4 and a standard deviation of 1.9. The agreement in the attention variants’ means is useful context for the ordering by median. It shows how close their segmentation results are in this condition.
Unsupervised selection on PKU, whole-corpus median word F1
Both attention encoders recover more reference words than the recurrent encoder by median F1.
The numbers
| System or setting | Word F1 |
|---|---|
| RSLM | 58.7 |
| DMSLM | 63.4 |
| MSLM (this paper) | 64.1 |
Using gold validation boundaries to select the configuration changes the comparison. The recurrent system records a whole-corpus mean word F1 of 61.2 ± 3.6 and a median of 60.2. The directional attention system records 72.2 ± 2.0 and a median of 72.7. The masked system records 72.3 ± 0.7 and a median of 72.6. The mean is slightly higher for the masked system and the median slightly higher for the directional one. Both results support a comparison between the attention encoders and the recurrent baseline much more clearly than an ordering between the attention encoders themselves.
The supervised information here belongs to validation selection. The improvement shows how much a practitioner with annotated validation data could gain by deciding which segmental configuration to keep. It also reveals a practical difficulty for fully unannotated use. A configuration that assigns a good score to validation text can choose a division somewhat different from the one the corpus uses. With both selection rules available in the experiment, the size of that difference can be inspected directly.
Chinese prediction loss
For the configurations selected by validation bpc, the MSLM also yields the lowest test bpc on PKU. Its result has a standard deviation of 0.01 across seeds. The recurrent baseline’s test bpc has a standard deviation of 0.01, and the directional attention system’s has a standard deviation of 0.03. The chart compares means. In this condition, the best median segmentation and best average test loss belong to the same architecture.
Unsupervised selection on PKU, mean test bits per character
The span-masked encoder has the lowest loss under validation selection by prediction.
The numbers
| System or setting | Bits per character |
|---|---|
| RSLM | 5.63 |
| DMSLM | 5.67 |
| MSLM (this paper) | 5.56 |
When the selection rule uses annotated boundaries, PKU test bpc is 5.67 ± 0.01 for the recurrent system, 6.08 ± 0.31 for the directional attention system, and 5.85 ± 0.12 for the masked system. The recurrent test loss is lower in that comparison even though the attention encoders achieve much higher word F1. Within the attention pair, access to following context accompanies lower prediction loss under both selection rules. This pattern gives a reason to consider the two tasks separately. Recovering a preferred division and assigning a strong score to the characters can favor different configurations, even on the same dataset.
English word recovery and prediction loss
On English PTB, the recurrent system has the highest word F1 under both selection rules. With unsupervised selection, its mean is 75.7 ± 2.6. The directional attention system has a mean of 67.9 ± 10.6, and the MSLM has a mean of 69.3 ± 5.6. The directional system’s median is closer to the recurrent median than its mean is. The variation in that condition is important when describing how comparable the systems are. A median summarizes the central trial, while the mean and standard deviation show the effect of weaker runs.
Unsupervised selection on PTB, whole-corpus median word F1
The recurrent encoder leads, and the directional encoder has the higher median of the attention systems.
The numbers
| System or setting | Word F1 |
|---|---|
| RSLM | 76.2 |
| DMSLM | 73.8 |
| MSLM (this paper) | 71.5 |
With the configurations selected on gold validation divisions, the recurrent system reaches a mean word F1 of 77.4 ± 0.7 and a median of 77.6. The directional attention system reaches 70.6 ± 6.4 and a median of 73.3. The span-masked system reaches 71.1 ± 5.6 and a median of 73.6. The medians place the attention encoders fairly close together. The recurrent system combines better central results with less variation in this condition. In contrast to PKU, access to validation divisions leaves the ordering between the recurrent encoder and the attention pair in place.
The English test loss has the same overall leader. Under unsupervised selection, test bpc is 1.96 ± 0.00 for the RSLM, 2.27 ± 0.04 for the DMSLM, and 2.27 ± 0.01 for the MSLM. With light supervision it is 2.10 ± 0.04, 2.36 ± 0.07, and 2.39 ± 0.06, respectively. The agreement of the two attention means in the unsupervised setting, and their proximity in the lightly supervised setting, provide little evidence that following context delivers the English bpc benefit observed on PKU. The RSLM’s lead also means that the availability of context on both sides did not ensure the lowest observed loss.
What the ablations show
Changing the encoder and changing the context
The directional attention control is the paper’s main architectural comparison. The recurrent encoder and the directional attention encoder see the characters to the left of the candidate. Both use a recurrent decoder for the candidate itself. The contrast between them asks what happens when prefix information is collected through attention rather than through an LSTM state. The comparison between the directional encoder and the span-masked encoder then asks what happens when the attention system can draw on the following characters while excluding the candidate’s own region.
On PKU, the directional control recovers much of the segmentation advantage of the MSLM. In the gold-selected condition, the two attention systems have very similar word F1. Under loss-based selection, they share the same mean word F1 and have nearby medians. Thus a system can obtain the Chinese segmentation gains seen here with left context alone, provided that it uses the attention encoder. The directional comparison with the recurrent baseline supports an architectural contribution within the tested setup. It leaves open which component of the attention implementation, including its representation of position, matters most.
Prediction loss shows a different pattern. On PKU, the masked encoder has lower test bpc than the directional attention encoder under both selection rules. The result supports a role for right context in the masked system’s Chinese prediction performance. The control varies the mask as a whole. It makes following characters available and changes the visible context used by candidates sharing a start. Its result is evidence about the tested conditioning arrangements. It cannot assign the contribution to a particular distance, a particular character type, or a specific attention head.
There is also a distinction between the advantage of an architecture after tuning and the effect of swapping its mask with every other training choice fixed. Each architecture is selected from its own sweep. Within a corpus, the appendix shows that the two attention variants frequently share a chosen learning rate. For unsupervised PTB, they do not. The comparisons characterize the trained configurations the authors could select under their procedure. They do not form a complete factorial account of architecture, optimization, and context for every condition. In particular, the experiments include no bidirectional recurrent encoder to fill the remaining combination of architectural and conditioning choices.
Selection by prediction and selection by boundaries
The lightly supervised and unsupervised runs isolate an important practical choice. When annotation can guide selection, the retained configuration can be chosen for better boundaries. In its absence, the validation loss has to stand in as an observable criterion. The PKU results show how much this choice can matter. The attention architectures have relatively high word F1 when selected for segmentation, while the MSLM selected for prediction gives the best test loss. A practitioner with annotated validation data has room to consider a range of configurations with different balances of these measures, as the authors point out.
The learning-rate analysis makes the uncertainty about validation loss more concrete. The Chinese MSLM chosen by prediction loss was trained at 2e-3 and achieved 5.625 validation bpc. The authors also report an MSLM trained at 1e-3 with 5.631 validation bpc and whole-corpus word F1 of 69.4 ± 2.0 by mean and standard deviation, with a median of 70.4. The configuration with the slightly higher validation loss yields stronger and less variable segmentation in that comparison. Ranking the two runs by loss would favor the one with poorer agreement with the reference boundaries.
This is evidence from a particular pair of learning rates on PKU. The paper suggests that a lower learning rate may sometimes provide a better balance between progress on the prediction objective and stability of the resulting division. The observed performance of this candidate does not establish a general learning-rate rule. It shows that the validation criterion can choose between systems that are very close as character predictors and more clearly separated as segmenters. In an unsupervised deployment, distinguishing such candidates by word F1 would require precisely the reference divisions the selection setup assumes are unavailable.
Where the predicted cuts fall
The authors inspect character-wise boundary precision and recall to understand the word-level comparison. Here each character position is evaluated for the presence or absence of a word break. A predicted break counts towards precision when it is also a reference break. Recall measures how many of the reference breaks the system finds. These measures give partial credit for useful boundaries even when the complete words on either side fail to match.
Under unsupervised selection on PKU, all three systems have very high boundary precision. The RSLM averages 98.2 ± 0.1 in precision and 80.8 ± 0.6 in recall. The DMSLM averages 98.6 ± 0.1 in precision and 78.5 ± 1.8 in recall. The MSLM averages 98.5 ± 0.1 in precision and 78.1 ± 1.9 in recall. The recurrent encoder finds more true breaks under this measure, while the attention systems’ proposed breaks are somewhat more often correct. In this case the attention systems have the stronger whole-word F1 in spite of their lower boundary recall. Boundary scores alone cannot say how often the correct cuts line up at both ends of a reference word.
The average length of the resulting PKU segments helps explain the recall figures. The gold average is 1.59 characters per word. Under unsupervised selection the RSLM returns segments averaging 1.93 ± 0.02 characters, the DMSLM 1.99 ± 0.04, and the MSLM 2.00 ± 0.05. All tend to leave more material together than the reference does. The attention systems propose the longest segments and find a smaller share of the reference boundaries. Higher precision can coexist with this pattern when a system proposes fewer cuts and places those cuts conservatively.
With validation boundaries available, the average PKU segment lengths of the attention systems move closer to the reference. The DMSLM averages 1.83 ± 0.04 characters and the MSLM 1.83 ± 0.01. Their boundary recall rises to 84.6 ± 1.5 and 84.5 ± 0.4, respectively. Precision is 97.5 ± 0.5 and 97.6 ± 0.1. The recurrent system in this setting averages 1.92 ± 0.02 characters per segment, with precision of 98.2 ± 0.1 and recall of 81.3 ± 0.7. The large improvement in word F1 for the attention variants comes with a willingness to propose more cuts, including more of the cuts the annotation calls for.
For English, the paper reports boundary statistics for unsupervised selection because the authors found similar patterns across the selection settings. The RSLM has recall of 95.5 ± 0.1 and precision of 86.1 ± 1.9. The DMSLM has recall of 88.9 ± 4.6 and precision of 85.4 ± 5.4. The MSLM has recall of 89.5 ± 3.5 and precision of 86.2 ± 1.5. The clearest recurrent advantage is in finding reference boundaries. The average segments are also shorter for the recurrent system, at 4.02 ± 0.08 characters, than for the directional and masked systems, at 4.27 ± 0.17 and 4.29 ± 0.12. All these averages are below the gold average of 4.44. The attention systems leave more material joined relative to the RSLM, while the overall means show that misplaced extra cuts are also part of the error pattern.
The example from PTB makes the mixture visible. The authors show systems dividing before into be and fore. In questionable, the proposed cut before able is linguistically interpretable, even though the corpus treats the whole form as a word. The attention variants add a cut between quest and ion in that example. The systems also have difficulty with asbestos. A predicted division can therefore contain a genuine-looking internal structure, an implausible break, and a missed reference boundary in the same stretch of text. The example illustrates possible errors. The boundary and word metrics give the evidence about how the systems behave across the corpus.
What the additional observations establish
The authors tried an inventory of character sequences and an expected-length regularizer in pilot settings. Earlier segmental work had reported gains from combining such techniques. The pilots in this study yielded no gains over the basic systems, and the authors suggest that a broader hyper-parameter search could change the result. The paper supplies no set of pilot scores for estimating the effect of either technique separately. The main comparison therefore concerns the encoder variants trained without those additions.
The appendix also reports batch runtimes. On PKU, the RSLM averages 2.942 seconds per step, the DMSLM 2.987, and the MSLM 2.988. On PTB, the respective averages are 2.177, 2.190, and 2.200 seconds per step. These measurements were made on an Nvidia Tesla M10 with 8GB of memory. They show comparable costs for the shallow configurations on that hardware, with the recurrent system slightly faster in the observed runs. The parallelism of the encoder is a property of the design. The appendix measures the existing implementation at the reported depth, leaving the effect of scaling depth or changing hardware unmeasured.
Limitations
Limits identified by the authors
The authors present the study as a demonstration of viability on two written corpora. They call for evaluation on more Chinese corpora because annotation standards make different decisions about the units to recover. A system that fits PKU’s level of granularity could behave differently when scored against another convention. The paper points to the Chinese Penn Treebank and other corpora from the SIGHAN evaluations as ways to test that question. A finding about PKU establishes performance against a particular reference within a particular corpus.
The authors also note that the material is relatively formal orthographic text. Their motivation includes the discovery of units in speech, but the experiments here feed the encoder written sequences. They suggest phonemic transcripts from the Brent Corpus as a step toward testing a different kind of input, since these give sequences from speech without requiring the system to handle a continuous acoustic signal. The suggested progression helps specify the current scope. Successful recovery from written Chinese and English gives evidence about character sequences. The adaptation to speech would have to be evaluated on input that represents speech, either through transcription or through an acoustic representation.
The same scope applies to languages with more elaborate word structure. The authors propose evaluating the approach on other orthographies, particularly where meaningful units within words are important. Their experiments score agreement with word divisions and give English examples that sometimes resemble divisions within a word. Those examples motivate a distinction between word segmentation and morphological segmentation. The paper has no evaluation showing that the system can recover annotated morpheme boundaries accurately in the languages it proposes for future testing.
Depth is another stated limitation. The context encoders in the experiments are shallow. The authors argue that the short computational paths within Transformer encoders make deeper segmental networks worth exploring. They also suspect that stronger position representations or deeper encoding could help on writing systems such as English. These are proposed explanations and directions for experiments. The tested attention encoder already includes learned scaling of character and position information, but the paper does not vary that design to show how it affects English word recovery.
The orthographic explanation is likewise presented as a hypothesis. The authors suggest that the large inventory of Chinese characters, many of which carry meaning, gives an attention encoder useful units on which to operate. English letters acquire much of their usefulness from their ordered combinations. The example of cat and act makes the order dependence concrete, since the same letters are arranged into different forms. The comparison gives a reason to investigate whether the positional information is strong enough. It leaves the causal contribution of orthography unresolved.
Limits visible in the experimental setup
Several factors change together across the two corpora. Character vocabulary, reference word length, language, corpus contents, annotations, candidate length limit, and training schedule all vary. PKU and PTB offer a meaningful comparison between two segmentation settings. A controlled test of the orthography hypothesis would need a way to vary how linguistic information is represented while keeping more of those factors fixed. The reported English disadvantage could reflect a combination of position information, corpus properties, the learning procedure, and the different demands their reference boundaries place on the system.
The length limit also has two roles in the MSLM. As a search constraint, it excludes spans longer than the chosen bound. As a masking parameter, it withholds a range of characters after the start even for candidates that finish well before the end of that range. The right context available to a short candidate may omit the most immediate characters following its proposed end. The experiments test the shared mask with the selected length limits. They do not measure how much performance might change with exact masks for each candidate length or with alternative limits within each corpus.
Another limit concerns the scope of the segmentation scores. Whole-corpus word F1 is the paper’s chosen comparison protocol, while bpc is averaged on the test set. Held-out word F1 by itself would answer a more specific question about reference agreement on unseen text. The two reported measures also reward different properties. Even if a system scores observed characters consistently well, several paths can contribute to that score, and the best individual path may disagree with the reference division. A lower test bpc should therefore be interpreted in the context of the score being measured, particularly for a system that has access to characters following the region under prediction.
The random-seed analysis gives useful evidence about stability after selection. Since learning rates are initially chosen with a single seed, the procedure offers less information about whether the same rates would be selected under independently repeated sweeps. The large English variation for the directional attention encoder matters especially here. It shows that a chosen setting can yield quite different results across runs. A distribution over trials at the retained setting answers a different question from the stability of the entire selection procedure.
Finally, the comparisons establish a relationship to recurrent segmental systems. The background discusses Bayesian segmentation and ordinary sub-word tokenization because they illuminate different goals, but the experiments do not put those systems into the same benchmark comparison. The results can support claims about the encoder choices evaluated with the segmental objective, common decoder design, and particular data settings. Claims about the best overall way to find words, to build linguistic tools, or to tokenize for another downstream task would require evidence that directly measures those goals.
What came after
The two related works concern open-vocabulary tokenization and low-resource generation. Their topics connect to different parts of Downey and colleagues’ motivation. Open-vocabulary modeling raises the question of what units a predictor can use when it encounters forms outside a fixed inventory. Generation in a low-resource agglutinative language raises a question about how systems should represent words with substantial internal structure. The details of the connection are clearer at the level of these research problems than at the level of demonstrated reuse of the span mask.
Between Words and Characters is a history of open-vocabulary modeling and tokenization dated 2021, while the masked segmental paper is dated 2022. On that chronology, it belongs alongside the background to the problem rather than an account of later adoption. The point of contact is the choice between using word units and building representations from their characters. Downey and colleagues address a particular version of that choice by leaving the divisions unobserved in training and learning to score alternative groupings.
Triples-to-isiXhosa (T2X) concerns data-to-text generation for low-resource agglutinative isiXhosa. Its subject is close to the masked segmental paper’s motivation for studying languages in which complex word forms and scarce annotations can make segmentation consequential. The task differs from the experiments on PKU and PTB. It begins with structured triples and seeks text output, while Downey and colleagues begin with existing character sequences and seek their divisions. The connection establishes a related setting in which the choice of linguistic unit matters. Whether T2X adopted the segmental objective, its masking scheme, or its decoding procedure is unspecified.
Cite
Cite as C.M. Downey, Fei Xia, Gina-Anne Levow and Shane Steinert-Threlkeld. 2022. A Masked Segmental Language Model for Unsupervised Natural Language Segmentation. Proceedings of the 19th SIGMORPHON Workshop on Computational Research in Phonetics, Phonology, and Morphology.
@inproceedings{downey2022masked,
title = {{A Masked Segmental Language Model for Unsupervised Natural Language Segmentation}},
author = {C.M. Downey, Fei Xia, Gina-Anne Levow and Shane Steinert-Threlkeld},
booktitle = {Proceedings of the 19th SIGMORPHON Workshop on Computational Research in Phonetics, Phonology, and Morphology},
year = {2022},
doi = {10.18653/v1/2022.sigmorphon-1.5},
url = {https://doi.org/10.18653/v1/2022.sigmorphon-1.5}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/downey-2022-masked-segmental-language-model-unsupervised/