Elamur Research

Diacritics Restoration using BERT with Analysis on Czech language

Paper · 2021 · Jakub Náplava, Milan Straka and Jana Straková

Summary

Removing diacritics can turn different words into the same string of letters. In Czech, both krize and kříže become krize, so the spelling to restore depends on what the surrounding text says. Náplava and colleagues approach this as a set of decisions about the letters already present. Their system uses BERT, a pretrained language model, to read the unaccented sentence and decide where to add marks. It predicts an editing instruction for each piece of text, instead of learning a separate output label for every accented spelling. An instruction can place several marks on a piece or leave it as it is.

The authors train a separate system for each of the 12 languages in their benchmark, beginning with the same multilingual BERT. Their system significantly improves on the previous recurrent system with an external language model in 9 of the 12 languages. The largest improvements the authors identify are for Vietnamese and Latvian. They then put the Czech system to a different test, using school essays, web discussions and learner writing alongside the benchmark’s Wikipedia material. Accuracy remains roughly stable when the system reads these noisier sentences, under an evaluation that leaves unrelated errors visible in the sentence while excluding the affected words from scoring.

The Czech analysis also asks what a spelling mismatch means. An automatic test treats the spelling in the reference text as the sole answer. Human reviewers found that about 44% of the adjudicated mismatches were acceptable predictions. In 19% of cases, both spellings worked in context, and in 25%, the prediction corrected a problem in the reference. The authors also found 50 cases in which a spelling worked within its own sentence but surrounding sentences made another spelling necessary. Confirmed errors included choices between distinct dictionary forms, rare names, and inflectional distinctions such as singular and plural. The study therefore measures both how well the system recovers written accents and how often an apparent failure comes from the way the test defines a correct answer.

Deep dive: Diacritics Restoration using BERT with Analysis on Czech language

How BERT restores missing diacritics across languages, and what a detailed study of Czech reveals about ambiguity, noisy text, and evaluation. · about 31 minutes to read

The problem and its context

What disappears when the accents disappear

Restoring diacritics begins with text whose basic letters are still available. The missing information is carried by marks such as the acute accent and the caron. Sometimes the visible letters identify the intended spelling without much help. In other cases, the same unaccented string can represent several spellings. A system has to identify which of those spellings belongs in this particular sentence. It must also recognize words that already have the right form without any marks, since adding an unwarranted accent changes the spelling just as surely as leaving out a necessary one.

The Czech pair krize and kříže illustrates a basic asymmetry. One member already looks like the unaccented input. The other has marks in places where the input has plain letters. Seeing krize in a stripped sentence tells the system which letters it has to work with, but there is no mark left to tell it whether the unchanged spelling is right. The choice has to come from evidence elsewhere. A restoration method that treats every plain spelling as a damaged version of an accented word would therefore make mistakes even on input that contains no missing marks at that position.

Some competing spellings express different words. Others belong to the same underlying word and express different grammatical information. That makes restoration partly a problem of morphology, the study of word structure and grammatical forms. The contrast between programu and programů, for instance, can be a contrast in number within the same grammatical case. A surrounding phrase that identifies the intended number can settle the issue. Where either number makes sense, the sentence may support both spellings. The same letters and the same kinds of marks consequently present very different decisions from one occurrence to the next.

Czech gives the authors ample reason to look beyond overall accuracy. They describe it as a language with rich inflection and extensive use of diacritics. In the multilingual benchmark, they rank Czech 4-th by how heavily it is diacritized. The question for the Czech study is how the system handles this combination. A missing accent can obscure the identity of a word, its grammatical form, or the spelling of a name. An error count that combines all those outcomes can show how often the reference was recovered. Understanding where restoration breaks down requires looking at the competing readings.

How much of the surrounding text matters

The useful evidence may be close to the ambiguous word. A neighboring word can constrain a grammatical form, or the sentence as a whole can make a particular reading more likely. Sometimes the evidence is farther away. The paper gives vily and víly as possible restorations in a sentence about things mentioned elsewhere. When the sentence itself is compatible with either choice, an earlier mention may identify which is intended. The ambiguity comes from what the sentence refers to, even though the actual edit is a mark on a letter.

The authors also distinguish textual evidence from knowledge of the world. Their example involving satelitu and satelitů shows how the number of entities being referred to can determine the appropriate form. It may take knowledge beyond the words in the sentence to resolve that number. From the standpoint of restoration, these are different sources of information. The nearby words can favor one grammatical reading, the document can supply a referent, and knowledge about that referent can settle a choice the wording leaves open. A system that sees only a sentence can sometimes infer the intended form and sometimes has to choose among readings the input leaves open.

This distinction matters because the usual test can be built very simply. Start with accented text, strip the marks, and ask the system to reconstruct the original. The original gives an answer for every position without asking people to write a new reference. But the original spelling records what the author wrote on that occasion. It does not enumerate all the spellings that would produce an acceptable sentence from the stripped input. It can also contain a mistake. The restoration task and the reconstruction test line up closely in many cases, but Czech offers ways to examine where they diverge.

What earlier systems did

