# Neural Linguistic Steganalysis via Multi-Head Self-Attention

Authors: Sai-Mei Jiao; Hai-feng Wang; Kun Zhang; Ya-qi Hu
Journal: Journal of Electrical and Computer Engineering
 (2021)

---

## Abstract

Linguistic steganalysis can indicate the existence of steganographic content in suspicious text carriers. Precise linguistic steganalysis on suspicious carrier is critical for multimedia security. In this paper, we introduced a neural linguistic steganalysis approach based on multi-head self-attention. In the proposed steganalysis approach, words in text are firstly mapped into semantic space with a hidden representation for better modeling the semantic features. Then, we utilize multi-head self-attention to model the interactions between words in carrier. Finally, a softmax layer is utilized to categorize the input text as cover or stego. Extensive experiments validate the effectiveness of our approach.


---

## Body

## 1. Introduction

Steganography is an ancient technique aiming at embedding secret messages into carriers which can be divided into image steganography [1], text steganography [2], and audio steganography [3] according to the different types of carriers. On the contrary, steganalysis mainly focuses on how to detect hidden messages in suspicious carriers.Text steganography is the process of embedding secret data through a cover text so that the existence of the data is invisible/undetectable for adversaries or casual viewers. It has been widely considered as an attractive technology to improve the use of conventional cryptography algorithms in the area of multimedia security by concealing a secret message/watermark into a cover text file/message to protect confidential information. However, this technology can also be used by terrorists and other criminals for malicious purposes, which poses great threats to security in cyberspace. Besides, text steganography technology has been significantly changed with the significant development of natural language processing technology. Thus, it is crucial to propose a linguistic steganalysis approach with most recent technologies.Traditional linguistic steganalysis always firstly extracts statistical features from the carrier directly and then conducts the following classification procedure. For example, Taskiran et al. [4] distinguished cover and stego text based on a 3-gram language model as the feature and used Support Vector Machine (SVM) for classification. Chen et al. [5] proposed a steganalysis scheme (NFZ-WDA) to model the language structure based on the word distribution in different natural frequency zones. The authors in [6] utilized the meta features which included word frequency, word length, and space rate and immune mechanism to select the proper features. The main difficulties of previous approach are that they always need related domain knowledge and the generalized performance to the proposed latest text steganography is very limited.Zuo et al. [7] firstly proposed word embedding feature which can better exploit semantic and statistical distortion in linguistic steganography. Many other neural steganalysis approaches are based on CNNs and RNNs or their combination [8]. Although being studied, precise linguistic steganalysis still remains an unsolved problem.Our work is motivated by the observation that the interactions between words in text are important for steganalysis and multi-head self-attention has great potential to model these interactions [9, 10]. Thus, we propose a neural steganalysis approach with multi-head self-attention. In the proposed approach, a hidden representation layer is utilized to mapping words in text into semantic space for better exploitation of the semantic features. Secondly, we utilized multi-head self-attention to exploit the relationships between different words in a text, which is crucial in linguistic steganalysis. Finally, we concatenated the representation from words and the calibration representation from multi-head self-attention for further classification. The softmax layer is used to categorize the text into “cover” or “stego.” Experiments validate the effectiveness of the proposed approach.The contribution of our work is as follows. (1) As far as we know, we are the first to propose an approach based on attention mechanism to model and extract correlation features in linguistic steganalysis. (2) Experiments show that the proposed steganalysis method achieves excellent performance in detecting generative linguistic steganography.The content of the paper is divided into four parts. Section2 describes many details of the proposed linguistic steganalysis approach based on multi-head self-attention. Section 3 introduces the experimental results, and model is discussed in this part. Finally, concluding remarks and future works are given in Section 4.


## 2. Proposed Approach

The architecture of the proposed linguistic steganalysis approach is shown in Figure1. It contains three major modules, i.e., text representation, carrier encoder, and carrier prediction. Detailed analyses on different components of the proposed architecture are presented in the subsequent subsections.Figure 1
Structure of proposed linguistic steganalysis approach.


### 2.1. Text Representation

