Original: T EXT S HIELD : B EYOND S UCCESSFULLY D ETECTING A DVERSARIAL S ENTENCES Anonymous authors Paper under double-blind review
Revised: T EXT S HIELD : B EYOND S UCCESSFULLY D ETECTING A DVERSARIAL S ENTENCES IN TEXT CLASSIFICATION

Original: A BSTRACT
Revised: A BSTRACT

Original: Adversarial attack serves as a major challenge for neural network models in NLP, which precludes the model’s deployment in safety-critical applications.
Revised: Adversarial attack serves as a major challenge for neural network models in NLP, which precludes the model’s deployment in safety-critical applications.

Original: A recent line of work, detection-based defense, aims to distinguish adversarial sentences from benign ones.
Revised: A recent line of work, detection-based defense, aims to distinguish adversarial sentences from benign ones.

Original: However, there remains a significant gap between successfully detecting adversarial sentences and correctly classifying adversarial sentences for a specific application.
Revised: However, the core limitation of previous detection methods is being incapable of giving correct predictions on adversarial sentences unlike defense methods from other paradigms.

Original: To mitigate such a huge gap, this paper proposes TextShield: (1) we discover a link between text attack and saliency information, and then we propose a saliency-based detector, which can effectively detect whether an input sentence is adversarial or not.
Revised: To solve this issue, this paper proposes TextShield: (1) we discover a link between text attack and saliency information, and then we propose a saliency-based detector, which can effectively detect whether an input sentence is adversarial or not.

Original: (2) We design a saliencybased corrector, which converts the detected adversary sentences to benign ones.
Revised: (2) We design a saliencybased corrector, which converts the detected adversary sentences to benign ones.

Original: By combining the saliency-based detector and corrector, TextShield extends the detection-only paradigm to a detection-correction paradigm, thus filling the gap in the existing detection-based defense.
Revised: By combining the saliency-based detector and corrector, TextShield extends the detection-only paradigm to a detection-correction paradigm, thus filling the gap in the existing detection-based defense.

Original: Comprehensive experiments show that (a)
Revised: Comprehensive experiments show that (a)

Original: TextShield consistently achieves higher or comparable performance than state-ofthe-art defense methods across various attacks on different benchmarks.
Revised: TextShield consistently achieves higher or comparable performance than state-ofthe-art defense methods across various attacks on different benchmarks.

Original: (b) our saliency-based detector outperforms existing detectors for detecting adversarial sentences.
Revised: (b) our saliency-based detector outperforms existing detectors for detecting adversarial sentences.

Original:  I NTRODUCTION
Revised:  I NTRODUCTION

Original: Deep Neural Networks (DNNs) have obtained great progress in the field of natural language processing (NLP) but are vulnerable to adversarial attacks, leading to security and safety concerns, and research on defense algorithms against such attacks is urgently needed.
Revised: Deep Neural Networks (DNNs) have obtained great progress in the field of natural language processing (NLP) but are vulnerable to adversarial attacks, leading to security and safety concerns, and research on defense algorithms against such attacks is urgently needed.

Original: Specifically, the most common attack for NLP is word-level attack (Wang et al., 2019a; Garg & Ramakrishnan, 2020; Zang et al., 2020; Li et al., 2021), which is usually implemented by adding, deleting or substituting words within a sentence.
Revised: Specifically, the most common attack for NLP is word-level attack (Wang et al., 2019b; Garg & Ramakrishnan, 2020; Zang et al., 2020; Li et al., 2021), which is usually implemented by adding, deleting or substituting words within a sentence.

Original: Such an attack often brings catastrophic performance degradation to DNN-based models.
Revised: Such an attack often brings catastrophic performance degradation to DNN-based models.

Original: Therefore, we choose to study defending against word-level attacks 1 in this paper.
Revised: Therefore, we choose to study defending against word-level attacks 1 in this paper.

Original: Although a number of defense methods can be found in the literature of NLP (Jia et al., 2019; Ko et al., 2019; Jones et al., 2020; Wang et al., 2020b; Zhou et al., 2021; Dong et al., 2021; Bao et al., 2021), there are remaining several unsolved research problems.
Revised: Although a number of defense methods can be found in the literature of NLP (Jia et al., 2019; Ko et al., 2019; Jones et al., 2020; Wang et al., 2020b; Zhou et al., 2021; Dong et al., 2021; Bao et al., 2021), there are remaining several unsolved research problems.

Original: One problem lies in the ineffective application of the existing detection-based defense paradigm to the adversarial defense scenario, which consists of two steps: adversarial detection that detects whether an input sentence is adversarial or not, and a model prediction that predicts a label for the input.
Revised: One problem lies in the ineffective application of the existing detection-based defense paradigm to the adversarial defense scenario, which consists of two steps: adversarial detection that detects whether an input sentence is adversarial or not, and a model prediction that predicts a label for the input.

Original: Notice that the model prediction is usually specific for a practical application, e.g., different text classification tasks used in this paper.
Revised: Notice that the model prediction is usually specific for a practical application, e.g., different text classification tasks used in this paper.

Original: However, the detection-based defense paradigm only focuses on adversarial detection and does not make efforts to adversarial sentence prediction.
Revised: However, the detection-based defense paradigm only focuses on adversarial detection and does not make efforts to adversarial sentence prediction.

Original: That is, even if adversarial detection can successfully detect adversarial sentences, correctly predicting such adversaries remains incapable.
Revised: That is, even if adversarial detection can successfully detect adversarial sentences, correctly predicting such adversaries remains incapable.

Original: Considering that an adversarial sentence is usually generated through adding an imperceptible perturbation into a benign sentence, we believe a practical defense paradigm should have another operation, a correction that transforms the adversarial sentence into the benign sentence as much as possible, and then use the corrected adversarial sentence for the model prediction.
Revised: Considering that an adversarial sentence is usually generated through adding an imperceptible perturbation into a benign sentence, we believe a practical defense paradigm should have another operation, a correction that transforms the adversarial sentence into the benign sentence as much as possible, and then use the corrected adversarial sentence for the model prediction.

Original: Therefore, considering the paradigm problem, we propose a detection-correction defense method in this paper.
Revised: Therefore, considering the paradigm problem, we propose a detection-correction defense method in this paper.

Original: Another problem is that most existing defense methods rely either on word frequency or on prediction logits to detect adversarial sentences (Mozes et al., 2021; Mosca et al., 2022).
Revised: Another problem is that most existing defense methods rely either on word frequency or on prediction logits to detect adversarial sentences (Mozes et al., 2021; Mosca et al., 2022).

Original: One may wonder whether any other information can be leveraged for adversarial detection.
Revised: One may wonder whether any other information can be leveraged for adversarial detection.

Original: In this paper, we discover that the mechanism of text attack is related to saliency, a measure used in the explainability of DNNs (Simonyan et al., 2013).
Revised: In this paper, we discover that the mechanism of text attack is related to saliency, a measure used in the explainability of DNNs (Simonyan et al., 2013).

Original: Based on such discovery, we propose the saliency-based detector to enhance adversarial detection.
Revised: Based on such discovery, we propose the saliency-based detector to enhance adversarial detection.

Original: Overall, to address the two issues, in this paper, we build our TextShield, a defense method consisting of a detector and a corrector.
Revised: Overall, to address the two issues, in this paper, we build our TextShield, a defense method consisting of a detector and a corrector.

Original: Motivated by the link between adversarial sentence and saliency, we define a metric called adaptive word importance (AWI) based on saliency computation (Simonyan et al., 2013), and then design the detector and corrector based on AWI.
Revised: Motivated by the link between adversarial sentence and saliency, we define a metric called adaptive word importance (AWI) based on saliency computation (Simonyan et al., 2013), and then design the detector and corrector based on AWI.

Original: Specifically, the detector combines four saliency-based sub-detectors to inform whether an input sentence is adversarial,
Revised: Specifically, the detector combines four saliency-based sub-detectors to inform whether an input sentence is adversarial,

Original: where the four sub-detector utilize four saliency computation methods (Simonyan et al., 2013; Springenberg et al., 2015; Bach et al., 2015; Sundararajan et al., 2017) to calculate AWI, respectively.
Revised: where the four sub-detector utilize four saliency computation methods (Simonyan et al., 2013; Springenberg et al., 2015; Bach et al., 2015; Sundararajan et al., 2017) to calculate AWI, respectively.

Original: Then, if the detector recognizes the input as adversarial, the corrector rectifies the words with high adversarial probabilities in the sentence by their high-frequency synonyms, where the adversarial probability is determined by AWI.
Revised: Then, if the detector recognizes the input as adversarial, the corrector rectifies the words with high adversarial probabilities in the sentence by their high-frequency synonyms, where the adversarial probability is determined by AWI.

Original: Finally, the corrected sentence is used for model prediction.
Revised: Finally, the corrected sentence is used for model prediction.

Original: Our extensive experiments demonstrate that TextShield can effectively defend against adversarial attacks on several text classification benchmarks.
Revised: Our extensive experiments demonstrate that TextShield can effectively defend against adversarial attacks on several text classification benchmarks.