The paper describes prior work on restoration in languages including Vietnamese, Romanian, Czech and Turkish, as well as Arabic. Its account groups the main approaches by how they process the surrounding text. Convolutional systems use filters that look for patterns in the input. The authors characterize these systems as fast to train and run, while reporting that they generally trail recurrent and attention-based approaches. They associate that weakness with difficulty using evidence from farther apart in the sequence. That is especially relevant when a short stretch of neighboring letters offers little indication of the intended word.

A recurrent network processes a sequence by carrying a representation forward as it goes. In the earlier restoration systems discussed by the paper, recurrence was often paired with an external language model. The previous result used for the multilingual comparison comes from a system of that kind. The paper also describes earlier systems based on the Transformer and attention, including work on Arabic restoration. Attention lets a representation draw on other positions in the input. Some earlier restoration approaches generated an output sequence in order, so obtaining one part of the result depended on producing earlier parts.

BERT gives the authors a way to use attention while framing restoration as classification over the input. The encoder builds a contextual representation of each input piece. A classifier then makes a prediction for each position, with no need to finish the output for one position before scoring the next. The speed argument in the paper concerns this distinction between parallel classification and output generation that proceeds in sequence. The authors’ decision about what to classify is equally important. Since the basic letters already appear in the input, the output can describe edits to those letters. That reduces the burden on the classifier and makes it possible for a single class to express the same pattern of accents across different strings.

The method, step by step

From an unaccented sentence to an editing instruction

The system sees an unaccented sentence. BERT’s tokenizer splits the sentence into units that can be whole words or smaller pieces. This is subword tokenization. A written word can therefore give rise to several classifier positions. In the tokenizer’s notation, some pieces have a ## prefix to signal that they continue a word. The prefix describes the segmentation. The accent edits themselves refer to positions in the text represented by the piece.

BERT reads those pieces together and assigns a contextual representation to each. A contextual embedding is a vector that represents an input piece in light of its surroundings. The same plain spelling can therefore receive different representations when it appears in different sentences. BERT’s self-attention layers allow information from other input positions to contribute to each representation. That gives the classifier a way to associate an accent choice with grammatical or lexical evidence around the word, even though the classifier ultimately returns a separate label at each position.

A fully connected network takes each contextual representation and produces a score for each instruction available in that language. A softmax turns the scores into a probability distribution over the instruction inventory. The system selects the instruction with the highest probability, then applies it to the current piece. It has no separate stage in which previously restored words are fed back as new evidence for later classifier decisions. The sentence context enters through the encoder before the labels are chosen.

How BERT restores diacritics in a sentence

The steps in order.

How BERT restores diacritics in a sentenceStep 1: Split the unaccented sentence into subwords1. Split the unaccented sentence into subwordsStep 2: Encode each subword in its sentence context2. Encode each subword in its sentence contextStep 3: Score the language’s restoration instructions3. Score the language’s restoration instructionsStep 4: Select the most probable instruction per subword4. Select the most probable instruction per subwordStep 5: Apply valid edits and retain unchanged letters5. Apply valid edits and retain unchanged letters

The distinction between an instruction and a spelling is easiest to see in dite. Its character indices run from 0 to 3. The instruction 1:ACUTE;3:CARON puts an acute accent on i and a caron on e. Applied to this input, it produces dítě. The label contains the locations and kinds of marks. It does not contain the letters d, i, t, and e as an output string that the system has to regenerate. If the same instructions are valid for another piece, that piece can use the same class.

There is also a label, <KEEP>, for text that should stay as it is. This gives the classifier an explicit way to preserve a plain spelling. An impossible instruction produces the same visible result by a different route. If the selected edit cannot be applied to the input, the system leaves the piece unchanged. A predicted instruction does not have to correspond to an applicable edit simply because it belongs to the language’s inventory. The output rule therefore has a fallback at the point where a class is converted to characters.

The use of complete instruction patterns makes the classifier’s decision different from a series of independent choices at the character level. In the dite example, adding the acute and adding the caron are parts of one label. The classifier scores that combination as a unit. A different combination would require a different instruction. This lets the system reuse a pattern wherever it fits, while making the available patterns depend on what the authors extracted from the training data. The editing vocabulary is smaller in purpose than a vocabulary of accented strings, but it still has to cover the combinations that the task calls for.

How the authors obtain the labels

The training texts already have diacritics, which provides a starting point for building input and target pairs. The authors strip the marks from the input copy and tokenize that copy. They align its pieces with the corresponding portions of the accented original. The alignment locates the letters that each input piece covers in the target. By comparing those portions, they can see which positions need marks and which kind of mark belongs at each position. The accented original thus plays two roles. It defines the desired output, and it determines which instructions can be collected in the first place.

The Unicode name of the target character supplies the type of mark used in an instruction. The positions belong to the piece, so the same character edit can appear at different indices depending on how the unaccented sentence is segmented. The inventory is consequently an inventory for the actual input representation. Even if two words end in the same accented letter, the corresponding instruction can differ if the letter occurs at a different place within its piece. Conversely, pieces with different basic letters can share a label when the relevant positions and marks match.

