# English-Chinese Machine Translation Model Based on Bidirectional Neural Network with Attention Mechanism

Authors: Li Yonglan; He Wenjia
Journal: Journal of Sensors
 (2022)

---

## Abstract

In recent years, with the development of deep learning, machine translation using neural network has gradually become the mainstream method in industry and academia. The existing Chinese-English machine translation models generally adopt the deep neural network architecture based on attention mechanism. However, it is still a challenging problem to model short and long sequences simultaneously. Therefore, a bidirectional LSTM model integrating attention mechanism is proposed. Firstly, by using the word vector as the input data of the translation model, the linguistic symbols used in the translation process are mathematized. Secondly, two attention mechanisms are designed: local attention mechanism and global attention mechanism. The local attention mechanism is mainly used to learn which words or phrases in the input sequence are more important for modeling, while the global attention mechanism is used to learn which layer of expression vector in the input sequence is more critical. Bidirectional LSTM can better fuse the feature information in the input sequence, while bidirectional LSTM with attention mechanism can simultaneously model short and long sequences. The experimental results show that compared with many existing translation models, the bidirectional LSTM model with attention mechanism can effectively improve the quality of machine translation.


---

## Body

## 1. Introduction

Machine translation is an important part of natural language processing. Machine translation (MT) mainly studies the process of how to automatically translate one human language into another by computer [1–5], so as to realize the mutual conversion between different languages. With the rapid development of science and technology and social economy, the cultural exchanges at home and abroad are increasing, which leads to the increasing demand for Chinese-English translation. Google, Microsoft, Baidu, Sogou, and other companies are constantly developing and perfecting machine translation systems. Compared with human translation, machine translation, as a low-cost and efficient communication method, has become an indispensable part of the translation industry. The mainstream machine translation models mainly include statistical machine translation (SMT) [6–8] and neural machine translation (NMT) [9–11]. The traditional machine translation method is the SMT model, which counts information such as word pairs, parallel phrase pairs, and parallel syntactic structures from large-scale parallel corpus to establish a statistical model for the translation process. The research methods mainly include word-based statistical methods [12], phrase-based statistical methods [13], and syntactic structure-based statistical methods [14]. Among them, the phrase-based statistical machine translation takes phrases (that is, any consecutive words) as the basic translation unit, which can well solve the dependency relationship between the local contexts of sentences, and the translation quality has been greatly improved compared with the word-based statistical method. In recent years, with the development of deep learning, a translation model using neural network to map Chinese to English has emerged, which is called NMT model [15, 16]. NMT model significantly improves the quality of machine translation, surpasses the performance of traditional SMT methods, and becomes the mainstream method in industry and academia at present. Different from the traditional SMT, NMT is committed to building a separate neural network to achieve the best translation performance through joint training and adjustment. The benchmark NMT system is the encoder-decoder framework [17], which uses bilingual parallel corpus to realize the end-to-end [18] training process. Coding and decoding functions are realized by recurrent neural networks (RNN) [19, 20]. These two cyclic neural networks are modeled by an attention layer connection, which detects the information related to all the words at the source when translating the target words. This process is called attention mechanism [21]. RNN is a connection model, which can capture the dynamic information of input sequence through cyclic operation in network nodes. Unlike the standard feedforward neural network, the circular neural network can maintain a state, which can represent information in any long context window. Gulcehre et al. [22] proposed the method of integrating RNN language model into NMT. Sano et al. [23] expanded the RNN structure, transferred the derivative to historical information, and improved the memory ability of translation model for long-distance information. In view of the difficulty in introducing translation rules into NMT, Wu et al. [24] coded the rules and selected the rules through attention mechanism in the process of translation, which achieved good translation results, but it also caused high time complexity. In recent years, the long short-term memory (LSTM) network has made breakthrough progress in many learning tasks in the computer field, such as adding subtitles to images, language translation, and handwriting font recognition. Ren et al. [25] extended the LSTM network structure to 16 layers, which made the single model translation result better than SMT. However, the general neural network model will not save the intermediate information and will give the same weight to the short sequence or phrase in the input sequence. Therefore, this paper proposes an attention bidirectional LSTM (A-BLSTM) model which integrates attention mechanism. Because different words and phrases in an input sequence will contain different amounts of information, the A-BLSTM model contains a local attention mechanism. Local attention mechanism is mainly used to learn which word or phrase in the input sequence contains more information. Global attention mechanism is used to learn which layer of representation vector of input sequence should be given more attention (weight). Our main contributions are as follows: Firstly, for the simultaneous modeling of short sequences and long sequences, a hierarchical structure integrating attention mechanism is proposed, which can obtain multilayer intermediate representation vectors of input sequences instead of a single fixed-length word vector. Secondly, the number of network layers in A-BLSTM model can change with the complexity of tasks. Finally, the local attention mechanism can effectively select relatively important words or phrases, and the global attention mechanism can effectively select more credible intermediate representation vectors.