Original: Our main contribution can be summarized as follows:
Revised: Our main contribution are listed as follows:

Original: • We design a defense method, TextShield, which extends the existing detection-based defense paradigm to the detection-correction paradigm.
Revised: • We design a defense method, TextShield, which extends the existing detection-based defense paradigm to the detection-correction paradigm.

Original: The incorporation of a corrector in TextShield can resolve the model prediction incapability problem in detection-based defense.
Revised: The incorporation of a corrector in TextShield can resolve the model prediction incapability problem in detection-based defense.

Original: • We discover another word-level information for detecting adversarial sentences, saliency, and then design a detector based on adaptive word importance (AWI), a novel metric based on saliency computation.
Revised: • We discover another word-level information for detecting adversarial sentences, saliency, and then design a detector based on adaptive word importance (AWI), a novel metric based on saliency computation.

Original: Furthermore, AWI is also used to design the corrector.
Revised: Furthermore, AWI is also used to design the corrector.

Original: • Comprehensive experiments demonstrate that our TextShield performs comparably or better than SoTA defense methods under various victim classifiers on several text classification benchmarks
Revised: • Comprehensive experiments demonstrate that our TextShield performs comparably or better than SoTA defense methods under various victim classifiers on several text classification benchmarks.

Original:  R ELATED W ORK
Revised:  R ELATED W ORK

Original: In recent years, many adversarial attack methods have been proposed for NLP, which try to modify the text data while making them less perceptible by humans.
Revised: In recent years, many adversarial attack methods have been proposed for NLP, different from backdoor attacks Chen et al. ; Liu et al. ; Wang et al. (2019a)

Revised: ; Li et al.

Original:  Coarsely, these attacks modifies the text data at character level (Belinkov & Bisk, 2018;
Revised: (2020c) ; Shen et al. (2022a), adversarial attacks try to modify the text data while making them less perceptible by humans. Coarsely, these attacks modifies the text data at character level (Belinkov & Bisk, 2018;

Original: Eger et al., 2019;
Revised: Eger et al., 2019;

Original: He et al., 2021), word level (Alzantot et al., 2018; Zhang et al., 2021; Wang et al., 2022) or sentence level (Jia & Liang, 2017; Ribeiro et al., 2018; Zhang et al., 2019b; Lin et al., 2021).
Revised: He et al., 2021), word level (Alzantot et al., 2018; Zhang et al., 2021; Wang et al., 2022) or sentence level (Jia & Liang, 2017; Ribeiro et al., 2018; Zhang et al., 2019b; Lin et al., 2021).

Original: Since word-level text attack is the most common and effective attack for text classification, in this paper, we focus on defense methods against wordlevel text attacks, which can be categorized into three paradigms: (1) model-enhancement-based, (2) certified-robustness-based, and (3) detection-based.
Revised: Since word-level text attack is the most common and effective attack for text classification, in this paper, we focus on defense methods against word-level text attacks, which can be categorized into three paradigms: (1) model-enhancement-based, (2) certified-robustness-based, and (3) detection-based.

Original: Model enhancement is a popular way to improvethe model’s robustness against text attacks, and one popular way is adversarial training which re-trains a victim model with additional adversarial examples to obtain an enhanced model.
Revised: Model enhancement is a common way to improve model’s robustness against text attacks, and one popular way is adversarial training which re-trains a victim model with extra adversarial examples to obtain an enhanced model.

Original: Alzantot et al.
Revised: Alzantot et al.

Original: and Ren et al.
Revised: ; Ren et al.

Original: (2019) generated adversarial examples by an attack method and re-trained models more robust against the attack.
Revised: (2019) generated adversarial examples by an attack method and re-trained models more robust against the attack.

Original: More successful defense based on model enhancement can be regarded as synonym encoding (Le et al., 2021; Dong et al., 2021; Wang et al., 2021a), a series of methods against text attacks through setting the same embedding for different synonyms.
Revised: More successful defense based on model enhancement can be regarded as synonym encoding (Le et al., 2021; Dong et al., 2021; Wang et al., 2021a), a series of methods defend text attacks through setting the same embedding for different synonyms.

Original: Unfortunately, the robustness of re-trained models is often determined by the diversity of adversarial examples used in re-training (Shen et al., 2022).
Revised: Unfortunately, the robustness of re-trained models is often determined by the diversity of adversarial examples used in re-training (Shen et al., 2022b).

Original: As a result, adversarial training is vulnerable to unknown attacks.
Revised: As a result, adversarial training is vulnerable to unknown attacks.

Original: Besides, a stream of recent popular defense methods (Huang et al., 2019; Jia et al., 2019) concentrates on certified robustness, which ensures models are robust to all potential word perturbations within the constraints.
Revised: Besides, a stream of recent popular defense methods (Huang et al., 2019; Jia et al., 2019) concentrates on certified robustness, which ensures models are robust to all potential word perturbations within the constraints.

Original: However, because of the extreme time cost in the training stage, certified robustness is  difficult to be applied to complex models.
Revised: However, because of the extreme time cost in the training stage, certified robustness is more difficult to be applied to complex models compared to other paradigms of defenses.

Original: For example, IBP (Jia et al., 2019) performed catastrophically on large pre-trained language models (e.g., BERT).
Revised: For example, IBP (Jia et al., 2019) performed catastrophically on large pre-trained language models.

Original: Recently, some excellent works have designed detection-based defense methods.
Revised: Recently, some excellent works have designed detection-based defense methods.

Original: For example,
Revised: For example,

Original: Mozes et al.
Revised: Mozes et al.

Original: (2021) used the word frequency difference to design detectors; Le et al.
Revised: (2021) used the word frequency difference to design detectors; Le et al.

Original: (2021) designed a detector specific for the ‘Universal trigger’; Mosca et al.
Revised: (2021) designed a detector specific for the ‘Universal trigger’; Mosca et al.

Original: (2022) proposed a detection method by leveraging prediction logits.
Revised: (2022) proposed a detection method by leveraging prediction logits.

Original: Despite their success, such detection-based defense methods own a key issue: the incapability of correctly classifying adversarial sentences.
Revised: Despite their success, such detection-based defense methods own a key issue: the incapability of correctly classifying adversarial sentences.

Original: An intuitive and straightforward idea is to design a corrector to convert adversarial sentences to their original benign ones, which has proved effective in the the field of computer vision (CV) (Liu et al., 2019; Qin et al., 2019; Li et al., 2020; Deng et al., 2021).
Revised: An intuitive and straightforward idea is to design a corrector to convert adversarial sentences to their original benign ones, which has proved effective in the the field of computer vision (CV) (Liu et al., 2019; Qin et al., 2019; Li et al., 2020b; Deng et al., 2021).

Original: However, the different essence between languages and pixels makes correctors used in CV not transferable in NLP.
Revised: However, the different essence between languages and pixels makes correctors used in CV not transferable in NLP.

Original: In this paper, based on the generation mechanism of adversarial sentences, we design a proper detector and corrector for text attacks.
Revised: In this paper, based on the generation mechanism of adversarial sentences, we design a proper detector and corrector for text attacks.

Original:  B ACKGROUND
Revised:  B ACKGROUND

Original: In this section, we present basic definitions used in adversarial text attack and saliency computation.
Revised: In this section, we present basic definitions used in adversarial text attack and saliency computation.

Original: Adversarial text attack In a text classification scenario, X = { w 1 , . .
Revised: Adversarial text attack In a text classification scenario, X = { w 1 , . .

Original: . , w d } is a sentence with d words, and w 1 , . .
Revised: . , w d } is a sentence with d words, and w 1 , . .

Original: . , w d are the corresponding embeddings.
Revised: . , w d are the corresponding embeddings.

Original: Given a text classifier F , F ( X ) denotes the probability distribution over the class set Y for input sentence X .
Revised: Given a text classifier F , F ( X ) denotes the probability distribution over the class set Y for input sentence X .

Original: Then, class y j with the largest probability in F ( X ) is selected as the prediction of X .
Revised: Then, class y j with the largest probability in F ( X ) is selected as the prediction of X .

Original: Furthermore, in a word-level text attack for a text classification scenario, there is a victim classifier F and a text attack G .
Revised: Furthermore, in a word-level text attack for a text classification scenario, there is a victim classifier F and a text attack G .

Original: • Victim Classifier:
Revised: • Victim Classifier:

Original: Given a set of benign sentences in a text classification benchmark, the victim classifier F can be trained with the benign sentences, where the sentence encoder is usually selected as TextCNN (Kim, 2014), LSTM (Hochreiter & Schmidhuber, 1997) or BERT (Devlin et al., 2019).
Revised: Given a set of benign sentences in a text classification benchmark, the victim classifier F can be trained with the benign sentences, where the sentence encoder is usually selected as TextCNN (Kim, 2014), LSTM (Hochreiter & Schmidhuber, 1997) or BERT (Devlin et al., 2019).