The authors retain an instruction when it appears at least twice in the training set. They use this frequency cutoff to avoid giving the classifier a class for an isolated pattern, such as one introduced by a foreign word or a misspelling. Frequency here belongs to the instruction. A rare spelling may still be reachable if another word teaches the system the same position-and-mark pattern. By the same logic, a combination of ordinary marks can be unavailable if the combination itself is too rare. The cutoff addresses sparsity in the classes, at the possible cost of omitting a useful pattern.

The inventory is computed independently for each language. The authors join the benchmark’s Wiki and Web training material for that language, use it to collect the instructions, and train the corresponding classifier on the combined material. The multilingual initialization provides a common starting point. The subsequent training and set of output classes are specific to the language. As a result, the experiment tests whether the same procedure works across languages while letting each language learn from the mark patterns found in its own text.

Romanian also receives a normalization pass. In its Web material, the authors find cedilla spellings ş and ţ where the standard forms use a comma below, ș and ț. They replace the former forms with the latter. This matters to the construction of the instructions because the Unicode distinctions would otherwise enter the target labels. Two spellings intended to represent the same Romanian forms could teach the classifier different marks. The normalization makes the target convention consistent for those characters before the training material is used.

What the classifier optimizes

For a given input, the prediction rule can be written as follows.

ŷᵢ = arg maxₐ ∈ 𝒜 pθ(a ∣ x, i)

Here x is the tokenized unaccented input. The index i identifies the piece being restored, and 𝒜 is the inventory of instructions for its language. The symbol a denotes a candidate instruction in that inventory, with ∈ indicating membership. The symbol θ represents the trainable parameters, and pθ(a ∣ x, i) is the probability assigned to instruction a at position i given the input x. The expression arg max selects the instruction that has the greatest probability. Its result is ŷᵢ, the predicted instruction for that piece. The subsequent character edit is a separate step.

Training uses negative log-likelihood. For the supervised positions of an input, the objective the authors describe takes this form.

ℒ(θ; x, y) = −∑ᵢ log pθ(yᵢ ∣ x, i)

In this expression, ℒ is the loss, θ contains the parameters, and x is the unaccented tokenized input. The symbol y denotes the reference instructions, with yᵢ the instruction at supervised position i. The probability pθ is the classifier’s probability for that instruction, conditional on the input and position after the vertical bar. The symbol log denotes the logarithm, ∑ᵢ adds the terms over the supervised positions, and the minus sign makes a low probability for the reference instruction contribute a larger penalty. The separator after θ distinguishes the parameters from the training example. The objective encourages the classifier to give the reference instruction high probability, including at positions where the desired label leaves the letters unchanged.

Both the encoder and the classifier are trained. This is fine-tuning, in which training on a new task adjusts parameters inherited from pretraining as well as learning the new output predictions. The authors initialize BERT with bert-base-multilingual-uncased and use Hugging Face’s BertForTokenClassification implementation. AdamW performs the parameter updates. The learning rate rises linearly from 0 to 5e-5 during the first 10,000 training steps and then stays at 5e-5. That schedule applies to optimization. It is separate from both the frequency rule that sets up the instruction inventory and the decision rule used to restore new text.

The training batch size is 2048 sentences. The authors truncate training sentences to 128 tokens, where tokens are the pieces produced by the tokenizer. A training example can contain less than a complete long sentence as a result. Each language’s training run takes about 14 days on an Nvidia P5000 GPU. The authors choose the checkpoint, a saved state from training, by performance on the development set. They also release their implementation in the bert-diacritics-restoration repository.

The method therefore makes decisions at several different levels. The training corpus determines what can be expressed by the classifier. The encoder determines what evidence about a piece is available to the classifier. The selected instruction determines what edit is attempted. The application rule then checks whether that edit can be carried out on the letters at hand. These levels matter when interpreting a mistake. A wrong spelling could be reachable by an allowed instruction that loses to another instruction. A desired spelling could also require a pattern that the classifier never had available to select. The overall evaluation counts spelling outcomes without measuring those explanations separately.

Experiments and results

The multilingual comparison

The authors use Náplava and colleagues’ earlier diacritization benchmark. It covers Vietnamese, Romanian, Latvian and Czech, as well as Polish, Slovak, Irish and Hungarian. French, Turkish, Spanish and Croatian complete the 12-language evaluation. Every language has its own training and evaluation material. The system is trained separately for each, so a benchmark result measures a particular language’s trained system against earlier results for that language. The multilingual BERT checkpoint is common to the experiments, but the reported results come from a set of language-specific adaptations.

The reported metric is alpha-word accuracy. It checks whole-word spelling, omitting items composed of nonalphabetical characters, such as punctuation. An eligible word must match the reference spelling to count as correct. This makes the measure easy to interpret as a rate of exact reconstruction on the scored words. It gives no partial credit when several decisions within the word are right and one mark is wrong. It also does not give credit to an alternative spelling that a reader would accept unless that spelling agrees with the reference.

The distinction between prediction units and scoring units is important here. The classifier makes decisions for sub-words, whereas the accuracy measure concerns words. If an eligible word contains several pieces, their restored forms together determine whether the word matches. Conversely, a piece can require an instruction with several marks, and that complete instruction can be enough to restore the spelling of an entire word when the tokenizer keeps it together. The unit of classification is a way to operate on the input. The unit of evaluation expresses what constitutes a successful output for the benchmark.