## 2. Word Vector Generation

To transform the machine translation problem into a machine learning problem, it is first necessary to mathematize the language symbols used in the translation process. As the input data of the translation model, word vector has a great influence on the quality of the final model. As the transmission form of data in NMT, the acquisition of word vector is the basis of all research work.


### 2.1. Word Vector Model

Skip-gram model is used for word vector model. Skip-gram model [26], also known as skip model, takes a word as input and predicts its context around a text sequence. For example, for an example text sequence [“that”, “is”, “a”, “question”]. Given “is”, assuming that the window size is 2, what the model needs to obtain is the probability of its neighboring words “that”, “a”, and “question”. At this time, “is” is called the head word, and other words are called background words. The basic idea of this model is to encode all words in One-Hot mode, input them into the neural network with only one hidden layer for training, and use the weight of hidden layer as the expression vector of words after training. The Skip-gram network structure is shown in Figure 1.Figure 1
Structure of Skip-gram.In this network, the dimensions of the input and output vectors of the neural network are the same, and there is no activation function in the hidden layer. In order to ensure that the output vector is a probability distribution, the output layer uses softmax. The number of neurons in the hidden layer depends on the dimension of word vector, and the number of neurons in the output layer is equal to the number of words in the corpus. Suppose the dictionary size is∣v∣. Match each word in the dictionary with integers from 0 to ∣v∣−1 one by one, and establish the dictionary index set v=0,1,⋯,∣v∣−1. For any word in the dictionary, its corresponding integer in the dictionary is the index of the word. Assuming that a text sequence of length T is given, the word corresponding to time t is wt, and the size of time window is m, then the Skip-gram model maximizes the probability of any central word generating background words, and the calculation method is shown in formula (1):
(1)J=∏t=1T∏−m≤j≤m,j≠0Pwt+jwt.In order to maximize the objective function, the original maximum likelihood estimation becomes the minimization of formula (2).
(2)J=−1T∑t=1T∑−m≤j≤m,j≠0logPw+jwt.v and u represent the vector of the central word and the background word, respectively. For the word with index i in the dictionary, the vector of the word as the central word and the background word is expressed as vi and ui, respectively. In order to embed the model parameters into the loss function, it is necessary to use the model parameters to calculate the probability of generating background words from the center words in the loss function. Assume that the probabilities of generating background words from the central word are independent of each other. For the center word wc and the background word wo, the probability that the center word in the loss function generates the background word is calculated by the softmax function.
(3)Pwowc=expuoTvc∑i∈vexpuiTvc.When the sequence length is large, a smaller subsequence is usually randomly sampled to calculate the loss function, and the random gradient descent method is used to optimize the loss function. Then, the gradient of the generation probability is as follows:(4)∂logPwowc∂vc=uo−∑j∈vexpujTvc∑i∈vexpuiTvcuj.The formula is equivalent to the following:(5)∂logPwowc∂vc=uo−∑j∈vPwjwcuj.After the gradient is calculated by this formula, the stochastic gradient descent method is used to update the model parametervc iteratively. Similarly, the model parameter vo can be obtained. After the final training, for the word with index i in the dictionary, two groups of word vectors vi and uiwith this word as the central word and background word can be obtained.


### 2.2. Model Optimization

