---
title: "Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese"
description: "Tail-to-Tail corrects Chinese text by scoring neighboring characters together, allowing edits that shorten, lengthen, or reorder a sentence."
canonical: "https://research.elamur.ai/free/en/papers/li-2021-tail-tail-non-autoregressive-sequence/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/li-2021-tail-tail-non-autoregressive-sequence/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2021](https://md.research.elamur.ai/free/en/papers/2021/) / Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese Grammatical Error Correction

# Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese Grammatical Error Correction

Paper · 2021 · Piji Li and Shuming Shi

**Authors:** [Piji Li](https://md.research.elamur.ai/free/en/authors/piji-li/) and [Shuming Shi](https://md.research.elamur.ai/free/en/authors/shuming-shi/) · **Year:** 2021 · **Venue:** Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[Cited by **21** papers in our library of the 163,136 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/li-2021-tail-tail-non-autoregressive-sequence/cited-by/) · Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2021.acl-long.385/)
- [PDF](https://aclanthology.org/2021.acl-long.385.pdf)
- [DOI 10.18653/v1/2021.acl-long.385](https://doi.org/10.18653/v1/2021.acl-long.385)
- [arXiv 2106.01609](https://arxiv.org/abs/2106.01609)

## Summary

A Chinese sentence can contain a wrong character, a missing word, or a phrase whose words are in the wrong order. An automatic corrector has to make the necessary changes while preserving the material the writer already got right. That balance matters in applications such as writing assistance, where a fluent rewrite can introduce a new error or change the intended meaning. The authors propose Tail-to-Tail, abbreviated TtT, as a way to preserve the input where possible while still correcting errors that change the length of a sentence. Their starting point is that most characters already belong in the answer. [Grammatical error correction](https://md.research.elamur.ai/free/en/topics/grammatical-error-correction/)

TtT uses an encoder initialized from Chinese BERT to read each input character in light of the characters on both sides. The encoder produces scores for possible output characters at each position. A conditional random field, or CRF, then scores neighboring choices together, so the strongest answer can be a sequence whose characters work well in combination. This is non-autoregressive prediction. The encoder gives every position its scores without waiting for the corrector to commit to earlier output characters. Special markers provide extra output space when a correction needs to grow and allow shorter answers to end before the available positions run out.

The authors also change what counts most during learning. A correct character that the system already predicts with high confidence contributes less to the objective under focal loss. A character that the system is still struggling to predict retains more influence. The same idea applies to the probability of a whole corrected sentence. This gives the learning procedure a way to spend less of its effort on easy copies, while still providing a direct signal about which characters should be preserved. The ablation compares training with both sources of supervision against training with either alone, and the authors report that using both gives the better result.

On the fixed-length SIGHAN2015 test split, the authors report stronger sentence-level F1 for finding and correcting errors than most of the comparison systems. They also construct TtTSet from HybirdSet by introducing missing material, redundant material, and local changes in word order. On the TtTSet test split, TtT compares favorably with generators that can also change sentence length. The timing comparison puts TtT ahead of the two autoregressive generators, while direct BERT fine-tuning takes less time per example and is limited to fixed-length correction in this comparison. The authors release the implementation as TtT. [Fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/)

## Deep dive: Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese Grammatical Error Correction

Tail-to-Tail corrects Chinese text by scoring neighboring characters together, allowing edits that shorten, lengthen, or reorder a sentence. · about 36 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Preserving the parts of a sentence that already work

The paper treats correction as a transformation from a reported sentence to the sentence the writer was trying to produce. That differs from generating text from a topic or a short instruction. The input supplies much of the desired answer, frequently down to the individual character. A system that processes the sentence well should preserve that information even when the error sits nearby. An attractive correction is therefore a small, well-supported intervention in a sentence the system has read as a whole.

Chinese spelling gives a concrete reason to use context. The authors describe errors associated with Pinyin input, where the intended expression and an accidentally selected expression can share a pronunciation. They use a case in which the wrong and right expressions are both pronounced FeiChang. The characters around the expression help determine which written form belongs. Replacing the mistaken material can leave the sentence the same length, so the corrector can compare the input and output position by position.

This fixed-length case is important in its own right. It is also a favorable architecture test for any system that gives each input position a corresponding output position. A replacement can change the character at that position while letting the rest of the sequence retain its alignment. The paper calls this setting FixLen. Its attraction is that the input itself sets the output length and supplies a strong starting point for almost every prediction.

Missing and redundant material put pressure on that arrangement. If a character is omitted, the expected answer has room for material that the original sentence never contained. If redundant material is removed, the answer can end earlier. Either change can shift where subsequent characters appear in the output. A corrector that chooses the best substitute for each existing position may recognize that something is wrong and still lack a way to return a sentence of the required length.

The authors also describe local paraphrasing. Here the difficulty can lie in the arrangement of material rather than in a single implausible character. Repair may involve emitting a small stretch of the sentence in a different order, sometimes with a concomitant change in length. The paper groups these cases with deletions and insertions under variable-length correction, or VarLen. A local reordering can preserve length. The reason to group it with the broader setting is that the correct phrase may require a change more substantial than choosing an isolated substitute at an otherwise aligned position.

The taxonomy comes from the authors’ examination of the SIGHAN and NLPCC corpora. It explains what the system must express, rather than prescribing separate linguistic modules for each error. From the writer’s perspective an omission and a redundancy are different mistakes. From the system’s perspective they both require a way to return an answer whose usable positions differ from those of the input. Local changes in word order add a further requirement. Several adjacent choices may have to change together for the repair to make sense.

#### What earlier approaches offered

One established approach treats the erroneous and corrected sentences as two sequences in a translation problem. An encoder reads the original and a decoder generates the correction. Attention helps the decoder draw on relevant input information. This is a natural extension of the sequence-to-sequence methods the paper cites from neural machine translation. A decoder can end its output when appropriate and can emit material in a different order, so the format can represent the authors’ range of correction operations. [Machine translation](https://md.research.elamur.ai/free/en/topics/machine-translation/) · [Neural Machine Translation by Jointly Learning to Align and Translate](https://md.research.elamur.ai/free/en/papers/bahdanau-2014-neural-machine-translation-jointly-learning/)

The freedom of the translation approach creates a fidelity problem. At test time, the decoder has to continue from its own previous choices. Once an earlier choice goes astray, later decisions are made in that altered context. The authors connect this mismatch between training and inference to exposure bias. In correction, an unsupported continuation can take the form of text that sounds plausible but no longer follows the input. The paper uses hallucination for this kind of loss of faithfulness. A copying mechanism gives the decoder a way to preserve input material, but the paper describes unwanted deviations even in systems with that option. [Sequence Level Training with Recurrent Neural Networks](https://md.research.elamur.ai/free/en/papers/ranzato-2015-sequence-level-training-recurrent-neural/) · [Bridging the Gap Between Training and Inference](https://md.research.elamur.ai/free/en/papers/zhang-2019-bridging-gap-between-training-inference/) · [Incorporating Copying Mechanism in Sequence-to-Sequence Learning](https://md.research.elamur.ai/free/en/papers/gu-2016-incorporating-copying-mechanism-sequence-sequence/)

Tagging starts from the input as well, but makes the output a series of instructions attached to positions. A tag can tell the corrector to preserve material, remove it, or introduce specified material. With appropriate tags, the system can still produce a sentence of a different length. The authors identify a cost in the particular tagging schemes they discuss. When insertions and substitutions each acquire their own vocabulary-sized family of labels, a word can appear in the inventory under several operation names. The authors describe the resulting inventory as about three times as large as the original vocabulary.

Those tagging schemes also perform successive passes. An edit in one pass can create the context in which the next edit is recognized, and processing continues until the predicted tags call for no more changes. This is useful when edits interact, but it adds repeated computation. TtT asks whether the same sentence can instead be decided in a single structured prediction over one set of encoder scores. The paper’s argument concerns the tagging designs it surveys, whose label inventories and iterative procedures give rise to these costs.

Directly adapting a pretrained BERT encoder gives a third point of comparison. Such a system reads both sides of an input character and predicts a replacement at its position. It inherits the useful alignment between an input character and its candidate correction. As described in the paper, the fixed-length form of this setup lacks the extra positions needed when the corrected sentence is longer. The authors also discuss a spelling corrector that makes error detection an explicit intermediate step, sending the detector’s output to BERT through soft masking. It still belongs to the fixed-length side of their comparison. [Spelling Error Correction with Soft-Masked BERT](https://md.research.elamur.ai/free/en/papers/zhang-2020-spelling-error-correction-soft-masked/)

The line between these approaches concerns what each decision is about. A generator chooses the next output symbol after reading a prefix it has already produced. A tagger chooses an operation attached to a position in its current input. A direct BERT corrector chooses the character that should go in the corresponding output slot. TtT also starts from output slots, but it separates the computation of those slots’ scores from the choice of a compatible path through them. That division lets the authors combine a position-oriented encoder with a decoder that considers successive output choices together.

#### Why learning from correct text can be too easy

The predominance of correct characters affects training as well as architecture. When the objective rewards matching all positions, every successful copy helps. Many such positions can make the aggregate objective improve markedly even when the system is still poor at making changes. The authors regard this imbalance as particularly important in correction because the minority of difficult positions often determines whether the output provides any benefit at all.

A per-character learning objective also answers a narrower question than the sentence-level benchmark. It rewards a correct character wherever it occurs. The benchmark can require every error position and its repair to be correct before the sentence earns credit. A system might learn to transmit the input faithfully and make several sensible edits, yet score the entire sentence as a failure if it misses one annotated error. The paper responds to this difference with supervision at both levels and a mechanism that discounts predictions the system already finds easy.

### The method, step by step

#### Give the answer enough positions

TtT predicts corrected characters directly. Its bottom tail is the input side of the encoder stack, where characters and position information enter. Its top tail is where the corrected sequence is read out. Much of the information needed at the top originates in the input character at the corresponding position. A character that should be preserved can be recovered using that information. Several positions can also change when the output needs to reorder or shift the surrounding material.

The important distinction is between the length of a sentence and the length of the representation used to process it. A shorter answer can be represented within a longer array because the answer has an end marker. A longer answer needs more positions, so the input side receives extra slots. Comparing source and target lengths during training tells the authors which of these preparations a pair needs.

How Tail-to-Tail predicts a corrected sentence The steps in order.

```
X = (x₁, x₂, …, x_T)
```

Here X is the input sequence, x is an input token, and its subscript gives its position. The ellipsis stands for the intervening tokens and T is the input length. The ordinary text units in the formulation are Chinese characters. The sequence can also contain control symbols, such as the end marker. This choice fixes the units in which positions and sentence lengths are counted. [Tokenization](https://md.research.elamur.ai/free/en/concepts/tokenization/)

```
Y = (y₁, y₂, …, y_T′)
```

Here Y is the corrected sequence, y is an output token, the subscript gives its output position, and the ellipsis covers the intervening tokens. T′ is the target length. The prime distinguishes this length from the input length T. An x and a y at the same position can represent the same character, but a shift in the corrected sentence can also place a different character there.

```
X = (x₁, x₂, x₃, <eos>)
```

In this example X contains input characters x₁, x₂, and x₃ in that order. The symbol `<eos>` marks the end of the sentence. Parentheses represent the ordered sequence. In the equal-length case, the corresponding target has the same layout.

```
Y = (y₁, y₂, y₃, <eos>)
```

Y is the target, the y terms are the corrected characters in order, and `<eos>` closes the sentence. This example needs no extra positions or padding. Some corrected characters may be identical to their input counterparts.

```
Y = (y₁, y₂, <eos>, <pad>)
```

Here the y terms are the characters of a shorter target Y. The end marker `<eos>` now occurs earlier. The trailing `<pad>` is padding that makes the represented target as long as the example input. Generally, the count of padding symbols is the difference between input length T and the shorter target length T′. The end marker identifies which positions make up the actual sentence.

```
Y = (y₁, y₂, y₃, y₄, y₅, <eos>)
```

In this example Y is a longer target, with the subscripted y terms denoting the consecutive target characters and `<eos>` marking the end. The input needs more positions so that a prediction head with one output slot per encoder position can represent the entire answer.

```
X = (x₁, x₂, x₃, <eos>, <mask>, <mask>)
```

Here X is the expanded input, the x terms are its original characters, and `<eos>` still marks the end of the original sentence. Each `<mask>` reserves an additional position for prediction. The masks are appended after the original sentence, even when the correction requires new material somewhere in the middle.

This last point is easy to miss. An appended mask provides capacity. It does not mark the linguistic location of a missing character. A repair near the beginning can change which characters must be emitted at subsequent positions, with an extra slot at the far end allowing the full sentence to fit. Conversely, an early `<eos>` on the output side represents the new endpoint of a shorter answer regardless of where the redundancy occurred in the input. The operation is visible in the difference between the sentences, while the prediction itself consists of a sequence of characters and markers.

The same representation explains how local reordering can be expressed. A corrected stretch can consist of different predictions at several adjacent positions. The slot representation has no separate instruction to move a particular word from one index to another. The encoder gives each position information from the complete input, and the decoder can select successive characters that reproduce the relevant material in its corrected order. The paper’s length examples illustrate the available positions. They do not constitute an algorithm that identifies the edit type before prediction.

#### Encode the source from both directions

The encoder is a stack of Transformer layers initialized from pretrained Chinese BERT-base. The first representation at a position combines an embedding for the character with an embedding for the position. An embedding is a vector of learned numerical features. Starting with both kinds of information gives later layers a representation of the symbol and of where it occurred. [Transformer and attention](https://md.research.elamur.ai/free/en/concepts/transformer/) · [Word embeddings](https://md.research.elamur.ai/free/en/concepts/word-embeddings/)

```
H⁰ₜ = E_{wₜ} + E_{pₜ}
```

H⁰ₜ is the initial state vector at position t, and the superscript 0 denotes the embedding layer. E denotes an embedding vector selected by the subscript. Here wₜ identifies the input token at t and pₜ identifies that position. The plus sign adds the token and position vectors component by component.

Each attention layer computes queries, keys, and values. A query represents the information sought at a position. Keys give the query a way to score positions in the input, and values supply the information those positions can contribute. The paper’s equations use the initial states to illustrate the projections in the first layer.

```
Q⁰ = H⁰ W^Q
```

Q⁰ is the collection of query vectors formed from layer 0. H⁰ is the collection of initial state vectors, and W^Q is the learned query projection matrix. Juxtaposition denotes matrix multiplication, and the superscript Q identifies the purpose of the projection.

```
K⁰ = H⁰ W^K
```

K⁰ is the collection of key vectors formed from layer 0. H⁰ again supplies the input states, and W^K is the learned projection for keys. The superscript K distinguishes it from the query projection.

```
V⁰ = H⁰ W^V
```

V⁰ is the collection of value vectors formed from layer 0. H⁰ contains the same initial states, and W^V is the separate learned projection for values. V⁰ here refers to attention vectors, distinct from the vocabulary denoted later by 𝒱.

The paper uses the same state label for the attention output and the result of the subsequent feed-forward sublayer. A temporary name A makes the order of the two updates explicit.

```
Aₜ = LN(SelfAtt(Q⁰ₜ, K⁰, V⁰) + H⁰ₜ)
```

Aₜ is the intermediate state at position t after the attention update. SelfAtt is multi-head self-attention. It takes the query Q⁰ₜ at this position and uses the collections K⁰ and V⁰ from the whole sequence. The addition restores a direct contribution from the previous state H⁰ₜ. LN is layer normalization, applied here to the sum.

```
H¹ₜ = LN(FFN(Aₜ) + Aₜ)
```

H¹ₜ is the output at position t from the first Transformer layer. FFN is the feed-forward network applied to the intermediate vector Aₜ. The addition preserves a route for Aₜ into the updated state, and LN normalizes the result. The superscript 1 identifies the completed layer in this example.

A character’s query has access to keys and values on both sides. That matters in the FeiChang illustration. Evidence favoring the correct written expression could lie after the ambiguous material just as well as before it. The same access can help a position emit a character drawn from a different part of the input when a correction shifts the alignment. Multi-head attention supplies several learned ways of mixing that evidence. The residual additions in the equations help explain the authors’ image of information flowing up through the stack alongside those contextual updates.

```
Hᴸ ∈ ℝ^(max(T, T′) × d)
```

Hᴸ is the array of final states after L Transformer layers, with the superscript L identifying the final layer. The symbol ∈ means that the array belongs to the indicated space, and ℝ denotes real numbers. The maximum of T and T′ is the represented length after the source and target have been prepared for a pair. The multiplication sign separates the position and feature dimensions, and d is the width of a state vector. At inference, it is the available input and any appended slots that determine how many positions the encoder can supply.

#### Score individual characters before choosing a sentence

Given a final state at a position, the simplest readout assigns a score to each token in the target vocabulary. The same learned linear projection is used at every position. A softmax converts the resulting scores into a distribution, so the score for the reference token can supervise learning and the most probable token can serve as a direct prediction.

```
sₜ = hₜᵀ Wₛ + bₛ
```

Here sₜ is the vector of output scores at position t. The vector hₜ is that position’s final encoder state from Hᴸ, and the superscript ᵀ transposes it for multiplication. Wₛ is the learned scoring matrix, bₛ is its bias vector, and the subscript s identifies parameters of the scoring layer. Wₛ maps d features to the size of the target vocabulary 𝒱. Both bₛ and sₜ have an entry for each token in 𝒱.

```
P_dp(yₜ | X) = softmax(sₜ)[index(yₜ)]
```

P_dp is the probability from direct prediction, indicated by dp, and the vertical bar means it is conditioned on input X. The function softmax exponentiates and normalizes the scores in sₜ. The bracketed selection chooses the component at the vocabulary index of yₜ, the proposed output token at position t. Repeating that selection across the vocabulary gives the full probability distribution at the position.

```
y′ₜ = argmax_{v ∈ 𝒱} P_dp(v | X)
```

Here y′ₜ is the token chosen by direct prediction at position t. The function argmax returns the candidate v attaining the largest probability. The symbol ∈ means that candidates range over vocabulary 𝒱. The conditional probability P_dp is the distribution at t given X.

These predictions use contextualized encoder states. Each distribution can therefore reflect an ambiguity elsewhere in the input. What independent selection leaves out is the effect of choosing a particular output token at a neighboring position. If two positions each have plausible alternatives, choosing the highest individual score at both need not yield the best pair. In the paper’s design, the next layer supplies a score for the pair itself.

That distinction matters for the authors’ treatment of length changes. Extra slots make a longer sequence representable. They cannot on their own decide which material should shift, which characters should neighbor one another, or where the corrected sequence ought to end. The authors motivate the CRF as a way to improve those linked choices. Direct prediction remains valuable for learning what belongs at each position, which is why it remains part of the training objective.

#### Compare whole sequences with a conditional random field

A linear-chain conditional random field assigns a score to each candidate output path. A path chooses a token at every modeled position. Its score receives a contribution from the encoder at each position and a contribution for every adjacent pair of chosen tokens. In this setting, the output labels are vocabulary items. They identify the characters or markers the decoder should emit.

```
P_crf(Y | X) = exp(Σ_{t=1}^{T′} sₜ[index(yₜ)] + Σ_{t=2}^{T′} M_{yₜ₋₁,yₜ}) / Z(X)
```

P_crf is the probability assigned by the CRF to the candidate sequence Y given input X. The first summation, indicated by Σ, runs from the first position through T′ and adds the score in sₜ for each candidate token yₜ. The second starts at the second position because it scores a transition from the preceding token yₜ₋₁ to the current token yₜ. M is the transition matrix, indexed here by the vocabulary identities of the two tokens. The function exp exponentiates the combined path score, and division by Z(X) normalizes the scores over the candidate paths. The equation uses T′ for the target positions being scored. The preparation of slots and the end marker govern the length of the usable output.

For a fixed input, the normalizer is common to all paths. The highest-scoring path is therefore also the highest-probability path within the same candidate space. During training, the normalizer is essential. It sets the reference path’s score against the scores of alternative paths. A sentence can receive a substantial unnormalized score and still have a low probability if competing sequences score well too.

The matrix entry for a transition is shared across the positions that use it. The encoder’s character scores can vary with the entire input and with the position. The transition score supplies a separate preference about which choices fit next to each other. A token with the strongest local score can lose to a locally weaker candidate if the latter fits the surrounding output choices better. The chain comparison makes that tradeoff along the whole sentence.

The word “chain” describes the terms that the score explicitly connects. Each transition involves consecutive output tokens. Information about more distant positions can enter through the encoder, whose states already incorporate both sides of the input. The decoder’s explicit pair scores, meanwhile, give it a tractable way to coordinate adjacent output choices. This division of labor is central to how TtT incorporates structure without generating the sentence character by character.

#### Keep the structured calculation practical

A separate learned parameter for every ordered pair of vocabulary items would make the transition matrix large. The paper points to vocabularies of more than 32k in text generation as motivation for avoiding a dense parameterization. Its solution, adapted from earlier structured decoding work, gives each vocabulary item compact factors for its two roles in a transition.

```
M = E₁ E₂ᵀ
```

M is the matrix of ordered token-pair scores. E₁ and E₂ are learned factor matrices, each with a row for every vocabulary item and dₘ columns. The subscripts distinguish the factors for the earlier and later tokens of a pair, and the superscript ᵀ transposes E₂. Their product defines each transition score through the inner product of the corresponding rows.

```
dₘ ≪ |𝒱|
```

Here dₘ is the width of each factor, |𝒱| is the number of items in the target vocabulary, and ≪ means much smaller than. The authors set the factor width to 32. This constrains how token-pair scores vary and avoids learning an independent parameter for every cell of the conceptual matrix. The factorization addresses the size of the parameters. The search still needs a way to avoid considering too many candidate transitions.

The other step is to retain only the top-k candidate nodes at each position. Here k is the number of retained candidates per step, with a setting of 64 for the normalization calculation. The paper describes this as truncated or beamed Viterbi. The underlying chain has a repeated computation along the output positions. With the full candidate set, the Viterbi calculation can retain the best partial path to each candidate and extend those partial paths through the next position. The truncated version works with fewer candidates at each step.

Normalization and best-path decoding use the chain for different calculations. The normalizer collects the contributions from competing paths for training, while decoding needs the path with the highest score. In both cases, pruning the candidate nodes limits the paths available to the calculation. If a locally weak candidate would have received strong enough transition scores to belong to a globally good path, removing it early makes that path unavailable. The speed benefit and the approximation come from the same restriction.

This search also clarifies what non-autoregressive means in the paper. All contextual character scores are available before the search begins. The dynamic program still moves along positions because the transitions link successive decisions. It can compare multiple paths without having to run the encoder again after committing to each new character. A dependence in the output score is compatible with parallel computation of the underlying character scores.

#### Train the position scores and the sentence scores together

The writers first formulate both learning objectives as negative log likelihoods. The position objective accumulates evidence about the correct token at each position. The sequence objective asks whether the correct path receives high probability in the CRF. The two losses share the encoder and its output scores, so they can both influence the same representations.

```
ℒ_dp = −Σ_{t=1}^{T′} log P_dp(yₜ | X)
```

ℒ_dp is the direct-prediction loss. The summation Σ runs from position t equal to 1 through target length T′. P_dp is the probability of the target token yₜ at that position given input X. The function log takes its logarithm, and the minus sign makes smaller reference probabilities yield larger losses.

```
ℒ_crf = −log P_crf(Y | X)
```

ℒ_crf is the sentence loss from the conditional random field. P_crf is the probability of the entire reference sequence Y given X, log is the logarithm, and the minus sign converts log likelihood into a quantity to minimize. This term concerns how the reference path competes with other sequences, including their transition scores.

```
ℒ = ℒ_dp + ℒ_crf
```

ℒ is the combined objective before introducing focal weighting. The two terms are the position loss ℒ_dp and the sequence loss ℒ_crf. The plus sign adds them as written, without a separate mixing coefficient in the equation.

An ordinary negative log likelihood already gives a larger loss to a low-probability reference than to a high-probability one. Focal loss changes the relative contribution further. Its multiplier decreases as the reference probability increases. The most confident predictions get the smallest weights, so a large collection of easy positions can account for less of the objective. This is based on the system’s estimated difficulty. The paper applies it without requiring a separate instruction that every changed position should receive the same special weight.

```
ℒ_dp^fl = −Σ_{t=1}^{T′} (1 − P_dp(yₜ | X))^γ log P_dp(yₜ | X)
```

ℒ_dp^fl is the direct-prediction loss with focal weighting, denoted by fl. The summation goes from t equal to 1 through T′. P_dp is the probability of the reference token yₜ given input X at that position. Subtracting that probability from 1 and raising the result to γ gives the focal multiplier, with γ controlling its strength. The remaining factor is the log of the same reference probability, and the leading minus sign makes the result a loss. Each position has its own multiplier.

```
ℒ_crf^fl = −(1 − P_crf(Y | X))^γ log P_crf(Y | X)
```

ℒ_crf^fl is the focal-weighted CRF loss. P_crf gives the probability of reference sequence Y given X, and the multiplier uses 1 minus that sequence probability raised to γ. The log and minus sign have the same roles as in the ordinary CRF loss. This multiplier applies to the entire sample. When several examples are trained together in a batch, their CRF contributions can accordingly have different weights.

```
ℒ^fl = ℒ_dp^fl + ℒ_crf^fl
```

ℒ^fl is the full training objective with focal weighting. It adds the focal position loss ℒ_dp^fl to the focal sequence loss ℒ_crf^fl. The two levels can identify different kinds of difficulty. A position can receive a strong character score while the correct path still faces close alternatives once transitions and the rest of the sentence are considered.

The chosen γ is 0.5. The authors train in batches of 100, use a learning rate of 1e-5 and a dropout rate of 0.1, and update the parameters with Adam. The learning rate sets the scale of the parameter updates, and dropout introduces training-time omissions in the computation. Initializing the encoder from Chinese BERT-base gives the correction task pretrained representations. The character scores and CRF then learn from the supplied correction pairs. [Adam](https://md.research.elamur.ai/free/en/papers/kingma-2014-adam-method-stochastic-optimization/)

At inference, the authors describe both full-vocabulary and truncated Viterbi decoding. Full search chooses the highest-scoring path for the positions and candidates supplied to the chain. Truncated search chooses a path within the reduced space. The resulting characters up to the predicted end marker form the correction. The focal losses supervise how the scores are learned. The decoder’s job at test time is to use the scores and transitions to select an answer.

### Experiments and results

#### The data separate substitution from changes in length

For fixed-length evaluation, the paper uses SIGHAN15, also called SIGHAN2015 in its results. The benchmark contains 2,339 training samples and 1,100 test samples. The test split provides a common comparison with prior Chinese spelling correction systems. Because the source and reference have the same length, this evaluation can show whether a system preserves appropriate characters and finds the right substitutions even though its ability to increase or decrease length goes unused.

HybirdSet supplies a much larger pool of fixed-length pairs. Its construction uses a prepared confusion set informed by automatic speech recognition and optical character recognition. A confusion set specifies plausible alternatives for items that can be mistaken for one another. The paper describes about 270k paired samples. The fixed-length results discussion identifies this corpus as the training data for TtT and for the authors’ Transformer-s2s, GPT2-finetune, and BERT-finetune comparisons. The Hybrid baseline also uses it. [A Hybrid Approach to Automatic Corpus Generation for Chinese Spelling Check](https://md.research.elamur.ai/free/en/papers/wang-2018-hybrid-approach-automatic-corpus-generation/)

TtTSet extends the evaluation to cases where the correction can change sentence length. The authors take original sentences from the HybirdSet corpus and create erroneous versions using deletion, insertion, or local shuffling. The names of the operations here describe how they damage the source material to create an example. A deletion used to create a damaged sentence gives the corrector something to restore, and an insertion gives it extra text to remove. Local shuffling creates a span whose order needs repair. Each operation covers one-third of the constructed samples, and the paper reports about 540k samples in the resulting corpus.

The TtTSet test split contains 5662 samples. The study thus has two distinct test settings, one based on an established fixed-length benchmark and one built to test the broader edit space. Their sample counts describe the extent of each evaluation. Since their error distributions and construction differ, a larger test split and a higher correction score would answer two separate questions.

Test split sizes for the SIGHAN2015 and TtTSet evaluations The variable-length evaluation uses the larger test split.

**The numbers**

| System or setting | test samples |
| --- | --- |
| SIGHAN2015 fixed-length evaluation | 1100 |
| TtTSet variable-length evaluation (this paper) | 5662 |

NLPCC serves a different role in the paper. It informs the authors’ discussion of the kinds of changes a Chinese corrector should make. The reported variable-length comparison uses TtTSet. Keeping those roles distinct matters because the benchmark comparison then measures performance on deliberately introduced errors drawn from the paper’s construction procedure.

#### The baselines test different ways of choosing a correction

The established spelling baselines include systems that rank alternative character sequences using different kinds of evidence. NTOU uses contiguous groups of tokens to score language patterns and adds a reranking step. HanSpeller++ combines a hidden Markov approach with reranking. NCTU-NTUT uses a CRF to represent dependencies among output labels. That last comparison is important for reading the contribution accurately. TtT’s proposal combines structured scoring with contextual encoding, length preparation, and focal training. Structured label scoring itself was already present among the comparison approaches. [N-gram](https://md.research.elamur.ai/free/en/concepts/n-gram/)

The paper also includes baselines that bring different knowledge to the task. SpellGCN uses a graph-based computation informed by similarities in sound and appearance. Chunk looks for corrections over chunks so that single characters and longer forms can be handled in a common procedure, with a decision over the combined output. FASPell brings BERT into sequence prediction. SoftMask-BERT first estimates errors using a recurrent detector and then passes that information into the BERT correction stage through a soft mask. [Chunk-based Chinese Spelling Check with Global Optimization](https://md.research.elamur.ai/free/en/papers/bao-2020-chunk-based-chinese-spelling-check/)

Other comparisons address how freely the system can generate. Hybrid is a sequence-to-sequence predictor based on a recurrent architecture. Confusionset includes a copying mechanism in its sequence-to-sequence approach. Transformer-s2s is the authors’ Transformer encoder-decoder comparison, and GPT2-finetune adapts pretrained Chinese GPT2 for generation. The latter two decode using beam search with beam size 5. That beam keeps competing output prefixes during generation. It serves a different purpose from the top-k restriction used over vocabulary candidates at the positions of the TtT chain. [Attention Is All You Need](https://md.research.elamur.ai/free/en/papers/vaswani-2017-attention-all-need/)

BERT-finetune gives the authors a simpler position-oriented comparison. It directly adapts Chinese BERT to correction, without the full combination of mechanisms in TtT. Its strength is that it can read the input bidirectionally and score a correction at each position. Its fixed-length output also makes it a useful reference for understanding which additional capabilities matter in the variable-length setting.

The training conditions are not uniform across every published comparison. The paper singles out the best SoftMask-BERT results as coming after pretraining on 500M paired examples. TtT and the specified direct comparisons use HybirdSet for the fixed-length training described in the results. The table therefore brings together both a set of experiments sharing correction data and published systems developed under their own conditions. The comparisons answer how the approaches perform in those setups, with the amount and kind of training data still relevant to interpreting the scores.

#### Sentence-level scoring asks for whole repairs

The authors evaluate both detection and correction. Detection credits the proposed locations of the errors when they agree completely with the reference locations for a sentence. Correction demands that the repairs at those locations agree as well. A system can identify the right positions and still lose correction credit by choosing the wrong replacements. A sentence with several errors provides an especially clear example. Finding most of its error positions falls short of an exact detection match, and an exact detection match can still precede an incorrect repair.

The reported measures are sentence-level accuracy, precision, recall, and F1. Accuracy summarizes decisions across evaluated sentences. Precision measures success among the cases identified as containing errors, while recall measures success among reference error cases. F1 combines precision and recall. The exact-match criteria give those names their concrete meaning here. A single remaining mismatch can affect an entire sentence’s credit, even when many of its individual characters are correct.

This evaluation fits the authors’ emphasis on preservation. An additional edit at a correct position interferes with exact detection or correction, even if it leaves the sentence fluent. Returning the input unchanged also gives the system few opportunities to earn credit on sentences whose references require edits. There is consequently a reason to read both kinds of results. Detection captures whether the system localized the mistakes, and correction captures whether it also produced the expected repair.

#### What the comparisons establish

For the SIGHAN2015 test split, the authors emphasize sentence-level F1. TtT improves on most of the strong comparison systems for both detection and correction. The fixed-length result tests a real part of the proposal even without exercising length changes. Position cues remain strong throughout a substitution task, so the structured decoder and training objective must operate in a setting where the simpler BERT-style decision already has a suitable output format. The reported F1 comparisons show that adding TtT’s other machinery can help in that setting too.

For the TtTSet test split, the relevant comparison includes Transformer-s2s and GPT2-finetune because both can return a different number of characters from the input. The authors report that TtT performs better in this variable-length setting. They identify two problems with the alternatives. Direct BERT fine-tuning has trouble when there are too few input positions to accommodate the answer, while the generators can repeat material or introduce output unsupported by the source. TtT occupies a useful point between those designs. It reads the complete input with an encoder, preserves a position-oriented representation, and allows the selected output to use a different length.

The authors compare the computing cost as time per sample. The comparison favors TtT over Transformer-s2s and GPT2-finetune. BERT-finetune has the shorter time per sample, alongside its fixed-length restriction. These are different architectural costs. Independent fixed-length predictions avoid the expense of structured chain search. TtT pays for that search while obtaining all position scores in one encoder pass. The sequence generators repeatedly extend output prefixes. The timing comparison supports the authors’ claim that structured prediction can be a practical way to handle length changes at lower cost than the generators they tested.

Speed and correction quality answer separate questions. The most direct position-based system is attractive when compatible with the edit space. For the broader task, the comparison asks whether supplying the missing flexibility incurs the full cost of autoregressive generation. In these experiments, the authors find it possible to give the corrector the needed output positions and use pairwise dependencies while keeping per-sample time below those generator baselines. The measured result concerns the particular decoding and training configurations used in the paper.

### What the ablations show

#### Changing the training corpus while holding the test split fixed

The authors train on datasets of different scales and evaluate the resulting systems on the same SIGHAN2015 test split. TtT leads the compared systems across the training settings reported. Holding the evaluation split constant matters because the difficulty of that split stays the same when the training material changes. The result supports the view that TtT’s fixed-length performance is present across the examined training conditions.

The comparison combines several possible influences. Changing the correction corpus can change the volume of supervision, the styles of the original sentences, and the kinds of artificial or observed errors included. The result establishes consistency of the comparison across the selected training regimes. A dedicated estimate of the effect of additional samples would require varying the amount under otherwise comparable data conditions.

The use of a fixed-length test split also defines what this ablation can reveal. A corrector trained on broader error types may learn representations or decisions that carry over to spelling errors, and SIGHAN2015 can register improvement on those errors. The same comparison does not independently measure proficiency on each form of variable-length repair. That question belongs to the variable-length evaluation.

#### Removing either training objective

The loss ablation compares full TtT with a variant that leaves out the direct-prediction loss and a variant that leaves out the CRF loss. The authors report that joint training gives the better result. The direct term supplies a separate signal every time the reference character is assigned too little probability. The sequence term compares the complete reference with alternative paths, incorporating both the character scores and the transitions. Using both means that good character readout and good sequence scoring each have an explicit training objective.

The ablation gives a concrete role to direct prediction even though the final decision can use a CRF. The direct objective teaches the shared encoder and readout to put useful candidates high in the distribution at each position. At the same time, sequence supervision rewards a configuration of scores and transitions that makes the reference path competitive as a whole. Favorable results for the sum are consistent with the two terms supplying complementary information.

The ablation is about objectives. Removing a training term changes the learning signal to the shared components and can change the scores available to the decoder. The resulting performance gap therefore describes the value of joint supervision in the tested setup. It would take a separate comparison of predictions from the same learned scores to measure the effect of changing only the decoding rule. Similarly, an aggregate score for the ablation cannot say which edit types are most sensitive to each loss.

#### Varying the strength of focal weighting

The authors search over γ values of 0, 0.1, 0.5, 1, 2, and 5. They select 0.5 for TtT. The setting of 0 suppresses the focal modulation and corresponds to the ordinary likelihood-based loss. Positive settings change how much easy predictions are discounted. For the same reference probability below certainty, a larger exponent places greater emphasis on the predictions that the system still handles poorly relative to highly confident ones.

The useful distinction is between confidence and edit status. An unchanged character near a confusing phrase can be a difficult prediction. A familiar substitution can eventually become an easy one. The focal factor reacts to the probability of the reference in either case. At sequence level, it reacts to the probability of the whole corrected sentence. The mechanism can therefore put weight on difficult preservation decisions as well as on difficult changes.

The parameter search supports the setting the authors use for this task. It does not identify a universal focal strength, and the selected value cannot reveal how much of the improvement came from downweighting easy token predictions versus easy sentence predictions. The paper varies their shared exponent. An experiment that changed those weights independently would answer a narrower question about their separate contributions.

#### Comparing the cost of the complete systems

The timing analysis offers a check on the design motivation alongside the training ablations. A position-wise corrector is faster in the reported comparison, while the two generators are slower. TtT’s intermediate position shows that the additional work of a chain decoder can still fit within a lower per-sample time than autoregressive generation in the tested configurations. It gives the reader a way to judge the practical value of the quality comparison.

Low-rank factors and candidate pruning address different parts of that cost, but the per-sample comparison measures the combined system. A separate sweep over factor widths or candidate limits would be needed to show which setting explains how much of the timing or quality outcome. The results as discussed support the joint configuration the authors evaluated. They supply less direct evidence about how the speed and accuracy trade off as one of those settings is changed while the others stay fixed.

### Limitations

#### Limits the authors identify

The authors focus on Chinese. They discuss correction as a problem that occurs across languages, but their evaluation studies Chinese corpora, Chinese character prediction, and initialization from Chinese BERT. Their examples and motivation include phenomena specific to that setting, such as selecting a plausible written expression from alternatives with the same pronunciation. They present a design for handling this task, with experiments grounded in that choice of representation and data.

They also describe forms of lexical analysis they would like to add. Word segmentation could supply information about which characters form words, and fine-grained named entity recognition could help represent particular kinds of names. In the reported system, the encoder receives characters and positions, and the output chain scores neighboring vocabulary items. The proposed additions remain future work. The results therefore give no measured gain attributable to either form of lexical information. [Named entity recognition](https://md.research.elamur.ai/free/en/concepts/named-entity-recognition/)

The authors acknowledge an approximation in making the CRF practical. Parameter factors limit the form of the transition matrix, and truncating the candidate set restricts which paths can compete. They offer full Viterbi as an inference option and truncated search as the efficient alternative. The global optimum of the full chain is a well-defined decoding goal. The optimum within a truncated chain depends on the candidates that survived. This distinction is important for understanding what the paper means by structured prediction in the efficient configuration.

#### Limits visible in the evaluation design

The SIGHAN2015 test evaluates fixed-length correction. Its results show what happens on a standard substitution-oriented task, where the architecture’s additional output capacity may be unnecessary. TtTSet tests that capacity with deliberately introduced deletions, insertions, and shuffling. Such construction is appropriate for checking whether the method can learn to reverse those perturbations. The balance of errors in naturally produced writing can still differ from the balance chosen for construction, and the patterns encountered there may differ in difficulty from the operations applied to HybirdSet sentences.

Since the base sentences for TtTSet come from HybirdSet, differences between the two benchmarks concern more than target lengths. They also involve the origins of the sentences and the procedure that creates errors. The benchmarks support claims about their own test settings. They do not isolate how much of the result is due to length flexibility, training on similar perturbations, or other properties of the data. Similarly, the variable-length experiments do not give a separate result on the NLPCC corpus that motivated part of the taxonomy.

One open practical detail is how many extra masks to append when a longer answer may be needed for a new input. In the training exposition, the paired example supplies the target length, making the number of positions required visible. At test time, the correct target is unknown. The inference description explains how to search the chain, but leaves the allocation policy for extra positions less explicit. Whatever policy supplies those positions places a ceiling on the length that one pass can represent. A generous budget gives the decoder room to grow and also presents it with more positions at which it may need to infer an appropriate ending.

The sentence-level metrics are strict about exact agreement. This is useful for measuring faithful reproduction of an annotated repair, particularly in the spelling setting. Where a phrase has more than one acceptable reordering or paraphrase, exact agreement can treat a different usable repair as an error unless the references account for it. The results show agreement under the benchmark criteria. A direct assessment of fluency, acceptable alternative repairs, or changes to meaning would be a separate form of evidence.

The authors ascribe some weaknesses of the generative comparisons to hallucination and repetition. Those explanations are consistent with the architecture and with the risks they describe. Detecting or correcting a sentence incorrectly under the benchmark does not reveal which of those failure modes occurred. A categorical analysis of generator errors would be needed to establish how frequently repetition or unsupported additions explain the aggregate difference.

The timing results likewise apply to the tested implementations and decoding settings. The authors interpret the measured per-sample cost as evidence of suitability for online use. That is a claim about the observed computational profile, with deployment properties such as throughput under concurrent requests or delay for unusually long inputs remaining beyond what a per-sample comparison establishes. The largest speed comparisons also involve systems with different decoding procedures, so the measurements characterize complete configurations.

Finally, the reported direction of a benchmark comparison and its numerical size are different pieces of evidence. The fixed-length and variable-length discussions establish comparative findings, but the quantitative result statements here are limited to benchmark sizes and explicitly stated experimental settings. Exact score and timing margins cannot be inferred from the qualitative rankings.

### What came after

[Linguistic Rules-Based Corpus Generation for Native Chinese Grammatical Error Correction](https://md.research.elamur.ai/free/en/papers/ma-2022-linguistic-rules-based-corpus-generation/) cites TtT and takes up the data side of correction. Its stated subject is generating a corpus for native Chinese correction through linguistic rules. In TtT, the need for a variable-length evaluation leads the authors to create examples with deletion, insertion, and local shuffling. The later work’s focus on linguistic rules concerns how to define the errors that populate such a corpus. This is a related choice with a distinct purpose. A corrector needs enough supervision for infrequent changes, and the construction of those examples determines which grammatical phenomena it can encounter during development. The citation establishes the connection between the papers. It does not establish that the later work adopted TtT’s encoder, its chain decoder, or its specific perturbation procedure.

[Multi-Reference Benchmarks for Russian Grammatical Error Correction](https://md.research.elamur.ai/free/en/papers/gomez-2024-multi-reference-benchmarks-russian-grammatical/) cites TtT from the evaluation side, in Russian. Its subject is benchmarking against multiple references. That concern is pertinent to the distinction between detecting a problem and prescribing a particular repair. TtT’s correction criterion asks for agreement with the reference at the repaired positions. Where several corrected phrasings could be acceptable, the number of references matters to how frequently an evaluation recognizes one of them. The later paper’s benchmark focus takes up that broader evaluation question in another language. Its citation does not in itself demonstrate transfer of TtT’s architecture to Russian.

Together, the two works locate different decisions that surround the correction system. Rules for corpus generation influence which errors and repairs the system encounters. Multiple-reference evaluation concerns which repairs can receive credit once a system returns an answer. TtT’s experiments tie those decisions to a specific architectural question by constructing a variable-length test and applying strict sentence-level scoring. The later papers address neighboring questions about the examples that make grammatical correction learnable and the reference answers that make its performance measurable.

## Cite

Cite as Piji Li and Shuming Shi. 2021. Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese Grammatical Error Correction. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2021.acl-long.385](https://doi.org/10.18653/v1/2021.acl-long.385) · [arXiv 2106.01609](https://arxiv.org/abs/2106.01609)

```bibtex
@inproceedings{li2021tail,
  title = {{Tail-to-Tail Non-Autoregressive Sequence Prediction for Chinese Grammatical Error Correction}},
  author = {Piji Li and Shuming Shi},
  booktitle = {Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.385},
  eprint = {2106.01609},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.18653/v1/2021.acl-long.385}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
