interpretability in nlpsding/downloads/msft-1010-slides.pdfinterpretability in nlp: moving beyond...

93
Interpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in collaboration with Philipp Koehn and Hainan Xu

Upload: others

Post on 19-Mar-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Interpretability in NLP: Moving Beyond Vision

Shuoyang Ding

Microsoft Translator Talk Series Oct 10th, 2019

Work done in collaboration with Philipp Koehn and Hainan Xu

Page 2: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Outline• A Quick Tour of Interpretability

• Model Transparency

• Post-hoc Interpretations

• Moving Visual Interpretability to Language:

• Word Alignment for NMT Via Model Interpretation

• Benchmarking Interpretations Via Lexical Agreement

• Future Work

2

Page 3: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Outline• A Quick Tour of Interpretability

• Model Transparency

• Post-hoc Interpretations

• Moving Visual Interpretability to Language:

• Word Alignment for NMT Via Model Interpretation

• Benchmarking Interpretations Via Lexical Agreement

• Future Work

3

Page 4: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in
Page 5: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

What is Interpretability?

• No consensus!

• Categorization proposed in [Lipton 2018]

• Model Transparency

• Post-hoc Interpretation

5

Page 6: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Toy Example

6

Speaker

TV Box CD LaptopGame

Console

Page 7: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Toy Example

7

Speaker

TV Box CD LaptopGame

Console

? ?

?

Page 8: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

A Transparent Model

8

Speaker

TV Box CD LaptopGame

Console

Amplifier

1 2 3 4

Page 9: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Transparent Models• Build another model that accomplishes the same

task, but with easily explainable behaviors

• Deep neural networks are not interpretable…

• So what models are? (Open question)

• log-linear model?

• attention model?

9

Page 10: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Meh. Too lazy for that!

10

Speaker

TV Box CD LaptopGame

Console

? ?

?

Page 11: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Post-hoc Interpretation

• Ask a human

• Interpretation with stand-alone model (different task!)

• Jiggle the cable!

• Interpretation with sensitivity w.r.t. features

11

Page 12: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Post-hoc Interpretation

• Ask a human

• Interpretation with stand-alone model (different task!)

• Jiggle the cable!

• Interpretation with sensitivity w.r.t. features

12

Page 13: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

A Little Abstraction…

13

Page 14: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

A Little Abstraction…

14

Page 15: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

A Little Abstraction…

15

Page 16: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

A Little Abstraction…

16

Page 17: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Relative Sensitivity…?

17

Page 18: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Relative Sensitivity…?

18

when :

Page 19: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Saliency

19

Page 20: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

What’s good about this?

1. Model-agnostic, and yet with some exposure to the interpreted model

2. Derivatives are easy to obtain for any DL toolkit

20

Page 21: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Saliency in Computer Vision

21

https://pair-code.github.io/saliency/

Image Saliency

Page 22: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad

• Gradients are very local measure of sensitivity.

• Highly non-linear models may have pathological points where the gradients are noisy.

22

[Smilkov et al. 2017]

Page 23: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad

23

Page 24: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad

24

Page 25: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad

• Solution: calculate saliency for multiple copies of the same input corrupted with gaussian noise, and average the saliency of copies.

25

Page 26: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad

26

Page 27: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

SmoothGrad in Computer Vision

27

Original Image Vanilla

SmoothGrad Integrated Gradients

https://pair-code.github.io/saliency/

Page 28: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Integrated Gradients (IG)

28

[Sundararajan et al. 2017]

• Proposed to solve feature saturation

• Baseline: an input that carries no information

• Compute gradients on interpolated baseline & input and average by integration

Page 29: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

IG in Computer Vision

29

Original Image Vanilla

SmoothGrad Integrated Gradients

https://pair-code.github.io/saliency/

Page 30: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Summary

30

Speaker

TV Box CD Computer Game Console

Speaker

TV Box CD Computer Game Console

Model Transparency: • Build model that operates in

an explainable way • Interpretation does not

depend on output

Post-hoc interpretation: • Keep the original model intact • Interpretation depends on

specific output

Page 31: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Summary• How is this related to what I’m talking about next?

• Word Alignment for NMT Via Model Interpretation

• transparent models vs. post-hoc interpretations

• Benchmarking Interpretations Via Lexical Agreement

• different post-hoc interpretation methods

31

Page 32: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Outline• A Quick Tour of Interpretability

• Model Transparency

• Post-hoc Interpretations

• Moving Visual Interpretability to Language:

• Word Alignment for NMT Via Model Interpretation

• Benchmarking Interpretations Via Lexical Agreement

• Future Work

32

Page 33: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Word Alignment

33

Page 34: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Word Alignment

34

Page 35: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Model Transparency?

35

Page 36: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Model Transparency?

36

Wait… word alignments should be aware of the output!