It can be found that the cost of gradient calculation in each step of the word vector model is related to the dictionary size∣v∣. When the dictionary is large in scale, ordinary training methods will consume a lot of space resources. Therefore, it is necessary to use approximate method to calculate the gradient, so as to reduce the calculation cost and improve the operation performance. The approximate training method adopted is sequence softmax. Sequence softmax uses a Huffman-coded binary tree to represent all words in the vocabulary. Each leaf node in the tree independently represents a word. There is a unique path from the root node to the leaf node for each leaf node. This path is used to estimate the probability of words represented by leaf nodes. Sequence softmax binary tree structure is shown in Figure 2.Figure 2
Binary tree structure of sequence softmax.SupposeLw represents the number of nodes on the path from the root node to the leaf node. Let nw,i be the i-th node on this path, and the vector of this node is expressed as unw,i. Then, the probability of word vector model generating word w from arbitrary word wi is as follows:
(6)Pwwi=∏j=1Lw−1σnw,j+1=leftChildnw,j⋅unw,jTvi,where σ represents sigmoid function and leftChild represents the left branch.


## 2.1. Word Vector Model

Skip-gram model is used for word vector model. Skip-gram model [26], also known as skip model, takes a word as input and predicts its context around a text sequence. For example, for an example text sequence [“that”, “is”, “a”, “question”]. Given “is”, assuming that the window size is 2, what the model needs to obtain is the probability of its neighboring words “that”, “a”, and “question”. At this time, “is” is called the head word, and other words are called background words. The basic idea of this model is to encode all words in One-Hot mode, input them into the neural network with only one hidden layer for training, and use the weight of hidden layer as the expression vector of words after training. The Skip-gram network structure is shown in Figure 1.Figure 1
Structure of Skip-gram.In this network, the dimensions of the input and output vectors of the neural network are the same, and there is no activation function in the hidden layer. In order to ensure that the output vector is a probability distribution, the output layer uses softmax. The number of neurons in the hidden layer depends on the dimension of word vector, and the number of neurons in the output layer is equal to the number of words in the corpus. Suppose the dictionary size is∣v∣. Match each word in the dictionary with integers from 0 to ∣v∣−1 one by one, and establish the dictionary index set v=0,1,⋯,∣v∣−1. For any word in the dictionary, its corresponding integer in the dictionary is the index of the word. Assuming that a text sequence of length T is given, the word corresponding to time t is wt, and the size of time window is m, then the Skip-gram model maximizes the probability of any central word generating background words, and the calculation method is shown in formula (1):
(1)J=∏t=1T∏−m≤j≤m,j≠0Pwt+jwt.In order to maximize the objective function, the original maximum likelihood estimation becomes the minimization of formula (2).
(2)J=−1T∑t=1T∑−m≤j≤m,j≠0logPw+jwt.v and u represent the vector of the central word and the background word, respectively. For the word with index i in the dictionary, the vector of the word as the central word and the background word is expressed as vi and ui, respectively. In order to embed the model parameters into the loss function, it is necessary to use the model parameters to calculate the probability of generating background words from the center words in the loss function. Assume that the probabilities of generating background words from the central word are independent of each other. For the center word wc and the background word wo, the probability that the center word in the loss function generates the background word is calculated by the softmax function.
(3)Pwowc=expuoTvc∑i∈vexpuiTvc.When the sequence length is large, a smaller subsequence is usually randomly sampled to calculate the loss function, and the random gradient descent method is used to optimize the loss function. Then, the gradient of the generation probability is as follows:(4)∂logPwowc∂vc=uo−∑j∈vexpujTvc∑i∈vexpuiTvcuj.The formula is equivalent to the following:(5)∂logPwowc∂vc=uo−∑j∈vPwjwcuj.After the gradient is calculated by this formula, the stochastic gradient descent method is used to update the model parametervc iteratively. Similarly, the model parameter vo can be obtained. After the final training, for the word with index i in the dictionary, two groups of word vectors vi and uiwith this word as the central word and background word can be obtained.


## 2.2. Model Optimization

