[Notes](EMNLP2019) NRMS: Neural News Recommendation with Multi-Head Self-Attention

Haren Lin
10 min readMay 27, 2022

--

Paper Link

https://wuch15.github.io/paper/EMNLP2019-NRMS.pdf

Idea

Several news browsed by an example user. Orange and green dashed lines represent the interactions between words and news respectively.

審視這篇論文作者的論點:

  1. Interaction between words in news title are important for understanding the news. 文章標題的字與字之間的交互對於這個新聞的理解很重要。怎麼說呢?E.g. Rockets trade Carter-Williams to the Bulls. 火箭隊將CW交易到公牛隊。「Rockets」跟「Bulls」其實是有很強的連結性的,都是球隊的名字。
  2. Different news articles browsed by the same user may also have relatedness. 同一個user瀏覽的不同新聞文章也可能具有相關性。怎麼說呢?E.g. 第二篇文章其實跟第一跟第三篇有關係。
  3. Different words may have different importance in representing news. 不同的詞在表示新聞時可能具有不同的重要性。E.g. 第一篇:「NBA」的重要性就比2018來得高。
  4. Different news articles browsed by the same user may also have different importance in representing the user. 同一用戶瀏覽的不同新聞文章在代表用戶方面也可能具有不同的重要性。怎麼說呢?E.g. 很明顯前三篇新聞對於 User interest 比第四篇重要。

綜合以上的論述,作者會根據這四個點進行強化來協助 User interests 的建模。

Model Architecture

那接下來我們就看看作者是怎麼處理這個 issue 的,以下是模型的大架構。模型一樣會有 News Encoder, User Encoder, & Click Predictor 的部分。

NRMS Model Architecture

(I) News Encoder

News Encoder 可以分為三個 Parts:

第一部分為 Word Embedding Layer,他的工作是把單一一篇 News title 的字,假設長度為M,把他們全部轉換為 Word embedding 向量表示,本篇論文使用的方法是 GloVe embeddings。

第二部分為 Word-Level MHA,這邊回顧的是剛才作者提出的假設 -字與字之間的交互作用對於新聞向量的表示很重要,我們用 MHA 來得到他們Contextualized Embeddings,這個 alpha_i_j 就是第 i 個字與第 j 個字之間交互的 Attention score,小 k 是代表第幾個 head。Qk 跟 Vk 就是第 k 個 Head 中的 projection parameters,注意力分數的來源就是把 i-th 字的 Embeddings乘 Query 再乘以 j-th 字的 Embeddings 然後過 Soft-max。有了分數之後我們再去跟每個字的 Embeddings 做 Weighted Sum,且乘上 Value Matrix 得到代表第 k 個 Head 在第 i 個字上面的 Embeddings,最後把所有 Head 的輸出 Embeddings 給 Concat 起來得到這個字的新的 Embedding hw_i (w means word, i = i-th word in news title)

第三部分為 Additive Word Attention,呼應前面作者提出的假設 - 新聞標題中不同字有不同的重要性,於是我們這邊就先把第 i 個字的 Word Embeddings 過一個 Linear transform 以及 Hyperbolic tangent 的非線性轉換,再乘上 Query term 得到暫時的分數 ai,並把這些分數去過softmax,得到 Word-level attention score alpha_i,最後把他們與 Word embeddings 做 Weighted sum 得到當前這個 News 的 News representation r

(II) User Encoder

接下來是 User encoder,假設我們取歷史長度為 N 筆資料,這些 News 我們都會用 r1 ~ rN 表示。

第一部分為 News-Level MHA,我們要算出 News-level 的 attention score,代表新聞跟新聞之間彼此的相關性,beta_i_j 為這個使用者的歷史紀錄中,第 i-th 篇新聞與第 j-th 篇新聞之間的注意力分數。有了分數之後我們再去跟每個新聞的 Embeddings 做 Weighted Sum,且乘上 Value Matrix 得到代表第 k 個 Head 在第 i 個新聞上面的 Embeddings,最後把所有 Head 的輸出 Embeddings 給 Concat 起來得到這個新聞的新的 Embedding hn_i (n means news, i = i-th news in clicked history)

第二部分為 Addictive News Attention,這也跟 News encoder part3 在做的事情很像,不同的新聞對於同一個 User 的表示有不同的權重/重要性,一樣過一個 Attention Network 並把分數過 Soft-max,最後把得到的權重跟各自的 News 做Weighted sum 得到 User representation u

(III) Click Predictor

Predict the probability of a user clicking a candidate news via inner-product.

Model Training

Other Details: In the experiments, the word embeddings are 300-dimensional and initialized by the Glove embedding. The self-attention networks have 16 heads, and the out- put of each head is 16-dimensional. The dimen-sion of the additive attention query vectors is 200. Following, the negative sam- pling ratio K is 4. Adam is used for model optimization. We apply 20% dropout to the word embeddings to mitigate over-fitting. The batch size is 64. These hyperparameters are tuned on validation set. We conducted experiments on a machine with Xeon E5–2620 v4 CPUs and a GTX1080Ti GPU. We independently repeated each experiment 10 times and reported average results in terms of AUC, MRR, nDCG@5 and nDCG@10.

Experiments

MSN Logs Dataset Statistics
The results of different methods. The improvement is significant at p < 0.01.

作者在 MSN Logs 上面做了實驗,實驗資料的資訊大概如上表。那從表格我們可以知道一些資訊:

(1) NN-Based 的模型比傳統的模型像是 Lib-FM 之類的效能來的好,作者認為 NN 的模型相較於傳統 Matrix Factorization (MF) 能學到比較好的 Representation。

(2) DL-based的模型中,能夠學習到 News 之間相互關係的模型,表現較佳。像是 Conv3D, GRU, NRMS。畢竟了解 News 之間的相互關係對於 User representation 的表達較好。

(3) NRMS 的確表現不錯,作者表示 Attention 佔了很大的功勞,有利於 User & news representation。

Ablation Study

作者也有做了一些 Ablation Test 來強調他們所做的 Attention 的有效性!

先看左邊的(a)圖,作者認為 Word-level Attention 很有用,因為對字與字之間的交互作用來建模以及選出重要的字對於 News embedding representation 有很大的幫助。那當然 News-level Attention也很有用,選出新聞與新聞之間得交互作用對於 User embedding representation 也有很大的幫助。如果同時將這兩個結合,效果會很更好。

再來是看隔壁的圖(b),作者表示 Self-Attention 其實很有用,原因就如同剛才所述,字與字或是新聞與新聞之間的作用很重要。那 Additive Attention 也能提供 Performance improvement,畢竟從不同的字之間挑出重要的字,或是從不同的新聞挑出重要的,能幫忙學到更好的 User / News embedding。

Conclusion

  1. Attention is all you need.
  2. In the future, it is suggested to include positional information of words and news.
  3. Explore how to efficiently incorporate multiple kinds of news info, especially long sequence.

This article will be updated at any time! Thanks for your reading. If you like the content, please clip the “clap” button. You can also press the follow button to track new articles. Feel free to connect with me via LinkedIn or email.

--

--

Haren Lin

MSWE @ UC Irvine | MSCS @ NTU GINM | B.S. @ NCCU CS x B.A. @ NCCU ECON | ex-SWE intern @ TrendMicro