Adapting Sequence Models for Sentence Correction
Allen Schmaltz Yoon Kim Alexander M. Rush Stuart M. Shieber
cs.CL


[NO \title GIVEN]
    [NO \author GIVEN]
    December 30, 2023
======================




In a controlled experiment of sequence-to-sequence approaches for the task of sentence correction, we find that character-based models are generally more effective than word-based models and models that encode subword information via convolutions, and that modeling the output data as a series of diffs improves effectiveness over standard approaches. Our strongest sequence-to-sequence model improves over our strongest phrase-based statistical machine translation model, with access to the same data, by 6 M^2 (0.5 GLEU) points. Additionally, in the data environment of the standard CoNLL-2014 setup, we demonstrate that modeling (and tuning against) diffs yields similar or better M^2 scores with simpler models and/or significantly less data than previous sequence-to-sequence approaches.
 



§ INTRODUCTION

 The task of sentence correction is to convert a natural language sentence that may or may not have errors into a corrected version. The task is envisioned as a component of a learning tool or writing-assistant, and has seen increased interest since 2011 driven by a  series of shared tasks  <cit.>. 

Most recent work on language correction has focused on the data provided by the CoNLL-2014 shared task <cit.>, a set of corrected essays by second-language learners. The CoNLL-2014 data consists of only around 60,000 sentences, and as such, competitive systems have made use of large amounts of corrected text without annotations, and in some cases lower-quality crowd-annotated data, in addition to the shared data. In this data environment, it has been suggested that statistical phrase-based machine translation (MT) with task-specific features is the state-of-the-art for the task <cit.>, outperforming word- and character-based sequence-to-sequence models <cit.>, phrase-based systems with neural features <cit.>, re-ranking output from phrase-based systems <cit.>, and combining phrase-based systems with classifiers trained for hand-picked subsets of errors <cit.>.

We revisit the comparison across translation approaches for the correction task in light of the Automated Evaluation of Scientific Writing (AESW) 2016 dataset, a correction dataset containing over 1 million sentences, holding constant the training data across approaches. The dataset was previously proposed for the distinct binary classification task of grammatical error identification. 

Experiments demonstrate that pure character-level sequence-to-sequence models are more effective on AESW than word-based models and models that encode subword information via convolutions over characters, and that representing the output data as a series of diffs significantly increases effectiveness on this task. Our strongest character-level model achieves statistically significant improvements over our strongest phrase-based statistical machine translation model by 6 M^2 (0.5 GLEU) points, with additional gains when including domain information. Furthermore, in the partially crowd-sourced data environment of the standard CoNLL-2014 setup in which there are comparatively few professionally annotated sentences, we find that tuning against the tags marking the diffs yields similar or superior effectiveness relative to existing sequence-to-sequence approaches despite using significantly less data, with or without using secondary models. All code is available at <https://github.com/allenschmaltz/grammar>.



§ BACKGROUND AND METHODS



  
Task 
We follow recent work and treat the task of sentence correction as translation from a source sentence (the unedited sentence) into a target sentence (a corrected version in the same language as the source). We do not make a distinction between grammatical and stylistic corrections.

We assume a vocabulary  of natural language word types (some of which have orthographic errors).
Given a sentence 𝐬 = [s_1 ⋯ s_I], where s_i ∈ is the i-th token of the sentence of length I, we seek to predict the corrected target sentence 𝐭 = [t_1 ⋯ t_J], where t_j ∈ is the j-th token of the corrected sentence of length J.
We are given both 𝐬 and 𝐭 for supervised training in the standard setup. At test time, we are only given access to sequence 𝐬. We learn to predict sequence 𝐭 (which is often identical to 𝐬).



  
Sequence-to-sequence
 
We explore word and character variants of the sequence-to-sequence framework.
 We use a standard word-based model (Word), similar to that of luong-pham-manning:2015:EMNLP, as well as a model that uses a convolutional neural network (CNN) and a highway network over characters (CharCNN), based on the work of KimEtAl-2016-CharLM, instead of word embeddings as the input to the encoder and decoder. With both of these models, predictions are made at the word level. We also consider the use of bidirectional versions of these encoders (+Bi). 
 
 Our character-based model (Char+Bi) 
 follows the architecture of the Word+Bi model, but the input and output consist of characters rather than words. In this case, the input and output sequences are converted to a series of characters and whitespace delimiters. The output sequence is converted back to 𝐭 prior to evaluation.
 