It can be found that the cost of gradient calculation in each step of the word vector model is related to the dictionary size∣v∣. When the dictionary is large in scale, ordinary training methods will consume a lot of space resources. Therefore, it is necessary to use approximate method to calculate the gradient, so as to reduce the calculation cost and improve the operation performance. The approximate training method adopted is sequence softmax. Sequence softmax uses a Huffman-coded binary tree to represent all words in the vocabulary. Each leaf node in the tree independently represents a word. There is a unique path from the root node to the leaf node for each leaf node. This path is used to estimate the probability of words represented by leaf nodes. Sequence softmax binary tree structure is shown in Figure 2.Figure 2
Binary tree structure of sequence softmax.SupposeLw represents the number of nodes on the path from the root node to the leaf node. Let nw,i be the i-th node on this path, and the vector of this node is expressed as unw,i. Then, the probability of word vector model generating word w from arbitrary word wi is as follows:
(6)Pwwi=∏j=1Lw−1σnw,j+1=leftChildnw,j⋅unw,jTvi,where σ represents sigmoid function and leftChild represents the left branch.


## 3. Machine Translation Model Integrating Attention Mechanism

The whole structure of the proposed A-BLSTM model is shown in Figure3. Compared with other RNN models, one advantage of this model is that the number of model layers can change with the complexity of tasks. Moreover, with the increase of network layers, the number of nodes of A-BLSTM decreases layer by layer, and the computational complexity of each layer also decreases. We will take the three-tier network structure as an example to elaborate. Specifically, A-BLSTM includes the following three parts: sequence encoder based on BLSTM, local attention mechanism structure, and global attention mechanism structure.Figure 3
Overall architecture of A-BLSTM.Figure 4
The architecture of LSTM.


### 3.1. Sequence Encoder Based on BLSTM

In RNN, the hidden layer stateht at time t is calculated by a function f, as shown in formula (7):
(7)ht=0,t=0,fht−1,Xt,others,where xt represents the current input state and f represents a nonlinear radiation transfer function.LSTM is an improved time recursive neural network, which can effectively deal with the problem of long-term dependence in time series, so it has strong advantages in speech recognition. LSTM can effectively solve the problem that traditional RNN cannot learn long-distance dependence in the training process. LSTM contains a single memory cell unit, which will update its stored information as needed. Figure4 shows the structure of LSTM network, in which the repeated modules represent the hidden layer in each iteration.The LSTM unit at timet is composed of a group of vectors, which include an input gate it, a forgetting gate ft, an output gate ot, a memory cell ct, and a hidden state ht. The conversion equation in LSTM network is as follows:
(8)it=σWiXt+Uiht−1+bi,ft=σWfXt+Ufht−1+bf,ot=σWoXt+Uoht−1+bo,zt=thahWzXt+Uzht−1+bz,ct=it⊙zt+ft⊙ct−1,ht=ot⊙tanhct,where ⊙ represents the multiplication by element, b represents the bias vector parameter, and zt represents an update gate.Compared with unidirectional LSTM, bidirectional long short-term memory network (BLSTM) [27] uses extra backward information, which has the advantage of enhancing the memory ability of the network. The hidden state of each node in BLSTM can be calculated by the following formula.
(9)h~jl=hjl⟶⊕hjl⟵,where ⊕ represents the connection operation, and ~ represents the output of BLSTM unit.


### 3.2. Local Attention Mechanism and Global Attention Mechanism

Traditional LSTM modeling uses the last hidden state as the sequence vector or averages to get the final sequence vector. However, the importance of different words or phrases in sentences is different [28]. Therefore, we introduce local attention mechanism into BLSTM. The mechanism of local attention is shown in Figure 5.Figure 5
Local attention mechanism.For thel-th layer in the network structure, rl represents a representation vector of the input sequence, and its calculation formula is as follows:
(10)rl=∑j=1DZj⊙h~jl,where l∈1,3, Zj represents the normalized coefficient vector, and D represents the length of the input sequence.
(11)Zj=∑j=1Dexpu1lu2I⋮uDl,ujl=tanhWuh~jl+bu,where Wu and bu are parameters in the network.The higher the number of layers of the network, the less original information retained in the obtained sentence vector, and the higher the abstract level of sentence meaning. Therefore, with the different input sequences and tasks, the trust weight of each layer in the network should be different. In order to reward the layer that is more meaningful for correctly classifying labels, we introduce the global attention mechanism in the network. The global attention mechanism is shown in Figure6.Figure 6
Global attention mechanism.The principle of global attention mechanism is to give a weight to the classification probability of each layer, which represents how much probability the neural network trusts the output of this layer. The formula of global attention mechanism is as follows:(12)pl=P•xj;θ=softmaxWprl+bp,ol=tanhWgpl+bg,αl=expolTog∑lexpolTog,P=∑lαlpl,where Wp, Wg, bp, bg, and og are all parameters in the network. We can calculate an overall classification probability distribution P through the classification probability of each layer and the trust weight of each layer in the network structure.