Original: • Text Attack: For a benign sentence X witha true label y j , the text attack G can generate an adversarial sentence X ∗ =
Revised: • Text Attack: For a benign sentence X with true label y j , the text attack G generates an adversarial sentence X ∗ =

Original: G ( X ) by substituting words w i in X with w ∗ i , satisfying: (1) F ( X ∗ ) and F ( X ) output different predicted labels; ( 2) Dist ( w i , w ∗ i ) < δ , where Dist ( · , · ) is a distance metric and δ is a threshold to limit the distance between the two words.
Revised: G ( X ) by substituting words w i in X with w ∗ i , satisfying: (1) F ( X ∗ ) and F ( X ) output different predicted labels; (2) Dist ( w i , w ∗ i ) < δ , where Dist ( · , · ) is a distance metric and δ is a threshold to limit the distance.

Original: Saliency computation In the field ofthe explainability of DNNs,the saliency map is a common technique to identify input features that are most salient.
Revised: Saliency computation In the field of explainability of DNNs, saliency map is a common technique to identify input features that are most salient.

Original: In other words, these input features cause a maximum influence on the model’s output.
Revised: In other words, these input features cause a maximum influence on the model’s output.

Original: Specifically, saliency is a measure that quantifies the sensitivity of an output class for an input feature in a DNN-based model, and a saliency map is a transparent colored heatmap overlaid on the input features.
Revised: Specifically, saliency is a measure that quantifies the sensitivity of an output class for an input feature in a DNN-based model, and a saliency map is a transparent colored heatmap overlaid on the input features.

Original: Furthermore, back-propagation-based methods, which have been widely used to compute saliency in the explainability of DNNs, treat saliency as the gradient of a DNN-based model.
Revised: Furthermore, back-propagation-based methods, which have been widely used to compute saliency in the explainability of DNNs, treat saliency as the gradient of a DNN-based model.

Original: There are different ways to calculate gradients based on gradient signals passed from output to input during model training, which leads to different saliency computation methods.
Revised: There are different ways to calculate gradients based on gradient signals passed from output to input during model training, which leads to different saliency computation methods.

Original: For example, in the vanilla gradient (VG) method (Simonyan et al., 2013), saliency is directly defined as the partial derivative of the network output concerning each input feature scaled by its value.
Revised: For example, in the vanilla gradient (VG) method (Simonyan et al., 2013), saliency is directly defined as the partial derivative of the network output concerning each input feature scaled by its value.

Original: Formally, given a classifier
Revised: Formally, given a classifier

Original: F and a sentence X containing words
Revised: F and a sentence X containing words

Original: w i , the saliency of w i to prediction y j is defined as follows:
Revised: w i , the saliency of w i to prediction y j is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: where F y j ( X ) is the prediction confidence for y j when applying F on X .
Revised: where F y j ( X ) is the prediction confidence for y j when applying F on X .

Original:  M OTIVATION AND I NTUITION
Revised:  M OTIVATION AND I NTUITION

Original: This section illustrates intuitions that motivate us to design TextShield.
Revised: This section illustrates intuitions that motivate us to design TextShield.

Original: Firstly, we present our basic derivations to show a cross-cutting connection between adversarial robustness and saliency.
Revised: Firstly, we present our basic derivations to show a cross-cutting connection between adversarial robustness and saliency.

Original: Then, we define adaptive word importance (AWI), a metric that helps us to detect adversarial sentences.
Revised: Then, we define adaptive word importance (AWI), a metric that helps us to detect adversarial sentences.

Original: 4. T HE CONNECTION BETWEEN ADVERSARIAL ROBUSTNESS AND SALIENCY
Revised: 4. T HE CONNECTION BETWEEN ADVERSARIAL ROBUSTNESS AND SALIENCY

Original: In this part, we explain why saliency is highly related to adversarial robustness, indicating there is a connection between adversarial robustness and saliency.
Revised: In this part, we explain why saliency is highly related to adversarial robustness, indicating there is a connection between adversarial robustness and saliency.

Original: Given a victim classifier F and a benign sentence X with label y j predicted by F , the objective of a text attack that generates an adversarial sentence X ∗ with a wrong predicted label (namely y k ) is defined as follows:
Revised: Given a victim classifier F and a benign sentence X with label y j predicted by F , the objective of a text attack that generates an adversarial sentence X ∗ with a wrong predicted label (namely y k ) is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: where L is a loss function (e.g., cross-entropy loss).
Revised: where L is a loss function (e.g., cross-entropy loss).

Original: In a vanilla gradient-based attack (Goodfellow et al., 2014), Eq 2 is optimized by a gradient descent method.
Revised: In a vanilla gradient-based attack (Goodfellow et al., 2014), Eq 2 is optimized by a gradient descent method.

Original: Specifically, in each iteration of the attack, word w i is substituted with a word whose embedding is closest to w i .
Revised: Specifically, in each iteration of the attack, word w i is substituted with a word whose embedding is closest to w i .

Original: In other words, word embedding w i is perturbed with a step rate r 1 by the attack, which is defined as follows:
Revised: In other words, word embedding w i is perturbed with a step rate r 1 by the attack, which is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: In ease of clarification, we regard the word embeddings as continuous variables.
Revised: In ease of clarification, we regard the word embeddings as continuous variables.

Original: Then, based on
Revised: Then, based on

Original: Eq 1, we can further derive the term w i − r 1 ∂ L ( F yj ( X ) ,y k )
Revised: Eq 1, we can further derive the term w i − r 1 ∂ L ( F yj ( X ) ,y k )

Original: ∂w i , and rewrite it as follows:
Revised: ∂w i , and rewrite it as follows:

Original: [Equation]
Revised: [Equation]

Original: As shown in Eq 4, words with larger | r ij | are perturbed more severely by the attack, indicating that saliency | r ij | may serve as a key for adversary detection.
Revised: As shown in Eq 4, words with larger | r ij | are perturbed more severely by the attack, indicating that saliency | r ij | may serve as a key for adversary detection.

Original: 4. A DAPTIVE WORD IMPORTANCE
Revised: 4. A DAPTIVE WORD IMPORTANCE

Original: Inspired from previous analysis and finding, we design a novel metric called adaptive word importance (AWI) based on saliency.
Revised: Inspired from previous analysis and finding, we design a novel metric called adaptive word importance (AWI) based on saliency.

Original: Definition 1.
Revised: Definition 1.

Original: Given sentence X with label y j predicted by text classifier F , the adaptive word importance (AWI) of word w i in the sentence, R ij , is defined as follows:
Revised: Given sentence X with label y j predicted by text classifier F , the adaptive word importance (AWI) of word w i in the sentence, R ij , is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: ∆ is a saliency computation method, e.g., VG.
Revised: ∆ is a saliency computation method, e.g., VG.

Original: Given sentence X , the ( i, j ) -th element R ij reflects the importance of word w i towards prediction y j in victim classifier F .
Revised: Given sentence X , the ( i, j ) -th element R ij reflects the importance of word w i towards prediction y j in victim classifier F .

Original: Thus, AWI can reflect the importance of a word, and a larger AWI value indicates higher importance.
Revised: Thus, AWI can reflect the importance of a word, and a larger AWI value indicates higher importance.

Original:  T EXT S HIELD 5. O VERVIEW
Revised:  T EXT S HIELD 5. O VERVIEW

Original: Based on previous analysis, we present TextShield, which is like a shield in front of the victim classifier , as shown in Figure 1.
Revised: Based on previous analysis, we present TextShield, which is like a shield in front of the victim classifier , as shown in Figure 1.

Original: Generally, TextShield has two principal components: a detector and a corrector.
Revised: Generally, TextShield has two principal components: a detector and a corrector.

Original: The detector is a learning-based binary classifier that takes a sentence as input and outputs whether the input is adversarial or not.
Revised: The detector is a learning-based binary classifier that takes a sentence as input and outputs whether the input is adversarial or not.

Original: The corrector continues to correct adversarial sentences to benign ones, which makes up the blank of previous detection-based defense methods.
Revised: The corrector continues to correct adversarial sentences to benign ones, which makes up the blank of previous detection-based defense methods.

Original: Specifically, given an input sentence X , X is fed to the victim classifier F to get prediction y j .
Revised: Specifically, given an input sentence X , X is fed to the victim classifier F to get prediction y j .

Original: Then the detector is used to judge whether X is adversarial based on prediction y j .
Revised: Then the detector is used to judge whether X is adversarial based on prediction y j .

Original: If X is benign, the final prediction for X will be y j (i.e., F ( X ) ).
Revised: If X is benign, the final prediction for X will be y j (i.e., F ( X ) ).

Original: Otherwise, a corrector is used to transform X to X ′ , and the final prediction for X will be F ( X ′ ) .
Revised: Otherwise, a corrector is used to transform X to X ′ , and the final prediction for X will be F ( X ′ ) .

Original: 5. D ETECTOR
Revised: D ETECTOR

Original: As shown in Figure 2, the detector consists of four sub-detectors and one combiner.
Revised: As shown in Figure 2, the detector consists of four sub-detectors and one combiner.