The Word models encode and decode over a closed vocabulary (of the 50k most frequent words); the CharCNN models encode over an open vocabulary and decode over a closed vocabulary; and the Char models encode and decode over an open vocabulary.  

Our contribution is to investigate the impact of sequence-to-sequence approaches (including those not considered in previous work) in a series of controlled experiments, holding the data constant. In doing so, we demonstrate that on a large, professionally annotated dataset, the most effective sequence-to-sequence approach can significantly outperform a state-of-the-art SMT system without augmenting the sequence-to-sequence model with a secondary model to handle low-frequency words <cit.> or an additional model to improve precision or intersecting a large language model <cit.>. We also demonstrate improvements over these previous sequence-to-sequence approaches on the CoNLL-2014 data and competitive results with JiEtal2017arXiv-NestedAttention, despite using significantly less data. 

The work of schmaltz-EtAl:2016:BEA11 applies Word and CharCNN models to the distinct binary classification task of error identification.



  
Additional Approaches

The standard formulation of the correction task is to model the output sequence as 𝐭 above. Here, we also propose modeling the diffs between 𝐬 and 𝐭. The diffs are provided in-line within 𝐭 and are described via tags marking the starts and ends of insertions and deletions, with replacements represented as deletion-insertion pairs, as in the following example selected from the training set:  “Some key points are worth del emphasiz  /del ins emphasizing /ins .”. Here, “emphasiz” is replaced with “emphasizing”. The models, including the Char model, treat each tag as a single, atomic token. 

The diffs enable a means of tuning the model's propensity to generate corrections by modifying the probabilities generated by the decoder for the 4 diff tags, which we examine with the CoNLL data. We include four bias parameters associated with each diff tag, and run a grid search between 0 and 1.0 to set their values based on the tuning set.

It is possible for models with diffs to output invalid target sequences (for example, inserting a word without using a diff tag). To fix this, a deterministic post-processing step is performed (greedily from left to right) that returns to source any non-source tokens outside of insertion tags. Diffs are removed prior to evaluation. We indicate models that do not incorporate target diff annotation tags with the designator –diffs.

The AESW dataset provides the paragraph context and a journal domain (a classification of the document into one of nine subject categories) for each sentence.[The paragraphs are shuffled for purposes of obfuscation, 
so document-level context is not available.] For the sequence-to-sequence models we propose modeling the input and output sequences with a special initial token representing the journal domain (+dom).[Characteristics of the dataset preclude experiments with additional paragraph context features. (See Appendix A.)] 

 




§ EXPERIMENTS





  
Data
AESW <cit.> consists of sentences taken from academic articles annotated with corrections by professional editors used for the AESW shared task. The training set contains 1,182,491 sentences, of which 460,901 sentences have edits. We set aside a 9,947 sentence sample from the original development set for tuning (of which 3,797 contain edits), and use the remaining 137,446 sentences as the dev set[The dev set contains 13,562 unique deletion types, 29,952 insertion types, and 39,930 replacement types.] (of which 53,502 contain edits). The test set contains 146,478 sentences.

