Is Attention Interpretable?

Is Attention Interpretable?

by Chih-Chi Wu 2020.06.29
論文

tags: ‘NLP’, ‘paper’, ‘NLP study group’
  • Q:此篇論文的目標?
    想探討「attention可偵測出模型中認為重要的訊息」這件事的正確性。

可解釋性可以理解為,Attention權重的高低應該與對應位置信息的重要程度正相關;高權重的輸入單元對於輸出結果有決定性作用。本文的主要研究方法是中間表示擦除,主要邏輯在於越重要的權重對輸出結果的影響越大,將它置零就會對結果有直接的影響。
https://www.cnblogs.com/bernieloveslife/p/12748433.html

  • Q:這篇和上一篇的差異?
    上一篇論文(Attention is not explanation)較頃向從整體來看,譬如:整組的attention weight換掉是否對結果有差?而此論文則著重在attention到底有沒有抓到重點?
    (此段文字頃向自己的解讀,若有理解錯歡迎糾正…)
    論文中在講和之前的差異的內文如下:

    One point worth noting is the facet of interpretability that our tests are designed to capture. By examining only how well attention represents the importance of intermediate quantities, which may themselves already have changed uninterpretably from the model’s inputs, we are testing for a relatively low level of interpretability. So far, other work looking at attention has examined whether attention suffices as a holistic explanation for a model’s decision (Jain and Wallace, 2019), which is a higher bar. We instead focus on the lowest standard of interpretability that attention might be expected to meet, ignoring prior model layers.

  • Q:簡短敘述這篇論文?
    為了探討「attention可找出模型中認為重要的特徵訊息」這件事的正確性,這篇論文設計了一個實驗驗證架構:使用擦掉某些attention weight的方式(在此篇論文中假設weight較大表示較重要),去看看對模型預測的影響。
    結論是attention weight雖有稍微的反應出特徵(feature)的重要性,但並沒有非常直接的相關。

註:這裡的feature指的是input經過encoder後的向量。

論文中使用的任務、資料集

  • topic classification (dataset: Yahoo answers)
  • review rating (datasets: IMDB, Amazon, Yelp)

模型架構

主要使用Hierarchical Attention Network(HAN)架構(一種text classification的模型),HAN的特色在先對「詞」做attention,再對「句子」做attention,請看圖一(之前小勛講的那篇,忘記可以回顧一下)

在此篇論文中僅對句子那層的attention去做測試,attention則是使用Bahdanau et al. (2015)提出的架構如下(就是之前討論過的第一篇attention ):

除此之外,此論文也探討兩個HAN的變化模型:

  1. flat attention networks (簡稱FLAN):僅考慮一層attention,也就是不像HAN分詞、句子去做attention,而是不分句子,把所有句子的詞攤平一起看。
  2. 將原本HAN模型裡的word encoder的雙向GRU結構改成convolutional encoder

所以,此篇論文總共考慮的模型有:HANrnns (bi-GRU), HANconvs, HANnoencs, FLANrnns, FLANconvs, FLANnoencs


HAN(圖一)圖出處


convolutional encoder的FLAN示意圖 圖出處

如何透過實驗驗證目標?

實驗驗證架構

此論文透過擦掉某些重要的attention weight的方式,去觀察結果的差異。因此,實驗在Part 1 of model(即做完attention、還沒跑linear classification的部分)之後分兩部分去探討:

  1. attention weight不變,直接放到Part 2 of model(即最後一層linear classification的部分)
  2. 擦掉某些重要的attention weight,再放入最後一層linear(這裡為什麼要做renormalize?是為了避免擦去較大的attention weight之後,document representation的地方趨近於0,使擦去後的representation和原始training放入最後一層linear classification的representation差太多)

    驗證方式

    此論文分兩部分來探討:
  3. 擦掉一個attention weight(將最大的attention設為0的意思)
  4. 擦掉一些attention weights

針對上述兩點,論文進行了不同的驗證實驗。

1. 擦掉一個attention weight(將最大的attention設為0的意思)

驗證方式1

  • 比較:
    • 最高attention weight
    • 隨機選取的attention weight


x軸:上述兩項的attention weight的差距;
y軸:原模型分別對其的JS divergence差距
如預期的,大部分的attention weight差距越大,$\triangle JS$也大多有變大的現象。|是負值的部分,也大都趨近於0


x軸:-$\triangle JS$; y軸:數量
註:若較高的attention weight影響力比較高,那麼$\triangle JS$差值應該大於0。

註:但我們其實不知道多大的差距可以詮釋attention weight重要性。

上圖的意思是:分別去看在「remove 最大attention weight」及「remove 隨機attention weight」時是否造成翻轉決策?
從上圖可發現,大部分都是兩個都沒有影響結果。雖然remove最大attention weight仍比remove隨機的attention weight造成翻轉決策較多,但並沒有高很多。(這裡只放rnn based的結果,但其他模型架構結果差不多,有興趣可以看論文)

2. 擦掉一些attention weights

上述的方法(僅去掉其中一個attention weight),會看到只擦去一個attention weight大多不會翻轉決策、$\triangle JS$趨近於0等問題,因此本論文又再做更進一步的探討。

如何探討呢?想法是:若attention weight真的呈現出feature重要性,那麼應該擦去越小的集合,就能夠翻轉決策。

某項token越重要,那麼mask它使模型分類錯誤的可能性也就越大,所以找到的mask集合越小,這個集合中的token越重要。
https://www.cnblogs.com/bernieloveslife/p/12748433.html

也就是透過不同的方法,去對feature重要性去做ranking,並按ranking結果依序擦去feature,直到會翻轉決策。而擦去的集合大小也某種程度呈現此方法到底好不好?(feature importance的概念),而此論文使用四種方式:

  1. 隨機mask
  2. 按attention weight大小做ranking,優先mask掉attention weight較大的。
  3. 透過分析最後一層classification layer的decision function的gradient去做ranking
  4. 透過直接「attention weight*上述的gradient值」去做ranking


從上圖(boxplot)可看到,attention*gradient(第4種方式)的方法,雖然整體而言最小(較好),但其實和gradient方法(第3種方法)差不多。而attention weight(第2種方法)的方法則更差(大部分的測試資料都需要擦去非常多feature,才能達到翻轉決策的效果)。

值得一提的是,rnn based的模型架構,相較convolution based的模型,通常需要擦去較多的attention weights,這也和RNN based的模型做完encoder後會有訊息遷移這件事相吻合。

limitations

  • 這篇主要著重在探討text classification,若此方法應用在其他的task(如翻譯,不只幾類,而是有許多預測結果)就不一定適用。
  • 因為分類結果中有很多類別,但這裡只考慮出來結果機率最大的,其他的都沒有考慮。(可能需要針對每個類別都去找最重要的token是什麼)
  • 還有許多其他的模型架構

    結論

    attention weight雖有稍微的反應出特徵的重要性,但並沒有非常直接的相關。

future work

  • 除了擦去重要的attention weight的方法,還有許多方法可以探討attention weight的解釋性議題。
  • 期望轉換成「找出一個更加好的ranking方式」

思考問題

  • 為什麼要設計FLAN?(可能是因為只有一層;HAN有兩層)

https://www.cnblogs.com/bernieloveslife/p/12748433.html

Powered by Hexo and Hexo-theme-hiker

Copyright © 2020 - 2021 DSMI Lab's website All Rights Reserved.

UV : | PV :