The core of text representation is word embedding, which is used to convert a text carrier from a sequence of words into a sequence of low-dimensional embedding vectors. Denote a suspicious carrier text withM words as w1,w2,…,wM. Through this layer it is converted into a vector sequence e1,e2,…,eM. Besides, in order to provide more position information of words in text for the approach, we added a position embedding vector to word embedding sequence, and thus get a new word representation sequence h1,h2,…,hM.In the carrier encoder layer, we adopt multi-head self-attention [9] which has recently achieved remarkable performances in modeling complicated relations between context words. Taking the m-th word representation feature hm as an example, we will explain how to identify multiple meaningful correlation features involving feature hm based on such a mechanism. At first, we define the correlation between feature hm and feature hk under a specific attention head i as follows:(1)αm,ki=expφihm,hk∑l=1Mexpφihm,hl,where φi·,· is an attention function which defines the correlation between feature hm and feature hk. The attention functions have many different forms and most of them are neural networks. In our case, we adopted the widely used form inner product, which can be formularized as follows:(2)φihm,hk=Wqueryihm,Wkeyihk,where Wqueryi,Wkeyi∈Rd×d′ are transformation matrices which map the original embedding space Rd into a new semantic space Rd′.After getting these correlation coefficients, we recalibrate representation of featurehm in subspace i by combining all relevant features guided by coefficients αm,ki:(3)h^mi=∑k=1Mαm,kiWvalueihk,where Wvaluei∈Rd×d′ and M is the text length. Since h^mi∈Rd′ is a combination of feature hm and its relevant features under head h, it represents a new combinatorial feature learned by our method. The multi-head representation h^ of the i-th word is the concatenation of the representations produced by H separate self-attention heads, i.e., h^m1;h^m2;…;h^mH.An interesting intuition is that utilizing more different levels of features may boost the performance, and inspired by the residual connection structure in ResNet [11], we concatenate features from calibration representation h^ and the origin word representation h in concatenation layers. The final feature vector r in these layers can be formulated as follows:(4)r=h^;h,where r was taken as the text representation for the proposed linguistic steganalysis problem. Then, global average pooling is utilized to reduce dimension of features because the dimension of r is very high which may lead the model under the risk of overfitting. After that, the pooling features were fed in to a classification layer for the model to generate the probability distribution and give an indicator over the label set.


### 2.2. Carrier Prediction

The main focus of the carrier prediction module is to categorize whether a text belongs to “cover” or “stego.” The prediction layer is composed of two dense layers with ReLU and sigmoid activation functions, and the layer can be formulated as(5)T=σw∗r+b,where σx=1/1+e−x, w and b are parameters and bias terms of linear transformation. Finally, the suspicious text belonging to “stego” cover was reflected by output value T which is a probability. A prediction label can be finally determined by a threshold, which can be formulated by following equation:(6)y^=1,T≥threshold,0,T<threshold.


### 2.3. Training Framework

Optimization of proposed approach is based on a supervised learning framework. Loss function of the network is cross entropy error loss. Parameters in the proposed model are updated by the back propagation. The gradient of the procedure is computed by minimizing the cross entropy loss, and the procedure can be formulated as follows:(7)L=−1N∑i=1Nyilogy^i+1−yilog1−y^i.Moreover, in order to mitigate the overfitting issue, we applied batch normalization [12] and dropout technique [13] to regularize the proposed model.


## 2.1. Text Representation

The core of text representation is word embedding, which is used to convert a text carrier from a sequence of words into a sequence of low-dimensional embedding vectors. Denote a suspicious carrier text withM words as w1,w2,…,wM. Through this layer it is converted into a vector sequence e1,e2,…,eM. Besides, in order to provide more position information of words in text for the approach, we added a position embedding vector to word embedding sequence, and thus get a new word representation sequence h1,h2,…,hM.In the carrier encoder layer, we adopt multi-head self-attention [9] which has recently achieved remarkable performances in modeling complicated relations between context words. Taking the m-th word representation feature hm as an example, we will explain how to identify multiple meaningful correlation features involving feature hm based on such a mechanism. At first, we define the correlation between feature hm and feature hk under a specific attention head i as follows:(1)αm,ki=expφihm,hk∑l=1Mexpφihm,hl,where φi·,· is an attention function which defines the correlation between feature hm and feature hk. The attention functions have many different forms and most of them are neural networks. In our case, we adopted the widely used form inner product, which can be formularized as follows:(2)φihm,hk=Wqueryihm,Wkeyihk,where Wqueryi,Wkeyi∈Rd×d′ are transformation matrices which map the original embedding space Rd into a new semantic space Rd′.After getting these correlation coefficients, we recalibrate representation of featurehm in subspace i by combining all relevant features guided by coefficients αm,ki:(3)h^mi=∑k=1Mαm,kiWvalueihk,where Wvaluei∈Rd×d′ and M is the text length. Since h^mi∈Rd′ is a combination of feature hm and its relevant features under head h, it represents a new combinatorial feature learned by our method. The multi-head representation h^ of the i-th word is the concatenation of the representations produced by H separate self-attention heads, i.e., h^m1;h^m2;…;h^mH.An interesting intuition is that utilizing more different levels of features may boost the performance, and inspired by the residual connection structure in ResNet [11], we concatenate features from calibration representation h^ and the origin word representation h in concatenation layers. The final feature vector r in these layers can be formulated as follows:(4)r=h^;h,where r was taken as the text representation for the proposed linguistic steganalysis problem. Then, global average pooling is utilized to reduce dimension of features because the dimension of r is very high which may lead the model under the risk of overfitting. After that, the pooling features were fed in to a classification layer for the model to generate the probability distribution and give an indicator over the label set.