The primary focus of the present study is conducting controlled experiments on the AESW dataset, but we also investigate results on the CoNLL-2014 shared task data in light of recent neural results <cit.> and to serve as a baseline of comparison against existing sequence-to-sequence approaches <cit.>. We use the common sets of public data appearing in past work for training: the National University of Singapore (NUS) Corpus of Learner English (NUCLE) <cit.> and the publicly available Lang-8 data <cit.>. The Lang-8 dataset of corrections is large[about 1.4 million sentences after filtering] but is crowd-sourced[derived from the Lang-8 language-learning website] and is thus of a different nature than the professionally annotated AESW and NUCLE datasets. We use the revised CoNLL-2013 test set as a tuning/dev set and the CoNLL-2014 test set (without alternatives) for testing. We do not make use of the non-public Cambridge Learner Corpus (CLC) <cit.>, which contains over 1.5 million sentence pairs. 



  
Evaluation We follow past work and use the Generalized Language Understanding Evaluation (GLEU) <cit.> and MaxMatch (M^2) metrics <cit.>.



  
Parameters
All our models, implemented with OpenNMT <cit.>, are 2-layer LSTMs with 750 hidden units. For the Word model,
the word embedding size is also set to 750, while for the CharCNN and Char models
we use a character embedding size of 25. The CharCNN model has a convolutional
layer with 1000 filters of width 6 followed by max-pooling, which is fed into a 2-layer highway network. Additional training details are provided in Appendix A. For AESW, the Word+Bi model contains around 144 million parameters, the CharCNN+Bi model around 79 million parameters, and the Char+Bi model around 25 million parameters.



  
Statistical Machine Translation
 As a baseline of comparison, we experiment with a phrase-based machine translation approach (SMT) shown to be state-of-the-art for the CoNLL-2014 shared task data in previous work <cit.>, which adds task specific features and the M^2 metric as a scorer to the Moses statistical machine translation system. The SMT model follows the training, parameters, and dense and sparse task-specific features that generate state-of-the-art results for CoNLL-2014 shared task data, as implemented in publicly available code.[SRI International provided access to SRILM <cit.> for running junczysdowmunt-grundkiewicz:2016:EMNLP2016] However, to compare models against the same training data, we remove language model features associated with external data.[We found that including the features and data associated with the large language models of junczysdowmunt-grundkiewicz:2016:EMNLP2016, created from Common Crawl text filtered against the NUCLE corpus, hurt effectiveness for the phrase-based models. This is likely a reflection of the domain specific nature of the academic text and LaTeX holder symbols appearing in the text. Here, we conduct controlled experiments without introducing additional domain-specific monolingual data.] We experiment with tuning against M^2 (+M^2) and BLEU (+BLEU). Models trained with diffs were only tuned with BLEU, since the tuning pipeline from previous work is not designed to handle removing such annotation tags prior to M^2 scoring. 



§ RESULTS AND ANALYSIS: AESW








Table 1 shows the full set of experimental results on the AESW development and test data. 

The Char+Bi+dom model is stronger than the Word+Bi+dom and CharCNN+dom models by 2.9 M^2 (0.2 GLEU) and 3.3 M^2 (0.3 GLEU), respectively. 
The sequence-to-sequence models were also more effective than the SMT models, as shown in Table <ref>. We find that training with target diffs is beneficial across all models, with an increase of about 5 M^2 points for the Word+bi model, for example. Adding +dom information slightly improves effectiveness across models.

We analyzed deletion, insertion, and replacement error types.
Table <ref> compares effectiveness across replacement errors. We found the CharCNN+Bi models were less effective than CharCNN variants in terms of GLEU and M^2, and the strongest CharCNN models were eclipsed by the Word+Bi models in terms of the GLEU and M^2 scores. However, Table <ref> shows CharCNN+dom is stronger on lower frequency replacements than Word models. The Char+Bi+dom model is relatively strong on article and punctuation replacements, as well as errors appearing with low frequency in the training set and overall across deletion and insertion error types, which are summarized in Table <ref>. 



  
Errors never occurring in training 
The comparatively high Micro F_0.5 score (18.66) for the Char+Bi+dom model on replacement errors (Table  <ref>) never occurring in training is a result of a high precision (92.65) coupled with a low recall (4.45). This suggests some limited capacity to generalize to items not seen in training. A selectively chosen example is the replacement from “discontinous” to “discontinuous”, which never occurs in training. However, similar errors of low edit distance also occur once in the dev set and never in training, but the Char+Bi+dom model never correctly recovers many of these errors, and many of the correctly recovered errors are minor changes in capitalization or hyphenation.



  
Error frequency About 39% of the AESW training sentences have errors, and of those sentences, on average, 2.4 words are involved in changes in deletions, insertions, or replacements (i.e., the count of words occurring between diff tags) per sentence. In the NUCLE data, about 37% of the sentences have errors, of which on average, 5.3 words are involved in changes. On the AESW dev set, if we only consider the 9545 sentences in which 4 or more words are involved in a change (average of 5.8 words in changes per sentence), the Char+Bi model is still more effective than SMT+BLEU, with a GLEU score of 67.21 vs. 65.34. The baseline GLEU score (No Change) is 60.86, reflecting the greater number of changes relative to the full dataset (cf. Table 1).



  
Re-annotation
The AESW dataset only provides 1 annotation for each sentence, so we perform a small re-annotation of the data to gauge effectiveness in the presence of multiple annotations. We collected 3 outputs (source, gold, and generated sentences from the Char+Bi+dom model) for 200 randomly sampled sentences, re-annotating to create 3 new references for each sentence. The GLEU scores for the 200 original source, Char+Bi+dom, and original gold sentences evaluated against the 3 new references were 79.79, 81.72, and 84.78, respectively, suggesting that there is still progress to be made on the task relative to human levels of annotation. 



