ValCAT: Variable-Length Contextualized Adversarial Transformations Using Encoder-Decoder Language Model
Paper · 2022 · Chuyun Deng, Mingxuan Liu, Yue Qin et al.
Summary
A text classifier can assign the right label to a review or news story and change its answer after an edit that leaves the text largely recognizable. Examples like these can reveal weaknesses that ordinary accuracy tests miss. They are also hard to interpret. If an edit reverses a review’s sentiment or changes what a sentence implies, a different prediction may be appropriate. ValCAT investigates whether changing groups of neighboring words can expose more weaknesses while producing text that still reads naturally and conveys much the same meaning.
Earlier approaches discussed by the authors generally organize their edits around individual words, even when they use surrounding text to propose a change. ValCAT treats a contiguous stretch of text, called a span, as the unit of analysis and editing. It measures how much the classifier’s output changes when a span is obscured, then has T5 propose wording that fits the surrounding text. The proposed wording can replace an existing span or be inserted before it. Its length can differ from that of the wording it replaces. The classifier is treated as a black box. The authors use its prediction scores, with no access to its internal parameters during the evaluation.
The main experiments use fine-tuned BERT classifiers on English news categorization, review sentiment and sentence-pair tasks. ValCAT changes more initially correct decisions than the tested baselines in every reported comparison. On Yelp Polarity, its success rate is 93.1%, compared with 79.5% for BERT-Attack. Its edited Yelp texts also have lower perplexity, a measure of how surprising the wording is to a separate predictor. Across the main tests, ValCAT records the highest automatic semantic similarity to the original text. Its relative performance on the amount of editing and the automatic grammar check varies by dataset and by which part of the input is edited.
An AG News evaluation adds a human check. On selected items where ValCAT and BERT-Attack had already induced the same wrong classifier label, readers rated ValCAT’s wording higher for fluency, grammaticality and resemblance to the original. Their category labels showed a smaller advantage. The paper also tests a defense on Yelp Polarity. Additional training with edited reviews reduces ValCAT’s success rate from 93.1% to 72.4%, while accuracy on unedited test reviews moves from 98.3% to 98.0%. The results show both how span editing can make a robustness test more revealing and how much the conclusions depend on the way meaning, readability and task labels are checked.
Deep dive: ValCAT: Variable-Length Contextualized Adversarial Transformations Using Encoder-Decoder Language Model
ValCAT tests how well text classifiers withstand context-aware edits of varying lengths and how closely the edited texts preserve the original meaning. · about 34 minutes to read
The problem and its context
What should survive a change in wording?
Ordinary text classification accuracy asks whether a system assigns the expected labels to a collection of inputs. A robustness test starts with an input that receives the right answer and asks whether the answer survives a change that should leave the task intact. A news article may still belong to the same category after a phrase is reworded. A favorable review may still express approval after a different adjective phrase takes the place of the original. In cases like these, a change in the classifier’s answer tells us something that its original correctness could not.
The qualification about the task matters. A sentence-pair example asks what relation holds between two pieces of text. A short change to one of them can introduce a contradiction that the original pair did not contain. A shift in the prediction would then be consistent with a shift in the evidence. The authors therefore pursue several objectives together. They want to alter a prediction, keep the edit small, preserve meaning and produce text that a person can read comfortably. Each objective raises a different question about the resulting example.
The paper situates this problem in a line of research on adversarial examples, inputs deliberately altered to change a prediction. Earlier work established the relevance of such inputs to evaluating neural networks. The authors emphasize a difficulty particular to text. A change to a character or a word replaces a discrete part of the input, and even a visually small edit can change the meaning or make the wording awkward. Counting altered words gives an estimate of the size of an edit. It leaves open what those words contribute to the task. Explaining and Harnessing Adversarial Examples
That distinction gives the paper its reason for looking at spans. Neighboring words can work together to express a property, a degree or a relation. An isolated word change may leave the surrounding phrase ill fitted to its new wording. Changing a short stretch as a unit gives the replacement room to express the same idea in a different construction. At the same time, a span can contain several words that jointly matter to the classifier, even if a test of each word in isolation gives an incomplete picture of their contribution.
How earlier methods chose what to change
The authors describe earlier methods at the character, word and sentence levels. Character-level methods can create a small surface edit by altering the spelling or appearance of a word. The paper notes that the resulting forms can be conspicuous to a reader. TextBugger, one of the baselines, combines character-level changes with a word substitution option. Its presence in the evaluation gives the paper a comparison with an approach whose edits can act at finer granularity than ValCAT’s spans. TextBugger
Some word-level methods choose alternatives using information associated with the word itself. The paper cites methods based on morphology, lexical relationships and word embeddings. TextFooler, for instance, draws on a word representation space to identify nearby alternatives and uses grammatical and meaning-related checks. The alternatives can be plausible as substitutes in isolation, but a word’s suitability also depends on the surrounding phrase and the sense it has there. Is BERT Really Robust?
Other word-level methods use the sentence context during generation. A masked-position predictor estimates which wording would fit a gap, taking the surrounding sentence into account. The paper treats this as an important advance over choosing candidates mainly from properties of the original word. It still sees a restriction in how the edit is organized. A procedure can offer several sorts of changes and use substantial surrounding context while continuing to choose each edit around an individual word. Context can improve the choices available at a position without changing the unit that the procedure examines. BERT-Attack · BAE · Contextualized Perturbation for Textual Adversarial Attack
The sentence-level approaches the authors discuss can make broader changes. Some work in an internal numerical representation of a sentence and produce new text from that altered representation. The paper identifies a different difficulty there. When wording can change across the sentence, keeping control over the quality of the result can be harder. ValCAT locates its edits within identifiable portions of the original input. The surrounding text still supplies context, and a single local operation can affect multiple words.
Where ValCAT changes the design
The paper separates the choice of where to edit from the choice of what wording to use. The first question concerns the classifier. How responsive is its output to the temporary removal of information from a particular stretch? The second concerns language. What could plausibly go in that location, and how closely would it preserve what the original text said? The authors use different evidence for the two questions. The classifier’s scores indicate sensitivity, and the surrounding words guide the production of candidate phrases.
Variable length has a distinct role at each stage. During the search for positions, it allows the authors to inspect stretches of different widths. During editing, it allows generated wording to have a different length from the target wording. A method could broaden the first stage while requiring all replacements to be the same length, or it could restrict discovery to single words while allowing a replacement phrase. ValCAT tests a system that broadens both stages. Its ablations then vary which spans and operations the system uses, providing evidence about some of the choices within that broader design.
The focus on local changes also shapes what the authors mean by a successful test. A classifier can change its answer for many reasons, and the paper has no direct access to its internal decision process in the stated setup. The method observes the relationship between edits and output scores. A highly ranked stretch is a place where a particular probe affected the output. That observation is useful for constructing a robustness test. It gives a more limited account of the role each word played in the original decision.
The method, step by step
From an original input to an edited one
ValCAT begins with text whose recorded label agrees with the classifier’s prediction. It first identifies stretches that appear to matter to the classifier, then tries to alter the wording at those locations. Discovery uses a temporary placeholder so that the original words can be obscured in a standardized way. The final candidate texts contain generated wording. The probe and the candidate have different jobs. The probe measures whether a location is promising, while the candidate must meet the conditions for a successful test.
Consider what happens when a local description is rewritten. A short expression of approval can be replaced by a longer phrase that still expresses approval. This is a replacement, and the original expression disappears from that position. An insertion leaves the expression in place and adds wording just before it. The two operations can have different effects even at the same location. An insertion can preserve all the original words while changing their interpretation. A replacement can remove some words while retaining the same practical message.
The generator proposes text that fits the context, and the classification test determines whether an eligible candidate changes the prediction. If multiple eligible candidates succeed during a round, the procedure favors the one judged closest in meaning to the original input. If none succeeds, it can carry a candidate forward and edit another location. Later rounds therefore work from a text that may already differ from the original in several places.
How ValCAT evaluates and edits a classified text
The steps in order.
What the classifier reveals
The paper represents the classifier as a function from inputs to labels. The category predicted for an input is a separate piece of information from the score assigned to each possible category. This distinction matters because a probe can weaken confidence in the original label while leaving it in first place.
F : X → Y
Here F is the classifier, X is its input space, and Y is the set of allowable output labels. The arrow shows that applying F to an input returns a label.
x = w₁ w₂ … wₙ
The symbol x denotes the original text. Each w is a word, and its subscript gives its position in that text. The last index n is the number of words. The ellipsis stands for the intervening positions, and writing the words side by side preserves their order.
F(x̃) ≠ F(x)
The symbol x̃ is a changed version of x, and F is the same classifier on both sides. The inequality is the condition that the changed text receive a different predicted label. Because the original was correctly classified, any different predicted label satisfies this part of the success condition. The amount of editing and the similarity of the resulting text are assessed separately.
The authors call their access setting soft-label black box. The classifier supplies a score for a proposed label on a submitted input. The score is written as P(y | x), where y is a label, x is an input and the vertical bar indicates that the score is for that label given that input. The setup refers to logit output, while the equations describe the quantities as probabilities. The procedure uses differences between label scores to distinguish better and worse probes. Seeing the final category alone would provide less information, since two probes could return the same label while affecting its score to different degrees.
How the span ranking works
A span covers consecutive words, with a starting position and a length. ValCAT tests spans of different lengths by moving a window through the text. A window of a given width shifts from one starting position to the next until no complete span remains at that width. The method repeats this process for the other allowed widths. The discovery window in the main implementation has a maximum length of 3 words. That setting applies to the material being examined for sensitivity. It does not fix the length of the eventual generated replacement.
sᵢ:ᵢ₊ₗ = wᵢ … wᵢ₊ₗ₋₁
The symbol s denotes a span, i is its first position, and l is its length. The subscript i:i+l identifies its boundaries. The last included word is wᵢ₊ₗ₋₁, so position i+l lies just beyond the span. The ellipsis stands for the words between the first and last included positions.
To probe a span, the authors replace it with an unknown-word marker and obtain new scores from the classifier. Even when the span covered several words, the marker stands in for the span as a whole. The response is compared with the score on the unchanged input. This measures sensitivity to the information obscured by the probe under the paper’s particular way of obscuring it.
dᵧ(x, x̃) = P(y | x) − P(y | x̃)
Here dᵧ is a signed score difference for label y. The first P term is the score for y on original text x, and the second is the score for the same label on altered text x̃. The subtraction gives a positive value when the alteration lowers the score of y. A negative value means that the alteration raises it.
That difference can help rank changes even when their predicted labels stay the same. If an alteration changes the label, the paper also takes account of the score gained by the newly predicted class. It uses the same difference with the inputs reversed and the new label in place of the old one.
Dᵧ(x, x̃) = ⎧ dᵧ(x, x̃) if y = ỹ
⎩ dᵧ(x, x̃) + dᵧ̃(x̃, x) if y ≠ ỹ
The symbol Dᵧ denotes the decision difference used by ValCAT. The label y is the prediction for x, and ỹ is the prediction for x̃. The upper branch applies when the labels are equal and uses the change in the original label’s score. The lower branch applies when the labels differ. Its additional term, dᵧ̃(x̃, x), compares the new label’s score on the altered input with its score on the original input. The plus sign combines the loss in support for the old label and the gain in support for the new label.
IPₓ(s) = Dᵧ(x, x̃ₛ)
Here IPₓ(s) is the importance score of span s in text x. The symbol x̃ₛ denotes the probe text with that span replaced by the unknown-word marker. The score is the decision difference Dᵧ, evaluated using original prediction y and that particular probe.
Every ranked entry records where the span starts, how long it is and what importance score it received. The list is ordered from the largest score down. The scores come from probes on the original input. The text being edited can change as the procedure continues, so a later candidate may be evaluated in wording different from the context in which its position was first ranked. The paper also drops subsequent ranked spans that overlap with a selected span. It uses this rule to avoid repeatedly modifying the same original words.
How wording is generated for a location
Ranked spans identify places to consider. T5 supplies the wording. The authors explain the choice by distinguishing masked prediction from sequential continuation. A gap somewhere in a text can be identified for a predictor that reads the surrounding context. Sequential generation, in turn, allows the output for that gap to contain a variable number of words. T5 combines an encoder, which reads the input with a missing portion, and a decoder, which produces the content for it. Its pretraining already includes this kind of missing-span task. The authors also point to the C4 pretraining corpus when explaining their choice.
In replacement, the input to the generator consists of the retained text with a mask at the target location. This mask serves a different purpose from the unknown-word marker used in discovery. The classifier sees the discovery probe so that the authors can measure a change in scores. The generator sees the replacement mask as a request to supply text for the missing region.
x̃[i:i+l] = w₁ … wᵢ₋₁ [mask] wᵢ₊ₗ … wₙ
The expression x̃[i:i+l] denotes the masked text for a replacement at the span beginning at i and having length l. The word wᵢ₋₁ is the last one before the gap, and wᵢ₊ₗ starts the retained suffix. The literal [mask] indicates the missing region. The words denoted by the ellipses retain their original order, and wₙ is the final word position.
x̃[i:i+l],ₛ = w₁ … wᵢ₋₁ s wᵢ₊ₗ … wₙ
The expression on the left denotes the candidate made by filling the replacement gap with s. In this equation s is a generated span, one member of the set of candidate spans. The indices i, l and n have the same roles as in the masked expression. The generated span takes the place of the selected original words and may contain a different number of words.
The generator can use the words on either side of the gap to propose natural wording. In replacement, it has lost access to the very words it is meant to preserve in meaning. A fluent completion can therefore express a different claim. The authors address that possibility with similarity checks after generation, including a comparison of the generated span with the original span. They use the Universal Sentence Encoder to represent the texts numerically and cosine similarity to compare the direction of their representations. The replacement may exceed the target in length by no more than two words. The paper also imposes an overall limit on the proportion of words changed.
Insertion creates a gap just before the target starts. The target words remain visible to the generator and remain in the edited text.
x̃ᵢ = w₁ … wᵢ₋₁ [mask] wᵢ … wₙ
Here x̃ᵢ is the masked input for insertion at position i. The words through wᵢ₋₁ form the prefix, and the original text resumes at wᵢ after the [mask] marker. The ellipses show words outside the insertion point, and wₙ is the last word of the original.
x̃ᵢ,ₛ = w₁ … wᵢ₋₁ s wᵢ … wₙ
The expression x̃ᵢ,ₛ denotes the resulting candidate. The generated span s is added between the prefix and wᵢ, so the original words from wᵢ through wₙ stay in place. The amount added is counted against the edit budget, and the candidate is subject to the paper’s similarity constraints.
The different treatment of the target has consequences for how the two operations preserve wording. A replacement can keep a shared sequence of words while rearranging or extending the surrounding expression. An insertion keeps the whole original sequence and changes what accompanies it. The paper’s edit accounting is designed to give credit for unchanged words in a replacement and to count every newly added word in an insertion.
How much change the procedure counts
The replacement calculation uses the longest common subsequence of the original and generated spans. A common subsequence consists of words that appear in the same order in both spans. They can be separated by intervening words. The longest such subsequence gives the largest amount of ordered material that the two spans have in common under this measure.
replacement modifications = max(lₜ, lₐ) − lLCS
The symbol lₜ is the length of the target span, and lₐ is the length of the generated span. The function max takes the larger of those lengths. The quantity lLCS is the length of their longest common subsequence. Subtracting it leaves the number of modifications assigned to the replacement. For an insertion, the assigned number of modifications is simply the length of the added span. The word perturbation rate expresses the modifications relative to the original text’s word count.
This accounting supports length-changing edits without treating all words in an altered stretch as new. It measures preservation of word sequences. Meaning and grammatical fit are distinct enough that the authors evaluate them separately. An edit that leaves most words in their original order can still change a relation or stance important to the task.
How the rounds end
At a ranked position, ValCAT considers the candidate texts produced by replacement and insertion and checks their predictions. Among eligible texts that change the classifier’s label in that round, it returns the one with the highest similarity to the original text. The similarity comparison is anchored to the original even though the current input may include edits from earlier rounds. Once a successful round has a result, the procedure ends. The decision rule therefore identifies the closest success in that round from the available candidates.
When no candidate changes the label in a round, the procedure uses the decision difference to choose which candidate to carry into the next round. It keeps one current text, favoring the candidate that most affects the classifier’s scores according to the paper’s rule. This is a greedy choice. It follows the best candidate under the current criterion without exploring every combination of earlier and later edits. If the procedure cannot reach a successful example within the permitted changes, the test records a failure.
The main experiments use a BERT classifier adapted to each task through fine-tuning, with T5 serving separately as the span generator. The classifier supplies task predictions and the generation system supplies text. The paper releases an implementation under the ValCAT name. Its defense experiment reverses the role of the edits in the research design. There, generated and intermediate texts become additional training examples, with the original gold labels retained, before the classifier is evaluated again.
Experiments and results
The tasks and inputs
The authors report drawing 1000 instances at random from each English dataset in the main evaluation. AG News assigns a news item to a topic, with 4 categories covering world news, sports, business and science or technology. Yelp Polarity asks whether a restaurant review is positive or negative. IMDB gives a corresponding binary sentiment task for movie reviews. Together these collections test edits to inputs whose labels depend on quite different kinds of evidence. A news category can be supported by subject matter spread across the article, while review sentiment can depend heavily on the expressions used to evaluate a place or a film. Character-level Convolutional Networks for Text Classification · Learning Word Vectors for Sentiment Analysis
SNLI and MNLI use paired inputs. A premise and a hypothesis are classified according to whether the premise entails the hypothesis, contradicts it or leaves the relationship neutral. The authors describe MNLI as covering varied genres. QNLI is a binary classification version of a question-answering dataset, with a question and a sentence as the two inputs. The paired evaluations report results separately for edits to the first and second parts. In SNLI and MNLI those parts are the premise and the hypothesis. In QNLI they are the question and the sentence. A Large Annotated Corpus for Learning Natural Language Inference · A Broad-Coverage Challenge Corpus for Sentence Understanding through Inference · GLUE
The paired structure changes the interpretation of a test. When the premise is edited, the evidence available for evaluating the hypothesis can change. When the hypothesis is edited, the claim that must be evaluated can change. On QNLI, changing the question can alter what information the sentence is supposed to supply, while changing the sentence can alter what evidence is available. The two directions are reported separately because the same aggregate could hide different levels of sensitivity at the two input positions.
The paper sets the allowed perturbation rate and minimum semantic similarity by dataset. In the main evaluation, AG News and Yelp Polarity use a perturbation limit of 0.4 and a similarity threshold of 0.8. IMDB uses 0.3 for the edit limit and 0.9 for similarity. SNLI, MNLI and QNLI use 0.6 for both constraints. Comparisons among methods on a given dataset share the specified constraint setting. The dataset-specific limits are part of what distinguishes one reported setting from another.
Baselines and measurements
TextBugger, TextFooler and BERT-Attack serve as the comparison methods. Their main difference for the purposes of this experiment is how they propose local changes. TextBugger includes spelling-level alterations and synonym replacement. TextFooler chooses word replacements using nearby representations and checks their grammatical role and meaning. BERT-Attack uses the surrounding text to suggest a word for a masked position. BERT-Attack is the closest comparison in its use of contextual prediction, while TextFooler and TextBugger provide different ways to construct candidate edits.
The paper reports original accuracy, attacked accuracy and attack success rate. Original accuracy is the share of unedited inputs classified correctly. Attacked accuracy reflects the predictions after the attempted changes. Success rate describes how frequently the method overturns the initial correct prediction in examples eligible for an attack. These measures give related views of the same evaluation, but they describe different populations or stages of it. An incorrect prediction on an unedited input already affects original accuracy. It cannot count as a successful reversal of a correct prediction.
Perplexity estimates how readily GPT-2 predicts the resulting wording. Lower perplexity means the text is less surprising to that predictor. The authors use it as an automatic fluency indicator and report the original text’s perplexity as a point of comparison. The semantic similarity measure compares representations of original and edited texts from the Universal Sentence Encoder. Higher similarity means the representations are closer by that measure. These quantities address separate properties. An ordinary-looking sentence can be easy to predict while saying something different, and an unusual sentence can be close in meaning to its source.
The paper also reports the share of words perturbed and the increase in grammatical errors. For the latter, it uses LanguageTool to count errors in the original and edited texts and records the increment. Lower values are preferred for both measures. The edit rate indicates how much material changed according to the paper’s accounting rule. The grammar measure indicates how much additional material the checker identifies as erroneous. Human ratings supplement both the grammar and fluency measurements in a separate study.
News and review classification
ValCAT’s success on the sampled Yelp Polarity inputs stands out both for the frequency of prediction changes and for the fluency of the resulting texts. The unedited accuracy is 98.3%. ValCAT brings attacked accuracy to 6.8%, with a success rate of 93.1%. BERT-Attack yields attacked accuracy of 20.2% and a success rate of 79.5%. On the same data, TextFooler’s success rate is 71.8% and TextBugger’s is 45.4%.
Attack success rate by method on sampled Yelp Polarity inputs
ValCAT reverses the largest share of initially correct predictions.
The numbers
| System or setting | success rate % |
|---|---|
| TextBugger | 45.4 |
| TextFooler | 71.8 |
| BERT-Attack | 79.5 |
| ValCAT (this paper) | 93.1 |
The Yelp Polarity outputs from ValCAT have perplexity of 81.6, compared with 71.1 for the original texts and 162.9 for BERT-Attack’s outputs in the main results. ValCAT’s semantic similarity is 0.950. TextFooler, at 0.890, is the closest baseline on that measure in this comparison. The edit-rate result has a different ordering. ValCAT records 11.6%, while TextFooler records 11.2%. ValCAT’s output can therefore be closer by the embedding measure while having a slightly larger proportion of words changed. Its increase in grammar errors is 0.11, compared with 0.15 for BERT-Attack.
AG News is the classification setting in which ValCAT’s success rate is lowest. The BERT classifier is initially correct on 94.4% of the sampled inputs. ValCAT’s attacked accuracy is 35.3%, and its success rate is 62.6%. TextFooler reaches 52.5% success, ahead of BERT-Attack’s 49.7% in this dataset. TextBugger reaches 34.3%. The result illustrates why BERT-Attack’s role as the strongest baseline overall should be distinguished from the ranking in each setting.
On AG News, the unedited texts have perplexity of 98.4, and ValCAT’s outputs have perplexity of 136.2. The corresponding figures for BERT-Attack and TextFooler are 326.9 and 418.6. ValCAT’s semantic similarity is 0.922, higher than the reported baseline values, and its grammar-error increment is 0.39. TextFooler uses a smaller measured edit rate, 15.7% compared with ValCAT’s 16.1%, while giving a lower success rate. The joint reading is that ValCAT finds more successful edits on these items and produces outputs with better automatic fluency and similarity scores, with a small disadvantage to TextFooler in the amount of editing.
On IMDB, original accuracy is 94.6%. ValCAT reaches 86.5% success and attacked accuracy of 12.8%. BERT-Attack reaches 80.7% success and attacked accuracy of 18.3%. ValCAT’s output perplexity is 65.6 against 58.8 for the original reviews. TextFooler’s output perplexity is 95.6 and BERT-Attack’s is 98.0. ValCAT’s semantic similarity is 0.977, while its perturbation rate is 6.7%. TextFooler reports a smaller perturbation rate of 5.9%, and BERT-Attack has a slightly smaller grammar-error increase, 0.08 compared with ValCAT’s 0.09.
These classification results show why the paper reports several measures together. The ranking on success, perplexity and semantic similarity consistently favors ValCAT in the main tests. Counting changed words yields a different ranking in the news and review comparisons. A span edit can use more words and still be easier for the fluency evaluator to predict. The human study takes up the question of whether an advantage of that sort is visible to readers.
Sentence-pair classification
On SNLI, original accuracy is 89.8%. Editing the premise, ValCAT attains 88.2% success and attacked accuracy of 10.6%. Editing the hypothesis, it attains 89.2% success and attacked accuracy of 9.7%. The corresponding BERT-Attack success rates are 61.2% on the premise and 77.2% on the hypothesis. ValCAT obtains semantic similarity of 0.854 for premise edits and 0.840 for hypothesis edits. Its perplexities are 90.9 and 78.6 in those settings, respectively, against original-text perplexity of 68.0.
The edit-rate comparison on SNLI depends on which part is changed. ValCAT’s premise edit rate is 21.3%, and BERT-Attack’s is 24.8%. On hypotheses, ValCAT’s is 22.9% and BERT-Attack’s is 19.3%. BERT-Attack also has a smaller grammar-error increment on hypothesis edits, 0.09 against 0.15 for ValCAT. The gains in success and semantic similarity thus coexist with higher measured editing and added grammar errors on that side of the pair.
On MNLI, the original accuracy is 82.7%. ValCAT’s success rates are 91.2% for editing the premise and 97.0% for editing the hypothesis. Its attacked accuracies are 7.3% and 2.5% in the same order. BERT-Attack reports 72.9% success on premises and 78.6% on hypotheses. The ValCAT outputs have perplexities of 93.5 and 89.5, compared with 79.5 for the original dataset texts. The premise and hypothesis similarities are 0.879 and 0.869.
Attack success rate by method when editing MNLI hypotheses
ValCAT produces the most prediction changes under the shared evaluation setting.
The numbers
| System or setting | success rate % |
|---|---|
| TextBugger | 58.0 |
| TextFooler | 74.1 |
| BERT-Attack | 78.6 |
| ValCAT (this paper) | 97.0 |
On QNLI, the original accuracy is 90.0%. ValCAT achieves 79.2% success when editing questions and 92.9% when editing sentences. The attacked accuracies are 18.7% on questions and 6.4% on sentences. BERT-Attack reaches 63.8% success on questions and 72.6% on sentences. ValCAT’s semantic similarities are 0.828 and 0.892 for question and sentence edits, respectively. Their perplexities are 70.4 and 87.5, with original perplexity of 66.1.
The amount of editing on QNLI again depends on the input side. ValCAT’s perturbation rate for questions is 27.8%, compared with 20.7% for TextFooler. Its perturbation rate for sentences is 18.4%, the lowest of the tested methods in that setting. The question and sentence results describe different opportunities to change an input. An overall result for QNLI alone would conceal this difference.
In every main configuration, ValCAT has the lowest perplexity and the highest automatic similarity. The authors describe its perplexity as approximately 50% of BERT-Attack’s in their overall account. Individual settings vary. On IMDB, the values for ValCAT and BERT-Attack are 65.6 and 98.0. On QNLI sentence edits, they are 87.5 and 215.5. The paper reports the lowest grammar-error increase for ValCAT in five out of nine comparisons. Its grammar claim is accordingly narrower than its result on perplexity.
What people saw in the edited news
The authors recruited five annotators with CET-4 certification. They randomly selected 100 eligible AG News examples for which both ValCAT and BERT-Attack had already induced the same mistaken category. This selection makes the texts comparable in terms of what the tested classifier did. The human evaluation then asks what the original and altered texts look like to a reader.
For fluency and grammaticality, the original and both edited versions of an item were grouped and shuffled before rating. For semantic similarity, annotators saw the original and separately judged how closely each edited version resembled it, with presentation order randomized. Both tasks used a scale from 1 to 5, with criteria and examples for the grades. For category labeling, the original and edited texts were mixed, and the annotators assigned categories. The authors normalized and averaged the ratings and used majority vote to combine the category decisions.
The combined fluency and grammaticality rating is 3.37 for ValCAT, 2.98 for BERT-Attack and 3.97 for the original AG News texts in this selected evaluation. The similarity rating is 3.92 for ValCAT and 3.41 for BERT-Attack. These judgments agree with the automatic measures on the relative quality of the two systems’ edited examples. They also show that the original texts retain an advantage in the combined readability rating.
Human labeling accuracy on the selected items is 63.0% for ValCAT, 62.0% for BERT-Attack and 65.0% for the original texts. The difference between the edited versions is small beside the separation in the ratings. The three measures capture recognizable distinctions. Readers can find an edited text more natural or closer to the original while assigning a topic label with almost the same accuracy. The original-text result provides a working reference for how the readers agreed with the labels on this particular sample.
What the ablations show
Which kinds of span edits contribute?
The transformation ablation changes the kinds of edits available to ValCAT. The paper uses the label n-Many for a replacement in which n is the length of the original target span and the generated replacement can vary in length. The label therefore describes the source span. It does not promise that the new phrase will have more words. A replacement may be shorter, equal in length or longer.
The full configuration records 93.1% success on Yelp Polarity in this comparison. With replacements at target lengths of 1, 2 or 3 words and no insertions, the reported success rate is 90.8%. Using only the first two target lengths produces 91.7%. Restricting the target to a single word produces 87.9%. Insertion alone yields 86.4%. The full system obtains the best success rate among the tested variants, while the two mixed replacement settings show that including another replacement option does not guarantee a higher score in every configuration. The procedure follows the candidates chosen along its current path, so changing the options can affect the path as well as the range of possible edits.
Attack success rate by transformation setting on Yelp Polarity
The complete set of transformations performs best, while the replacement-only settings vary with the lengths available.
The numbers
| System or setting | success rate % |
|---|---|
| 3-Many | 80.7 |
| 2-Many | 86.1 |
| Insertion only | 86.4 |
| 1-Many | 87.9 |
| 1, 2, 3-Many | 90.8 |
| 1, 2-Many | 91.7 |
| Full ValCAT (this paper) | 93.1 |
The ablation gives a different answer if the question is how predictable the resulting wording is. The 3-Many configuration has the lowest perplexity, 77.1, compared with 81.6 for full ValCAT. Its perturbation rate, 16.0%, is higher than the full method’s 11.6%. The authors suggest that a longer target gives the generator room to produce an appropriate alternative while using more of the edit allowance in a single operation. This explanation fits the joint pattern of low perplexity, higher perturbation and lower success in that setting. The experiment does not track separately how often each of those mechanisms determined the outcome.
The number of classifier queries also varies substantially. The Yelp ablation reports 266 for 3-Many, 340 for 1-Many, 431 for 1, 2-Many and 490 for 1, 2, 3-Many. Full ValCAT is listed at 673. Insertion alone reaches 799 even though it has fewer types of operation than the full method. A broader configuration can evaluate more candidates in a round. A narrower configuration can continue for longer before finding a successful change. The reported counts reflect the resulting search, including when it stops.
Insertion alone achieves similarity of 0.953, above full ValCAT’s 0.950 in the Yelp ablation. Its word perturbation rate is 14.4%, above the full method’s 11.6%. The ordering is consistent with the distinction between preserving existing language and minimizing the total words counted as changed. Insertion leaves the source wording present but charges the procedure for each added word. The full method can use a replacement whose source and generated spans share material. The measured similarity and edit-rate values show that each metric rewards a different property of the text.
The 1-Many setting makes a useful comparison with the contextual baseline. Its Yelp success rate is 87.9%, its perplexity is 84.4 and its similarity is 0.933. BERT-Attack’s ablation entries for those measures are 79.5%, 162.8 and 0.881. A method can therefore retain a one-word target and still benefit from the broader replacement lengths and other choices in ValCAT. Because the two methods differ in more than the length of their output, this comparison establishes the performance of the tested configurations. It does not isolate a contribution due solely to length.
How constraints and candidate counts change the outcome
On Yelp Polarity the authors vary the allowable extent of editing and the similarity requirement. As they tighten access to candidate changes, success rates decline. ValCAT’s success declines more slowly than those of the baselines in the reported comparison and remains at almost 70% under the strictest setting shown. The perplexity curve for ValCAT stays low across those settings. This indicates that its relative performance on Yelp is present with several constraint choices, alongside the particular limits used for the main results.
The candidate-count analysis asks a different question. A wider set of generated possibilities gives the procedure more ways to find a change that affects the classifier. In the reported figure, considering more candidates improves success. The authors also observe that perplexity can rise, especially on AG News. They attribute this to selection. When a larger pool is available, a candidate that is less probable as natural text can still be chosen for having a stronger effect on the classifier. The generation procedure and the choice among generated candidates therefore both matter to the final wording.
The two analyses address different sources of restriction. A perturbation or similarity threshold determines which edits can remain eligible. The number of generated candidates determines how much material is available for evaluation. Improving success by expanding the latter can come with higher perplexity. Tightening the former can reduce success while leaving the surviving texts closer to their originals under the measured constraints.
What the successful edits contain
In the successful examples, the authors report that 62% of transformations are replacements and 38% are insertions, on average. Replacement is more common in the completed examples. The operation count describes what survived a selection process in which different candidates could have competed for the same location. It gives the composition of successful outputs without supplying a success probability for every attempted operation.
The span-length counts show that the procedure uses its ability to change lengths in practice. The authors find that the selected source spans tend to be longer than the wording that replaces them. Among the original spans selected for replacement, 26.2% contain one word and 38.0% contain 3 words. Among the generated spans used for replacement, 33.1% contain one word and 24.6% contain 3 words. The contrast is consistent with a generator that frequently fits a shorter wording into a location identified through a wider probe. Variable length is therefore relevant to compression as well as expansion.
The paper also checks the part-of-speech patterns in the spans. Replacement strings show common grammatical categories resembling those of the material they replace. Adjectives make up 7.6% of the listed patterns for source spans and 8.4% for generated replacements. Among insertion patterns, adverbs account for 12.4%, and adjectives account for 6.7%. These observations describe what the selected texts contain. An inserted modifier is a plausible way to add wording at a local position, and similarities in grammatical patterns are compatible with the intended contextual fit. The distributions alone cannot establish that a replacement is grammatical or preserves the intended meaning in a particular sentence.
Changing the generator and the classifier
The authors compare several variants of T5 for span generation. The base configuration reports 93.1% success, perplexity of 81.6 and similarity of 0.950 in the comparison. The larger variant records 90.3% success and perplexity of 84.0. The multilingual base variant reaches 94.2% success, with perplexity of 84.6 and similarity of 0.949. The T5 v1.1 base variant records 92.3% success and perplexity of 101.8. The authors report longer generation times for the larger and multilingual variants. The standard base configuration has the lowest perplexity and highest similarity in that set, while the multilingual variant has the highest success rate. The authors regard the standard base configuration as sufficient for their application.
The Yelp generalization study keeps the ValCAT approach and changes the classifier being evaluated. On RoBERTa, original accuracy is 99.1%, attacked accuracy is 13.3% and success is 86.6%. On the LSTM classifier, original accuracy is 95.3%, attacked accuracy is 0.7% and success is 99.3%. On wordCNN, original accuracy is 95.4%, attacked accuracy is 1.1% and success is 98.8%. BERT’s success rate in the same study is 93.1%. The authors speculate that RoBERTa’s pretraining may help explain its relative performance. The comparison changes the classifier as a whole and does not isolate a particular part of pretraining.
A separate test asks whether successful examples carry over from the classifier they were made for to another classifier. The paper calls this transferability. Once an edited input has been obtained for one classifier, it can be evaluated on another without searching for new wording for that second system. The transfer table reports attacked accuracy with the source of the examples in the rows and the system receiving them in the columns. For example, the BERT-generated examples leave wordCNN at 76.1% attacked accuracy. In the other direction, the wordCNN-generated examples leave BERT at 83.4% attacked accuracy. The authors report a general tendency for examples generated against BERT and RoBERTa to affect the LSTM and wordCNN more than examples generated in the reverse direction. The comparison is conditional on the examples having succeeded against their original targets, so each row describes a selected collection.
Training on the edited reviews
The defense experiment asks whether exposing BERT to altered Yelp reviews during training changes its subsequent behavior. From the Yelp training dataset, the authors draw a sample of 10,000 instances. They use ValCAT to generate edits and combine final examples with intermediate texts from the procedure. The resulting material contains approximately 60,000 texts. They fine-tune BERT on these texts using the original gold labels.
On the Yelp test dataset, clean accuracy changes from 98.3% to 98.0% after this training. ValCAT’s success rate goes from 93.1% against the original classifier to 72.4% against the retrained classifier. Under attack, classification accuracy goes from 6.8% to 27.0%. The measured perturbation rate goes from 11.6% to 14.0%, and the query figures reported for this experiment are 673.3 and 884.2. The retrained classifier retains nearly the same accuracy on original reviews and requires more effort to produce successful alterations under the paper’s test. A substantial share of reviews remain susceptible within that setting.
The training comparison gives the paper evidence for a defensive use of the generated material. Its interpretation depends on the training labels. Keeping the original label is appropriate when an edit preserves sentiment. The paper’s automatic similarity checks are relevant to that assumption, and the human study provides evidence about resemblance and readability on selected news articles. The Yelp experiment itself establishes the effect of using the generated training material under inherited labels and then testing with ValCAT.
Limitations
Limits identified by the authors
The authors identify classifier queries as a cost of the full procedure. Probing multiple lengths adds to the work of finding a location. Generating replacements and insertions creates additional candidates whose predictions may need to be checked. The paper reports an average of 34 secs to generate a successful example on its stated configuration, which includes a V100 GPU. That timing concerns successful generation on the reported hardware. The ablation illustrates how narrowing the available transformations changes the query burden and the measured output quality.
The authors also point to a limitation in the replacement generator. The original span has already been masked when T5 receives the text. A completion can make sense with the visible words even if it supplies a different property, event or relationship from the one removed. The procedure tries to catch such changes after generation with similarity comparisons. The proposed direction for future research in the paper is to change the training so that the replacement can be guided more directly by the meaning of the source span.
These limits concern different stages. Query cost arises from discovering positions and testing candidate outputs. The generator’s missing source information affects what type of candidate those stages have available to test. Changing the width of the search can influence both the time and the chances of finding a usable alteration. Improving direct preservation of the source meaning would address the candidate wording itself.
Limits visible in the evaluation
The main tests cover English classification and inference datasets, with the primary comparisons made against fine-tuned BERT. The additional classifier comparison and transfer study are on Yelp Polarity. This gives direct evidence about restaurant-review sentiment beyond BERT, while news classification and sentence-pair inference have a narrower set of evaluated classifiers. The paper’s soft-label access assumption is also part of the result. The ranking requires scores whose changes can be observed before a decision flips. An interface returning only a label would give different information.
The authors describe the procedure as deterministic and report the results from a single run. Their main evaluations also start with random samples from each dataset. The absence of randomness in the procedure after those inputs have been chosen does not establish how much the reported values would vary over other independently drawn samples. The numerical results describe the samples and constraint settings tested. The paper also gives average timing for a successful example, leaving the cost of unsuccessful attempts outside that particular figure.
The constraint settings affect comparisons across tasks. The minimum similarity allowed in IMDB is 0.9, while the paired tasks use 0.6. The permitted edit rates also differ. A larger success rate on one dataset can reflect differences in text, labels, classifier behavior or the space of allowed alterations. Within a setting the methods can be compared under the reported limits. Across settings the numbers describe robustness under different conditions, and they provide no single ranking of which task is intrinsically most vulnerable.
Semantic preservation remains partly an open measurement problem. The Universal Sentence Encoder contributes to the similarity constraint and supplies the metric used in the main results. The high similarity scores show strong performance under that representation. They offer less independence from the criteria used to select the outputs. A pair of texts can be judged close overall by an embedding while a changed phrase affects the exact sentiment or inference label. This matters particularly when a premise and hypothesis differ in their logical relationship because of a local change.
Perplexity and the grammar checker give additional automatic views of text quality, each with a limited interpretation. GPT-2 perplexity measures how readily a separate predictor can anticipate the text. LanguageTool measures the increase in errors it recognizes. Human judgments address properties those measurements approximate, but only on the selected AG News sample. The study considers shared successes against the classifier that induce the same wrong topic label. It therefore compares the quality of edited text under that condition, leaving the readability and label preservation of other outputs less directly assessed.
The human labels offer a further reason for care. On the selected news items, annotators attain 65.0% accuracy on the originals, 63.0% on ValCAT and 62.0% on BERT-Attack. Those figures show how the compared texts fare against the task labels under the study’s voting procedure. The original-text result also shows considerable room for disagreement on the sample before any adversarial editing. The experiment supports a relative advantage in ratings for ValCAT. Its small difference in human labeling accuracy supplies less evidence of a clear advantage in category preservation.
Finally, the defense study evaluates training with ValCAT examples and a subsequent ValCAT test on the same kind of review data. That design supports the conclusion that the retrained classifier is harder to alter with this procedure on Yelp Polarity. The paper does not run the corresponding defensive comparisons across the other tasks or against a separate set of attacks. The transfer experiment addresses whether existing examples affect other classifiers. It answers a different question from whether the protection conferred by training extends to different ways of constructing the examples.
What came after
No later work is documented here, so there is no supported account of subsequent research adopting or modifying ValCAT.
Cite
Cite as Chuyun Deng, Mingxuan Liu, Yue Qin, Jia Zhang, Hai-Xin Duan and Donghong Sun. 2022. ValCAT: Variable-Length Contextualized Adversarial Transformations Using Encoder-Decoder Language Model. Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
@inproceedings{deng2022valcat,
title = {{ValCAT: Variable-Length Contextualized Adversarial Transformations Using Encoder-Decoder Language Model}},
author = {Chuyun Deng, Mingxuan Liu, Yue Qin, Jia Zhang, Hai-Xin Duan and Donghong Sun},
booktitle = {Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies},
year = {2022},
doi = {10.18653/v1/2022.naacl-main.125},
url = {https://doi.org/10.18653/v1/2022.naacl-main.125}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/deng-2022-valcat-variable-length-contextualized-adversarial/