### 3.3. A-BLSTM

The proposed A-BLSTM model is a hierarchical structure, which continuously integrates the information of each layer in a bottom-up way and finally can effectively model the combined features. The layer number of A-BLSTM is expressed byl∈0,3. For the l layer, the input hjl of the j-th node is calculated as follows:
(13)hjl=h~2jl−1⊕h~2j+1l−1,h~2jl−1=BLSTMh2jl−1,h~2j+1l−1=BLSTMh2j+1l−1,where h~2jl−1 and h~2j+1l−1 are the outputs of BLSTM unit. A word is the input of the first layer in the network structure, and then, the output of each layer recursively becomes the input of the upper layer until the top layer of the network structure.


## 3.1. Sequence Encoder Based on BLSTM

In RNN, the hidden layer stateht at time t is calculated by a function f, as shown in formula (7):
(7)ht=0,t=0,fht−1,Xt,others,where xt represents the current input state and f represents a nonlinear radiation transfer function.LSTM is an improved time recursive neural network, which can effectively deal with the problem of long-term dependence in time series, so it has strong advantages in speech recognition. LSTM can effectively solve the problem that traditional RNN cannot learn long-distance dependence in the training process. LSTM contains a single memory cell unit, which will update its stored information as needed. Figure4 shows the structure of LSTM network, in which the repeated modules represent the hidden layer in each iteration.The LSTM unit at timet is composed of a group of vectors, which include an input gate it, a forgetting gate ft, an output gate ot, a memory cell ct, and a hidden state ht. The conversion equation in LSTM network is as follows:
(8)it=σWiXt+Uiht−1+bi,ft=σWfXt+Ufht−1+bf,ot=σWoXt+Uoht−1+bo,zt=thahWzXt+Uzht−1+bz,ct=it⊙zt+ft⊙ct−1,ht=ot⊙tanhct,where ⊙ represents the multiplication by element, b represents the bias vector parameter, and zt represents an update gate.Compared with unidirectional LSTM, bidirectional long short-term memory network (BLSTM) [27] uses extra backward information, which has the advantage of enhancing the memory ability of the network. The hidden state of each node in BLSTM can be calculated by the following formula.
(9)h~jl=hjl⟶⊕hjl⟵,where ⊕ represents the connection operation, and ~ represents the output of BLSTM unit.


## 3.2. Local Attention Mechanism and Global Attention Mechanism

Traditional LSTM modeling uses the last hidden state as the sequence vector or averages to get the final sequence vector. However, the importance of different words or phrases in sentences is different [28]. Therefore, we introduce local attention mechanism into BLSTM. The mechanism of local attention is shown in Figure 5.Figure 5
Local attention mechanism.For thel-th layer in the network structure, rl represents a representation vector of the input sequence, and its calculation formula is as follows:
(10)rl=∑j=1DZj⊙h~jl,where l∈1,3, Zj represents the normalized coefficient vector, and D represents the length of the input sequence.
(11)Zj=∑j=1Dexpu1lu2I⋮uDl,ujl=tanhWuh~jl+bu,where Wu and bu are parameters in the network.The higher the number of layers of the network, the less original information retained in the obtained sentence vector, and the higher the abstract level of sentence meaning. Therefore, with the different input sequences and tasks, the trust weight of each layer in the network should be different. In order to reward the layer that is more meaningful for correctly classifying labels, we introduce the global attention mechanism in the network. The global attention mechanism is shown in Figure6.Figure 6
Global attention mechanism.The principle of global attention mechanism is to give a weight to the classification probability of each layer, which represents how much probability the neural network trusts the output of this layer. The formula of global attention mechanism is as follows:(12)pl=P•xj;θ=softmaxWprl+bp,ol=tanhWgpl+bg,αl=expolTog∑lexpolTog,P=∑lαlpl,where Wp, Wg, bp, bg, and og are all parameters in the network. We can calculate an overall classification probability distribution P through the classification probability of each layer and the trust weight of each layer in the network structure.