## 2.2. Carrier Prediction

The main focus of the carrier prediction module is to categorize whether a text belongs to “cover” or “stego.” The prediction layer is composed of two dense layers with ReLU and sigmoid activation functions, and the layer can be formulated as(5)T=σw∗r+b,where σx=1/1+e−x, w and b are parameters and bias terms of linear transformation. Finally, the suspicious text belonging to “stego” cover was reflected by output value T which is a probability. A prediction label can be finally determined by a threshold, which can be formulated by following equation:(6)y^=1,T≥threshold,0,T<threshold.


## 2.3. Training Framework

Optimization of proposed approach is based on a supervised learning framework. Loss function of the network is cross entropy error loss. Parameters in the proposed model are updated by the back propagation. The gradient of the procedure is computed by minimizing the cross entropy loss, and the procedure can be formulated as follows:(7)L=−1N∑i=1Nyilogy^i+1−yilog1−y^i.Moreover, in order to mitigate the overfitting issue, we applied batch normalization [12] and dropout technique [13] to regularize the proposed model.


## 3. Experiments and Analysis

### 3.1. Dataset and Experimental Settings

A linguistic stegosystem was firstly constructed based on the proposed approach in [14] for the purpose of evaluating the performance of the proposed approach. Three large-scale text datasets containing the most common text media on the Internet are taken as our training sets, which are Twitter [15], Movie reviews [16], and News to train the Linguistic stegosystem.Then, we utilized the linguistic stegosystem to construct our own steganalysis dataset. 10000 stego samples were generated and 10000 nature texts were randomly chosen in each dataset as our dataset to conduct steganalysis. Note that sentences for different types of text with different embedding rates are different.The cross validation process in the validation set determined the hyperparameters in the proposed model. Specifically, the number of heads in multi-head self-attention is 8. The embedding sized is 256. The dimension of fully connected layer in classification layer is 100. The detection threshold is set as 0.5. Optimization method in the training process is Adam [17], where the learning rates were initially set as 0.001, dropout rate was set as 0.9, and the batch size was set as 256.


### 3.2. Evaluation Metrics

Several evaluation metrics commonly used in classification tasks were utilized to evaluate the performance of proposed model, including accuracy (Acc), precision (P), recall (R), and F1 score. The definition of metrics is formularized as follows:(8)accuracy=TP+FNTP+FP+TN+FN,(9)precision=TPTP+FP,(10)recall=TPTP+TN,where TP (true positive) represents the number of positive samples that are predicted to be positive by the approach, FN (false negative) illustrates the number of positive samples predicted to be negative, TN (true negative) represents the number of negative samples predicted to be negative, FP (false positive) indicates the number of negative samples predicted to be positive, and F1 score is the harmonic mean of the precision and recall.


### 3.3. Performance Evaluation