§ RESULTS AND ANALYSIS: CONLL




Table <ref> shows the results on the CoNLL dev set, and Table <ref> contains the final test results.

Since the CoNLL data does not contain enough data for training neural models, previous works add the crowd-sourced Lang-8 data; however, this data is not professionally annotated. Since the distribution of corrections differs between the dev/test and training sets, we need to tune the precision and recall.

As shown in Table <ref>, Word+Bi effectiveness increases significantly by tuning the weights[In contrast, in early experiments on AESW, tuning yielded negligible improvements.] assigned to the diff tags on the CoNLL-2013 set[The single model with highest M^2 score was then run on the test set. Here, a single set is used for tuning and dev.]. Note that we are tuning the weights on this same CoNLL-2013 set. Without tuning, the model very rarely generates a change, albeit with a high precision. After tuning, it exceeds the effectiveness of Word+Bi–diffs. The comparatively low effectiveness of Word+Bi–diffs is consistent with past sequence-to-sequence approaches utilizing data augmentation, additional annotated data, and/or secondary models to achieve competitive levels of effectiveness.

Table <ref> shows that Word+Bi is within 0.2 M^2 of JiEtal2017arXiv-NestedAttention, despite using over 1 million fewer sentence pairs, and exceeds the M^2 scores of XieEtAl.2016-arxiv-NLCwithCharAttention and yuan-briscoe:2016:N16-1 without the secondary models of those systems. We hypothesize that further gains are possible utilizing the CLC data and moving to the character model. (The character model is omitted here due to the long training time of about 4 weeks.) Notably, SMT systems (with LMs) are still more effective than reported sequence-to-sequence results, as in JiEtal2017arXiv-NestedAttention, on CoNLL.[For reference, the reported M^2 results of the carefully optimized SMT system of  junczysdowmunt-grundkiewicz:2016:EMNLP2016 trained on NUCLE and Lang-8, with parameter vectors averaged over multiple runs, with a Wikipedia LM is 45.95 and adding a Common Crawl LM is 49.49. We leave to future work the intersection of a LM for the CoNLL environment and more generally, whether these patterns hold in the presence of additional monolingual data.]
 




§ CONCLUSION


Our experiments demonstrate that on a large, professionally annotated dataset, a sequence-to-sequence character-based model of diffs can lead to considerable effectiveness gains over a state-of-the-art SMT system with task-specific features, ceteris paribus. Furthermore, in the crowd-sourced environment of the CoNLL data, in which there are comparatively few professionally annotated sentences in training, modeling diffs enables a means of tuning that improves the effectiveness of sequence-to-sequence models for the task.


emnlp_natbib





§ SUPPLEMENTAL MATERIAL





  
Additional Model Training and Inference Details We provide additional replication details for our experiments here. Our code and related materials are available at the following url: <https://github.com/allenschmaltz/grammar>.

The training and tuning sizes of the AESW dataset are those after dropping sentences exceeding 126 tokens on the source or target side (in source sequences or target sequences with diff annotation tags) from the raw AESW dataset. All evaluation metrics on the development and test set are on the data without filtering based on sentence lengths.

As part of preprocessing, the sentences from the AESW XML are converted to Penn Treebank-style tokenization. Case is maintained and digits are not replaced with holder symbols for the sequence-to-sequence models. For the SMT models, the truecasing[Here, the truecase language model is created from the training 𝐭 sequences (or where applicable, the target with diffs).] and tokenization pipeline of the publicly available code is used. For consistency, all model output and all reference files are converted to cased Moses-style tokenization prior to evaluation. 

For the Char model, the L_2-normalized gradients were constrained to be ≤ 1 (instead of ≤ 5 with the other models), and our learning rate schedule started the learning rate at 0.5 (instead of 1 for the other models) for stable training. The maximum sequence length of 421 was used for models given character sequences, which was equivalent to the maximum sequence length of 126 used for models given word sequences. The maximum sequence lengths were increased by 1 for the models with the +dom features. The training and tuning set sizes cited in Section 3 are the number of sentences from the raw dataset after dropping sentences exceeding these maximum sequence lengths.

In practice, we were able to train each of the purely character-based models (e.g., the Char+Bi+dom model) with a single NVIDIA Quadro P6000 GPU with 24 GB of memory in about 3 weeks with a batch size of 12.