Page 37: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Post-hoc Interpretations with Stand-alone Models?

37

p(aij | e, f)Hint: GIZA++, fast-align, etc.

Page 38: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Post-hoc Interpretations with Perturbation/Sensitivity?

38

Page 39: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Post-hoc Interpretations with Perturbation/Sensitivity?

39

Page 40: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

“Feature” in Computer Vision

40

Photo Credit: Hainan Xu

Page 41: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

“Feature” in NLP

41

It’s straight-forward to compute saliency for a single dimension of the word embedding.

Page 42: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

“Feature” in NLP

42

But how to compose the saliency of each dimension into the saliency of a word?

Page 43: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Li et al. 2016

43

Visualizing and Understanding Neural Models in NLP

1N

N

∑i=1

∂y∂ei

(0, ∞)range:

Page 44: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Our Proposal

44

Consider word embedding look-up as a dot product between the embedding matrix and an one-hot vector.

Page 45: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Our Proposal

45

The 1 in the one-hot vector denotes the identity of the input word.

Page 46: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Our Proposal

46

Let’s perturb that 1 like a real value! i.e. take gradients with regard to the 1.

Page 47: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Our Proposal

47

∑i

ei ⋅∂y∂ei

(−∞, ∞)range:

Recall this is different from Li’s proposal: 1N

N

∑i=1

∂y∂ei

Page 48: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Why is this proposal better?

• A input word may strongly discourage certain translation and still carry a large (negative) gradient.

• Those are salient words, but shouldn’t be aligned.

• Absolute value/L2-norm falls into this pit.

48

Page 49: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Evaluation

• Evaluation of interpretations is tricky!

• Fortunately, there’s human judgments to rely on.

• Need to do force decoding with NMT model.

49

Page 50: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Setup

• Architecture: Convolutional S2S, LSTM, Transformer (with fairseq default hyper-parameters)

• Dataset: Following Zenkel et al. [2019], which covers de-en, fr-en and ro-en.

• SmoothGrad hyper-parameters: N=30 and σ=0.15

50

Page 51: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Baselines• Attention weights

• Smoothed Attention: forward pass on multiple corrupted input samples, then average the attention weights over samples

• [Li et al. 2016]: compute element-wise absolute value of embedding gradients, then average over embedding dimensions

• [Li et al. 2016] + SmoothGrad

51

Page 52: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Convolutional S2S on de-en

AER

15

20

25

30

35

40

45

Atte

ntio

nSm

ooth

ed A

ttent

ion

Li+G

rad

Li+S

moo

thGr

adOu

rs+G

rad

Ours

+Sm

ooth

Grad

fast

-alig

nZe

nkel

et a

l. [2

019]

GIZA

++ 52

Better

Worse

Page 53: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Attention on de-en

53

AER

15

25

35

45

55

65

Conv

LSTM

Tran

sfor

mer

fast

-alig

nZe

nkel

et a

l. [2

019]

GIZA

++

Better

Worse

Page 54: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Ours+SmoothGrad on de-en

54

AER

15

25

35

45

55

65

Conv

LSTM

Tran

sfor

mer

fast

-alig

nZe

nkel

et a

l. [2

019]

GIZA

++

Better

Worse

Page 55: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Li vs. Ours

55

Page 56: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Li vs. Ours

56

(English: We do not believe that we should cherry-pick .)

Page 57: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Summary• For each of these interpretation methods:

• Attention: maximum transparency on how the model works, but is hard to interpret

• Stand-alone Alignment Models: gives best word alignments, but has nothing to do with the translation model

• Saliency: a good combination of both worlds!

57

Page 58: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Outline• A Quick Tour of Interpretability

• Model Transparency

• Post-hoc Interpretations

• Moving Visual Interpretability to Language:

• Word Alignment for NMT Via Model Interpretation

• Benchmarking Interpretations Via Lexical Agreement

• Future Work

58

Page 59: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

How about other NLP tasks?

• Text Classification: [Aubakirova and Bansal 2016][Arras et al. 2016]

• Sentiment Analysis: [Li et al. 2016][Arras et al. 2017]

• Question Answering: [Mudrakarta et al. 2018]

59

Page 60: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Assumption

60

Post-hoc Interpretation =

How did the model make decision

Page 61: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Assumption

61

Post-hoc Interpretation =

How did the model make decision?

Page 62: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Quick Flashback

62

Page 63: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Quick Flashback

63

Li et al. 2016

Ours+SmoothGrad

Page 64: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Research Question

• How can we quantitatively test the effectiveness of model interpretation methods in the context of NLP?

• What are the said “effectiveness” correlated with?model size? architecture? task performance?

64

Page 65: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Computer Vision

65

Yao et al. 2018 Weakly Supervised Medical Diagnosis and Localization from Multiple Resolutions