Original: A sub-detector is a binary classifier that utilizes a saliency computation method and a LSTM layer to predict whether input sentence X is adversarial or not.
Revised: A sub-detector is a binary classifier that utilizes a saliency computation method and a LSTM layer to predict whether input sentence X is adversarial or not.

Original: In this paper, four saliency computation methods, vanilla gradient (VG), guided backpropagation (GBP), layerwise relevance propagation (LRP), and integration gradient (IG), are chosen, which correspond to the four sub-detectors, respectively.
Revised: In this paper, four saliency computation methods, vanilla gradient (VG), guided backpropagation (GBP), layerwise relevance propagation (LRP) and integration gradient (IG), are chosen, which correspond to the four sub-detectors, respectively.

Original: Then, the combiner uses a linear layer to combine four predictions from the four sub-detectors, respectively.
Revised: Then, the combiner uses a linear layer to combine four predictions from the four sub-detectors, respectively.

Original: Specifically, for a sub-detector based on a saliency computation method I , given an input sentence
Revised: Specifically, for a sub-detector based on a saliency computation method I , given an input sentence

Original: X , one AWI matrix is calculated for X using I, and then the AWI matrix is fed to an LSTM to obtain a prediction.
Revised: X , one AWI matrix is calculated for X using I and then the AWI matrix is fed to an LSTM to obtain a prediction.

Original: Takings VG as an example, the VG-based sub-detector is calculated as follows.
Revised: Takings VG as an example, the VG-based sub-detector is calculated as follows.

Original: [Equation]
Revised: [Equation]

Original: where R · j is a column of AWI matrix R , and z ( V G ) is a binary prediction from VG-based subdetector.
Revised: where R · j is a column of AWI matrix R , and z ( V G ) is a binary prediction from VG-based subdetector.

Original: Similarly, z ( GBP ) , z ( LRP ) and z ( IG ) are predictions from GBP-based, LRP-based, and
Revised: Similarly, z ( GBP ) , z ( LRP ) and z ( IG ) are predictions from GBP-based, LRP-based, and

Original: IG-based sub-detectors, respectively.
Revised: IG-based sub-detectors, respectively.

Original: Finally, through a linear combiner, the four binary predictions are combined to give the prediction z :
Revised: Finally, through a linear combiner, the four binary predictions are combined to give the prediction z :

Original: [Equation]
Revised: [Equation]

Original: where  the  z is the label reflecting whether X is adversarial.
Revised: where L is the linear layer and z is the label reflecting whether X is adversarial.

Original: In the following section, we will present the four saliency computation methods and then give the details of the detector’s training.
Revised: In the following section, we will present the four saliency computation methods and then give the details of the detector’s training.

Original: Vanilla Gradient (VG)
Revised: Vanilla Gradient (VG)

Original: For text classifier F , the AWI value of word w i in sentence X to prediction y j is calculated by the vanilla gradient method (Simonyan et al., 2013) as follows:
Revised: For text classifier F , the AWI value of word w i in sentence X to prediction y j is calculated by the vanilla gradient method (Simonyan et al., 2013) as follows:

Original: [Equation]
Revised: [Equation]

Original: where R ( V G ) ij , the ( i, j ) -th element of AWI matrix R ( V G ) , is the AWI value of word w i to prediction y j , F y j is the prediction confidence for y j from F , and w i is the word embedding for word w i .
Revised: where R ( V G ) ij , the ( i, j ) -th element of AWI matrix R ( V G ) , is the AWI value of word w i to prediction y j , F y j is the prediction confidence for y j from F , and w i is the word embedding for word w i .

Original: In fact, when calculating R ( V G ) ij , F y j is a scalar and w i ∈ R 1 × k is a vector, where k is the dimension of the word embedding.
Revised: In fact, when calculating R ( V G ) ij , F y j is a scalar and w i ∈ R 1 × k is a vector, where k is the dimension of the word embedding.

Original: Thus, ∂F yj ( X ) ∂ w i is a vector with the form R 1 × k , and an average operation is made to obtain R ( V G ) ij .
Revised: Thus, ∂F yj ( X ) ∂ w i is a vector with the form R 1 × k , and an average operation is made to obtain R ( V G ) ij .

Original: For brevity, we omit the operation in the paper.
Revised: For brevity, we omit the operation in the paper.

Original: Guided Backpropagation (GBP)
Revised: Guided Backpropagation (GBP)

Original: Following the idea of the vanilla gradient, GBP (Springenberg et al., 2015) chooses only ‘positive’ ( > 0) gradients and discards ‘negative’ ( < 0) gradients.
Revised: Following the idea of the vanilla gradient, GBP (Springenberg et al., 2015) chooses only ‘positive’ ( > 0) gradients and discards ‘negative’ ( < 0) gradients.

Original: Positive gradients indicate supporting the prediction, while negative ones mean the opposite.
Revised: Positive gradients indicate supporting the prediction, while negative ones mean the opposite.

Original: Such a choice enables us to capture what text classifier F learns and yet discard anything that F does not learn.
Revised: Such a choice enables us to capture what text classifier F learns and yet discard anything that F does not learn.

Original: We take the final outputs of GBP as AWI matrix R GBP .
Revised: We take the final outputs of GBP as AWI matrix R GBP .

Original: Layerwise Relevance Propagation (LRP) GBP owns an obvious drawback called gradient saturation (Bach et al., 2015; Binder et al., 2016) that gradients computed by GBP are always zeros under some cases.
Revised: Layerwise Relevance Propagation (LRP) GBP owns an obvious drawback called gradient saturation (Bach et al., 2015; Binder et al., 2016) that gradients computed by GBP are always zeros under some cases.

Original: Therefore, Layerwise Relevance Propagation (LRP) (Bach et al., 2015) is proposed, which tackles the problem using a reference input besides the target input to calculate gradients.
Revised: Therefore, Layerwise Relevance Propagation (LRP) (Bach et al., 2015) is proposed, which tackles the problem using a reference input besides the target input to calculate gradients.

Original: The
Revised: The

Original: LRP method calculates a weight for each connection in the gradient chain and uses a reference input instead of roughly setting the weights as 0 or 1 like GBP.
Revised: LRP method calculates a weight for each connection in the gradient chain and uses a reference input instead of roughly setting the weights as 0 or 1 like GBP.

Original: The reference input is a ‘neutral’ input and will be different in different tasks (e.g., blank images in the CV field or zero embeddings in the NLP field).
Revised: The reference input is a ‘neutral’ input and will be different in different tasks (e.g., blank images in the CV field or zero embeddings in the NLP field).

Original: Finally, such gradients compose AWI matrix R LRP .
Revised: Finally, such gradients compose AWI matrix R LRP .

Original: Integrated Gradient (IG)Some works (Sundararajan et al., 2017) pointed out that LRP is calculating discrete gradients.
Revised: Integrated Gradient (IG) LRP is calculating discrete gradients.

Original: However, the chain rule does not hold for discrete gradients so that LRP has essential drawbacks.
Revised: However, the chain rule does not hold for discrete gradients so that LRP has essential drawbacks.

Original: Thus, the integrated gradient (IG) (Sundararajan et al., 2017) is proposed, which calculates the influence of word w i to prediction y j by integrating vanilla gradient, which is defined as follows:
Revised: Thus, the integrated gradient (IG) (Sundararajan et al., 2017) is proposed, which calculates the influence of word w i to prediction y j by integrating vanilla gradient, which is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: where w ′ i is a zero embedding and
Revised: where w ′ i is a zero embedding and

Original: F y j
Revised: F y j