For the sequence-to-sequence models, the closed vocabularies were restricted to the 50,000 most common tokens, and a single special 𝗎𝗇𝗄 token was used for all remaining low frequency tokens. An 𝗎𝗇𝗄 token generated in the target sentence by the Word and CharCNN models was replaced with the source token associated with the maximum attention weight. The “open” vocabularies were only limited to the space of characters seen in training.

For the phrase-based machine translation baseline model from the work of junczysdowmunt-grundkiewicz:2016:EMNLP2016, for dense features, we used the stateless edit distance features and the stateful Operation Sequence Model (OSM) of durrani-EtAl:2013:Short[The OSM features use the SRI Language Modeling Toolkit (SRILM) <cit.>. 

]. Since for our controlled data experiments we removed the language model features associated with external data, we did not use the word-class language model feature, so for the sparse features, we used the set of edit operations on “words with left/right context of maximum length 1 on words” (set “E0C10” from the original paper), instead of those dependent on word classes.

The training and tuning splits for the phrase-based machine translation models were the same as for the sequence-to-sequence models. For tuning, we used Batch-Mira, setting the background corpus decay rate to 0.001, as in previous work. As in previous work, we repeated the tuning process multiple times (in this case, 5 times) and averaged the final weight vectors.

The sequence-to-sequence models were decoded with a beam size of 10. 

Decoding of the SMT models used the same approach of junczysdowmunt-grundkiewicz:2016:EMNLP2016 (i.e., the open-source Moses decoder run with the cube pruning search algorithm).

In our experiments, we do not include additional paragraph context features, since the underlying AESW data appears to have been collected such that nearly all paragraphs (including those containing a single sentence) contain at least one error; thus, modeling paragraph information provides additional signal that seems unlikely to reflect real-world environments.



  
CoNLL-2014 Shared Task
For training, we used the copy of the Lang-8 corpus distributed in the repo for the code of junczysdowmunt-grundkiewicz:2016:EMNLP2016: <https://github.com/grammatical/baselines-emnlp2016>. We filtered the Lang-8 data to remove duplicates and target sentences containing emoticon text, informal colloquial words (e.g., “haha”, “lol”, “yay”), and non-ascii characters. Target sentences not starting with a capital letter were dropped, as were target sentences not ending in a period, question mark, exclamation mark, or quotation mark. (Target sentences ending in a parenthesis were dropped as they often indicate informal additional comments from the editor.) In the combined NUCLE and Lang-8 training set, source sentences longer than 79 tokens and target sentences longer than 100 tokens were dropped. This resulted in a training set with 1,470,992 sentences. Diffs were created using the Python class difflib.SequenceMatcher.

For tuning on the dev set[Previous work, such as junczysdowmunt-grundkiewicz:2016:EMNLP2016, also used the CoNLL-2013 set for tuning.], a coarse grid search between 0 and 1.0 was used to set the four bias parameters associated with each diff tag. (Training was performed without re-weighting.) The bias parameter (in this case 0.7) yielding the highest M^2 score on the decoded dev set was chosen for use in evaluation of the final test set. The M^2 scores across the tuning runs on the dev set for the Word+Bi model are shown in Table <ref>.



For future comparisons to our work on the CoNLL-2014 shared task data, we recommend using the preprocessing scripts provided in our code repo (<https://github.com/allenschmaltz/grammar>).



  
Table 2 The seven columns of Table 2 appearing in the main text are Micro F_0.5 scores for the errors within each frequency grouping. There are a total of 39,916 replacement changes. The replacements are grouped in regard to the changes within the opening and closing deletion tags and subsequent opening and closing insertion tags, as follows: (1) whether the replacement involves (on the deletion and/or insertion side) a single punctuation symbol (comma, colon, period, hyphen, apostrophe, quotation mark, semicolon, exclamation, question mark); (2) whether the replacement involves (on the deletion and/or insertion side) a single article (a, an, the); (3) non-article, non-punctuation grouped errors with frequency greater than 100 in the gold training data; (4) non-article, non-punctuation grouped errors with frequency less than or equal to 100 and greater than or equal to 5; (5) non-article, non-punctuation grouped errors with frequency less than 5 and greater than or equal to 2; (6) non-article, non-punctuation grouped errors with frequency equal to 1; (7) non-article, non-punctuation grouped errors that never occurred in the training data. Note that the large number of unique instances occurring for the “punctuation” and “articles” classes are a result of the large number of errors that can occur on the non-article, non-punctuation side of the replacement. The Micro F_0.5 scores are calculated by treating each individual error (rather than the agglomerated classes here) as binary classifications.


