Char2Subword: Extending the Subword Embedding Space Using Robust Character Compositionality
Paper · 2021 · Gustavo Aguilar, Bryan McCann, Tong Niu et al.
Summary
A small spelling change can alter what multilingual BERT receives as input. A familiar word may have an entry of its own, while a capitalized or mistyped version breaks into several pieces. Each piece then gets its own vector, and the rest of the network has to interpret them together. On social media, where informal spelling and shifts between languages are common, this can happen even when a reader would recognize the intended word immediately. Char2Subword gives multilingual BERT, or mBERT, another way to represent that word. It reads the characters and combines them into a single vector that can occupy the same place as a vector from the original lookup table.
The authors train the character component to imitate the table before using it to represent unfamiliar spellings. Each vocabulary entry supplies both a character string and a target vector. The training objective rewards agreement in direction, distance, nearest neighbors, and the identity of the original token. The authors also introduce edits such as repeated letters, changes in case, and inserted punctuation, so an altered spelling can learn to produce a vector close to the clean spelling's target. A subsequent stage exposes the component to Wikipedia sentences through masked-token prediction while keeping mBERT's upper layers fixed. Returning to table imitation after that contextual training yields an average neighbor precision of 82.4%, compared with 60.0% from the initial approximation with all the objectives.
In downstream experiments on LinCE, a benchmark for text that mixes languages, Char2Subword can either supply all input vectors or fill in only for words absent from the original vocabulary. The latter arrangement performs particularly well on the Hindi–English validation sets. With contextual training and renewed table approximation, it scores 89.64% on part-of-speech tagging, against 87.86% for mBERT, and 74.91% F₁ on named entity recognition, against 72.94%. Language identification scores remain close. On the Spanish–English sentiment validation set, the hybrid system also retains more of its weighted accuracy after character perturbations.
The full replacement uses 50M parameters for the character component, compared with 91M for the original lookup table. It spends more computation constructing each input vector, while giving the upper layers shorter sequences where the original tokenizer would split words. The results also show a cost to treating similar spellings alike. When a letter helps distinguish English from Spanish, some of the tolerance that makes a typo easier to recognize can make the language harder to identify.
Deep dive: Char2Subword: Extending the Subword Embedding Space Using Robust Character Compositionality
Char2Subword learns to build BERT-compatible embeddings from spelling, helping multilingual BERT handle noisy and unfamiliar words in social media. · about 34 minutes to read
The problem and its context
What changes when a word is split
Tokenization determines which units enter a text-processing system. For mBERT, those units normally come from a fixed vocabulary, and each has a corresponding row in an embedding table. An embedding is a vector of learned numbers. Its job at the input is to give the network a representation it can work with when interpreting the surrounding text. The boundaries chosen by the tokenizer determine how many vectors a word contributes and which entries supply them.
A vocabulary of whole words gives each listed spelling direct access to its vector. It faces an immediate coverage problem when a spelling is rare, absent from the training material, or simply different from the form recorded in the vocabulary. Subword tokenization handles much of this problem by allowing a word to be represented as a sequence of smaller entries. A system can keep common forms intact while reusing pieces across rarer forms. The pieces can preserve the word's letters even when none of the larger spans has its own entry.
Byte-pair encoding, or BPE, builds such a vocabulary by growing units from characters according to frequencies in a corpus and a desired vocabulary size. The authors situate this idea in earlier work on rare words in machine translation, particularly the approach of Sennrich and colleagues. They discuss WordPiece, the variant used by mBERT, alongside other ways of choosing pieces. In a greedy approach, segmentation can proceed by selecting the longest available prefix. Subword Regularization explores sampling different segmentations during training, giving the system experience with more than one way of dividing a form.
The pieces that a vocabulary can supply depend on the material from which it was built. A segmentation can be valid in the narrow sense that its pieces reconstruct the input and still be linguistically awkward. In the paper's illustration, the extra letter in helllo allows a split that includes hell. The pieces for BUSINESS make a common word look almost like a string of isolated letters. In nan-otechnologi, the subdivisions bear little resemblance to the parts of the word that would be useful to an analysis of morphology. Each case puts extra work on the upper layers. They receive the pieces in sentence order and have to work out which belong together and what they mean.
Case changes, punctuation and irregular spellings make this a domain problem as well as a vocabulary problem. Wikipedia provides one kind of writing when the vocabulary and embeddings are learned. User-generated social media text presents a different mixture of forms. Multilingual social media adds another complication. A post may switch languages between clauses or use forms that combine material associated with different languages. Even a word whose meaning is clear in context may arrive at the network as a set of pieces whose individual vectors offer weak clues.
What earlier representations offered
The paper traces the problem back to work on word embeddings such as word2vec and GloVe. Those approaches showed that a continuous vector space could capture relationships among words. The authors emphasize the uneven coverage that comes with learning a vector for each entry. Rare words may get weak representations, and a word outside the vocabulary has no vector of its own. Earlier research used morphological structure to share information, for example by composing representations recursively or using morpheme vectors to inform probabilistic word embeddings. Informal spellings still complicate the job of finding the relevant parts.
Character-based approaches offer coverage at a finer grain. A character sequence can express a spelling whose whole form has never been entered in a table, and patterns shared across spellings can inform the representation. The paper cites strong earlier work on text classification using characters, along with mixed early experience in multilingual translation. Long character sequences increased processing time, and the usefulness of character information varied across languages. The authors cite earlier comparisons in which character-level properties were helpful for morphologically rich languages such as Czech and Arabic, while English showed less benefit over word-level representations. This history matters to a multilingual study because character-level processing can offer different evidence in different writing systems.
Hybrid methods had already explored assigning word vectors where available and backing off to characters for unfamiliar words. Other research used characters to build intermediate word representations before processing context. The paper discusses Character-Aware Neural Language Models and Finding Function in Form in this connection. It also points to ELMo and Flair as examples of contextual representations built from characters, with related work applying character-based representations to social media and code-switching.
The closest antecedent in the paper's account is embedding imitation. Pinter and colleagues took entries from a pretrained word dictionary, read each as characters, and learned to reproduce the supplied vector. This gave the character encoder a set of targets without requiring it to discover a vector space from raw text. Schick and Schütze then explored using context as well as spelling when imitating embeddings. Char2Subword brings the imitation idea to a sub-word table whose vectors already serve as the input to a pretrained Transformer. That creates a particular compatibility requirement. The character component has to produce vectors that the upper layers can use in the space where they already operate.
This requirement explains why the paper concerns more than vocabulary coverage. Any system that assigns some vector to an unfamiliar string has covered it in a mechanical sense. The useful question is what the vector does once it reaches the rest of mBERT. An embedding based on a misspelled word has to carry enough of the information associated with the intended form for sentence processing to benefit. At the same time, embedding a whole word in one position changes the sequence that the upper layers see. The method addresses the vector interface directly and tests the consequences of the resulting sequence changes downstream.
The method, step by step
What comes in and what goes out
Char2Subword starts with a decision about which stretch of text to embed. That stretch may be a word or a sub-word. The component reads its characters and returns one vector with the width expected at mBERT's input. A space-based split can supply whole words, and the original tokenizer or another user-selected procedure can supply pieces. This flexibility concerns the units presented to the character component. Within a unit, character composition always has the same job of turning a sequence of spellings and positions into one vector.
Consider what happens when a word has an entry in the original table. Its vector provides a known answer to the question of how the character component should represent that spelling. If the word has no entry, the component can still carry out the same character computation. Its result is an estimate based on patterns learned from the entries that did have targets. The estimate is sent on as a vector. There is no requirement to pick a substitute vocabulary entry and use that entry's vector as the representation of the unfamiliar form.
The paper first describes a word and its sub-word sequence as follows.
s = (s₀, s₁, …, sₙ)
Here s is the ordered sequence for a word w. The symbols s₀ and s₁ denote its initial pieces, the ellipsis represents intervening pieces, and sₙ is the final piece indexed by n. Joining the pieces in order reconstructs w. The segmentation determines the input units under ordinary sub-word processing. Char2Subword makes the vector for a supplied unit from its characters, so a single unit can also cover a whole word that lacks a table entry.
How Char2Subword is trained and used
The steps in order.
Learning the shape of the original embedding space
The original table gives the authors a training set in which the input and the target are already paired. For each selected vocabulary entry, the input is its character sequence and the target is its mBERT vector. The paper denotes the table this way.
E ∈ ℝ^{|V| × d}
Here E is the embedding matrix and V is the vocabulary. The bars in |V| indicate the number of entries, and d is the width of an embedding vector. The symbol ∈ means that the matrix belongs to the indicated space of real-valued arrays, written with ℝ. The multiplication sign in the dimensions separates the row count from the column count. Each row describes one vocabulary entry.
The underlying imitation problem is the following.
êᵢ = fθ(cᵢ) ≈ eᵢ
The index i identifies the entry sᵢ. Its character sequence is cᵢ, and its original vector in E is eᵢ. The function fθ is the character component, with learned parameters denoted by θ. Its output is êᵢ, where the hat marks a prediction. The approximation sign describes the training goal. The target remains the original vector even when a spelling edit is applied to the input.
Matching a table involves several kinds of agreement. A predicted vector can point in a similar direction to its target but have a different length. It can also resemble the target directly while placing neighboring entries in a different order. A separate check asks whether a projection back into the vocabulary identifies the token whose spelling was supplied. The authors combine these criteria in a single objective.
L(cᵢ, eᵢ, yᵢ, fθ) = Lcos(eᵢ, fθ(cᵢ)) + L₂(eᵢ, fθ(cᵢ)) + Lnbr(eᵢ, fθ(cᵢ)) + Lce(yᵢ, fθ(cᵢ))
Here L is the total loss to minimize, and yᵢ indicates the target token in the vocabulary. The terms Lcos, L₂, Lnbr, and Lce are the cosine, Euclidean, neighbor, and cross-entropy losses. Each plus sign adds another criterion to the objective. The terms offer complementary training signals, all using the known spelling or vector associated with the entry.
The cosine loss compares directions.
Lcos(eᵢ, êᵢ) = 1 − (eᵢ · êᵢ) / (‖eᵢ‖ ‖êᵢ‖)
The dot denotes the dot product of the target and predicted vectors. The double bars give a vector's Euclidean length. The quotient is cosine similarity, and subtracting it from 1 gives cosine distance. The normalization by both lengths lets this term reward directional agreement independently of the scale of the prediction. That is useful for copying relationships expressed through angles, and it leaves the length of the output to be constrained by other terms.
The Euclidean term penalizes displacement directly.
L₂(eᵢ, êᵢ) = ‖eᵢ − êᵢ‖₂
Here eᵢ − êᵢ is the vector of coordinate differences, and the subscript ₂ denotes its Euclidean norm. Directional disagreement can increase this distance, and differing lengths can increase it even when the vectors point the same way. This matters because the output is about to be fed into layers trained on the original embedding table. The authors hypothesize that an input discrepancy can be amplified higher in the network, so they explicitly constrain the predicted vector's magnitude through this term.
The neighborhood term first identifies the reference entries around the target.
(n₁, …, nₖ) = topk(eᵢ, E)
The function topk searches E for the k closest vectors to eᵢ by cosine distance. Each nⱼ is the embedding vector of a selected neighbor at index j. The tuple on the left lists those references from n₁ to nₖ. The loss then uses those same references for the prediction.
Lnbr(eᵢ, êᵢ) = (1/k) ∑ⱼ₌₁ᵏ (dis(eᵢ, nⱼ) − dis(êᵢ, nⱼ))²
Here dis gives cosine distance, and the sum runs over the k neighbors selected for the target. For each j, the expression inside the parentheses subtracts the prediction's distance to that neighbor from the original vector's distance to it. Squaring makes errors in either direction contribute positively, and 1/k averages the squared errors. The computation asks the prediction to maintain a profile of distances to known reference vectors. The neighbors are selected once for this comparison from the target's surroundings.
For the vocabulary objective, the predicted vector is first scored against the rows of the original table.
ŷᵢ = softmax(êᵢ Eᵀ)
The symbol Eᵀ is the transpose of E, so multiplying the predicted row vector êᵢ by it gives a score for each vocabulary entry. softmax converts those scores to a probability distribution, denoted by ŷᵢ. The original table is fixed in this projection. The character component therefore has to produce a vector whose scores work with the table as it already exists.
Lce(yᵢ, êᵢ) = −∑ⱼ₌₁^{|V|} yᵢⱼ log ŷᵢⱼ
Here j indexes the vocabulary entries. The element yᵢⱼ is the target indicator for entry j on example i, and ŷᵢⱼ is the probability assigned to that entry. The sum covers the vocabulary, and log is the logarithm. The negative sign makes the loss smaller as the predicted probability of the target increases. This term gives the encoder a direct incentive to produce a vector that identifies its source entry. The neighbor objective, by contrast, is sensitive to how the output relates to several other entries even when the source can already be identified.
How the characters become a vector
The character encoder begins with an embedding for each character and adds a sinusoidal encoding of its position. A character's identity can therefore be represented by the same learned vector each time it appears, while its position gives the attention layers information about where it occurs in the spelling. The paper also specifies a boundary convention. It prepends ## in the character sequence for full words so the component can distinguish them from sub-word pieces. It gives the input sequence for a unit of length M as follows.
cᵢ = (cᵢ₁, cᵢ₂, …, cᵢₘ, …, cᵢM)
In this expression i identifies the unit, m is an arbitrary character position, and M is the number of positions in the sequence under consideration. Each cᵢₘ stands for the character at its indicated position. The ellipses represent the intervening characters. The sum of character embeddings and position encodings gives X₀, a sequence of vectors before the first attention layer.
A stack of l layers processes that sequence with k attention heads per layer. Here k counts heads within the architecture, independently of the use of k for the number of reference neighbors in the loss. The attention calculation in the appendix uses scaled dot products.
Attn(Q, K, V) = softmax(QKᵀ / √d₁) V
Here Q contains queries, K contains keys, and V contains values. In this equation V is a matrix of values for attention, separate from the vocabulary symbol used in the loss. The transpose Kᵀ allows the dot products between queries and keys to be formed. The square root √d₁ is the scale in the paper's attention expression, with d₁ the character representation dimension used in the stack. The softmax produces attention weights across positions, and multiplication by V gives weighted combinations of their value vectors. For a character position, the result can incorporate information from other positions in the same input unit.
Each head has its own projections. Writing h for the head index keeps it distinct from the example index i.
headₕ = Attn(X WʲQₕ, X WʲKₕ, X WʲVₕ)
Here headₕ is the sequence returned by head h in layer j, and X is the input sequence given to the multi-head component. The learned matrices WʲQₕ, WʲKₕ, and WʲVₕ project X to queries, keys, and values for that head. Attn is the scaled attention operation above. Separate projections let the heads compute different combinations of character information from the same spelling.
MultiHead(X) = [head₁ | … | headₖ] Wᴼ
Here MultiHead is the operation combining the heads, and the brackets and vertical bars indicate concatenation along the feature dimension. The ellipsis covers the intervening heads, and k is the head count. The matrix Wᴼ projects the concatenated output. If Xⱼ is the input at layer j, the appendix first denotes the attention output at that layer by X′ⱼ.
X′ⱼ = MultiHead(Xⱼ)
The prime in X′ⱼ marks the intermediate sequence associated with the attention component, and MultiHead is the operation defined above. The appendix then makes normalization and the residual additions explicit. The intermediate sequence goes to a feed-forward network, which transforms the vector at each position through a wider internal representation and then projects it back.
FFN(X′ⱼ) = GELU(X′ⱼ Wⱼ₁ + bⱼ₁) Wⱼ₂ + bⱼ₂
Here FFN denotes the feed-forward component. The matrices Wⱼ₁ and Wⱼ₂ are its input and output projections for layer j, and bⱼ₁ and bⱼ₂ are their biases. GELU is the nonlinear activation between the projections. The appendix describes the first projection as expanding the width from d₁ to 4d₁, with the second returning it to d₁.
The appendix uses a bar to indicate a normalized sequence.
X̄ⱼ = LayerNorm(Xⱼ)
Here LayerNorm is layer normalization, the normalization operation applied at a component's input. X̄ⱼ is the normalized form of Xⱼ. Likewise, X̄′ⱼ denotes the normalized form of the intermediate sequence X′ⱼ. In the full attention update, the appendix adds the normalized input back to the output of attention.
X′ⱼ = MultiHead(X̄ⱼ) + X̄ⱼ
Here the plus sign is a residual addition. The intermediate sequence contains the result of MultiHead and the normalized input X̄ⱼ. The feed-forward update follows the same pattern.
Xⱼ₊₁ = FFN(X̄′ⱼ) + X̄′ⱼ
Here Xⱼ₊₁ is the output passed to the next layer. The term FFN(X̄′ⱼ) transforms the normalized intermediate sequence, and the residual term adds that same sequence back. These operations keep a vector at each character position through the stack.
The final operation collapses the position dimension.
êᵢ = LayerNorm(maxpool(Xₗ Wₑ + bₑ))
Here Xₗ is the sequence after the l attention layers. The matrix Wₑ and bias bₑ project its positions to the output width required for the embedding space. maxpool takes the largest value across positions for each output coordinate, producing one vector for the unit. The final LayerNorm normalizes that pooled vector, yielding êᵢ. The character sequence has now been compressed to the same kind of input object as a row retrieved from the original table.
Teaching the encoder which spelling changes to tolerate
If the dictionary training pairs contained only canonical spellings, the encoder would learn imitation on those spellings and have to generalize to altered forms by itself. The authors create some of that variation directly. They apply one edit at a time, only to vocabulary forms longer than four characters. The length restriction is intended to reduce the chance that a small edit turns one valid short entry into another. The target remains the clean entry's vector, so the edit is treated as a variation of the input associated with that target.
The edits cover several common ways a spelling can change. A mistype replaces a character with a randomly selected nearby key. A repetition duplicates a selected character, a swap exchanges it with its successor, and a deletion removes it. A case edit toggles one character. A punctuation edit inserts a mark of the kind that can appear within a word, such as a dash or period. For keyboard-based substitutions, the authors use over 100 layouts to cover the range of languages in mBERT more broadly than a single keyboard would.
The training signal comes from the clean vector rather than from an explicit instruction about which characters to ignore. If a duplicated letter would otherwise push the prediction toward distant vocabulary entries, the same losses that train clean imitation pull it back towards the clean target. Because the training edit affects one character, consistent performance on a spelling with several changes would depend on generalization. The capitalization analysis later in the paper is useful precisely because it examines a transformation beyond the one-edit training case.
Putting the vectors into sentences
Learning to imitate isolated entries gives the encoder access to mBERT's lexical space. It does not give it direct practice supplying sequences of vectors whose importance depends on other words. The authors therefore initialize it from the approximation stage and place it in front of the pretrained mBERT layers. They continue training the character component with a masked language modeling objective, in which the system uses partially obscured text to identify selected input tokens. The upper layers are kept fixed. Gradients can teach the input component which representations work for the contextual prediction task without retraining those layers.
The masking procedure starts by choosing 15% of sub-word tokens. The treatment of selected tokens happens at the character level. The paper describes replacing 80% of the characters with [MASK], replacing 10% with randomly selected characters, and leaving the other 10% unchanged. The masking is dynamic, following the procedure the authors associate with RoBERTa. The character module embeds the resulting strings. After contextual processing, the system projects representations back to the vocabulary through the fixed embedding matrix and predicts the original entries.
For this stage the authors use 1M Wikipedia sequences, each containing 512 sub-word tokens. They take 200K sequences for each of English, Spanish, Hindi, Nepali and Arabic. Gradient accumulation gives an effective batch size of 2,000 samples, meaning that gradients from smaller passes are combined before an update. The authors describe a few epochs as sufficient in their setting. The character component starts with experience copying the embedding space, and the upper layers begin with their existing pretrained parameters and stay fixed during this stage.
The paper also trains a version that returns to the approximation objective after contextual training. That sequence has two distinct targets over time. Masked prediction trains the character component to participate in sentence processing. Renewed approximation once again trains it to align directly with the table. In the downstream results, the label “pre-trained” refers to this complete sequence of approximation, contextual training, and approximation again. The authors also evaluate versions that went through the initial approximation alone.
Choosing which words need composition
For downstream fine-tuning, the authors compare full and hybrid use of the character component. In full mode, the component supplies all input embeddings in place of the lookup table. The experiments use it to embed words as units, so the input sent to the upper layers can have fewer positions than the original sub-word sequence. This configuration tests whether the encoder can take over the table's role even for familiar words. It also changes the input segmentation wherever a familiar sequence of pieces becomes a single word vector.
The hybrid mode keeps direct lookup for words that appear as complete entries. It uses Char2Subword when a word as a whole is missing, composing a vector for that word in place of the usual division into pieces. The upper layers thus receive original embeddings in some positions and generated embeddings in others. The training on the original table gives those two sources a common reference space. This arrangement concentrates the change on forms for which direct lookup is unavailable.
The paper makes the Char2Subword implementation available under its method name and uses the existing LinCE benchmark for downstream evaluation. The method leaves room for other choices of segmentation. Full and hybrid use in the reported experiments are particular ways of deciding which character spans become individual vectors and when a direct table entry is used.
Experiments and results
Measuring imitation of the embedding table
The approximation experiment asks whether a vector produced from characters behaves like the original mBERT embedding. The authors report token accuracy and several measures of neighbor precision. Token accuracy asks whether the predicted vector, projected back to the vocabulary, retrieves the entry associated with the input. This is a useful check that the encoder can identify the spelling's source. A high score can occur even when the rest of the vocabulary looks quite different from the predicted vector's position.
Precision at a chosen neighbor count measures overlap between the target vector's nearest entries and the prediction's nearest entries. The lists come from the same embedding table. Precision at the nearest position therefore asks whether the first retrieved entry agrees. Precision at a wider cutoff tests how much of the surrounding neighborhood is shared. The paper emphasizes average precision when selecting an approximation objective, because its goal is to recover more of the table's structure than the identity of the source entry alone.
Loss choices on mBERT embedding approximation by average neighbor precision
The combined objective leads, and vocabulary cross-entropy is the strongest individual loss.
The numbers
| System or setting | Average precision % |
|---|---|
| Euclidean loss | 13.5 |
| Neighbor loss | 19.6 |
| Cosine loss | 28.5 |
| Vocabulary cross-entropy | 58.1 |
| All losses (this paper) | 60.0 |
The cross-entropy-only setting reports token accuracy of 99 and precision at the nearest position of 99.6. Its precision at the cutoff of 15 neighbors is 43.9. For the complete objective, the paper reports nearest-position precision of 98.3 and precision at 15 neighbors of 47.1. The selected objective thus gives up some agreement at the very first position and retrieves more of the target's neighborhood at the wider cutoff. The differences explain why the paper uses average neighbor precision to choose the system that proceeds to contextual training.
The training stages also change the neighborhood results substantially. Starting with the complete approximation objective and then moving to contextual masked prediction lowers precision across the neighbor cutoffs shown in the paper. The authors subsequently resume embedding approximation from that contextualized encoder. The resulting average precision is 82.4%. This is a measurement against the mBERT embedding table, independent of whether the same configuration wins a downstream task. The return to approximation is part of the system that the paper calls pretrained in those tasks.
Evaluating code-switched text
LinCE provides the downstream benchmark. Its text includes combinations of Spanish and English, Hindi and English, Nepali and English, and Modern Standard Arabic and Egyptian Arabic. The paper evaluates language identification, part-of-speech tagging, named entity recognition, and sentiment analysis. These tasks make different demands on the input. Language identification assigns a language label to a word. Part-of-speech tagging assigns a grammatical category. Named entity recognition evaluates the identification of entities in the text. Sentiment analysis predicts a label for the expression of sentiment.
The paper reports weighted F₁ for language identification, accuracy for part-of-speech tagging, F₁ for named entity recognition, and weighted accuracy for sentiment. Accuracy measures correct predictions, while F₁ combines precision and recall for the evaluation in which it is used. The weighted measures apply the benchmark's weighting rather than treating the reported result as an unweighted summary across categories. Because these columns use different metrics and cover different language combinations, the task and split matter more to interpretation than the overall average alone.
The main comparison is with mBERT using its original tokenization and embedding lookup. The validation table includes both Char2Subword modes and both adaptation histories. The test comparison includes mBERT, the pretrained hybrid, and scores from ELMo. ELMo is relevant here because it also composes representations from characters. Its test scores offer a separate character-based point of comparison, while mBERT provides the reference that shares the upper architecture with Char2Subword.
Where validation improves
Hindi–English illustrates the difference between task-level results. On the part-of-speech validation set, mBERT scores 87.86% accuracy. Full Char2Subword scores 89.04 with approximation and 89.38 with contextual training and renewed approximation. The hybrid scores 88.95 with approximation and 89.64% after the complete adaptation sequence. Each of these character-based conditions exceeds the baseline on this split. The authors report the pretrained hybrid's result as statistically significant relative to mBERT.
The Hindi–English entity results make the distinction between deployment modes more evident. Both full-mode rows fall below the baseline, while the pretrained hybrid improves on it. The paper also reports statistical significance for that hybrid result. The table gives the threshold as a p-value below 0.01 in a Student's t-test.
Embedding configurations on LinCE Hindi–English validation named entity recognition
The hybrid with contextual training and renewed approximation scores highest, while both full replacements fall below mBERT.
The numbers
| System or setting | F₁ |
|---|---|
| mBERT | 72.94 |
| Full, approximation | 70.79 |
| Full, contextual training and renewed approximation | 71.98 |
| Hybrid, approximation | 72.68 |
| Hybrid, contextual training and renewed approximation (this paper) | 74.91 |
The authors connect the Hindi–English results to transliteration. Hindi written in Roman characters can break into several pieces under the baseline tokenizer. Char2Subword can represent that same spelling in a single vector, leaving the upper layers to interpret the word in context. The hybrid also retains mBERT's existing vectors where whole-word lookup succeeds. The score pattern makes both aspects relevant. In Hindi–English entity recognition, treating every word as a character composition has a different outcome from using composition selectively.
For Spanish–English entity recognition, the approximation-only hybrid reaches 64.26 F₁ on validation, compared with 62.66 for mBERT. The hybrid that goes through contextual training and renewed approximation scores 63.32. The strongest Spanish–English validation result in this comparison therefore comes from the shorter training history. On Modern Standard Arabic–Egyptian Arabic entity recognition, the highest validation result is 80.45 for the pretrained hybrid, compared with 78.93 for mBERT. The authors discuss noisy social media spelling in both combinations and suggest that exposure to Spanish and Arabic during contextual training helps the character representations. The table shows that the best adaptation history depends on the combination being evaluated.
On Spanish–English part-of-speech tagging, mBERT reaches 97.29 accuracy on validation, and the approximation-only hybrid reaches 97.16. The other Char2Subword results on this split also fall below the baseline. On Spanish–English sentiment validation, the pretrained hybrid reaches 57.71 weighted accuracy, compared with 56.10 for mBERT. The full approximation-only version scores 55.98. Improvements thus depend on both the task and the way character composition is introduced.
For language identification, the authors give an average of 95.71% for mBERT and 95.80% for the pretrained hybrid across the validation language combinations. The split-level scores fall on either side of the baseline. Hindi–English validation weighted F₁ is 96.37 for mBERT and 96.98 for the approximation-only hybrid, while Nepali–English is 96.67 for mBERT and 96.50 for that hybrid. The tight scores support the authors' interpretation that the new embeddings can work with mBERT's upper layers. They offer limited evidence of a substantial gain in identifying languages.
Held-out performance and spelling perturbations
On the Hindi–English part-of-speech test set, the pretrained hybrid scores 88.23 accuracy, against 86.30 for mBERT and 86.71 for ELMo. On the Hindi–English entity test set, it reaches 73.38 F₁, compared with 72.57 for mBERT and 68.79 for ELMo. The direction of the validation improvement carries through to the test comparison for both tasks. Spanish–English entity test F₁ is 64.65 for the hybrid, 64.05 for mBERT and 52.58 for ELMo. On the Modern Standard Arabic–Egyptian Arabic entity test, the corresponding results are 66.13, 65.39 and 56.68.
The pretrained hybrid reaches 59.07 weighted accuracy on Spanish–English sentiment in the test results. mBERT scores 56.43 and ELMo scores 52.88. On Spanish–English part-of-speech tagging, the hybrid's test accuracy is 96.88, compared with 97.07 for mBERT. The language identification test scores again vary by combination. The hybrid improves on mBERT for Hindi–English, with 96.23 weighted F₁ against 94.24, while the original mBERT achieves the higher score for Nepali–English, with 96.32 against 96.19.
The authors also evaluate responses to deliberate spelling perturbations on the Spanish–English sentiment validation set. They use the DeepWordBug recipe in TextAttack to alter characters in words selected for their influence on the prediction. The alterations are chosen to keep edit distance small. The comparison asks whether the systems maintain sentiment accuracy when their inputs change in ways that preserve much of the original spelling.
Clean and perturbed weighted accuracy on LinCE Spanish–English sentiment validation
The hybrid keeps the higher weighted accuracy after perturbation, and both systems lose accuracy.
The numbers
| System or setting | Weighted accuracy % |
|---|---|
| mBERT, clean | 56.10 |
| Hybrid, clean (this paper) | 57.71 |
| mBERT, perturbed | 39.32 |
| Hybrid, perturbed | 45.30 |
The paper reports a loss of 16.78 points of weighted accuracy for mBERT and 12.41 points for the hybrid. The authors observe that many perturbations that affect mBERT's predictions involve entities. They suggest that keeping a modified name within a word-level vector gives the network a better opportunity to use the surrounding text than dividing the name into numerous pieces. The experiment establishes a smaller drop under this particular perturbation procedure and sentiment evaluation.
Parameters and input lengths
The mBERT instance examined in the paper has 177M parameters. Its embedding table accounts for 91M of them and has a vocabulary of 119K entries. Char2Subword uses 50M parameters, which the authors describe as about 45% fewer than the table. That comparison applies to the embedding components. In full mode, the character component takes the place of the table at the input. In hybrid mode, the original table remains available alongside it.
Lookup is computationally cheap for a token that already has an entry. A generated embedding requires character embeddings, attention, projection, and pooling. The character component consequently adds work at the input stage. Word-level sequences can reduce work in the upper layers by giving them fewer positions to process. The paper states that the parameter reduction can be obtained without sacrificing inference speed, while its detailed efficiency discussion quantifies parameter counts and input lengths and acknowledges the added cost of composing embeddings. The reported numbers describe the size and sequence tradeoff directly.
What the ablations show
Token recovery and geometric agreement are different tests
The individual-loss experiments isolate the supervision given to the same kind of character encoder. Vocabulary cross-entropy is the strongest single term by average neighbor precision, as well as a strong way to recover the source token. Cosine distance alone has lower average precision, but does better on that measure than the Euclidean or explicit neighbor term in isolation. The result for the neighbor term is especially informative. Giving the encoder reference distances directly does not by itself reproduce the full retrieval behavior of the original space.
The combined objective has the highest reported average precision. The comparison is close among some mixtures. Two settings in the table reach 59.9 and 59.8, while the complete objective reaches 60.0. The complete objective also has precision of 47.1 at the cutoff of 15, compared with 46.6 and 46.7 for those near-leading settings. The paper's choice follows from how it values overlap across the neighborhood. A reader interested only in retrieving the token associated with the spelling would learn something different from the cross-entropy-only result.
The experiment supports a claim about the training signals under the embedding diagnostic. It shows that combining losses can improve the particular geometric agreement measured against the table. The downstream experiments use the selected approximation setup. A separate downstream run for each single loss is outside the reported comparison, so the diagnostic gains are the direct evidence for choosing the objective.
Contextual training helps after the table becomes the target again
The authors compare results after initial approximation, after contextual masked prediction, and after resuming approximation from the contextualized state. If contextual prediction and geometric imitation improved in lockstep, neighbor precision would rise during the middle stage. The curve goes in the other direction. The encoder learns to support predictions in context, and its isolated outputs become less faithful to the original neighbor lists by the paper's measure.
Renewed approximation changes the outcome. The contextualized encoder is now trained again to produce the original table's vectors and matches their neighborhoods more closely than the initial approximation did. The authors interpret this as evidence that contextualization prepares the component to imitate the space more effectively when imitation is restored as an explicit objective. The neighbor curves capture the order of the stages and their interaction. They do not directly identify which contextual patterns account for the improvement.
Downstream comparisons show why the stronger geometric result cannot be read as a universal ranking of training histories. The hybrid with the complete history improves Hindi–English entity recognition on validation and improves Spanish–English sentiment compared with the approximation-only hybrid. The Spanish–English entity validation comparison favors the approximation-only hybrid. For these tasks, a vector's position relative to the reference table is one part of a system that also includes whole-word segmentation, context, and the available task supervision.
The same spelling with different character noise
The paper inspects neighbors for business to see whether the training augmentation changes the treatment of specific spellings. With the clean form, both versions of Char2Subword find relevant entries. The encoder trained without noise retrieves business with a reported similarity of 0.82 and Business at 0.50. The encoder trained with noise retrieves business at 0.80 and Business at 0.61. The clean original mBERT embedding is also included in the comparison, giving a reference neighborhood for the undisturbed word.
On bsusinessses, both character encoders retrieve businesses, but the reported similarity is 0.42 without noise training and 0.79 with it. The noisy-trained version also retrieves words such as companies and corporations. The ordinary mBERT tokenizer divides the altered string into pieces, so it supplies a sequence of lookup embeddings for that input. This example illustrates the practical difference between finding a vector close to a familiar word and representing the altered form as several available strings.
The all-capital BUSINESS gives a clearer qualitative difference. The encoder trained without added noise retrieves entries such as ASEAN and RSS. The augmented encoder retrieves Business at 0.53 and business at 0.32, together with entries related to corporate activity. The paper says the fully capitalized form did not appear in the augmentation training for this word, because the procedure changes at most one character at a time. This is an instance of generalization beyond the capitalization change supplied in training. It shows how the induced tolerance can work on a concrete example, and the sentiment perturbation experiment tests a wider set of predictions at the task level.
What shorter sequences change
The authors measure sequence lengths before and after ordinary sub-word segmentation on the LinCE development sets. For Hindi–English named entity recognition, the average moves from 17.0 original tokens to 40.5 sub-word tokens. For Modern Standard Arabic–Egyptian Arabic entity recognition, the corresponding means are 20.2 and 44.5. For Spanish–English entity recognition, they are 12.1 and 25.7. The length statistics describe the amount of fragmentation the alternative input schemes have an opportunity to avoid.
The authors suggest that fragmentation may account for part of the stronger results in entity recognition and part-of-speech tagging than in language identification. A word-level prediction about an entity or grammatical role may benefit when the word reaches the upper layers as a single representation. A language label can sometimes be supported by the surrounding words even when the target has been split. This is an explanation of the pattern, rather than a direct estimate of the effect of sequence length. The full and hybrid conditions also change the sources and contents of embeddings.
The full-versus-hybrid comparison helps localize the practical benefit. In Hindi–English validation entity recognition, replacing the complete input table with character embeddings yields lower scores than mBERT, even though full mode also reduces fragmentation. Selectively using character composition yields the best result. The ability to retain known whole-word vectors appears valuable in that combination. The comparison leaves open how much of the improvement comes from the generated vectors for unfamiliar words and how much depends on the mixture of generated and original vectors seen by the upper layers.
Where language identification still confuses spellings
An attention visualization examines a Spanish–English post that switches language within a sentence. The word consequencias has a spelling close to forms in both languages. The authors show word-level attention linking it with surrounding Spanish words, which provides contextual support for its Spanish label. Within the character component, the letter q and positions near the ending receive prominent connections. The paper relates those patterns to the contrast between a Spanish ending such as -cias and a possible English ending such as -ces. The visualization gives an example of character cues and sentence cues being available at different stages.
The development-set confusion matrix shows where that evidence can be insufficient. In the authors' description, 112 English words are predicted as Spanish, and 101 Spanish words are predicted as English. The paper also reports 63 instances processed through character backoff in the group of 101 errors, though the accompanying prose reverses the language label when describing that group. The examples give a clearer account of the ambiguity. Some spellings, including imagine and tacos, occur in both languages. Others are close, as with pajamas and Spanish pijamas. A spelling tolerance meant to support correction can also soften a distinction that is informative for language identification.
The authors identify interjections that look alike across languages and at least one apparent problem with the reference labels. The form larges, a misspelling of Spanish largues, appears in a Spanish context, and the system's Spanish prediction is counted as an error against the supplied label. The analysis thus finds several sources of mistakes or apparent mistakes. Shared spellings can leave little evidence within the word, near spellings can make the character objective less discriminating, and ambiguous or incorrect labels complicate an interpretation based entirely on the aggregate score.
Limitations
Limits identified by the authors
The character component has to compute each generated vector. A lookup table can return a stored vector as soon as its token is known. The authors acknowledge that composing embeddings takes more computation at the input. Shorter sequences can offset that cost farther up the network, and the parameter counts favor the complete replacement at the input. Those properties address different resources. The paper quantifies the size and length properties more directly than it quantifies their combined effect on inference time.
The robustness training is deliberately narrow. The authors choose one edit at a time and apply it only to forms longer than four characters. The restriction is meant to reduce ambiguity among short entries. Their error analysis acknowledges that the same invariance can still blur language boundaries. Spelling variation can be evidence of a typo in one example and a sign that the token belongs to another language in the next. That tension is visible even when language identification scores overall are close.
The authors also distinguish contextual adaptation from embedding imitation. The masked prediction stage has no term requiring a particular isolated neighbor list from the original table. The loss in neighbor precision after that stage demonstrates the consequence in this setup. The complete training history depends on resuming the objective that explicitly rewards table agreement. Claims about improved imitation therefore apply to that history, rather than to contextual training on its own.
Limits of the comparisons
The architecture is intended to fit other pretrained systems that use word or sub-word embeddings. The evidence for carrying it out comes from mBERT. The paper identifies RoBERTa and XLM-R as possible settings for the same approach. It does not report replacement and downstream testing in either one. Compatibility depends on whether an encoder can learn the target table and supply inputs useful to the upper layers of the particular system. The broad applicability claim follows from the interface, with direct experimental support confined to mBERT.
The contextual stage draws from Wikipedia in English, Spanish, Hindi, Nepali and Arabic, and the downstream tests come from LinCE. The setup thus tests a specific transfer between sources and a specific set of code-switching tasks. The paper gives examples of whole-word composition coping with transliteration and spelling noise, but the evaluation does not separately measure coverage across all the writing systems in mBERT, or all the types of inflection, punctuation and casing mentioned in the method's motivation. Fresh spellings can receive vectors through the character encoder. The quality and interpretation of those vectors still have to be established in their downstream setting.
The LinCE comparisons also couple several interventions. When the hybrid backs off on an unfamiliar word, it changes the representation, the number of positions occupied by the word, and the units through which context is processed. Full replacement changes the input of known words as well. Those comparisons show which configurations worked on the evaluated tasks. They do not decompose the contribution of each change. In particular, the explanation involving Romanized Hindi is consistent with the tokenization and scores, while a controlled separation of transliterated forms from other forms would be needed to assign it a precise share of the gain.
The parameter savings for Char2Subword describe the replacement of the table. Several of the strongest downstream results come from hybrid use, where the table is retained. The paper therefore offers evidence for a smaller input component in one configuration and strong downstream performance in another. The size claim and the best benchmark scores need to be read with their respective settings attached.
Finally, the attention and perturbation analyses have different evidential scopes. The attention figure gives a concrete example of where a system assigns weight, alongside an interpretation of the spelling and context. It does not establish which attended characters or words are causally necessary for the prediction. The perturbation results apply to the DeepWordBug evaluation on Spanish–English sentiment validation. Both systems lose weighted accuracy there, so the result measures relative resilience under those conditions. It gives no direct measure of resilience to different perturbations, different tasks, or unrestricted changes in social media text.
What came after
Between words and characters cites Char2Subword in a history of open-vocabulary processing and tokenization. Its subject is the longstanding choice of what units a text system handles. Char2Subword contributes an example in which the unit read by the embedding component can be smaller than the unit it passes onward. Characters provide the spelling evidence, and a composite word or sub-word vector enters the upper layers. The citation connects the paper to that broader history. It does not establish a further implementation or evaluation of the method.
LLM The Genius Paradox also cites Char2Subword. Its stated subject is difficulty with simple word-based counting problems. That topic raises a related question about what a system can do with the units it receives. In Char2Subword, the challenge is to recover a useful representation from a spelling that may be split awkwardly. In word-based counting, identifying the units to be counted is part of the problem posed to the system. The citation links those concerns, while the counting work's title and citation alone provide no evidence that it adopts character-to-subword composition or evaluates the paper's embedding method.
Cite
Cite as Gustavo Aguilar, Bryan McCann, Tong Niu, Nazneen Rajani, Nitish Shirish Keskar and Thamar Solorio. 2021. Char2Subword: Extending the Subword Embedding Space Using Robust Character Compositionality. Findings of the Association for Computational Linguistics: EMNLP 2021.
@inproceedings{aguilar2021char2subword,
title = {{Char2Subword: Extending the Subword Embedding Space Using Robust Character Compositionality}},
author = {Gustavo Aguilar, Bryan McCann, Tong Niu, Nazneen Rajani, Nitish Shirish Keskar and Thamar Solorio},
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2021},
year = {2021},
doi = {10.18653/v1/2021.findings-emnlp.141},
url = {https://doi.org/10.18653/v1/2021.findings-emnlp.141}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/aguilar-2021-char2subword-extending-subword-embedding-space/