Original: ( X, w i ′
Revised: ( X, w i ′

Original: +
Revised: +

Original: α ( w i − w i ′ ) means that the embedding of word w i , w i , is replaced with w i
Revised: α ( w i − w i ′ ) means that the embedding of word w i , w i , is replaced with w i

Original: + α ( w i − w i ′ ) .
Revised: + α ( w i − w i ′ ) .

Original: The final outputs of IG is AWI matrix R IG .
Revised: The final outputs of IG is AWI matrix R IG .

Original: Training of detector Generally, training the detector consists of the following three steps, where both the adversarial data setup and the balanced data setup prepare data for the model’s training.
Revised: Training of detector Generally, training the detector consists of the following three steps, where both the adversarial data setup and the balanced data setup prepare data for the model’s training.

Original: More training details are deferred to Appendix A.
Revised: More training details are deferred to Appendix A.

Original: • Adversarial data setup : Given benign data, the victim classifier F is fine-tuned by the data.
Revised: • Adversarial data setup : Given benign data, the victim classifier F is fine-tuned by the data.

Original: Then the adversarial attacks are used to generate adversarial sentences and 2, adversarial sentences per class that successfully attacksF are selected.
Revised: Then the adversarial attacks are used to generate adversarial sentences and 2, adversarial sentences per class that successfully attacks are selected.

Original: Moreover, the adversarial sentences are equally generated by GA, IGA, PWWS and TextFooler. • Balanced data setup : The adversarial data and the same-size benign data are mixed as balanced data.
Revised: Moreover, the adversarial sentences are equally generated by attacks.• Balanced data setup : The adversarial data and the same-size benign data are mixed as balanced data.

Original: Then, the balanced data is split into train-dev-test sets with a 7:2:1 proportion.
Revised: Then, the balanced data is split into train-dev-test sets with a 7:2:1 proportion.

Original: • Model training : The training data set is fed to train the detector, and the best-performance checkpoint is selected according to performance on the dev data set.
Revised: • Model training : The training data set is fed to train the detector, and the best-performance checkpoint is selected according to performance on the dev data set.

Original: 5. C ORRECTOR
Revised: 5. C ORRECTOR

Original: As mentioned in Sec 5.1, if the detector recognizes the input sentence X as an adversarial one, then the prediction y j for X is possibly inaccurate.
Revised: As mentioned in Sec 5.1, if the detector recognizes the input sentence X as an adversarial one, then the prediction y j for X is possibly inaccurate.

Original: Furthermore, as discussed in Sec 4.1, given  an AWI matrix R , larger R ij means word w i is more important for classifying the sentence as y j .
Revised: Furthermore, as discussed in Sec 4.1, given example defense an AWI matrix R , larger R ij means word w i is more important for classifying the sentence as y j .

Original: In other words, words with large AWI values are more likely to be perturbed by attacks to fool the victim classifier.
Revised: In other words, words with large AWI values are more likely to be perturbed by attacks to fool the victim classifier.

Original: Therefore, the corrector corrects the words with large AWI values in the adversarial sentence.
Revised: Therefore, the corrector corrects the words with large AWI values in the adversarial sentence.

Original: In addition, the corrector chooses R V G ij as R ij .
Revised: In addition, the corrector chooses R V G ij as R ij .

Original: Specifically, for an adversarial sentence X ∗ with prediction y j , the corrector regards a word w i as a suspect when its R ij exceeds a threshold, which is defined as follows:
Revised: Specifically, for an adversarial sentence X ∗ with prediction y j , the corrector regards a word w i as a suspect when its R ij exceeds a threshold, which is defined as follows:

Original: [Equation]
Revised: [Equation]

Original: where R max and R min are the largest and smallest values in R , and β is a hyper-parameter to control the ratio of suspects.
Revised: where R max and R min are the largest and smallest values in R , and β is a hyper-parameter to control the ratio of suspects.

Original: For a suspect w i , the corrector substitutes w i with the most frequent word w ′ ∈ S ( w i ) , where S ( w i ) is w i ’s synonyms (Loper & Bird, 2002).
Revised: For a suspect w i , the corrector substitutes w i with the most frequent word w ′ ∈ S ( w i ) , where S ( w i ) is w i ’s synonyms, extracted by NLTK (Loper & Bird, 2002).

Original:  E XPERIMENTS ON ADVERSARIAL DEFENSE
Revised:  E XPERIMENTS ON ADVERSARIAL DEFENSE

Original: In this section, we carry out two sets of experiments to comprehensively analyze our detectioncorrection defense method, TextShield. The first set of experiments examines TextShield to enhance defense against adversarial attacks. The second set of experiments are ablation analyses on TextShield to answer the following three questions: Q1) What is the impact of β , the hyperparameter of the corrector?
Revised: In this section, we conduct comprehensive experiments to compare TextShield to baselines.

Original: Q2)

Original: What is the impact of multiple sub-detectors?

Original: Q3)

Original: What is the impact of the number of adversarial sentences used to train detectors?

Original: Due to limited space, we present only the first set of experiments and defer the description and analysis of the ablation analyses to appendix B.

Original: 6. E XPERIMENTAL SETTINGS
Revised: 6. E XPERIMENTAL SETTINGS

Original: Firstly, we use TextCNN (Kim, 2014), LSTM (Hochreiter & Schmidhuber, 1997) and BERT (Devlin et al., 2019) as victim classifiers, and select four widely-used text attacks in the NLP field: TL  (Kuleshov et al., 2018), PWWS (Probability Weighted Word Saliency, Ren et al., 2019) , GA (Genetic Algorithm, Alzantot et al., 2018) and IGA (Improved Genetic Algorithm, Wang et al., 2019b).
Revised: Firstly, we use TextCNN (Kim, 2014), LSTM (Hochreiter & Schmidhuber, 1997) and BERT (Devlin et al., 2019) as victim classifiers, and select four widely-used text attacks in the NLP field: TL (TextFooler, (Kuleshov et al., 2018)), PWWS (Probability Weighted Word Saliency, Ren et al., 2019) , GA (Genetic Algorithm, Alzantot et al., 2018) and IGA (Improved Genetic Algorithm, Wang et al., 2019c).

Original: Moreover, we choose three popular benchmarks in text classification: IMDB (Potts, 2010), AG’s News (Zhang et al., 2015) and Yahoo!
Revised: Moreover, we choose three popular benchmarks in text classification: IMDB (Potts, 2010), AG’s News (Zhang et al., 2015) and Yahoo!

Original: Answers (Zhang et al., 2015).
Revised: Answers (Zhang et al., 2015).

Original: Then, given a victim classifier, an attack and a benchmark, we generate test data consisting of a benign dataset and an adversarial dataset, which are used to evaluate the generalization and robustness of defense methods.
Revised: Then, given a victim classifier, an attack and a benchmark, we generate test data consisting of a benign dataset and an adversarial dataset, which are used to evaluate the generalization and robustness of defense methods.

Original: Specifically, the benign dataset includes 1,000 benign sentences sampled from the benchmark, and the adversarial dataset includes 1,000 adversarial sentences generated by the attack based on the benchmark.
Revised: Specifically, the benign dataset includes 1,000 benign sentences sampled from the benchmark, and the adversarial dataset includes 1,000 adversarial sentences generated by the attack based on the benchmark.

Original: Please note that there is no overlap between the test data and the training data used for the detector’s training.
Revised: Please note that there is no overlap between the test data and the training data used for the detector’s training.

Original: Finally, we evaluate the performance of the victim models with or without defense methods on the test data.
Revised: Finally, we evaluate the performance of the victim models with or without defense methods.

Original: The more powerful a defense method is, the better classification accuracy on adversarial sentences is.

Original: Moreover, we compare TextShield with four state-of-the-art defense methods: (1) IBP (Jia et al., 2019): the most representative method in the certified robustness paradigm.
Revised: Moreover, we compare TextShield with four state-of-the-art defense methods: (1) IBP (Jia et al., 2019): the most representative method in the certified robustness paradigm.

Original: (2) Adversarial Sparse
Revised: (2) Adversarial Sparse

Original: Convex Combination (ASCC) (Dong et al., 2021): a model-enhancement-based defense method which leverages convex hull to defend against adversarial word substitutions.
Revised: Convex Combination (ASCC) (Dong et al., 2021): a model-enhancement-based defense method which leverages convex hull to defend against adversarial word substitutions.

Original: (3) Synonym Encoding Method (SEM) (Wang et al., 2021a): a model-enhancement-based defense method based on synonym encoding.
Revised: (3) Synonym Encoding Method (SEM) (Wang et al., 2021a): a model-enhancement-based defense method based on synonym encoding.

Original: (4) Frequency-based Word Substitution (FGWS) (Mozes et al., 2021): a detection-based method which leverages word frequency.
Revised: (4) Frequency-based Word Substitution (FGWS) (Mozes et al., 2021): a detection-based method which leverages word frequency.

Original: (5) Word-level Differential Reaction (WDR) (Mosca et al., 2022): a detection-based method which utilizes prediction logits.
Revised: (5) Word-level Differential Reaction (WDR) (Mosca et al., 2022): a detection-based method which utilizes prediction logits.

Original: Specifically, considering that FGWS and WDR are detection-only methods and cannot correctly classify adversarial sentences, we combine our corrector to them.
Revised: Specifically, considering that FGWS and WDR are detection-only methods and cannot correctly classify adversarial sentences, we combine our corrector to them.

Original: Moreover, the baselines’ settings are kept the same with corresponding papers.
Revised: The baselines’ settings are kept the same with corresponding papers.

Original: 6. P ERFORMANCE
Revised: 6. P ERFORMANCE

Original: Table 1 lists the performances of various defense models under different scenarios, which demonstrates both the generalization and the robustness of these defense models.
Revised: Table 1 lists the performances of various defense models under different scenarios, which demonstrates both the generalization and the robustness of these defense models.

Original: Effect on generalization When evaluated on benign sentences (see Column ’No’ in Table 1), normal training (NT) achieves the best results, and our proposed method, TextShield, achieves accuracy performance close to normal training (NT), indicating a good trade-off between robustness and generalization.
Revised: Effect on generalization When evaluated on benign sentences (see Column ’No’ in Table 1), normal training (NT) achieves the best results, and our proposed method, TextShield, achieves accuracy performance close to normal training (NT), indicating a good trade-off between robustness and generalization.