The baseline is the previous benchmark system that combines recurrent networks with an external language model. The authors report 95% confidence intervals using bootstrap resampling alongside alpha-word accuracy. Resampling uses the evaluation observations to estimate the variability of the scores. It adds a measure of statistical uncertainty to a point estimate. The reported comparison favors the BERT system significantly in 9 of the 12 languages. Vietnamese and Latvian stand out in the authors’ account as the languages with the most substantial improvements. The paper’s claim of improvement is about this particular benchmark and baseline. The cross-language outcome shows how widely it held under that setup.

Czech outside Wikipedia

The earlier Czech test consists of clean Wikipedia sentences. To see what happens when the surrounding prose is less controlled, the authors turn to a Czech corpus being annotated for grammatical error correction. Its Natives Formal material comes from Czech elementary-school pupils’ essays. Natives Informal comes from web discussions. Second Learners comprises essays by learners of Czech, and Romi consists of texts by Czech pupils who use a Romani ethnolect. These sources offer different kinds of writing, including departures from the spelling and grammar conventions that are better observed in the Wikipedia test.

The annotated corpus gives the authors access to original sentences and proposed repairs. It uses M2, a format for recording changes to text in error-correction data. The annotation identifies a stretch to be edited and specifies the correction. From those edits, the authors apply the ones that fix diacritics and casing when constructing the target for the restoration experiment. The intended accent spelling is then taken from this partially corrected text. Other problems remain in the sentence so that the restoration system still sees the sorts of contexts that made the new corpora interesting as a test.

Words affected by those other problems are excluded from scoring. The authors use a binary mask, an inclusion or exclusion indicator for each word, to record which positions count. This is a separate restriction from excluding punctuation in alpha-word accuracy. It is meant to prevent an unrelated spelling or grammatical problem from turning a word into a disputed restoration target. The surrounding sentence still contains the excluded word. A flawed form can therefore make a nearby scored word harder to restore, even though the system receives no direct penalty for the flawed form itself.

This setup is especially consequential in sentences where interpreting one word depends on a grammatical cue from another. If the cue is wrong, the reference accent may reflect the reading a reviewer can recover by mentally correcting the surrounding wording. The system is asked to restore the scored word from the actual sentence it receives. It can encounter misleading evidence even though the target word is well enough formed to evaluate. The authors’ examples of these contexts explain why the mask is compatible with a meaningful robustness test. Some difficulty remains in the input after the most controversial targets have been removed from the score.

The authors compare the added material with Wikipedia in terms of sentences, total words and words eligible for evaluation. They describe the new corpus as having half as many sentences and one third as many words as the Wikipedia data. They report roughly stable alpha-word accuracy across the Czech domains. Their suggested explanation is that writers in the noisier sources may use fewer foreign words, which are generally harder for the system to accent correctly. That is a hypothesis about why the aggregate scores stay close. The domain test establishes the performance pattern under its scoring rules without separately estimating the effect of foreign words.

What changes when people judge the spelling

The Czech data provide a second kind of result because the authors assess disagreements by hand. They pool outputs from Wikipedia and the additional Czech domains and look for words where the system spelling differs from the target. Some discrepancies are handled automatically with MorphoDiTa, a Czech linguistic analysis tool. When it recognizes the two forms as variants, the authors mark the prediction correct. When it recognizes the prediction as Czech and the target as nonexistent, the authors exclude the case as doubtful. The human exercise then concentrates on the remaining disagreements.

The authors prepare annotation material for 4702 words after that automatic filtering. For each disputed word, they make one item containing the predicted spelling and another containing the reference spelling. The item asks whether the word is acceptable in its current sentence and whether it is still acceptable when the reviewer can read the two preceding and two following sentences. The reviewers also flag other mistakes in the word. This arrangement gives the reference its own assessment. It can fail the same acceptability test applied to the prediction.

The annotation takes about 70 hours. The reviewers flag 960 disputed words as containing an error unrelated to diacritics, and the authors set those cases aside. The paper reports 3742 remaining disagreements for its manual error breakdown. About 44% of that set have a prediction judged acceptable. In 19%, both spellings are accepted. In 25%, the prediction is accepted and the reference is rejected. The paper reports 1% with neither spelling accepted and 55% with the reference accepted and the system spelling rejected. These percentages concern the adjudicated disagreements after exclusions. They are distinct from alpha-word accuracy over a whole test set.

Shares of adjudicated Czech spelling disagreements by prediction and reference verdict

Reviewers accepted many predicted spellings that exact reference matching had counted as errors.

Shares of adjudicated Czech spelling disagreements by prediction and reference verdictBoth the prediction and reference are acceptable (this paper): 19Both the prediction and reference areacceptable (this paper)19Prediction acceptable and reference unsuitable: 25Prediction acceptable and referenceunsuitable25Neither spelling is acceptable: 1Neither spelling is acceptable1Reference acceptable and prediction unsuitable: 55Reference acceptable and predictionunsuitable55
The numbers
System or settingShare of adjudicated mismatches %
Both the prediction and reference are acceptable (this paper)19
Prediction acceptable and reference unsuitable25
Neither spelling is acceptable1
Reference acceptable and prediction unsuitable55

