Acceso abierto

Computer Translation-Based Language Modeling Enables Multi-Scenario Applications of the English Language

  
17 mar 2025

Cite
Descargar portada

Introduction

In the past decade, with the development of many modern cutting-edge scientific technologies, the solution of cutting-edge problems in a number of disciplines has become increasingly dependent on the development of linguistics. Since language is the carrier of cultural and social information, the further development of information science depends to a large extent on the development of language science. For example, artificial intelligence, which must simulate the human brain mechanism and thinking process, cannot help but simulate the internal language process of human beings to some extent, because human abstract thinking is realized through the expression of language [1-4]. Take the human-computer dialogue, the most important thing is the modeling of natural language, without the study of language models, there is no realization of the high degree of formalization of natural language, therefore, it can be said that the “language model” is the “bridge” between linguistics and information science. From the perspective of “natural language processing”, language model is a mathematical model that describes the inner law of natural language, and the construction of language model is one of the core contents of the research method of computational linguistics, and it is also the core theory of corpus linguistics. It can be divided into rule model and statistical model [5-8].

Translating one language into another with the help of computers, referred to as computer translation (MT), is increasingly becoming an important technology, and the development of national defense, economy, political stability and social welfare depends on the sharing of information. Never in the history of mankind has the need to break through language barriers been felt more urgently than it is today, new common markets and growing world trade have created a strong need for language support, and the exchange of the nine official languages of the European Community alone means that a great deal of manpower is engaged in translating into seventy-two different languages in different directions every day [9-12]. Because of this, it is hoped that with the help of computers, the most powerful tool of information processing, people can be freed from such a heavy and tedious processing as translation work, or at least from a part or most of the repetitive and monotonous work, to engage in more creative labor. In summary, it seems very meaningful to examine the multi-scenario application of computer translation-based language modeling empowering the English language, through the practical use of language in communication, it can be observed whether the learners can use the learned language in a specific language environment well to carry out practical interactions and achieve the purpose of communication [13-15].

The study addresses the problem of catastrophic forgetting when incorporating BERT pre-trained language models into neural machine language models, and introduces a masking matrix strategy to mitigate it. Then, through the internal fusion and dynamic weighting of multi-attention mechanism, the model can make full use of the output information of the optimized BERT to realize the construction of English translation model based on improved Masking-BERT enhancement. The performance of the English translation model is analyzed in terms of English utterance compression effect, training loss and BLEU value, and its practical application effect is explored through the model’s translation accuracy, response time and expert satisfaction score. After that, Transformer is used to model grammatical error correction, taking into account both local contextual information and long-distance dependencies in the text. The English grammar error correction model is trained and tested, and other grammar error correction methods are selected to compare with this paper’s model, analyzing the accuracy rate, call rate and F0.5 value of different grammar error types, and exploring the effect of the constructed model on the detection and correction of English grammar errors.

Overview

Today, when the development of many cutting-edge scientific technologies has to rely more and more on language development, it is worthwhile to explore in depth how the research results on language can be used precisely and effectively for multi-scenario applications of the English language. Literature [16] summarizes the research related to ChatGPT, mainly analyzes the state-of-the-art large-scale language models in the GPT family and their applications in different domains, and points out that the key innovations of large-scale pre-training, instruction fine-tuning, and reinforcement learning from human feedback are of great importance for the adaptability and performance improvement of LLM. Literature [17] points out that pre-trained language models have led to a paradigm shift from supervised learning to pre-training to fine-tuning in the field of Natural Language Processing (NLP), and examines the future research directions in the field of language modeling by analyzing the classification methods, characterization methods, and frameworks for pre-trained models. Literature [18] proposes an extraction and abstraction neural network document summarization method based on transformational language models and experimentally verifies the effectiveness and feasibility of the method, which generates more abstract summaries and also achieves higher ROUGE scores. Literature [19] presents a cued large-scale language model for machine translation, which is verified to have excellent performance and can enhance translation results by using GLM-130B as a testbed. Literature [20] developed an English translation model based on intelligent recognition technology and deep learning framework, and designed experiments to verify its effectiveness, which has high accuracy and efficiency in speech recognition and translation, and provides a feasible and efficient solution for practical applications. Literature [21] proposed a machine translation language model by synthesizing feed-forward neural network decoder and attention mechanism, and experimentally verified that the proposed model has better performance and can be applied to different English scenarios, and the research provides new ideas for the direction of multi-scenario application of machine translation language model in the future.