Original: By the way, such a trade-off is common for attack/defense, which has been theoretically investigated in the CV field (Zhang et al., 2019a).
Revised: By the way, such a trade-off is common for attack/defense, which has been theoretically investigated in the CV field (Zhang et al., 2019a).

Original: In addition, generalization can be seen as a proper upper bound for accuracy performance on adversarial sentences.
Revised: In addition, generalization can be seen as a proper upper bound for accuracy performance on adversarial sentences.

Original: Moreover, among baselines, ASCC performs best, and IBP has lowest accuracy due to itshigh complexity and relatively loose bounds.
Revised: Moreover, among baselines, ASCC performs best, and IBP has lowest accuracy due to its relatively loose bounds.

Original: Besides, combined with our corrector, PGWS and WDR obtain 
Revised: Besides, combined with our corrector, PGWS and WDR obtain comparable per-

Original: [Table]
Revised: [Table]

Original: Effect on robustness When evaluated on adversarial sentences
Revised: Effect on robustness When evaluated on adversarial sentences

Original: TextShield performs best in most cases, demonstrating that TextShield can effectively improve the model’s robustness.
Revised: TextShield performs best in most cases, demonstrating that TextShield can effectively improve the model’s robustness.

Original: Furthermore, the enhancement of model’s robustness is derived from the leveraging a cross-cutting link between adversarial robustness and saliency, which is contrary to the conventional opinion (Zhang et al., 2020; Goyal et al., 2022) that text attacks should be  defended using discrete information(e.g., synonym encoding) instead of continuous information (e.g., saliency).
Revised: Furthermore, the enhancement of model’s robustness is derived from the leveraging a cross-cutting link between adversarial robustness and saliency, which is complementary to the conventional opinion (Zhang et al., 2020; Goyal et al., 2022) that text attacks should be better defended using discrete information instead of continuous information.

Original: Moreover, among the baselines, SEM, the state-of-the-art defense method against word-level attacks, achieves the best performance.
Revised: Moreover, among the baselines, SEM, the state-of-the-art defense method against word-level attacks, achieves the best performance.

Original: IBP, which was first proposed in the CV domain, is more suitable for TextCNN and does not perform excellently on other victim classifiers (e.g., LSTM).
Revised: IBP, which was first proposed in the CV domain, is more suitable for TextCNN and does not perform excellently on other victim classifiers.

Original: FGWS focuses only on word frequencies, so it is not sufficient to detect adversarial sentences when word frequency is not distinct.
Revised: FGWS focuses only on word frequencies, so it is not sufficient to detect adversarial sentences when word frequency is not distinct.

Original: Moreover, after combining with our corrector, WDR can yield a comparable performance towards ASCC, a competitive baseline using the model-enhancementbased paradigm, which indicates our corrector can combine well with existing detectors concerning model’s robustness.
Revised: Moreover, after combining with our corrector, WDR can yield a comparable performance towards ASCC, a competitive baseline using the model-enhancement-based paradigm, which indicates our corrector can combine well with existing detectors concerning model’s robustness.

Original:  E XPERIMENTS ON ADVERSARIAL DETECTION
Revised:  E XPERIMENTS ON ADVERSARIAL DETECTION

Original: In this section, we compare our saliency-based detector to current state-of-the-art adversarial detectors, and carry on the comparison in several configurations involving datasets and attacks.
Revised: This section compares our saliency-based detector to current SoTA adversarial detectors in several configurations involving datasets and attacks.

Original: Moreover, we also conduct experiments on adversarial detection for character-level and sentence-level attacks and defer the results and discussions to Appendix C.

Original: 7. E XPERIMENTAL SETTINGS
Revised: 7. E XPERIMENTAL SETTINGS

Original: In the experiments, only BERT (Devlin et al., 2019) is used as victim classifier.
Revised: In the experiments, only BERT (Devlin et al., 2019) is used as victim classifier.

Original: Then, four widely used adversarial attacks are selected: GA (Alzantot et al., 2018), PWWS (Ren et al., 2019), IGA (Wang et al., 2019b) and TextFooler (Jin et al., 2020).
Revised: Then, four widely used adversarial attacks are selected: GA (Alzantot et al., 2018), PWWS (Ren et al., 2019), IGA (Wang et al., 2019c) and TextFooler (Jin et al., 2020).

Original: Next, three popular benchmarks in text classification are selected: IMDB (Potts, 2010), AG’s News (Zhang et al., 2015) and
Revised: Next, three popular benchmarks in text classification are selected: IMDB (Potts, 2010), AG’s News (Zhang et al., 2015) and

Original: Yelp (Zhang et al., 2015).
Revised: Yelp (Zhang et al., 2015).

Original: Similar to the experiments on adversarial defense, given a victim classifier, an attack, and a benchmark, we generate test data which include 1,000 adversarial sentences generated by the attack based on the benchmark.
Revised: Similar to the experiments on adversarial defense, given a victim classifier, an attack, and a benchmark, we generate test data which include 1,000 adversarial sentences generated by the attack based on the benchmark.

Original: Finally, we evaluate the performance of the victim models on the  test data.
Revised: Finally, we evaluate the performance of the victim models on the [Table] test data.

Original: Following previous works (Mosca et al., 2022), the performance of adversarial detection is evaluated by F1-score and recall.
Revised: Following previous works (Mosca et al., 2022), the performance of adversarial detection is evaluated by F1-score and recall.

Original: Moreover, in order to examine the performance of our detector, two state-of-the-art detectors are chosen as baselines, FGWS (Mozes et al., 2021) and WDR (Mosca et al., 2022), where FGWS leverages word frequency to detect adversarial sentences, and WDR uses prediction logit information for adversarial detection.
Revised: Moreover, in order to examine the performance of our detector, two state-of-the-art detectors are chosen as baselines, FGWS (Mozes et al., 2021) and WDR (Mosca et al., 2022), where FGWS leverages word frequency to detect adversarial sentences, and WDR uses prediction logit information for adversarial detection.

Original: 7. P ERFORMANCE
Revised: 7. P ERFORMANCE

Original: Table 2 shows the performance of thethree detectors in various configurations.
Revised: Table 2 shows the performance of the detectors in various configurations.

Original: In Table 2, our proposed detector consistently shows very competitive results in terms of F1-score and recall.
Revised: In Table 2, our proposed detector consistently shows better results in terms of F1-score and recall.

Original: Specifically, our detector outperforms the best baseline in 11 configurations out of 12, and on average achieves 3.74% gain on F1-score.
Revised: Specifically, our detector outperforms the best baseline in 11 configurations out of 12, and on average achieves 3.74% gain on F1-score.

Original: Such results not only indicate the effectiveness of our saliencybased detector is general across different domains (e.g., news and movie reviews), but also highlight that the saliency-based detector reacts well to all selected attacks (e.g., IGA and GA).
Revised: Such results show that the saliency-based detector reacts well to all selected attacks.

Original: Moreover, we can also observe that TextFooler is easier to be detected than other attacks.
Revised: Moreover, we can also observe that TextFooler is easier to be detected than other attacks.

Original: Considering that TextFooler is much stronger than the attacks like GA and IGA, we can claim that there is no positive relation between attack’s attack power and detection difficulty.
Revised: Considering that TextFooler is much stronger than the attacks like GA and IGA, we can claim that there is no positive relation between attack’s attack power and detection difficulty.

Original: [Table]
Revised: We also illustrate the details or discussion towards critical designs of TextShield with additional experiments. We defer them to Appendix due to limited space.

Original:  is the best performance.
Revised: The outline is as follows:

Original: ‘Saliency’ represents our saliency-based detector.
Revised: The analyses of hyper-parameters are shown in Appendix B. Performance against extra wordlevel attacks is shown in Appendix C. Also, human evaluation towards attack quality is shown in Appendix D. Besides, computational cost and corrector design discussions are shown in Appendix E and F. Adversarial detection performance of TextShield against other levels of attacks (e.g., sentence-level attack) is shown in Appendix G.

Original:  C ONCLUSION
Revised:  C ONCLUSION

Original: This paper proposes TextShield, a detect-correct pipelined defense method against word-level text attacks.
Revised: This paper proposes TextShield, a detect-correct pipelined defense method against word-level text attacks.

Original: Based on basic derivations, we find a cross-cutting connection between adversarial robustness and saliency, and then we propose the adaptive word importance (AWI) metric based on saliency computation.
Revised: Based on basic derivations, we find a cross-cutting connection between adversarial robustness and saliency, and then we propose the adaptive word importance (AWI) metric based on saliency computation.

Original: Based on AWI, we design a saliency-based detector, which achieves better performance than previous detectors.
Revised: Based on AWI, we design a saliency-based detector, which achieves better performance than previous detectors.

Original: Then, we design a saliency-based corrector, which corrects adversarial sentences to benign ones using AWI.
Revised: Then, we design a saliency-based corrector, which corrects adversarial sentences to benign ones using AWI.

Original: Comprehensive experiments demonstrate that
Revised: Comprehensive experiments demonstrate that