The two starred outcomes count as successful restorations by the authors’ human criteria. They correspond to different ways that an exact-match score can miss a success. If both spellings work, the prediction produces an acceptable text even though it fails to reconstruct the original word. If only the prediction works, the system improves the spelling relative to the benchmark target. The other outcomes also differ. A wrong prediction against a sound reference is a restoration error with an available target to compare against. When both are wrong, the original test item lacks a correct reference for that occurrence.

The authors use the judgments to revise the Czech evaluations. Including the words handled with MorphoDiTa as well as those reviewed by people, they report error reductions ranging from 35% to 67%. They then remove words newly flagged by reviewers as containing a different kind of error. This further lowers the error rate by up to 33%. These are changes to the evaluated error rates under revised judgments and inclusion rules. The system outputs are already fixed. The smaller errors therefore quantify the effect of evaluating those outputs differently.

The amended evaluation answers a different question from literal recovery of the original text. A test that rewards exact reconstruction asks whether the system reproduced the form in the source. A judgment that recognizes plausible alternatives asks whether the returned form is defensible in context. Allowing a corrected reference also asks whether the output gives a better spelling than the original. That distinction is why both forms of evaluation belong in the paper. The benchmark comparison offers a repeatable common standard, while the Czech review identifies cases in which success for a reader and success under that standard diverge.

What the ablations show

The paper gives no component ablation. It instead compares performance across Czech domains, re-evaluates disagreements under human judgments, contrasts sentence-level with wider-context judgments, and examines the grammatical differences between competing spellings.

Noise in the input and noise in the target

The additional-domain evaluation keeps the Czech system fixed while changing the material on which it is tested. Its scores show that the system can cope with a substantial change in the source of its input under the study’s masking procedure. The change is broader than the addition of errors. Wikipedia, discussions and essays differ in what people write about and how they write it. As a result, roughly stable scores tell us how the system fares on those collections as a whole. They leave open how much any given source of difficulty contributed to the outcome.

The mask makes it possible to distinguish two roles that noise can play. A damaged word can itself be the object of a spelling decision, or it can provide evidence for a decision about another word. The additional Czech evaluation removes some words from the first role while retaining them in the second. The resulting test still exercises contextual prediction: a grammatical mistake may hide the expected agreement or make one reading look more natural than the intended one. A stable aggregate score under this design is evidence about restoration in sentences with imperfect cues.

The human audit changes the target side of the evaluation. A BERT prediction and a reference form are judged independently in context, so either can be accepted or ruled out. A reasonable alternative and a correction to the original receive different verdicts. This is analytically useful because the two outcomes point to different properties of the benchmark. Accepting a variant broadens the set of permissible targets. Correcting the original removes a target that should not have received credit in that context. Both changes lower the measured error, but for different reasons.

The later exclusion of words with an unrelated mistake changes which words contribute to the score. This is different again from widening the answer set. It identifies examples where diacritics are entangled with a problem that the system was never designed to repair. Under that exclusion, an unresolved typo cannot decide whether an otherwise related mark pattern was appropriate. Taken together, the scoring changes show that the higher apparent error came in part from narrow answer keys, in part from unsuitable references, and in part from examples that were difficult to judge as diacritics restoration alone.

When the competing forms are both reasonable

The authors count a prediction as a plausible variant only if both readings remain acceptable after the reviewer has read the wider window. A reading that looks fine in its sentence can lose its claim to being a plausible variant when a preceding or following sentence supplies decisive evidence. That rule makes the category specific to the context shown to reviewers. A disagreement between two spellings is not enough. The prediction and the original must each make sense in the sentence and continue to make sense given the neighboring sentences.

About 72% of the plausible variants share a lemma, the dictionary form used to group inflected forms of a word. In these cases, accent restoration commonly decides between grammatical forms of one word. A writer could reasonably mean the singular or plural without changing the underlying item being discussed. The authors identify masculine inanimate nouns in the genitive as the most frequent source of number ambiguity among the plausible variants. Their examples include programu and programů, as well as šachu and šachů. The needed mark can depend on whether the context specifies a quantity or leaves it open.

The contrast between a passive participle and an adjective is another recurring pattern. The authors illustrate it with založena and založená. The additional accent marks a difference between grammatical analyses that can both fit in an appropriate context. That example shows why plausible variants are more than spelling curiosities. The two reconstructed texts can differ in how they present a grammatical relationship and still meet ordinary standards for a well-formed reading. An evaluation that asks for the author’s exact form marks the distinction. An evaluation of acceptability can credit both outcomes when the context supports them.

The variation also has implications for how to read the lemma figure. Sharing a dictionary form helps identify a family of cases where the same word can take different endings or grammatical forms. It gives a description of the mismatch, instead of a verdict by itself. Some same-lemma disagreements are clear errors because the sentence fixes the grammatical form. The reviewers’ judgments are what establish whether each competing spelling works. The morphology helps explain why the acceptable alternatives arise in patterns, instead of being randomly scattered among the disagreements.

