天天看點

【論文筆記】Reasoning about Entailment with Neural AttentionReasoning about Entailment with Neural Attention

Reasoning about Entailment with Neural Attention

這篇論文主要講了他們第一次應用深度學習取得了比現階段人工特征更好的結果(201509),模型架構大體是:LSTM—Attention—FC分類

https://arxiv.org/pdf/1509.06664v1.pdf

【論文筆記】Reasoning about Entailment with Neural AttentionReasoning about Entailment with Neural Attention

LSTM層

他們使用兩個不同的LSTM來分别對Premise和Hypothesis進行向前傳播, L S T M h y p o t h e s i s LSTM_{hypothesis} LSTMhypothesis​的第一個中間狀态 c 0 c_0 c0​ 是由 L S T M p r e m i s e LSTM_{premise} LSTMpremise​的最後一個中間狀态初始化的。他們的說法是,沒有必要重複對Hypothesis進行encode(指将hypothesis句子經過和Premise同一個LSTM的處理稱為encode),這樣在 L S T M h y p o t h e s i s LSTM_{hypothesis} LSTMhypothesis​裡,會更加關注與premise的語義關聯的處理。

attention層

他們提出了兩種方法

  1. 傳統方法:将 L S T M p r e m i s e LSTM_{premise} LSTMpremise​輸出拼接為矩陣Y作為輸入向量, L S T M h y p o t h e s i s LSTM_{hypothesis} LSTMhypothesis​的最後一個輸出 h N h_N hN​ 作為查詢向量,使用加性模型計算attention:

    M = t a n h ( W y Y + W h h N ⨂ e L ) M = tanh(W^yY+W^hh_N\bigotimes e_L) M=tanh(WyY+WhhN​⨂eL​)

    α = s o f t m a x ( w T M ) \alpha = softmax(w^TM) α=softmax(wTM)

    r = Y α T r = Y\alpha^T r=YαT

    其中 ⨂ \bigotimes ⨂操作是外積,作用等價于 W h h N ∈ ( k × 1 ) W^hh_N\in (k×1) WhhN​∈(k×1)與一個 1 × L 1×L 1×L 維的純1向量點乘

    最後,通過如下計算得到用于分類的最終輸出

    h ∗ = t a n h ( W p r + W x h N ) h^* = tanh(W^pr + W^xh_N) h∗=tanh(Wpr+WxhN​)

  2. Word-by-word Attention:他們的想法是隻利用最後一個輸出hn作為查詢會遇到LSTM的對前面輸入記憶的瓶頸,于是疊代地對每一個 L S T M h y p o t h e s i s LSTM_{hypothesis} LSTMhypothesis​的輸出都用上面的方法進行注意力計算,并在每次計算中使用了上一次計算的輸出(即 r t − 1 r_{t-1} rt−1​)。最終得到的 r L h r_{L_h} rLh​​以同樣的方式處理。

    M t = t a n h [ W y Y + ( W h h t + W r r t − 1 ) ⨂ e L ] M_t = tanh[W^yY+(W^hh_t+W^rr_{t-1}) \bigotimes e_L] Mt​=tanh[WyY+(Whht​+Wrrt−1​)⨂eL​]

    α t = s o f t m a x ( w T M t ) \alpha_t = softmax(w^TM_t) αt​=softmax(wTMt​)

    r t = Y α L T + t a n h ( W t r t − 1 ) r_t = Y\alpha^T_L + tanh (W^tr_{t-1}) rt​=YαLT​+tanh(Wtrt−1​)

    h ∗ = t a n h ( W p r L + W x h N ) h^* = tanh(W^pr_L + W^xh_N) h∗=tanh(WprL​+WxhN​)

另外他們将Premise和Hypothesis換位輸入僅模型并将最後輸入合并進行分類,稱為雙向注意力,這個操作沒有帶來性能的提高,他們分析是因為蘊藏的含義具有非對稱的關系,是以使用相同模型再次encode Hypothesis時可能會造成噪聲(這點暫時不太了解)。

繼續閱讀