Several different representative steganalysis algorithms were chosen as our baseline models [18–21] to validate the performance of proposed model.The results of the comparison is shown in Table1. From the results, we can conclude that compared to other linguistic steganalysis methods, the proposed model has achieved the best detection performance on various metrics, including different text formats and different embedding rates. We can also observe that different datasets have different linguistic steganalysis performances. This may be because of different text lengths in different datasets. Longer texts may have more clues for steganalysis which lead to higher detection accuracy. Besides, we also noticed that the detection performance of steganographic text will increase with the increase of steganographic information in generated texts. One of the explanations of the phenomenon is that once more information is embedded in texts, the distortion of the generated texts will decrease, which will damage the coherence of text semantics and give more steganalysis clues.Table 1
Detection accuracy with previous linguistic steganalysis methods.
Method[18][19][20][21]OursFormatbpwAccPRAccPRAccPRAccPRAccPRNews10.5320.5170.3820.7630.7390.8120.8400.8690.8010.8580.8580.8580.9130.9300.89420.5130.5350.2040.7860.7620.8320.8350.8670.7910.8640.9150.8030.9200.9230.91630.5970.6790.3670.8240.7670.9310.8970.9090.8820.9200.9220.9180.9620.9660.95840.7550.8310.6400.8590.7970.9620.9380.9620.9110.9610.9790.9420.9730.9810.96650.8470.9180.7610.8810.8290.9590.9610.9760.9450.9730.9880.9580.9850.9830.987IMDB10.5770.6420.3450.7670.7790.7440.7870.8290.7220.8450.9410.7360.9010.9530.84420.7130.8070.5600.8490.9340.8710.8690.9110.8180.9180.9470.8860.9570.9720.94030.8400.9250.7410.900.8770.9310.9160.9440.8850.9410.9500.9320.9660.9830.94940.9090.9690.8450.9370.9050.9750.9620.9750.9470.9760.9860.9660.9870.9900.98350.9090.9890.8280.9290.9210.9400.9770.9870.9660.9900.9880.9920.9950.9960.993Twitter10.5380.5200.3870.6540.6520.6580.6650.6640.6700.7450.8110.6210.7860.8730.65720.5440.5230.3990.7450.7620.7120.7500.8270.6310.7930.9140.6470.8340.8830.77030.5770.6690.3030.8090.7980.8260.8340.8890.7640.8790.9390.8120.9080.9500.86140.7290.8360.5700.8420.8240.8710.8850.9500.8130.9340.9880.8790.9430.9860.89950.8500.9160.7700.8510.8390.8700.8990.9610.8320.9210.9600.8790.9360.9580.911We also conducted multi-classification experiments in the dataset which can be taken as embedded rate estimation task [22] where we mixed the texts at various embedding rates, i.e., bpw = 0, 1, 2, 3, 4, 5. The experimental results are shown in Table 2. From Table 2, we can see that our model can also outperform all the base models.Table 2
The results of embedded rate estimation experiments.
Method[18][19][20][21]OursFormatPRF1PRF1PRF1PRF1PRF1News0.4450.3960.4200.7010.7060.7030.7450.7410.7430.8170.8100.8110.8720.8700.871IMDB0.4900.5120.5010.7420.7450.7430.7670.7600.7630.8480.8420.8430.8790.8730.873Twitter0.4170.3630.3030.6200.6200.6200.6380.6150.6260.7500.7050.7120.8000.7580.766


## 3.1. Dataset and Experimental Settings

A linguistic stegosystem was firstly constructed based on the proposed approach in [14] for the purpose of evaluating the performance of the proposed approach. Three large-scale text datasets containing the most common text media on the Internet are taken as our training sets, which are Twitter [15], Movie reviews [16], and News to train the Linguistic stegosystem.Then, we utilized the linguistic stegosystem to construct our own steganalysis dataset. 10000 stego samples were generated and 10000 nature texts were randomly chosen in each dataset as our dataset to conduct steganalysis. Note that sentences for different types of text with different embedding rates are different.The cross validation process in the validation set determined the hyperparameters in the proposed model. Specifically, the number of heads in multi-head self-attention is 8. The embedding sized is 256. The dimension of fully connected layer in classification layer is 100. The detection threshold is set as 0.5. Optimization method in the training process is Adam [17], where the learning rates were initially set as 0.001, dropout rate was set as 0.9, and the batch size was set as 256.


## 3.2. Evaluation Metrics

Several evaluation metrics commonly used in classification tasks were utilized to evaluate the performance of proposed model, including accuracy (Acc), precision (P), recall (R), and F1 score. The definition of metrics is formularized as follows:(8)accuracy=TP+FNTP+FP+TN+FN,(9)precision=TPTP+FP,(10)recall=TPTP+TN,where TP (true positive) represents the number of positive samples that are predicted to be positive by the approach, FN (false negative) illustrates the number of positive samples predicted to be negative, TN (true negative) represents the number of negative samples predicted to be negative, FP (false positive) indicates the number of negative samples predicted to be positive, and F1 score is the harmonic mean of the precision and recall.


