Hostname: page-component-74656f9884-6grmk Total loading time: 0 Render date: 2026-11-06T00:45:07.290Z Has data issue: false hasContentIssue false

Towards improving the robustness of sequential labeling models against typographical adversarial examples using triplet loss

Published online by Cambridge University Press:  04 February 2022

Can Udomcharoenchaikit
Affiliation:
Department of Computer Engineering, Faculty of Engineering, Chulalongkorn University, Bangkok, Thailand
Prachya Boonkwan
Affiliation:
Language and Semantic Technology Lab (LST), NECTEC, Pathumthani, Thailand
Peerapon Vateekul*
Affiliation:
Department of Computer Engineering, Faculty of Engineering, Chulalongkorn University, Bangkok, Thailand
*
*Corresponding author. E-mail: peerapon.v@chula.ac.th
Rights & Permissions [Opens in a new window]

Abstract

Many fundamental tasks in natural language processing (NLP) such as part-of-speech tagging, text chunking, and named-entity recognition can be formulated as sequence labeling problems. Although neural sequence labeling models have shown excellent results on standard test sets, they are very brittle when presented with misspelled texts. In this paper, we introduce an adversarial training framework that enhances the robustness against typographical adversarial examples. We evaluate the robustness of sequence labeling models with an adversarial evaluation scheme that includes typographical adversarial examples. We generate two types of adversarial examples without access (black-box) or with full access (white-box) to the target model’s parameters. We conducted a series of extensive experiments on three languages (English, Thai, and German) across three sequence labeling tasks. Experiments show that the proposed adversarial training framework provides better resistance against adversarial examples on all tasks. We found that we can further improve the model’s robustness on the chunking task by including a triplet loss constraint.

Information

Type
Article
Copyright
© The Author(s), 2022. Published by Cambridge University Press
Figure 0

Table 1. The typographical errors for creating adversarial examples. * Note that capitalization error is not applicable to writing systems without capitalization such as Thai

Figure 1

Algorithm 1: White-box adversarial attack.

Figure 2

Figure 1. Our adversarial evaluation scheme (see section 3.4) expands one held-out test set into three parallel test sets:(1) original test set contains original unperturbed text, (2) black-box adversarial test set contains perturbed samples generated via black-box adversarial attacks, and (3) white-box adversarial test set contains perturbed samples generated using gradient-based white-box perturbation. This figure shows real samples collected from three parallel CoNLL2003 test sets with predictions from the baseline model (ELMo enhanced BiLSTM-CRF) from a supplementary experiment in Appendix A. Blue texts and boxes refer to correct predictions. Red texts and boxes refer to incorrect predictions.

Figure 3

Figure 2. An example of a triplet from the CoNLL2003 corpus. With triplet loss as a part of training objective, we want the distance between a clean text sequence and its perturbed pair to be closer than the distance between a clean text sequence and a random text sequence as illustrated in this figure.

Figure 4

Figure 3. The AT-P framework for training robust neural networks against typographical adversarial examples. It combines adversarial training with the pair similarity loss.

Figure 5

Figure 4. Our AT-T framework for training robust neural networks against typographical adversarial examples. It incorporates adversarial training with the triplet loss.

Figure 6

Figure 5. ELMo enhanced BiLSTM-CRF sequential tagger Peters et al. (2018) uses both context-independent representation and contextual representation. In this figure, the word representation for “Spanish” is the concatenation between context-independent word embeddings (CNN character representation and static word embeddings) and contextual word embeddings (ELMo).

Figure 7

Table 2. Data statistics of the English CoNLL2003, the Thai ORCHID, and the German TüBa-D/Z corpora (training set/validation set/test set). $\dagger$ - For English and German, an input sequence is a sentence. For Thai, an input sequence is a paragraph

Figure 8

Table 3. Data statistics of datasets with natural misspelling errors: Twitter-41 and Misspelled TüBa-D/Z

Figure 9

Table 4. $\,\,F_1$ scores and associated standard deviations on the English CONLL2003, the Thai ORCHID, and the German TüBa-D/Z corpora. The black-box and white-box adversarial test sets only contain insertion perturbation. We use the rest of the perturbation types for adversarial training. We averaged the scores across three runs with different random seeds and calculated their standard deviations. A bolded number refers to the best F-1 score for each task in each test set. An underlined number denotes statistical significance against all other models for all random seeds using McNemar’s Test (p-value $<=$ 0.05)

Figure 10

Table 5. Average cosine similarity scores between clean-perturbed pairs and clean-random pairs. We averaged the cosine similarity scores and their standard deviations across three runs with different random seeds. We want the similarity between each clean-random pair to be high and the similarity between each clean-random pair to be low. $\dagger$ - This shows a difference between the average cosine similarity scores of clean-perturbed pairs and clean-random pairs for each model

Figure 11

Table 6. $\,\,F_1$ scores and theirs standard deviations on the Thai Twitter-41 and the German TüBa-D/Z (misspelled) corpora. We averaged the scores across three runs with different random seeds and calculated their standard deviations. A bolded number refers to the best F-1 score for each task in each test set. An underlined number denotes statistical significance against all other models for all random seeds using McNemar’s Test (p-value $<=$ 0.05)

Figure 12

Table 7. Error rates on perturbed words: We calculate the error rates at word-level only. We excluded non-perturbed words from the calculation. Only top five classes with the highest number of perturbed words are shown in this table.

Figure 13

Table 8. Frequency of unperturbed/perturbed words in each of the top five classes with the highest number of perturbedwords

Figure 14

Table 9. $\,\,F_1$ scores and theirs standard deviations on the English CONLL2003 and the Thai ORCHID corpora. We averaged the scores across three runs with different random seeds, and calculated their standard deviations. A bolded number refers to the best F-1 score for each task in each test set. All perturbation types are used to generate adversarial examples for both adversarial training and adversarial evaluation

Figure 15

Table 10. Error rates and their standard deviations of models on different typographical errors. We calculate the error rates at word-level only. All perturbation types are used to generate adversarial examples for both adversarial training and adversarial evaluation. We excluded words with “O” (non-named entities, or non-syntactic chunks) as their ground truth from the calculation. $\ddagger$ - “Clean” refers to unperturbed words, these are words that are shorter than 4 characters. We do not alter words that are shorter than 4 character to ensure that the perturbed words are intelligible to humans. $\dagger$ - Thai has no capitalization