Original: TextShield is superior to previous defense methods on both generalization and robustness.  
Revised: TextShield is superior to previous defense methods for generalization and robustness.  A CKNOWLEDGEMENT

Original: Moreover, such a detect-correct pipeline is not specific to text classification, and we will explore the capacity of TextShield on other NLP tasks (e.g., QA, NLI) in the future. We believe that our work serves as a strong detect-correct defense, on which sounder systems can be built for the safe deployment of NLP models in practice.
Revised: The research was financially supported by National Precision Agriculture Application Project (Grant/Contract number: JZNYYY001) and Beijing Municipal Science and Technology Project (Grant/Contract number: Z201100008020008)

Original: A D ETAILS OF DETECTOR ’ S TRAINING
Revised: A D ETAILS OF DETECTOR ’ S TRAINING

Original: The learnable parameters in our saliency-based detectors are the ones in the four LSTMs of the detector and the two-layer MLP of the combiner.
Revised: The learnable parameters in our saliency-based detectors are the ones in the four LSTMs of the detector and the two-layer MLP of the combiner.

Original: After tokenization, we either conduct padding with ‘max length=128’ or do a truncation for each input sentence.
Revised: After tokenization, we either conduct padding with ‘max length=128’ or do a truncation for each input sentence.

Original: Then after saliency computation, we obtain the AWI matrix with a form (128 , |Y| ) , where |Y| is the size of the label set used in the focused text classification.
Revised: Then after saliency computation, we obtain the AWI matrix with a form (128 , |Y| ) , where |Y| is the size of the label set used in the focused text classification.

Original: Thus, the four LSTMs take the four AWI matrices as input correspondingly and output their hidden states (hidden size = 128).
Revised: Thus, the four LSTMs take the four AWI matrices as input correspondingly and output their hidden states (hidden size = 128).

Original: Finally, the hidden states are concatenated to feed to the combiner, which is a two-layer MLP + softmax function, with input dim = 128, intermediate layer dim = 64 and out dim = 2.
Revised: Finally, the hidden states are concatenated to feed to the combiner, which is a two-layer MLP + softmax function, with input dim = 128, intermediate layer dim = 64 and out dim = 2.

Original: In addition, the LSTMs and the two-layer MLP are simultaneously trained through the Adam optimizer with a 5 · e − 4 learning rate.
Revised: In addition, the LSTMs and the two-layer MLP are simultaneously trained through the Adam optimizer with a 5 · e − 4 learning rate.

Original: B A BLATION STUDY
Revised: B A BLATION STUDY

Original: This section conducts ablation studies of TextShield to answer the following three questions: Q1)
Revised: This section conducts ablation studies of TextShield to answer the following three questions: Q1)

Original: What is the impact of β , the hyper-parameters of the corrector?
Revised: What is the impact of β , the hyper-parameters of the corrector?

Original: Q2)
Revised: Q2)

Original: What is the impact of multiple sub-detectors?
Revised: What is the impact of multiple sub-detectors?

Original: Q3)
Revised: Q3)

Original: What is the impact of the number of adversarial sentences used to train detectors?
Revised: What is the impact of the number of adversarial sentences used to train detectors?

Original: The experimental settings are similar to the ones used in Sec 6.
Revised: The experimental settings are similar to the ones used in Sec 6.

Original: B. A NALYSIS OF HYPER - PARAMETER β
Revised: B. A NALYSIS OF HYPER - PARAMETER β

Original: We study the impact of β , the hyper-parameters of our corrector.
Revised: We study the impact of β , the hyper-parameters of our corrector.

Original: As shown in Figure 3, the best performance achieves when β is 0.4, and either a small or large β will cause a significant performance drop, especially when β is large.
Revised: As shown in Figure 3, the best performance achieves when β is 0.4, and either a small or large β will cause a significant performance drop, especially when β is large.

Original: This is because β serves to control the ratio of suspects in a sentence: when β is 0, only the most important word is considered as a suspect, which may be inadequate; on the contrary, when β is 1.0, every word is viewed as a suspect, which is inappropriate. 
Revised: This is because β serves to control the ratio of suspects in a sentence: when β is 0, only the most important word is considered as a suspect, which may be inadequate; on the contrary, when β is 1.0, every word is viewed as a suspect, which is inappropriate. [Figure] [Figure]

Original: B. A NALYSIS OF THE COMBINING OF MULTIPLE SUB - DETECTORS
Revised: B. A NALYSIS OF THE COMBINING OF MULTIPLE SUB - DETECTORS

Original: Since a crucial design of TextShield is the ensembling of the four sub-detectors with a combiner, we investigate the impact of such an ensembling strategy.
Revised: Since a crucial design of TextShield is the ensembling of the four sub-detectors with a combiner [Table] we investigate the impact of such an ensembling strategy.

Original: Specifically, we verify the performance after removing some sub-detectors, and the evaluation is launched using TextCNN on AGNews.
Revised: Specifically, we verify the performance after removing some sub-detectors, and the evaluation is launched using TextCNN on AGNews.

Original: As shown in Table 3, removing any sub-detector will cause a performance drop, demonstrating the effectiveness of each sub-detector.
Revised: As shown in Table [Table] removing any sub-detector will cause a performance drop, demonstrating the effectiveness of each sub-detector.

Original: Based on the results, the importance of sub-detectors can be ranked as follows: VG > LRP > IG > GBP.
Revised: Based on the results [Table] the importance of sub-detectors can be ranked as follows: VG > LRP > IG > GBP.

Original: Furthermore, removing all the sub-detectors shows a catastrophic performance drop, which confirms our arguments that different sub-detectors can complement well with each other and also shows the importance of integrating the four sub-detectors.
Revised: Furthermore, removing all the sub-detectors shows a catastrophic performance drop

Original: [Figure]
Revised: [Table]

Original: Specifically, the performance of  the three victim classifiers on AGNews is presented.
Revised: which confirms our arguments that different sub-detectors can complement well with each other and also shows the importance of integrating the four sub-detectors.

Original: Please note that neither the saliency computation methods nor the ensembling strategy of various sub-detectors are our paper’s focus.
Revised: Please note that neither the saliency computation methods nor the ensembling strategy of various sub-detectors are our paper’s focus.

Original: There are more sophisticated methods for saliency computation and sub-detector combination, and such methods can also be applied to TextShield. Removed sub
Revised: There are more sophisticated methods for saliency computation and sub-detector combination

Original: [Table]
Revised: [Table]

Original: TL PWWS GA IGA
Revised: and such methods can also be applied to TextShield.

Original: [Table]
Revised: [Table]

Original: B. A NALYSIS OF THE NUMBER OF ADVERSARIAL SENTENCES USED IN TRAINING DETECTORS
Revised: B. A NALYSIS OF THE NUMBER OF ADVERSARIAL SENTENCES USED IN TRAINING DETECTORS

Original: During the training process, we use the same number K of adversarial sentences per class, where
Revised: During the training process, we use the same number K of adversarial sentences per class, where

Original: K = 2000 .
Revised: K = 2000 .

Original: This experiment illustrates the relation between the performance of TextShield and K .
Revised: This experiment illustrates the relation between the performance of TextShield and K .

Original: Notice that, except for K , we keep the same training settings as the experimental setting used in
Revised: Notice that, except for K , we keep the same training settings as the experimental setting used in

Original: Sec 6.
Revised: Sec 6.

Original: The performance of TextShield under different K is shown in Figure 4.
Revised: The performance of TextShield under different K is shown in Figure 4.

Original: As illustrated in Figure 4, the defense capacity of TextShield is enhanced as K continuously increases since more samples used in the training data help the detector better recognize adversarial sentences.
Revised: As illustrated in Figure 4, the defense capacity of TextShield is enhanced as K continuously increases since more samples used in the training data help the detector better recognize adversarial sentences.

Original: Specifically, when K is larger than 2000 , the improvement becomes extremely subtle, indicating that we have arrived at the upper-bound of TextShield performance under such configurations. 
Revised: Specifically, when K is larger than 2000 , the improvement becomes extremely subtle, indicating that we have arrived at the upper-bound of TextShield performance under such configurations. [Table]

Original: C L IMITATION AND FUTURE WORKS
Revised: C P ERFORMANCE ON OTHER WORD - LEVEL ATTACKS

Revised: Additionally, we add BERT-attack (BA) Li et al. (2020a) to our attack methods. The settings of BA are the same from its paper Li et al.

Revised: (2020a).

Revised: Specifically, please note that we also train our detectors with adversarial samples generated by BA (same sample size as the experiments in Sec 6).

Revised: Then, we measure the defense capacity for each baseline, and the results are shown in Table 4.

Revised: [Table]

Revised: D H UMAN EVALUATION FOR THE TEXT ATTACK QUALITY

Revised: The quality of text attacks remains a challenge since it is difficult to ensure that text attacks will keep sentences’ ground truth towards the original label.

Revised: This is a problem that many SoTA adversarial defense methods have omitted.

Revised: Therefore, we conduct a human evaluation by examining the quality of four attacks selected in Sec 6.