## 3.3. Performance Evaluation

Several different representative steganalysis algorithms were chosen as our baseline models [18–21] to validate the performance of proposed model.The results of the comparison is shown in Table1. From the results, we can conclude that compared to other linguistic steganalysis methods, the proposed model has achieved the best detection performance on various metrics, including different text formats and different embedding rates. We can also observe that different datasets have different linguistic steganalysis performances. This may be because of different text lengths in different datasets. Longer texts may have more clues for steganalysis which lead to higher detection accuracy. Besides, we also noticed that the detection performance of steganographic text will increase with the increase of steganographic information in generated texts. One of the explanations of the phenomenon is that once more information is embedded in texts, the distortion of the generated texts will decrease, which will damage the coherence of text semantics and give more steganalysis clues.Table 1
Detection accuracy with previous linguistic steganalysis methods.
Method[18][19][20][21]OursFormatbpwAccPRAccPRAccPRAccPRAccPRNews10.5320.5170.3820.7630.7390.8120.8400.8690.8010.8580.8580.8580.9130.9300.89420.5130.5350.2040.7860.7620.8320.8350.8670.7910.8640.9150.8030.9200.9230.91630.5970.6790.3670.8240.7670.9310.8970.9090.8820.9200.9220.9180.9620.9660.95840.7550.8310.6400.8590.7970.9620.9380.9620.9110.9610.9790.9420.9730.9810.96650.8470.9180.7610.8810.8290.9590.9610.9760.9450.9730.9880.9580.9850.9830.987IMDB10.5770.6420.3450.7670.7790.7440.7870.8290.7220.8450.9410.7360.9010.9530.84420.7130.8070.5600.8490.9340.8710.8690.9110.8180.9180.9470.8860.9570.9720.94030.8400.9250.7410.900.8770.9310.9160.9440.8850.9410.9500.9320.9660.9830.94940.9090.9690.8450.9370.9050.9750.9620.9750.9470.9760.9860.9660.9870.9900.98350.9090.9890.8280.9290.9210.9400.9770.9870.9660.9900.9880.9920.9950.9960.993Twitter10.5380.5200.3870.6540.6520.6580.6650.6640.6700.7450.8110.6210.7860.8730.65720.5440.5230.3990.7450.7620.7120.7500.8270.6310.7930.9140.6470.8340.8830.77030.5770.6690.3030.8090.7980.8260.8340.8890.7640.8790.9390.8120.9080.9500.86140.7290.8360.5700.8420.8240.8710.8850.9500.8130.9340.9880.8790.9430.9860.89950.8500.9160.7700.8510.8390.8700.8990.9610.8320.9210.9600.8790.9360.9580.911We also conducted multi-classification experiments in the dataset which can be taken as embedded rate estimation task [22] where we mixed the texts at various embedding rates, i.e., bpw = 0, 1, 2, 3, 4, 5. The experimental results are shown in Table 2. From Table 2, we can see that our model can also outperform all the base models.Table 2
The results of embedded rate estimation experiments.
Method[18][19][20][21]OursFormatPRF1PRF1PRF1PRF1PRF1News0.4450.3960.4200.7010.7060.7030.7450.7410.7430.8170.8100.8110.8720.8700.871IMDB0.4900.5120.5010.7420.7450.7430.7670.7600.7630.8480.8420.8430.8790.8730.873Twitter0.4170.3630.3030.6200.6200.6200.6380.6150.6260.7500.7050.7120.8000.7580.766


## 4. Conclusions

Precise linguistic steganalysis on suspicious carrier is critical for multimedia security. In this paper, we introduced a neural linguistic steganalysis approach based on multi-head self-attention. In the proposed approach, words in text are firstly mapped into semantic space with a hidden representation for better exploitation of the semantic features. Then, we utilize multi-head self-attention to model the interactions between words in carrier. Finally, a softmax layer is utilized to categorize the input text as cover or stego. Extensive experiments validate the effectiveness of our approach. In the future, we will construct more general steganalysis approach to detect more linguistic steganography.



---

*Source: 6668369-2021-04-19.xml*