## 3.3. A-BLSTM

The proposed A-BLSTM model is a hierarchical structure, which continuously integrates the information of each layer in a bottom-up way and finally can effectively model the combined features. The layer number of A-BLSTM is expressed byl∈0,3. For the l layer, the input hjl of the j-th node is calculated as follows:
(13)hjl=h~2jl−1⊕h~2j+1l−1,h~2jl−1=BLSTMh2jl−1,h~2j+1l−1=BLSTMh2j+1l−1,where h~2jl−1 and h~2j+1l−1 are the outputs of BLSTM unit. A word is the input of the first layer in the network structure, and then, the output of each layer recursively becomes the input of the upper layer until the top layer of the network structure.


## 4. Experiment and Result Analysis

### 4.1. Machine Translation Evaluation Index

In order to evaluate the translation effect of the model, we use BLEU (bilingual evaluation under study) [29] proposed by IBM as the evaluation index of machine translation quality. BLEU is an internationally accepted evaluation method of machine translation. This method obtains the evaluation value by calculating the similarity between machine translation results and human translation results. The higher the similarity, the higher the score, that is, the higher the translation quality. The calculation formula of BLEU value is as follows:
(14)BLEU=BP⋅exp∑n=1Nωnlogpn,where BP represents the penalty factor, N represents the total number, ωn represents the weight, and pn is the matching accuracy.
(15)BP=1,lc>ls,exp1−lslc,lc≤ls,where lc represents the length of the candidate translation and ls represents the effective length of the reference translation.


### 4.2. Experimental Data and Data Processing

The experimental data is selected from the smaller data set of International Workshop on Spoken Language Translation (IWSLT). IWSLT is the most influential oral machine translation evaluation competition in the world. IWSLT 2015 data set includes 220,000 Chinese-English parallel sentences, including one development set data dev and three test set data (test1, test2, and test3). A variety of NMT models including A-BLSTM are built on TensorFlow, a deep learning framework. Parameters related to neural network are set as shown in Table1.Table 1
Parameter settings.
Parameter typeValueGlossary size30000Word vector dimension512Number of hidden layer nodes512Number of neural network layer1, 2, 3, 4, and 5Learning rate0.1Dropout0.5Batch_size128OptimizerStochastic gradient descentDuring the experiment, firstly, preprocess the corpus: (1) segment the corpus—mainly for Chinese data, use Stanford word segmentation to divide Chinese sentences into words, as shown in Table2; (2) symbol processing of corpus—mainly for English data, use tokenizer.per, a word segmentation script in Moses system, to insert spaces between words and punctuation marks in English data, as listed in Table 3; (3) converting uppercase into lowercase in English data; and (4) select the first 30000 high-frequency words from the processed training corpus and replace the rest words with < unk >.Table 2
Examples of Chinese word segmentation.
Chinese sentence2021年初，因感染新冠病毒而死亡的人数达到最高值.After word segmentation2021 年 初， 因 感染 新冠 病毒 而 死亡 的 人数 达到 最高 值.Table 3
Examples of English symbol processing.
English sentenceAt the beginning of 2021, the number of people who died from COVID-19 reached the highest value.After symbol processingAt the beginning of 2021, the number of people who died from COVID-19 reached the highest value.


### 4.3. Function Analysis of Network Layer Number