What neighboring sentences resolve

The reviewers found 50 cases in which the predicted form was acceptable in the current sentence but the wider context identified the intended form. The authors count those cases against 2084 confirmed system errors. A reader can see the nature of such evidence in the vily and víly example. The local sentence can point back to something mentioned earlier without naming it in a way that fixes the spelling. The surrounding passage can then determine which entity is involved. The accent decision follows from recovering that connection.

The comparison of judgments with different amounts of context demonstrates the existence of this problem. It does not test a system with a larger input window. The system under analysis is trained on inputs capped at 128 sub-words. Reviewers see the current sentence together with nearby sentences and can use whatever relationships those sentences make apparent. Thus the experiment changes what people can see when they judge predictions, while leaving the system and its predictions as they were. The observed cases identify a source of error that sentence-level input can leave unresolved.

The authors take the small number of these cases as a reason to expect limited overall benefit from training on longer input. The reasoning is specific to the mismatch audit. Among confirmed errors, the reviewers only occasionally found that the available neighboring sentences turned a locally defensible prediction into an identifiable mistake. The audit consequently gives a sense of how common that visible failure mode is in the material examined. Whether a system could make effective use of the relevant passages, and whether longer input would affect other kinds of mistake, would require a separate performance comparison.

What remains among the confirmed errors

For their grammatical analysis, the authors run UDPipe over the reference sentences and sentences containing the system’s predictions. UDPipe assigns part-of-speech tags and grammatical features in context. The authors use the categories from Universal Dependencies, including broad categories such as nouns and adjectives and features such as case and number. Applying the analyzer to both versions lets them compare the readings suggested by the predicted and reference spellings. They can then group mistakes by the grammatical distinction involved.

One comparison uses broad parts of speech, which can reveal when a mark changes the apparent category of a word. Another uses the extended features, which can expose distinctions between forms that share a part of speech. The authors identify a primary difference between the feature sets for their more detailed grouping. This is useful where different spellings yield the same grammatical category but differ in number or case. Reading only the broad tags in such a case could make a meaningful difference look like a small orthographic mistake within a single category.

The confirmed errors and the plausible variants contain some of the same types of mismatch, but the authors describe a different ordering among the frequent patterns. Among the confirmed errors, differences in lemma are especially prominent. Their examples include stát and stať, and že and ze. Such contrasts cannot always be described as choosing an inflection of a word whose identity is already established. The accent can change which lexical item the text expresses. Context must then support identification of the word itself, in addition to any grammatical form needed at that position.

Rare names are the next prominent group in the authors’ discussion, with examples such as Sokrates and Sókratés, or Aristoteles and Aristotelés. These contrasts can involve circumstances different from a number or case decision. The sentence can make it clear that a word is a name without providing strong evidence for how many accents the conventional spelling uses or where they go. The system can have enough evidence to read the grammatical role and still lack decisive evidence for the written form. The examples identify the pattern of errors; the analysis does not trace individual name mistakes to a particular stage of training or decoding.

Number also remains a source of genuine errors, especially for masculine inanimate nouns in the genitive. The authors give examples such as milionu and milionů, and dokumentu and dokumentů. The same general contrast occurs among the plausible variants. Here context supports the reference form and rules out the prediction. This is an important connection between the two parts of the study. The mere presence of a familiar morphological alternation tells the evaluator little about whether the prediction should be forgiven. Its status depends on whether the available context leaves the grammatical choice open in that specific occurrence.

The authors also identify case confusions in feminine forms, including ji and jí, and zemi and zemí. A difference carried by one accent can signal a choice of grammatical case that belongs to the structure of the sentence. These examples bring out the range of problems combined in a restoration score. Some errors require recognizing a lexical item, some require knowing the spelling of a name, and some require tracking grammar. The grammatical analysis can describe the difference between the forms without determining how the encoder represented the evidence or why the classifier gave the winning instruction its score.

Limitations

Limits the authors identify

The authors point out that their test data begin with a single reference spelling for each word. It comes from the original accented text or, for the additional domains, the target after the selected corrections. This makes the automatic protocol straightforward, but it leaves ambiguous forms underrepresented in the answers accepted by the test. The Czech audit exposes that limitation directly. For a language in the multilingual comparison without the equivalent manual review, the benchmark result still means agreement with the available reference under alpha-word accuracy. The Czech proportions cannot establish how frequently other languages would exhibit plausible variants or reference mistakes.

The authors also bound their investigation of wider context. They ask people to judge each spelling with its own sentence and with a view of neighboring sentences. The expanded window can resolve references near the target. It cannot expose every dependency within a document. Information earlier or later in the text may still matter, and a sentence can leave a question open even if the document includes no explicit answer. The paper’s example about Earth’s satellite or satellites illustrates the possible role of knowledge about the world. The count based on the annotated window has to be read in light of that boundary.