Page 66: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Main Challenge

No ground-truthinterpretation

66

Page 67: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Lexical Agreements

• Frequently studied for interpretability [Linzen et al. 2016][Marvin and Linzen 2018][Gulordava et al .2018][Giulianelli et al. 2018]

• They concentrate on evaluating probing task performance, i.e. whether the model can predict the lexical agreements properly

67

Page 68: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

E.g. Subject-Verb Agreements

However , most people , having been subjected to news footage of the devastated South Bronx , …

A. look B. looks

68

Page 69: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

E.g. Subject-Verb Agreements

However , most people , having been subjected to news footage of the devastated South Bronx , …

A. look B. looks

69

Page 70: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

E.g. Subject-Verb Agreements

However , most people , having been subjected to news footage of the devastated South Bronx , …

A. look B. looks

70

Page 71: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

E.g. Subject-Verb Agreements

However , most people , having been subjected to news footage of the devastated South Bronx , …

A. look B. looks

71

“Probing Task”

Page 72: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

The Test

72

However , most people , having been subjected to news footage of the devastated South Bronx , look

Page 73: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

The Test

73

However , most people , having been subjected to news footage of the devastated South Bronx , looks

Page 74: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

The Test

However , most people , having been subjected to news footage of the devastated South Bronx , look

The interpretation passes the test, if ∀ w ∈ {footage, Bronx}, s.t.

ψ(people) > ψ(w)

74

ψ: feature importance/saliency

Page 75: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

The Test

However , most people , having been subjected to news footage of the devastated South Bronx , looks

The interpretation passes the test, if ∃ w ∈ {footage, Bronx}, s.t.

ψ(people) < ψ(w)

75

ψ: feature importance/saliency

Page 76: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

The Test• We constructed test set based on two existing

human-annotated corpus

• Penn Treebank: new, multiple attractors

• syneval: Marvin and Linzen [2018], single attractor

• We plan to construct another one with CoNLL-2012 coreference resolution dataset -- stay tuned!

76

Page 77: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Interpreted Model

• Language Model!

• With final linear layer replaced with one that is fine-tuned for predicting specific agreement of interest

• Word prediction may introduce out-of-scope agreements and interfere with evaluation

77

Page 78: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Experiment• Architectures:

• LSTM model, trained on WikiText-2

• QRNN model [Bradbury et al. 2017], trained on WikiText-2

• Transformer model w/ adaptive input [Baevski and Auli, 2018], trained on WikiText-103

• All the fine-tuning was done on WikiText-2

• For subject-verb agreement, the verb tagging is done with Stanford POS-tagger

78

Page 79: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Probing Task Performance

79

0

0.25

0.5

0.75

1

penn syneval

LSTM QRNNTransformer

Page 80: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Interpretation of LSTM

80

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 81: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Interpretation of QRNN

81

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 82: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Interpretation of Transformer

82

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 83: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

What's up with Transformer?• Two hypothesis:

• Deep model hurts interpretability

• Too many heads hurts interpretability

• SOTA model: 16 layers, 8 heads

• Diagnostic model:

• 4 layers, 8 heads

• 4 layers, 1 head

83

Page 84: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

16 layers, 8 heads

84

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 85: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

4 layers, 8 heads

85

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 86: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

4 layers, 4 heads

86

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 87: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

4 layers, 2 heads

87

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

penn syneval

random vanillali li_smoothedsmoothed integral

Page 88: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Some Qualitative Checks

• Are those interpretations just looking at the immediate previous word?

• No. They seems to get a lot of things right!

88

Page 89: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Some Qualitative Checks

• Are they the same with different architectures?

• No. Different architectures work differently.

89

Page 90: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Summary

• Lexical agreements open up possibilities to do rigorous quantitative checks for post-hoc interpretation methods in the context of NLP

• Our proposed method works the best consistently

• Deep NLP models can be out-of-reach for existing interpretation methods.

90

Page 91: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Outline• A Quick Tour of Interpretability

• Model Transparency

• Post-hoc Interpretations

• Moving Visual Interpretability to Language:

• Word Alignment for NMT Via Model Interpretation

• Benchmarking Interpretations Via Lexical Agreement

• Future Work

91

Page 92: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Shuoyang Ding — Interpretability in NLP: Moving Beyond Vision

Future Work

• Better interpretation method that works for the deep architectures in NLP.

• How can we use interpretability in real-world applications (QE?), or improve our models?

• How can we use interpretability to validate whether the model learned certain linguistic properties?

92

Page 93: Interpretability in NLPsding/downloads/msft-1010-slides.pdfInterpretability in NLP: Moving Beyond Vision Shuoyang Ding Microsoft Translator Talk Series Oct 10th, 2019 Work done in

Thanks!email: [email protected] twitter: @_sding github: shuoyangd