The influence of different layer number on the A-BLSTM model in Chinese-English machine translation tasks is shown in Figure7.Figure 7
The BLEU change of translation model with one layer to five layers.
(a)(b)(c)(d)It can be seen that compared with the deeper or shallower hierarchical structure, the three-layer A-BLSTM structure has achieved the best results in both the development set and the test set. The performance of the two-layer A-BLSTM structure is poor, because only one abstract level of text vector representation can be obtained, so there is no advantage brought by applying the global attention mechanism. Generally speaking, with the increase of network layers, the network can learn more abstract semantic representation information, and the translation accuracy (BLEU value) will also be continuously improved. However, when there are too many network layers in the network structure (more than three layers), the translation accuracy will begin to decline. This is because for sequence modeling, too many layers are unnecessary, and extra noise will be introduced, which will reduce the accuracy of Chinese-English machine translation. In the follow-up experiments, A-BLSTM adopts three-layer architecture.


### 4.4. Analysis of the Effectiveness of Attention Mechanism

To illustrate the effectiveness of global attention mechanism, we compared the local attention BLSTM (LA-BLSTM) with A-BLSTM. The result of comparison between LA-BLSTM and A-BLSTM is shown in Figure8. Obviously, the performance of A-BLSTM model is better than that of LA-BLSTM, especially on test2 data set and test3 data set. The experimental results show that the global attention mechanism can accurately identify which layer of the network structure’s representation vector is more reliable for translation.Figure 8
Comparison between LA-BLSTM and A-BLSTM.


### 4.5. Performance Comparison of Translation Models

Different neural networks are used for training and testing in the translation model, and the experimental results are shown in Table4. In order to compare the translation performance of different models more intuitively, the data in Table 4 are displayed by histogram. The BLEU values of different translation models on the development set and the test set are shown in Figure 9.Table 4
Comparison of translation model performance.
Translation modelDevTest1Test2Test3RNN10.8711.6311.7912.39LSTM12.1513.8313.9914.47GRU12.1613.8514.0114.49BiGRU13.8215.4915.5816.21Attention+RNN14.7516.4116.6220.34Attention+LSTM20.7422.4722.5323.27Attention+GRU20.7722.4922.5523.31Attention+BiGRU21.8623.3723.4124.28A-BLSTM22.2723.7323.8724.48Figure 9
BLEU values of different translation models in development set and test set.From the results in Table4 and Figure 9, we can find that the attention mechanism can improve the translation performance of NMT model and the proposed A-BLSTM model structure can effectively improve the machine translation performance by modeling both short sequences and long sequences. The main reason is that the global attention mechanism can determine which layer of representation vector in the input sequence should be given more attention (weight).


## 4.1. Machine Translation Evaluation Index

In order to evaluate the translation effect of the model, we use BLEU (bilingual evaluation under study) [29] proposed by IBM as the evaluation index of machine translation quality. BLEU is an internationally accepted evaluation method of machine translation. This method obtains the evaluation value by calculating the similarity between machine translation results and human translation results. The higher the similarity, the higher the score, that is, the higher the translation quality. The calculation formula of BLEU value is as follows:
(14)BLEU=BP⋅exp∑n=1Nωnlogpn,where BP represents the penalty factor, N represents the total number, ωn represents the weight, and pn is the matching accuracy.
(15)BP=1,lc>ls,exp1−lslc,lc≤ls,where lc represents the length of the candidate translation and ls represents the effective length of the reference translation.


## 4.2. Experimental Data and Data Processing

The experimental data is selected from the smaller data set of International Workshop on Spoken Language Translation (IWSLT). IWSLT is the most influential oral machine translation evaluation competition in the world. IWSLT 2015 data set includes 220,000 Chinese-English parallel sentences, including one development set data dev and three test set data (test1, test2, and test3). A variety of NMT models including A-BLSTM are built on TensorFlow, a deep learning framework. Parameters related to neural network are set as shown in Table1.Table 1
Parameter settings.
Parameter typeValueGlossary size30000Word vector dimension512Number of hidden layer nodes512Number of neural network layer1, 2, 3, 4, and 5Learning rate0.1Dropout0.5Batch_size128OptimizerStochastic gradient descentDuring the experiment, firstly, preprocess the corpus: (1) segment the corpus—mainly for Chinese data, use Stanford word segmentation to divide Chinese sentences into words, as shown in Table2; (2) symbol processing of corpus—mainly for English data, use tokenizer.per, a word segmentation script in Moses system, to insert spaces between words and punctuation marks in English data, as listed in Table 3; (3) converting uppercase into lowercase in English data; and (4) select the first 30000 high-frequency words from the processed training corpus and replace the rest words with < unk >.Table 2
Examples of Chinese word segmentation.
Chinese sentence2021年初，因感染新冠病毒而死亡的人数达到最高值.After word segmentation2021 年 初， 因 感染 新冠 病毒 而 死亡 的 人数 达到 最高 值.Table 3
Examples of English symbol processing.
English sentenceAt the beginning of 2021, the number of people who died from COVID-19 reached the highest value.After symbol processingAt the beginning of 2021, the number of people who died from COVID-19 reached the highest value.