The Czech material includes words whose accent choices are controversial because of other mistakes. The authors address this by masking affected words in the noisy-domain test and excluding further problematic cases identified during manual review. This choice makes the comparisons easier to interpret as diacritics restoration. It also defines the scope of the claim about performance in noisy domains. The system succeeds on eligible words while reading sentences that may contain other problems. The experiment does not establish an error rate for restoring every word a writer produces in those domains.

The paper reports that an attempt to train a single system for all the languages was unsuccessful, including an attempt with a larger XLM-Roberta system. The authors propose trying a system shared by a subset of languages in future work. Their successful multilingual benchmark results therefore belong to the separate training runs. The initial joint-training experience gives a reason for further investigation, but the paper supplies no successful jointly trained condition with scores to compare, and it does not determine which languages would benefit from sharing.

What the experimental design leaves open

The benchmark comparison joins several changes into one system. The proposed approach uses multilingual pretraining, an attention-based contextual encoder, a particular sub-word segmentation and an output layer built around accent instructions. The earlier recurrent system has a different architecture and uses an external language model. The comparison establishes the difference in benchmark performance between complete systems. It cannot attribute the improvements to any one change. An evaluation specifically of the instruction representation would require comparable conditions in which the output representation changes while the other relevant choices stay fixed.

The same distinction applies to the paper’s explanation of speed. Per-position classification offers a reason for expecting faster inference than a decoding procedure that generates output in sequence. The reported training duration is about 14 days per language on the specified GPU. That duration indicates the resources used for training, while the claim about parallel classification concerns how a trained system runs. The benchmark comparison measures spelling accuracy. It supplies no matched timings showing how the proposed system and the baseline compare under a common inference setup.

The inventory is another boundary on what the system can do. Its classes are fixed from the training examples, and the frequency cutoff can remove an edit pattern that a test word needs. A rare word can still be restored if it uses a retained pattern, so the presence of unusual names among the errors does not establish that their instructions were missing. The paper does not break the errors down into missing instructions, inapplicable predictions and misranked valid alternatives. Its name examples and grammatical groupings describe the observable output mismatches. A finer attribution would need evidence from the candidate instructions and the classifier outputs for the disputed positions.

The revisions to Czech error rates also depend on how the manual items were selected. The authors start from system and reference disagreements. They classify some variants automatically, discard a dubious subset using MorphoDiTa, then remove additional items marked as having a different kind of error. The percentage breakdown concerns the remaining mismatches. It cannot be treated as the share of all Czech words that admit another spelling, the prevalence of errors in the full reference corpus, or a general rate of ambiguity. A word for which the system and reference agree could still permit multiple valid readings, but agreement gives this audit no reason to examine it.

The paper reports 3742 mismatches in the final adjudicated set, but its category counts do not fully reconcile with that denominator. The reported percentages describe the authors’ breakdown, and 2084 is the confirmed-error count that they use for the wider-context comparison. The uncertainty concerns the exact accounting of the categories. The separate findings that some predictions were valid alternatives and some corrected the references are supported by the manual classification and the examples the authors discuss.

The morphological groupings introduce another qualification. The judgments of acceptability come from people. The tags and feature sets used to characterize the forms come from UDPipe. This makes it possible to organize many disagreements consistently in terms of lemma, part of speech and inflection. It also means the resulting categories depend on the automatic annotations, which can themselves be difficult to assign in ambiguous or erroneous text. The groupings are best read as descriptions of recurring contrasts in the reviewed material. They do not independently validate every grammatical analysis or explain each prediction’s cause.

Finally, the Czech datasets differ in several ways at once. Roughly stable performance across them indicates that the system retained its measured ability on the eligible words under the authors’ target construction. It cannot by itself show whether the same performance would hold for a different mix of names, additional domains, or words with severe non-diacritical errors. The authors’ suggestion about foreign words is consistent with the difficulty they report for some names. The experiment does not count out the effects of vocabulary, sentence context and masking separately, so the suggested explanation remains open.

What came after

Improving Arabic Diacritization by Learning to Diacritize and Translate (2022) takes up accent restoration in Arabic and pairs learning to diacritize with learning to translate. The connection is the need to restore information omitted from the written input. In the Czech-centered paper, the authors address that problem with a contextual encoder and explicit accent instructions. The later study’s stated direction puts diacritization together with machine translation, so the learning problem includes rendering the text in another language as well as restoring its marks.

These are different ways of framing the relationship between context and a written form. Náplava and colleagues use the surrounding input to select edits, then examine cases where the resulting spellings change the grammatical or lexical reading. Pairing restoration with translation puts another language task alongside that choice. The citation establishes a connection between the studies. The later work’s stated scope supports describing the combination of tasks, while leaving its reuse of the BERT classifier, the editing instructions and the Czech judgment procedure unspecified.

Cite

Cite as Jakub Náplava, Milan Straka and Jana Straková. 2021. Diacritics Restoration using BERT with Analysis on Czech language. ˜The œPrague Bulletin of Mathematical Linguistics.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.14712/00326585.013 · arXiv 2105.11408

