3. Adversarial Attack in NLP
Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Entailment, AAAI ‘20
4. Prior works
- Character level error, adding / deleting words
- 부자연스러움
- 문법적 오류
- Rule-based synonym replacement
- TextFooler (AAAI ‘20)
- Synonym replacement
- Token-level similarity에만 의존
- e.g. The restaurant service was poor
→ broke : inappropriate
→ terrible : context-aware
- need more context-awareness
⇒ use BERT-MLM (Masked Language Model)
5. Problem Definition
- Given…
- S: 주어진 문장
- C: target model
- y: S의 ground-truth class
- 생성 목표: Sadv
- Semantic Similarity : Sadv
~ S
- Misclassification: C(Sadv
) != y
- This film offers many delights and surprises ⇒ C(S) = Positive
→ This movie offers enough pleasures and surprises ⇒ C(Sadv
) = Negative
6. Threat Model
- Black-box attack
- Classification 결과만 접근 가능
- Model weights, gradients, training data 접근 불가
- Soft-label
- score of classification
↔ hard-label : 0/1 class inclusion
7. 1. Token Importance
- token ti
가 classification에 영향을 주는 정도
- 이 token을 직접 바꾸거나, 주변에 다른 token을 넣으면 classification이 바뀔
가능성이 높음
- P(C(S)=y) - P(C(S - {ti
})=y)로 계산
This film offers many delights and surprises
0.1 0.3 0.2 0.4 0.9 0.1 0.6Ii
8. 2. Mask & predict top-K tokens
- Importance가 높은 token부터 masking
- BAE-I (insert)의 경우 token의 인접 위치에 mask를 삽입
- BERT-MLM을 이용해서 mask에 들어갈 token을 K개 예측
This film offers many ? and surprises
pleasures
twists
challenges
9. 3. Filter semantic similarity
- 원래 문장과 실제로 의미가 같은지 판단
- Universal Sentence Encoder (USE) 기반의 sentence similarity encoder 사용
- 문법 체크
- BAE-R의 경우 원래 token과 part of speech (POS)가 같은지 확인
This film offers many ? and surprises
pleasures
twists
challenges
10. 4. Apply perturbation
- 생성된 문장을 target model로 분류
- Prediction이 변하는 token이 여럿일 때 : USE score가 가장 높은 token
- Prediction이 변하는 token이 없을 때 : P(C(Sadv
) = y)를 가장 많이 낮추는 token
- 이 과정을 반복
This movie offers enough pleasures and surprises
16. 4. Human Evaluation
원본 / Attack 문장들에 대한 사람의 평가
- Sentiment accuracy & Naturalness
- R > R+I > TextFooler
✱ Automatic evaluation 에서
USE score는 R+I > R
⇒ USE의 한계점
17. 5. Replace vs. Insert
- A: (R/I) - R
- B: (R/I) - I
- A > B ⇒ Insert 필수 > Replace 필수
- C: (R/I) - R - I
- Subj에서 C의 비율이 가장 큼 & Subj가 가장 robust
⇒ Replace와 Insert를 모두 사용할 수 있다는 것이 중요