## 4.3. Function Analysis of Network Layer Number

The influence of different layer number on the A-BLSTM model in Chinese-English machine translation tasks is shown in Figure7.Figure 7
The BLEU change of translation model with one layer to five layers.
(a)(b)(c)(d)It can be seen that compared with the deeper or shallower hierarchical structure, the three-layer A-BLSTM structure has achieved the best results in both the development set and the test set. The performance of the two-layer A-BLSTM structure is poor, because only one abstract level of text vector representation can be obtained, so there is no advantage brought by applying the global attention mechanism. Generally speaking, with the increase of network layers, the network can learn more abstract semantic representation information, and the translation accuracy (BLEU value) will also be continuously improved. However, when there are too many network layers in the network structure (more than three layers), the translation accuracy will begin to decline. This is because for sequence modeling, too many layers are unnecessary, and extra noise will be introduced, which will reduce the accuracy of Chinese-English machine translation. In the follow-up experiments, A-BLSTM adopts three-layer architecture.


## 4.4. Analysis of the Effectiveness of Attention Mechanism

To illustrate the effectiveness of global attention mechanism, we compared the local attention BLSTM (LA-BLSTM) with A-BLSTM. The result of comparison between LA-BLSTM and A-BLSTM is shown in Figure8. Obviously, the performance of A-BLSTM model is better than that of LA-BLSTM, especially on test2 data set and test3 data set. The experimental results show that the global attention mechanism can accurately identify which layer of the network structure’s representation vector is more reliable for translation.Figure 8
Comparison between LA-BLSTM and A-BLSTM.


## 4.5. Performance Comparison of Translation Models

Different neural networks are used for training and testing in the translation model, and the experimental results are shown in Table4. In order to compare the translation performance of different models more intuitively, the data in Table 4 are displayed by histogram. The BLEU values of different translation models on the development set and the test set are shown in Figure 9.Table 4
Comparison of translation model performance.
Translation modelDevTest1Test2Test3RNN10.8711.6311.7912.39LSTM12.1513.8313.9914.47GRU12.1613.8514.0114.49BiGRU13.8215.4915.5816.21Attention+RNN14.7516.4116.6220.34Attention+LSTM20.7422.4722.5323.27Attention+GRU20.7722.4922.5523.31Attention+BiGRU21.8623.3723.4124.28A-BLSTM22.2723.7323.8724.48Figure 9
BLEU values of different translation models in development set and test set.From the results in Table4 and Figure 9, we can find that the attention mechanism can improve the translation performance of NMT model and the proposed A-BLSTM model structure can effectively improve the machine translation performance by modeling both short sequences and long sequences. The main reason is that the global attention mechanism can determine which layer of representation vector in the input sequence should be given more attention (weight).


## 5. Conclusions

This paper proposes a neural machine translation model, A-BLSTM, which integrates attention mechanism. A hierarchical structure is adopted to represent the input sequence as a multilayer representation vector instead of a single fixed-length representation vector. The introduction of local attention mechanism can effectively select words or phrases with large amount of information in the input sequence. The introduction of global attention mechanism can effectively select a more credible intermediate representation vector. Experimental results show that the A-BLSTM model has achieved relatively high BLEU values in both Chinese and English machine translation tasks, which has surpassed other existing neural machine translation models. Subsequently, we will try to use quantum weak measurement to simulate the reader’s understanding of sentences from the perspective of quantum cognition, so as to further improve the translation performance.



---

*Source: 5199248-2022-03-17.xml*