@article{naplava2021diacritics,
  title = {{Diacritics Restoration using BERT with Analysis on Czech language}},
  author = {Jakub Náplava, Milan Straka and Jana Straková},
  journal = {˜The œPrague Bulletin of Mathematical Linguistics},
  year = {2021},
  doi = {10.14712/00326585.013},
  eprint = {2105.11408},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.14712/00326585.013}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/naplava-2021-diacritics-restoration-bert-analysis-czech/

References

18 references, from the paper's own bibliography.

  1. Adali, Kübra and Gülşen Eryiğit. Vowel and diacritic restoration for social media texts. In Proceedings of the 5th Workshop on Language Analysis for Social Media (LASM), pages 53–61, 2014. . OpenAlex ↗ · Scholar ↗
  2. AlKhamissi, Badr, Muhammad N ElNokrashy, and Mohamed Gabr. Deep Diacritization: Efficient Hierarchical Recurrence for Improved Arabic Diacritization. arXiv preprint arXiv:2011.00538, 2020. our card
  3. Alqahtani, Sawsan, Ajay Mishra, and Mona Diab. Efficient Convolutional Neural Networks for Diacritic Restoration. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 1442–1448, 2019. . our card
  4. Belinkov, Yonatan and Yonatan Bisk. Synthetic and natural noise both break neural machine translation. arXiv preprint arXiv:1711.02173, 2017. OpenAlex ↗ · Scholar ↗
  5. Belinkov, Yonatan and James Glass. Arabic diacritization with recurrent neural networks. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pages 2281–2285, 2015. . our card
  6. Conneau, Alexis, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Édouard Grave, Myle Ott, Luke Zettlemoyer, and Veselin Stoyanov. Unsupervised Cross-lingual Representation Learning at Scale. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8440–8451, 2020. our card
  7. Devlin, Jacob, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171–4186, 2019. our card
  8. Madhfar, Mokhtar and Ali Mustafa Qamar. Effective Deep Learning Models for Automatic Diacritization of Arabic Text. IEEE Access, 2020. OpenAlex ↗ · Scholar ↗
  9. Mubarak, Hamdy, Ahmed Abdelali, Hassan Sajjad, Younes Samih, and Kareem Darwish. Highly effective Arabic diacritization using sequence to sequence modeling. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 2390–2395, 2019. our card
  10. Náplava, Jakub, Milan Straka, Pavel Straňák, and Jan Hajic. Diacritics restoration using neural networks. In Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018), 2018. OpenAlex ↗ · Scholar ↗
  11. Nga, Cao Hong, Nguyen Khai Thinh, Pao-Chi Chang, and Jia-Ching Wang. Deep Learning Based Vietnamese Diacritics Restoration. In 2019 IEEE International Symposium on Multimedia (ISM), pages 331–3313. IEEE, 2019. . OpenAlex ↗ · Scholar ↗
  12. Nivre, Joakim, Marie-Catherine de Marneffe, Filip Ginter, Jan Hajič, Christopher D. Manning, Sampo Pyysalo, Sebastian Schuster, Francis Tyers, and Daniel Zeman. Universal Dependencies v2: An Evergrowing Multilingual Treebank Collection. In Proceedings of the 12th Language Resources and Evaluation Conference, pages 4034–4043, Marseille, France, May 2020. European Language Resources Association. URL https://www.aclweb.org/anthology/2020.lrec-1.497. our card
  13. Nuţu, Maria, Beáta Lőrincz, and Adriana Stan. Deep learning for automatic diacritics restoration in romanian. In 2019 IEEE 15th International Conference on Intelligent Computer Communication and Processing (ICCP), pages 235–240. IEEE, 2019. . OpenAlex ↗ · Scholar ↗
  14. Orife, Iroro. Attentive Sequence-to-Sequence Learning for Diacritic Restoration of YorùBá Language Text. Proc. Interspeech 2018, pages 2848–2852, 2018. . OpenAlex ↗ · Scholar ↗
  15. Rychalska, Barbara, Dominika Basaj, Alicja Gosiewska, and Przemysław Biecek. Models in the Wild: On Corruption Robustness of Neural NLP Systems. In International Conference on Neural Information Processing, pages 235–247. Springer, 2019. . OpenAlex ↗ · Scholar ↗
  16. Straka, Milan, Jana Straková, and Jan Hajič. Czech Text Processing with Contextual Embeddings: POS Tagging, Lemmatization, Parsing and NER. In Ekštein, Kamil, editor, Text, Speech, and Dialogue, pages 137–150, Cham, 2019. Springer International Publishing. . OpenAlex ↗ · Scholar ↗
  17. Straková, Jana, Milan Straka, and Jan Hajič. Open-Source Tools for Morphology, Lemmatization, POS Tagging and Named Entity Recognition. In Proceedings of 52nd Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 13–18, Baltimore, Maryland, June 2014. Association for Computational Linguistics. . URL http://www.aclweb.org/anthology/P/P14/P14-5003.pdf. our card
  18. Zeman, Dan. DIAKRITIZACE TEXTU. In Petr Karlík, Marek Nekula, Jana Pleskalová (eds.), editor, CzechEncy - Nový encyklopedický slovník češtiny. Nakladatelství Lidové noviny, Praha, Czech Republic, 2016. OpenAlex ↗ · Scholar ↗