Revised: Considering there are over one thousand adversarial samples, which lead to the tremendous manual effort, we thus choose to sample 200 adversarial sentences for our selected attacks.

Revised: Then, we evaluate whether such attacks modify their ground-truth labels

Revised: [Table]

Revised: and the results are illustrated in Table 5.

Revised: Then

Revised: [Table]

Revised: we also present the F1-score on these samples (conducted human evaluation by us) in Table 6.

Revised: We can observe that the overall quality of adversarial sentences is good

Revised: [Table]

Revised: E C OMPUTATIONAL COST

Revised: Concerning the computational cost of our method

Revised: [Table]

Revised: we present a case study here.

Revised: On one RTX

Revised: GPU, the victim model is selected as BERT-base-uncased.

Revised: Setting the batch size as 8, each inference of BERT takes around 20-30ms, TextShield (only detector part) takes around 60ms, and the cost is acceptable.

Revised: The corrector + BERT inference takes around 20-30ms, nearly equal to BERT inference time since the information corrector needed has already been computed in the VG detector.

Revised: Overall, it takes around 80-90ms per inference time under the configuration.

Revised: Considering the training cost of detectors, since detectors only consist of LSTM and MLP, training them until convergence takes around 60min (On RTX3090).

Revised: F O THER BASELINES FOR CORRECTOR DESIGN

Revised: Since the baselines for our corrector remain blank

Revised: [Table]

Revised: we define some intuitive strategies for the corrector as follows: (1) replace words based on their part of speech (POS), (2) we replace words based on their word frequency in the benchmark (Freq).

Revised: The only thing that varied in this set of experiments is: how we select words to be replaced by high-frequency synonyms.

Revised: Specifically, since different selection methods have different optimal β , we tune β for these two baselines and report the best performance.

Revised: The remaining settings in the corrector are the same to ensure fair comparisons.

Revised: The results are shown in Table 7.

Revised: We can see that all of the methods perform significantly worse than our original design - leverage saliency for correction.

Revised: Specifically, we can see that combining verbs and nouns outperform merely either of them, which is reasonable.

Revised: Also, we find that replacing lowfrequency words achieves a not bad performance, which matches the empirical findings in Mozes et al.

Revised: Overall, the results demonstrate the effectiveness of our corrector design.

Revised: [Table]

Revised: G L IMITATION AND FUTURE WORKS

Original: TextShield mainly focuses on defending against word-level text attacks, so the main limitation in
Revised: TextShield mainly focuses on defending against word-level text attacks, so the main limitation in

Original: TextShield lies in the specificity of word-level attacks.
Revised: TextShield lies in the specificity of word-level attacks.

Original: Moreover, this limitation also exists in most adversarial defenses.
Revised: Moreover, this limitation also exists in most adversarial defenses.

Original: To validate the practical application of TextShield, in this section, we conduct similar experiments as the ones in Sec 7 yet on detecting sentence-level and character-level attacks (Wang et al., 2021a; Dong et al., 2021; Mozes et al., 2021; Mosca et al., 2022).
Revised: To validate the practical application of TextShield, in this section, we conduct similar experiments as the ones in Sec 7 yet on detecting sentence-level and character-level attacks (Wang et al., 2021a; Dong et al., 2021; Mozes et al., 2021; Mosca et al., 2022).

Original: Specifically, we select one character-level attack, Visual (Eger et al., 2019), and two sentence-level attacks, PAWS (Zhang et al., 2019b) and T3 (Wang et al., 2020a), and show the results in Table 4.
Revised: Specifically, we select one character-level attack, Visual (Eger et al., 2019), and two sentence-level attacks, PAWS (Zhang et al., 2019b) and T3 (Wang et al., 2020a), and show the results in Table 8.

Original: First, we can observe that all the detectors have a significant performance drop (about 10%) in both F1-score and recall when facing sentence-level attacks, compared to the performance on detecting word-level attacks in Table 1.

Original: The reason might be that the perturbation in sentence-level attacks is more complicated and is more likely to influence sentence’ semantics at a level higher than

Original: [Figure]

Original: [Table]

Original: PAWS 80.9 ± 1.

Original: 80.5 ± 0.

Original: 73.4 ± 1.

Original: 74.3 ± 1.

Original: [Table]
Revised: [Table]

Original: 76.9 ± 1.

Original: 76.8 ± 0.

Original: 73.0 ± 1.

Original: 71.5 ± 1. Visual 84.9 ± 1. 83.8 ± 0. 80.0 ± 1.
Revised: First, we can observe that all the detectors have a significant performance drop (about 10%) in both F1-score and recall when facing sentence-level attacks, compared to the performance on de- tecting word-level attacks in Table 1.

Original: 78.4 ± 0.

Original: IMDB

Original: PAWS 80.3 ± 0. 80.4 ± 1. 75.3 ± 0. 72.3 ± 1.
Revised: The reason might be that the perturbation in sentence-level attacks is more complicated and is more likely to influence sentence’ semantics at a level higher than word-level attacks, which makes sentence-level attacks more difficult to detect.

Original: T 81.4 ± 1.

Original: 80.3 ± 1.

Original: 74.7 ± 0.

Original: 74.4 ± 1.

Original: Visual 84.9 ± 1.

Original: 85.3 ± 0.

Original: 80.6 ± 0.

Original: 79.0 ± 1.

Original: YELP

Original: PAWS 80.

Original: [Table]

Original: [Table]

Original: ±

Original: [Table]

Original: 77.2 ±

Original: [Table]

Original: 74.2 ± 2.

Original: [Table]

Original: 80.1 ± 0.

Original: 81.7 ± 0.

Original: 75.0 ± 0.

Original: 72.5 ± 1.

Original: Visual 85.1 ± 0. 85.0 ± 0. 81.7 ± 0. 80.2 ± 1. performance ofdifferent detectors against sentence-level and character-level  attacks.
Revised: Moreover, the detection difficulty of character-level attacks lies between word-level attacks and sentence-level attacks.

Original: Generally, all the detectors become less effective when facing sentence-level attacks, but our saliency-based detector still outperforms the baselines.

Original: word-level attacks, which makes sentence-level attacks more difficult to detect.

Original: Moreover, the detection difficulty of character-level attacks lies between word-level attacks and sentence-level attacks.

Original: Therefore, due to its stealthiness, sentence-level attack is a more challenging issue for adversarial defense in NLP.
Revised: Therefore, due to its stealthiness, sentence-level attack is a more challenging issue for adversarial defense in NLP.

Original: Yet, most of existing adversarial defenses (Jia et al., 2019; Dong et al., 2021; Wang et al., 2021a;
Revised: Yet, most of existing adversarial defenses (Jia et al., 2019; Dong et al., 2021; Wang et al., 2021a;

Original: Mozes et al., 2021;
Revised: Mozes et al., 2021;

Original: Wang et al., 2021b; Mosca et al., 2022; Le et al., 2022a) focus on defending word-level attacks, and they will also counter significant performance drop when facing other text attacks (e.g., sentence-level).
Revised: Wang et al., 2021b; Mosca et al., 2022; Le et al., 2022a) focus on defending word-level attacks, and they will also counter significant performance drop when facing other text attacks (e.g., sentence-level).

Original: Second, there seems to be a contradiction between the generality and performance of a defense method.
Revised: Second, there seems to be a contradiction between the generality and performance of a defense method.

Original: There are some general defenses (Le et al., 2022b; Liu et al., 2022) that can defend sentence-level, word-level and character-level attacks.
Revised: There are some general defenses (Le et al., 2022b; Liu et al., 2022) that can defend sentence-level, word-level and character-level attacks.

Original: However, their performance is not comparable to state-of-the-art defense methods designed for a specific attack (e.g., word-level attacks).
Revised: However, their performance is not comparable to state-of-the-art defense methods designed for a specific attack (e.g., word-level attacks).

Original: Meanwhile, the success of state-of-the-art defense against one kind of attacks (e.g., word-level) can not transfer to another kind of attacks (e.g., sentence-level) (Zhang et al., 2020; Goyal et al., 2022).
Revised: Meanwhile, the success of state-of-the-art defense against one kind of attacks (e.g., word-level) can not transfer to another kind of attacks (e.g., sentence-level) (Zhang et al., 2020; Goyal et al., 2022).

Original: Thus, how to tackle such a trade-off between generality and performance remains a valuable question.
Revised: Thus, how to tackle such a trade-off between generality and performance remains a valuable question.

Original: We believe that designing more suitable detectors and correctors is a plausible direction since our saliency-based defense performs properly and shows strong potential to detect each kind of attacks.
Revised: We believe that designing more suitable detectors and correctors is a plausible direction since our saliency-based defense performs properly and shows strong potential to detect each kind of attacks.

Original: Specifically, there are two lines of future work to continue: (1) designing stronger detectors that perform well on three kinds of attacks, and (2) designing better correctors with general correction schemes.
Revised: Specifically, there are two lines of future work to continue: (1) designing stronger detectors that perform well on three kinds of attacks, and (2) designing better correctors with general correction schemes.