English Translation Model Based on Improved Masking-BERT Enhancement

With the rapid development of AI artificial intelligence technology, the use of computers to translate between different languages has become a big trend. In order to improve the efficiency and quality of English teaching, many educators apply the AI translation model to the English classroom. To address this phenomenon, an English translation model based on improved Masking-BERT enhancement is proposed.

Masking Matrix Strategy

In order to the oblivious catastrophe problem of BERT training, the study proposes to use a mask matrix based BERT training strategy as follows:

In BERT, the l st Transformer block consists of 6 linear layers, respectively Wl{ WKl,WQl,Wvl,W10l,Wll,W0l }${{W}^{l}}\in \left\{ W_{K}^{l},W_{Q}^{l},W_{v}^{l},W_{10}^{l},W_{l}^{l},W_{0}^{l} \right\}$ . Each of these linear layers Wl is associated with a real-valued matrix Ml of the same size as it, which is randomly initialized from a uniform distribution. During training, backpropagation continuously updates the matrix Ml with the loss values of the subsequent machine translation task. During forward propagation, the binary mask Mbinl$M_{bin}^{l}$ of the current linear layer in Ml is first computed by an element-level threshold function, which is calculated as in Equation (1): (mlinl)i,j={ 1,ifmi,jlτ0,otherwise ${{\left( m_{lin}^{l} \right)}_{i,j}}=\left\{ \begin{matrix} 1,ifm_{i,j}^{l}\ge \tau \\ 0,otherwise \\ \end{matrix} \right.$

where τ is the hyperparameter of the global threshold and , i, j represents the coordinates of the 2D linear layer , Mi,jlMl$M_{i,j}^{l}\in {{M}^{l}}$ .

Multiply this binary mask Mbinl$M_{bin}^{l}$ with the current linear layer Wl to get the updated linear layer w^l${{\hat{w}}^{l}}$ . By this method, the model can choose by itself the part of parameters needed to pre-train the model and freeze them, and then update the remaining parameters. The specific process of updating the improved parameters is shown in equation (2): w˙l:=wleMbinl \[{{\dot{w}}^{l}}:={{w}^{l}}eM_{bin}^{l}\]

Multi-attention mechanisms
Internal integration of multi-attention mechanisms

In order to make the neural machine translation model can better utilize the output information of BERT trained based on the masking matrix strategy, internal fusion of multiple attention mechanisms in the BERT model is performed. Based on the output of the final hidden layer of Masking-BERT, the encoding and decoding attention results of the current layer of the model are computed as in Eqs. (3)~(5), respectively: hi%=12( attns(hil1,HEl1,HEl1) +attnB(attens+(hil1,HEl1,HEl1),HB,HB) ) $$\matrix{ {h_i^\% = {1 \over 2}(att{n_s}\left( {h_i^{l - 1},H_E^{l - 1},H_E^{l - 1}} \right)} \cr { + att{n_B}\left( {atte{n_s} + \left( {h_i^{l - 1},H_E^{l - 1},H_E^{l - 1}} \right),{H_B},{H_B}} \right))} \cr } $$ s^tl=attns(stl1,s<l+1l1,s<l+1l1) \[\hat{s}_{t}^{l}=att{{n}_{s}}\left( s_{t}^{l-1},s_{<l+1}^{l-1},s_{<l+1}^{l-1} \right)\] s^tl=12(attnE(stμ,HEl,HEl)+attnB( attnE(stμ,HEl,HEl),HB,HB) \[\hat{s}_{t}^{l}=\frac{1}{2}\left( att{{n}_{E}}\left( s_{t}^{\mu },H_{E}^{l},H_{E}^{l} \right)+att{{n}_{B}}\left( att{{n}_{E}}\left( s_{t}^{\mu },H_{E}^{l},H_{E}^{l} \right),{{H}_{B}}, \right.{{H}_{B}} \right)\]

Dynamic weighted fusion methods

Let the two connected layers in layer l of the encoder side of the self-attention mechanism be ATTsl$ATT_{s}^{l}$ , and ATTBl$ATT_{\text{B}}^{l}$ , respectively, and aggregate the output information of the self-attention mechanism and the output information of the Masking BERT attention attention mechanism in the current layer, and in the current layer integrate the output of the self-attention mechanism with the output of the Masking-BERT attention attention mechanism in the current layer, to obtain the hidden layer state HEL$H_{E}^{L}$ of the output of the encoder side, which is calculated as in Equation (6). Integration, the hidden layer state 4 of the output at the encoder side can be obtained, which is calculated as in Eq. (6): HEL=glATTsl+(1gl)ATTBl \[H_{E}^{L}={{g}_{l}}\otimes ATT_{s}^{l}+\left( 1-{{g}_{l}} \right)\otimes ATT_{B}^{l}\]

ATTEd$ATT_{E}^{d}$ and ATTBd$ATT_{B}^{d}$ respectively, and integrate the output of the encoder-decoder attention mechanism of the current layer with the output of the Masking-BERT attention mechanism of the current layer in the current layer, and the output of the decoder side of the hidden layer state HEL$H_{E}^{L}$ , which is computed as in Eq. (7): HEL=glATTE+(1gl)ATTBl \[H_{E}^{L}={{g}_{l}}\otimes AT{{T}_{E}}\prime +\left( 1-{{g}_{l}} \right)\otimes ATT_{B}^{l}\]

Neural Machine Translation Model

Let the hidden layer representation of the l st layer at the encoder side be HEl$H_{E}^{l}$ , the hidden layer representation of the i th word at the l rd layer be Hil$H_{i}^{l}$ , and the output of the last hidden layer of Masking-BERT be HB . The attention mechanism of each layer at the encoder side is shown in Equation (8): Hiσ0=12(attns(hit1,HEt1,HEt1)+attnB(attens+(hit1,HEt1,HEt1),HB,HB)) \[\begin{array}{*{35}{l}} H_{i}^{{{\sigma }_{0}}} & =\frac{1}{2}(att{{n}_{s}}(h_{i}^{t-1},H_{E}^{t-1},H_{E}^{t-1}) \\ {} & +att{{n}_{B}}(atte{{n}_{s}}+(h_{i}^{t-1},H_{E}^{t-1},H_{E}^{t-1}),{{H}_{B}},{{H}_{B}})) \\ \end{array}\]

where attnS and attnB are the self-attention mechanisms, respectively.

Let the hidden layer state of the first t time step of layer l at the decoder side be S<ll$S_{<l}^{l}$ and S<εl=(s1l,,st1l)$S_{<\varepsilon }^{l}=\left( s_{1}^{l},\cdots ,s_{t-1}^{l} \right)$ , then the attention mechanism of each layer at the decoder side is shown in Eqs. (9) and (10): s^tl=attns(stl1,S<l+1l1,S<++1l1) \[\hat{s}_{t}^{l}=att{{n}_{s}}\left( s_{t}^{l-1},S_{<l+1}^{l-1},S_{<++1}^{l-1} \right)\] s^tl=12(attnE(stμ,HEl1,HEl1)+attnB(attnE(stμ,HEl1,HEl1),HB,HB) \[\begin{array}{*{35}{l}} \hat{s}_{t}^{l} & =\frac{1}{2}(att{{n}_{E}}(s_{t}^{\mu },H_{E}^{l-1},H_{E}^{l-1}) \\ {} & +att{{n}_{B}}(att{{n}_{E}}(s_{t}^{\mu },H_{E}^{l-1},H_{E}^{l-1}),{{H}_{B}},{{H}_{B}}) \\ \end{array}\]

where attns , attnB and attnE denote self-attention mechanisms, respectively.

Translation Model Performance Analysis
English utterance compression

In order to validate the performance of the English translation model based on improved Masking-BERT enhancement designed by the study, the study conducts experimental validation in the CoNLL 2020 dataset, and the study utilizes online translation and machine translation to compare with the method of this paper.

The compression rate and compression stability are used as comparison indexes. Figure 1 shows the compression rate and compression stability comparison results of the three methods, where (a) is the compression rate comparison results of the three methods, and (b) is the compression stability comparison results of the three methods. As can be seen from Fig. (a), the average values of compression rates of online translation, machine translation and the English translation model of this paper are 77.9%, 81.4% and 88.4%, respectively. As can be seen from Fig. (b), the average values of compression stability of online translation, machine translation and systematic approach are 75.2%, 82.3% and 86.8%, respectively. This indicates that the English translation model in this paper also has high performance in the process of English utterance compression.

Figure 1.

The comparison results of the compression and compression stability of 3 methods

Training Losses and BLEUs

To further validate the performance of the systematic approach, Figures 2 and 3 show the comparison of the training loss and BLEU evaluation results of the three models, respectively. The average loss of the English translation method in this paper is lower than that of online translation and machine translation, which are 0.80, 0.85 and 0.82, respectively.The BLEU scores of the English translation method in this paper are 0.86, while those of the online translation and machine translation are 0.78 and 0.82, respectively, which indicates that the English translation method in this paper has a certain degree of superiority compared with the more commonly used translation methods at present.

Figure 2.

The results of the training loss of the three models

Figure 3.

The results of the BLEU value of the three models

In order to further validate the performance of the designed English translation model based on improved Masking-BERT enhancement, the study evaluates the results of the three methods, and the evaluation results of the three are shown in Figure 4. The compression ratio (0.66), grammaticality (5.67) and information content (4.32) of the English translation method in this paper are significantly better than the other two methods, while the difference in the heat ratio (0.48) is not significant. It shows that the design of this paper can provide a higher-performance method for English translation.

Figure 4.

The result of three ways to translate English into Chinese

Effect of practical application of translation model

In order to test the application effect of the constructed translation models in real problems, the actual operation stability and translation satisfaction of different translation models in the whole translation system are analyzed.

Operational stability

Figure 5 shows the translation accuracy and system response time of different models under the English to Chinese and Chinese to English tasks. The response times of online translation, machine translation and the English translation model of this paper in English to Chinese are 8.16 s, 5.92 s, 1.21 s, and the translation accuracy reaches 0.74, 0.81, 0.87, respectively.In the task of Chinese to English, the response times are 10.39 s, 7.96 s, 2.65 s, and the translation accuracy reaches 0.72, 0.76, respectively, 0.84.

Figure 5.

Translation accuracy and system response time of different models

Satisfaction

Figure 6 shows the satisfaction of 20 experts for the three translation models in the actual translation task, of which Figures (a), (b) and (c) show the satisfaction results of online translation, machine translation and the English translation model of this paper, respectively. The experts’ translation satisfaction and situational fitness for the English translation model of this paper are almost all in the range of 3 to 5 points, and most of the experts are concentrated in the first quadrant, which shows that the model has the highest satisfaction. In addition, the expert satisfaction of the other three models is either concentrated in the middle or more dispersed, thus showing that their satisfaction is poor.

Figure 6.

Expert satisfaction test results

English grammar error correction model based on self-attention mechanism

Automatic grammatical error correction is a typical task in natural language processing research, where the goal is to build an automated system to correct possible grammatical errors in texts. Broadly speaking, research on grammatical error correction has undergone a methodological evolution from rule-based, to statistical-based, to machine translation-based approaches. Computer translation is used in English grammatical error correction to construct a model for English grammatical error correction based on neural machine translation based on Transformer, an encoder-decoder model with self-attention mechanism.

Baseline model for grammatical error correction
A formal definition of grammatical error correction

Grammatical error correction is defined as the following process: input a sentence containing a grammatical error and output a corrected sentence that does not contain a grammatical error and that preserves the semantics of the original input sentence.

p(y|x)=t=1np(yt|x,y1:t1;θ) \[p\left( y\left| x \right. \right)=\prod\limits_{t=1}^{n}{p}\left( {{y}_{t}}\left| x \right.,{{y}_{1:t-1}};\theta \right)\]

In general, model parameters θ are learned based on great likelihood estimation: θ=argmaxθt=1nlogp(yt|x,y1:t1;θ) \[\theta =\underset{\theta }{\mathop{\arg \max }}\,\sum\limits_{t=1}^{n}{\log }p\left( {{y}_{t}}\left| x \right.,{{y}_{1:t-1}};\theta \right)\]

Recurrent Neural Networks

A recurrent neural network is a classical model for modeling variable-length sequences, and its standard formalization is as follows: ht=ϕh(Whxt+Uhht1+bh) \[{{h}_{t}}={{\phi }_{h}}\left( {{W}_{h}}{{x}_{t}}+{{U}_{h}}{{h}_{t-1}}+{{b}_{h}} \right)\] yt=ϕy(Wyht+by) \[{{y}_{t}}={{\phi }_{y}}\left( {{W}_{y}}{{h}_{t}}+{{b}_{y}} \right)\]

In order to solve the above problems, Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) are introduced.The formal definition of LSTM is as follows: Input Gate:it=σ(Wixt+Uiht1+bi)Oblivion Gate:ft=σ(Wfxt+Ufht1+bf)Output Gate:ot=σ(Woxt+Uoht1+bo)Input conversion:c˜t=tanh(Wcxt+Ucht1+bc)Cell state:ct=ftct1+itc˜tImplicit state:ht=ottanh(ct) \[\begin{align} & Input\text{ }Gate:{{i}_{t}}=\sigma \left( {{W}_{i}}{{x}_{t}}+{{U}_{i}}{{h}_{t-1}}+{{b}_{i}} \right) \\ & Oblivion\text{ }Gate:{{f}_{t}}=\sigma \left( {{W}_{f}}{{x}_{t}}+{{U}_{f}}{{h}_{t-1}}+{{b}_{f}} \right) \\ & Output\text{ }Gate:{{o}_{t}}=\sigma \left( {{W}_{o}}{{x}_{t}}+{{U}_{o}}{{h}_{t-1}}+{{b}_{o}} \right) \\ & Input\text{ }conversion:{{{\tilde{c}}}_{t}}=\tanh \left( {{W}_{c}}{{x}_{t}}+{{U}_{c}}{{h}_{t-1}}+{{b}_{c}} \right) \\ & Cell\text{ }state:{{c}_{t}}={{f}_{t}}\circ {{c}_{t-1}}+{{i}_{t}}\circ {{{\tilde{c}}}_{t}} \\ & \operatorname{Im}plicit\text{ }state:{{h}_{t}}={{o}_{t}}\circ \tanh \left( {{c}_{t}} \right) \\ \end{align}\]

where W* , U* , b* are the parameters of the LSTM network. Is the bit-by-bit multiplication.GRU is simplified based on LSTM and contains only two gates in the loop cell, which is formally defined as: RESET GATE:rt=σ(Wrxt+Urht1+br)Updating doors:zt=σ(Wzxt+Uzht1+bz)Input conversion:h˜t=tanh(Whxt+Uh(rtht1)+bh)Implicit state: ht=(1zt)ht1+zth˜t $\begin{align} & RESET\text{ }GATE:{{r}_{t}}=\sigma \left( {{W}_{r}}{{x}_{t}}+{{U}_{r}}{{h}_{t-1}}+{{b}_{r}} \right) \\ & Updating\text{ }doors:{{z}_{t}}=\sigma \left( {{W}_{z}}{{x}_{t}}+{{U}_{z}}{{h}_{t-1}}+{{b}_{z}} \right) \\ & Input\text{ }conversion:{{{\tilde{h}}}_{t}}=\tanh \left( {{W}_{h}}{{x}_{t}}+{{U}_{h}}\left( {{r}_{t}}\circ {{h}_{t-1}} \right)+{{b}_{h}} \right) \\ & \operatorname{Im}plicit\text{ }state:\text{ }{{h}_{t}}=\left( 1-{{z}_{t}} \right)\circ {{h}_{t-1}}+{{z}_{t}}\circ {{{\tilde{h}}}_{t}} \\ \end{align}$

The encoder-decoder model

In sequence-to-sequence learning, this is typically modeled using a neural network encoder-decoder model. The encoder first encodes the input sequence into a series of implicit state representations (vectors) in a continuous space, and based on these implicit states output by the encoder, as well as the prefixes of the symbol sequence that have been output at the current time step, the decoder predicts the output of the next symbol. Formally: e1,e2,,em=encoder(x1,x2,,xm) \[{{e}_{1}},{{e}_{2}},\ldots ,{{e}_{m}}=encoder\left( {{x}_{1}},{{x}_{2}},\ldots ,{{x}_{m}} \right)\] yt=decoder(e1,e2,,em,y1,y2,,yt1) \[{{y}_{t}}=decoder\left( {{e}_{1}},{{e}_{2}},\ldots ,{{e}_{m}},{{y}_{1}},{{y}_{2}},\ldots ,{{y}_{t-1}} \right)\]

Attention mechanisms

The attention mechanism is an important component of today’s mainstream neural network encoder-decoder models. Specifically, at time step t , the current implicit state dt of the decoder, and the implicit states ei , i = 1, 2,…,m of the encoder output, are used to compute the attention weights assigned to ei . All the attentional weights form a probability distribution over the input sequence, based on which the encoder’s sequence of implied states ei , i = 1, 2,…,m , is weighted and summed to obtain the contextual representation ct at the current time step to help the decoder predict the t th target language word. The specific formula is given below: αt,i=exp(Atten(dt,ei))j=1mexp(Atten(dt,ej)) \[{{\alpha }_{t,i}}=\frac{\exp \left( Atten\left( {{d}_{t}},{{e}_{i}} \right) \right)}{\sum\limits_{j=1}^{m}{\exp }\left( Atten\left( {{d}_{t}},{{e}_{j}} \right) \right)}\] ct=i=1mαt,iei \[{{c}_{t}}=\sum\limits_{i=1}^{m}{{{\alpha }_{t,i}}}\cdot {{e}_{i}}\]

In the above equation, Atten is the function that calculates the attention score, commonly defined as: Atten(d,e)={ dTedotdTWAegeneralvTtanh(WA[ d;e ])concat $Atten\left( d,e \right)=\left\{ \begin{array}{*{35}{l}} {{d}^{\mathcal{T}}}e & dot \\ {{d}^{\mathcal{T}}}{{W}_{A}}e & general \\ {{v}^{\mathcal{T}}}\tanh \left( {{W}_{A}}\cdot \left[ d;e \right] \right) & concat \\ \end{array} \right.$

where WA and v are learnable parameters.

English Grammar Error Correction Model
Model structure

The Transformer model consists of an encoder and a decoder, given source-side error sentences x = (x1,x2,…,xm), xiX , X as source-side word lists, the Transformer encoder encodes x as a set of implicit state representations in continuous space e = (e1,e2,…,em) , based on which the Transformer decoder generates time-step by time-step corrected sentences y = (y1,y2,…,yn) , yiy , y as target-side word lists.

Encoder and Decoder

The encoder and decoder in Transformer each contain six identical layers, located in the encoder, consisting of a self-attention sublayer and a forward neural network sublayer. The input passes through the self-attention sublayer, after which the same forward neural network is applied to the output at different locations in the self-attention sublayer.

Attention mechanism in Transformer
Dot product attention for scaling

Given a query vector q , a set of key vectors K , and a set of value vectors V , the scaled dot product attention is given by: ScaAtten(q,K,V)=softmax(qKTdk)V \[ScaAtten(q,K,V)=soft\max \left( \frac{q{{K}^{\text{T}}}}{\sqrt{{{d}_{k}}}} \right)V\]

Multiple attention

In order to allow the model to simultaneously access information from different representation subspaces when encoding at different locations in the sequence, multi-head attention performs dot product attention computation with multiple scaling: MultiHead(q,K,V)=Concat(head1,head2,,headh)WO \[MultiHead\left( q,K,V \right)=Concat\left( hea{{d}_{1}},hea{{d}_{2}},\ldots ,hea{{d}_{h}} \right){{W}^{O}}\] headi=ScaAtten(qWiQ,KWiK,VWiV) \[hea{{d}_{i}}=ScaAtten\left( qW_{i}^{Q},KW_{i}^{K},VW_{i}^{V} \right)\]

Self-attention sublayer

Multihead attention is applied in the self-attention sublayer, where query vectors, key vectors, and value vectors are derived from the output of the previous sublayer (or directly the Embedding of the input).

Encoder-Decoder Attention Sublayer

This sublayer is similar to the attention layer in a typical recurrent neural network encoder-decoder model, with query vector q coming from the output of the previous sublayer in the decoder, and key vector set K and value vector set V both coming from the output of the encoder.

Positional Encoding

Since the Transformer model does not contain any loop structure, in order to utilize the positional information of the symbols in the sequence, position encoding is incorporated into the input Embedding, and the dimension of position encoding is the same as that of the implicit dimension dmodel of the Transformer model, which is computed by the formula: PE(pos,2i)=sin(pos100002idmodel)PE(pos,2i+1)=cos(pos100002iamodel) \[\begin{align} & P{{E}_{\left( pos,2i \right)}}=\sin \left( \frac{pos}{{{10000}^{\frac{2i}{{{d}_{\bmod el}}}}}} \right) \\ & P{{E}_{\left( pos,2i+1 \right)}}=\cos \left( \frac{pos}{{{10000}^{\frac{2i}{{{a}_{\bmod el}}}}}} \right) \\ \end{align}\]

Input and Output Layers

As with typical sequence-to-sequence models, Transformer uses embedding layers at the bottom of the encoder and decoder to convert symbols in the sequence into vectors. When decoding to generate the symbols at the target end, the output of the decoder is converted to a vector of probability distributions on the symbol table by a linear transformation and softmax function.Unlike Transformer’s original paper, the parameters of the Embedding layer of the encoder and decoder, as well as of the linear transformation layer in front of the softmax layer are not shared in this paper when modeling syntactic error correction.

Training guidelines

When training Transformer, great likelihood estimation is used with the goal of maximizing the likelihood of the model on training data S : θ=argmaxθ(x,y)Slogp(y|x;θ) \[\theta =\underset{\theta }{\mathop{\arg \max }}\,\sum\limits_{\left( x,y \right)\in S}{\log }p\left( y\left| x \right.;\theta \right)\]

Decoding Strategies

Given the input error sentence x , the Transformer model uses beam search decoding to generate the corrected sentence yhyp at the target end, and at each time step, the top k candidate prefix sentences with the highest scores are retained. In addition, to suppress the model’s behavior of favoring shorter sentences, a length penalty term is also introduced into the original likelihood scores, which is specified by the following formula: score(yhyp,x)=log(p(yhyp|x))LP(yhyp) \[score\left( {{y}_{hyp}},x \right)=\frac{\log \left( p\left( {{y}_{hyp}}\left| x \right. \right) \right)}{LP\left( {{y}_{hyp}} \right)}\] LP(yhyp)=(5+| yhyp |)α(5+1)α,α[ 0.6,0.7 ] $LP\left( {{y}_{hyp}} \right)=\frac{{{\left( 5+\left| {{y}_{hyp}} \right| \right)}^{\alpha }}}{{{\left( 5+1 \right)}^{\alpha }}},\alpha \in \left[ 0.6,0.7 \right]$

Experimental results and analysis
Experimental data

The training data for the experiments in this chapter attempts to incorporate forged error sentences to train the model, in addition to using manual labeling training data. Two different types of training data are used in this experiment, and the composition of the training data is described below:

1) Due to the major grammatical error types in the corpus with manual annotation, e.g., the NUCLE dataset has 57,151 sentences, but only 3,716 sentences contain at least one or more grammatical errors, less than 0.4% of the words in the whole dataset need to be corrected, with the coronal errors accounting for 14.8%, the noun singular-plural errors accounting for 8.4%, and the prepositional errors accounting for only 5.4%. The sparsity of grammatical errors will greatly affect the effectiveness of model training, so in this chapter of the study, sentences with grammatical errors will be extracted as training data.

2) Since the corpus data with artificial error annotations are less, in order to improve the performance of the error correction classification model, in addition to the training data introduced above, the training data with forged errors are also introduced for the experiments in this chapter. The WiKi-Text103 corpus is selected as the seed corpus for this experiment, and prepositional errors, coronal errors, and noun singular-plural errors are randomly created, i.e., prepositions and coronal errors are randomly replaced or deleted after they are recognized in a sentence, and nouns are randomly replaced with another singular-plural form of a noun when they are detected, so as to generate more training data for training the classifier for the corresponding error types.

In this chapter, W&I-dev will be chosen as the validation set, and the test data provided by CoNLL-2014 will be used as the test set for this experiment, and P, R, and F0.5 will be selected as the evaluation metrics for the experiment.

Training results

In this paper, the labeled data and the forged error data sets are merged together to jointly train the English error correction model based on the self-attention mechanism, and the training results of the model are shown in Fig. 7, and the performance of the final model achieves 93% accuracy on the test set, with the loss value stabilized at 0.08.

Figure 7.

Model training results

Comparative analysis of models

Experiments were conducted on the CoNLL-2014 test set on this paper’s English error correction method based on the self-attention mechanism and other grammar error correction methods (denoted as Method 1~ Method 4). The experimental comparison results of English grammar error correction methods are shown in Figure 8. The results of this paper’s model on the CoNLL-2014 test set are all improved compared with other grammar error correction methods, and the values of precision, recall, and F0.5 reach 0.783, 0.788, and 0.785, which are increased by 2.4%~12.7%, 7.0%~8.7%, and 5.1%~10.7%, respectively.The introduction of Transformer improves the grammar performance of the error correction model.

Figure 8.

The experimental comparison of English grammar error method

Error type analysis

The ERRANT Syntax Error Annotation Toolkit was used to explore the performance of the models in this paper under different syntax error types. The ERRANT toolkit was first used to convert the M2 files of the CoNLL-2014 test set into M2 files adapted to the input of the ERRANT toolkit prior to analysis. The prefixes “M”, “R”, and “U” represent the three meanings of missing, replacing, and uncorrected errors, respectively.

In this paper, we focus on the correction of common types of errors, and the syntactic error correction results of the model are shown in Fig. 9, where (a) and (b) are the test results of syntactic error correction and syntactic error detection, respectively. The model has a good effect of correcting nouns, prepositions, spelling errors, and verb form errors, and the accuracy of grammatical error correction is above 76%. Among them, the accuracy of correcting spelling errors is up to 79.1%. In terms of error type detection, the model has a high accuracy in identifying the type of error for singular and plural forms of nouns and verbs, with a 78.4% and 79.6%, respectively. For the identification and detection of punctuation errors, the combined performance of the model correction and detection achieved 0.726 and 0.748 on the F0.5 value, and the model in this paper has some ability to identify and correct errors of punctuation types.

Figure 9.

The grammatical error correction of the model

Conclusion

For better English language learning and utilization, this paper proposes an English translation model based on improved Masking-BERT enhancement based on the computer translation perspective. The English grammar error correction task is regarded as a sequence-to-sequence generative task, i.e., the error correction process is regarded as the process of translating an incorrect sentence into a correct one, and the self-attention mechanism is used to construct the English grammar error correction model. Through the analysis of the English translation and grammar error correction model, we explore its multi-scenario application in English language.

Compared with other models, the English translation model in this paper has better English utterance compression performance, with a compression rate and compression stability of 88.4% and 86.8%, respectively, and also outperforms the comparison model in terms of training loss and BLEU score. Meanwhile, the model’s translation accuracy in English to Chinese and Chinese to English reaches 72%~87%, the response time is less than 3s, and the satisfaction scores are concentrated in 3~5, which is superior in practical application.

The English grammar error correction model in this paper scores more than 78% in precision, recall, and F0.5 indexes, which is higher than other grammar error correction models, and is able to carry out English grammar error correction more accurately. Among them, the accuracy of the model in correcting nouns, prepositions, spelling errors, and verb form errors is greater than 76%, and the accuracy of detecting errors in singular and plural forms of nouns and verb forms is greater than 78%. The model in this paper is capable of successfully detecting and correcting common English grammar errors.

Under the trend of globalization, the increase in English usage scenarios such as work, study, and immigration has resulted in the emergence of a large number of English learning groups. This study constructs an English translation model and a grammar error correction model based on computer translation, which can assist the public in learning and daily application of the English language and promote the efficiency of English learning.

Funding:

This research was supported by the Ministry of Education’s Supply and Demand Integration Project of Employment and Education: “Research on Enhancing the Innovation and Entrepreneurship Ability of Traditional Chinese Medicine International Communication Talents” (No. 2024041148735).