Neural News Recommendation with Multi-Head Self-Attention
Chuhan Wu1 , Fangzhao Wu2 , Suyu Ge1 , Tao Qi1 , Yongfeng Huang1 ,and Xing Xie2
1
Department of Electronic Engineering, Tsinghua University, Beijing 100084, China
2
Microsoft Research Asia, Beijing 100080, China{wu-ch19, gsy17, qit16, yfhuang}@mails.tsinghua.edu.cn,{fangzwu, xing.xie}@microsoft.com

Abstract
News recommendation can help users find interested news and alleviate information overload. Precisely modeling news and users is
critical for news recommendation, and capturing the contexts of words and news is important to learn news and user representations.
In this paper, we propose a neural news recommendation approach with multi-head selfattention (NRMS). The core of our approach isa news encoder and a user encoder. In the news
encoder, we use multi-head self-attentions tolearn news representations from news titles bymodeling the interactions between words. In
the user encoder, we learn representations ofusers from their browsed news and use multihead self-attention to capture the relatedness
between the news. Besides, we apply additive attention to learn more informative news
and user representations by selecting important words and news. Experiments on a realworld dataset validate the effectiveness and efficiency of our approach.

1

Introduction

Online news platforms such as Google News1 and
MSN News2 have attracted many users to readnews online (Das et al., 2007). Massive news articles are generated everyday and it is impossible
for users to read all news to find their interested
content (Phelan et al., 2011). Thus, personalized
news recommendation is very important for online
news platforms to target user interests and alleviate information overload (IJntema et al., 2010).
Learning accurate representations of news andusers are two core tasks in news recommendation (Okura et al., 2017). Several deep learning based methods have been proposed for thesetasks (?Kumar et al., 2017; Khattar et al., 2018;1
2

https://news.google.com/
https://www.msn.com/en-us/news

Rockets trade CarterWilliams to the Bulls

Best NBA
Moments in 2018

Weather forecast
This Week

James Harden's incredible heroics lift
Rockets over Warriors in overtime

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

Wu et al., 2019b,c,a; Zhu et al., 2019; An et al.,2019). For example, Okura et al. (2017) proposed
to learn news representations from news bodies via
auto-encoders, and learn representations of users
from their browsed news via GRU. However, GRU
is quite time-consuming, and their method cannot
capture the contexts of words. Wang et al. (2018)
proposed to learn news representations from news
titles via a knowledge-aware convolutional neuralnetwork (CNN), and learn representations of users
based on the similarities between candidate news
and their browsed news. However, CNN cannot capture the long-distance contexts of words,
and their method cannot model the relatedness between browsed news.
Our work is motivated by several observations.
First, the interactions between words in news title are important for understanding the news. For
example, in Fig. 1, the word “Rockets” has strong
relatedness with “Bulls”. Besides, a word may interact with multiple words, e.g., “Rockets” also
has semantic interactions with “trade”. Second,different news articles browsed by the same user
may also have relatedness. For example, in Fig. 1
the second news is related to the first and the third
news. Third, different words may have different
importance in representing news. In Fig. 1, theword “NBA” is more informative than “2018”. Besides, different news articles browsed by the sameuser may also have different importance in repre-

2.1

News Encoder

The news encoder module is used to learn news
representations from news titles. It contains threelayers. The first one is word embedding, which
is used to convert a news title from a sequence ofwords into a sequence of low-dimensional embedding vectors. Denote a news title with M words
as [w1 , w2 , ..., wM ]. Through this layer it is converted into a vector sequence [e1 , e2 , ..., eM ].
The second layer is a word-level multi-head
self-attention network (Vaswani et al., 2017; Wu
et al., 2018). The interactions between words areimportant for learning news representations. For
example, in the news title “Rockets Ends 2018with a Win”, the interaction between “Rockets”
and “Win” is useful for understanding this news,
and such long-distance interactions usually cannot be captured by CNN. In addition, a word may
interact with multiple words in the same news.
For instance, in above example the word “Rockets” has interactions with both “Ends” and “Win”.
Thus, we propose to use multi-head self-attention
to learn contextual representations of words by
capturing their interactions. The representation of
the ith word learned by the kth attention head is

𝒆𝒆2

𝒆𝒆1

…
……

𝒓𝒓1 𝒓𝒓2

𝒆𝒆𝑀𝑀

News
Encoder

Word Embedding

𝑤𝑤𝑀𝑀

𝑤𝑤1 𝑤𝑤2

…
…
…
…
…
…
…
……

…
……
…
……
𝒆𝒆1 𝒆𝒆2

Click
Probability

𝒉𝒉𝑛𝑛𝑁𝑁…
…
…

Our NRMS approach for news recommendation isshown in Fig. 2. It contains three modules, i.e.,news encoder, user encoder and click predictor.

𝒆𝒆𝑀𝑀

𝒉𝒉1𝑛𝑛 𝒉𝒉𝑛𝑛2

𝒉𝒉𝑤𝑤
𝑀𝑀

…
…
…
…
…
…

Our Approach𝑤𝑤
𝛼𝛼1𝑤𝑤 𝛼𝛼2𝑤𝑤 𝒒𝒒𝑤𝑤 𝛼𝛼𝑀𝑀

𝒉𝒉1𝑤𝑤 𝒉𝒉𝑤𝑤
2

𝐷𝐷1

�
𝒚𝒚

Dot

𝑛𝑛
𝛼𝛼1𝑛𝑛 𝛼𝛼2𝑛𝑛 𝒒𝒒𝑛𝑛 𝛼𝛼𝑀𝑀

…
…
…

2

𝒖𝒖

𝒓𝒓

…
…
…
…
…
…

senting this user. For example, the first three news
articles are more informative than the last one.
In this paper, we propose a neural news
recommendation approach with multi-head selfattention (NRMS). The core of our approach is anews encoder and a user encoder. In the news encoder, we learn news representations from news titles by using multi-head self-attention to model theinteractions between words. In the user encoder,
we learn representations of users from their browsing by using multi-head self-attention to capture
their relatedness. Besides, we apply additive attentions to both news and user encoders to selectimportant words and news to learn more informative news and user representations. Extensive experiments on a real-world dataset show that ourapproach can effectively and efficiently improve
the performance of news recommendation.

𝒓𝒓𝑁𝑁

News
Encoder

𝐷𝐷𝑁𝑁

Browsed News

𝒓𝒓𝑁𝑁

𝒓𝒓2

𝒓𝒓1

𝒓𝒓

News
Encoder

𝐷𝐷 𝑐𝑐

Candidate News

Figure 2: The framework of our NRMS approach.

computed as:exp(eTi Qwkk ej )
,
αi,j
= PM
T
w
m=1 exp(ei Qk em )
M
X
w
k
(
=
V
αi,j
ej ),
hw
k
i,k

(1)

(2)

j=1
w
where Qw
k and Vk are the projection parameters
k indicates thein the kth self-attention head, and αi,jrelative importance of the interaction between the
ith and jth words. The multi-head representationhw
i of the ith word is the concatenation of the representations produced by h separate self-attentionw
w
w
heads, i.e., hw
i = [hi,1 ; hi,2 ; ...; hi,h ].
The third layer is an additive word attention network. Different words in the same news may havedifferent importance in representing this news. For
example, in the second news of Fig. 1, the word
“NFL” is more informative than “Today” for understanding this news. Thus, we propose to use
attention mechanism to select important words innews titles for learning more informative news
representations. The attention weight αiw of thei-th word in a news title is computed as:
Tw
aw
i = qw tanh(Vw × hi + vw ),(3)

exp(awi )αiw = PM,w
j=1 exp(aj )(4)where Vw and vw are projection parameters, andqw is the query vector. The final representation ofa news is the weighted summation of the contextual word representations, formulated as:
r=

M
X
i=1

αiw hw
i .

(5)

2.2

User Encoder

2.3

The user encoder module is used to learn the representations of users from their browsed news.
It contains two layers. The first one is a newslevel multi-head self-attention network. Usually,
news articles browsed by the same user may havesome relatedness. For example, in Fig. 1, thefirst two news articles are related. In addition, anews article may interact with multiple news articles browsed by the same user. Thus, we propose
to apply multi-head self-attention to enhance therepresentations of news by capturing their interactions. The representation of the ith news learned
by the kth attention head is formulated as follows:
exp(rTi Qnk rj )
k
βi,j
= PM
,
T n
m=1 exp(ri Qk rm )MXkhni,k = Vkn (
βi,j
rj ),

(6)

(7)

j=1

where Qnk and Vkn are parameters of the kth news
k represents the relative
self-attention head, and βi,jimportance of the interaction between the jth andthe kth news. The multi-head representation of
the ith news is the concatenation of the representations output by h separate self-attention heads,
i.e., hni = [hni,1 ; hni,2 ; ...; hni,h ].
The second layer is an additive news attention
network. Different news may have different informativeness in representing users. For example,
in Fig. 1 the first news is more informative than
the fourth news in modeling user interest, since
the latter one is usually browsed by massive users.
Thus, we propose to apply the additive attention
mechanism to select important news to learn more
informative user representations. The attention
weight of the ith news is computed as:

Click Predictor

The click predictor module is used to predict theprobability of a user clicking a candidate news.
Denote the representation of a candidate news Dc
as rc . Following (Okura et al., 2017), the click
probability score ŷ is computed by the inner product of the user representation vector and the news
representation vector, i.e., ŷ = uT rc . We also
explored other kinds of scoring methods such as
perception, but dot product shows the best performance and efficiency.
2.4

Model Training

Motivated by (Huang et al., 2013), we use negative sampling techniques for model training. For
each news browsed by a user (regarded as a positive sample), we randomly sample K news which
are shown in the same impression but not clickedby the user (regarded as negative samples). We
shuffle the orders of these news to avoid possible positional biases. Denote the click probability
score of the positive and the K negative news as−] respectively. These scoresŷ + and [ŷ1− , ŷ2− , ..., ŷK
are normalized by the softmax function to compute the posterior click probability of a positive
sample as follows:pi =exp(ŷi+ ).
P−
exp(ŷi+ ) + K
j=1 exp(ŷi,j )(11)

We re-formulate the news click probability prediction problem as a pseudo (K + 1)-way classification task, and the loss function for model trainingis the negative log-likelihood of all positive samples S, which is formulated as follows:L=−X

log(pi ).

(12)

i∈S

ani = qTn tanh(Vn × hni + vn ),(8)

exp(ani )αin = PN
,
n)
exp(a
j=1
j

(9)

where Vn , vn and qn are parameters in the attention network, and N is the number of thebrowsed news. The final user representation is theweighted summation of the representations of thenews browsed by this user, which is formulated as:
u=

N
X
i=1

αin hni .

(10)3

Experiments

3.1

Datasets and Experimental Settings

We conducted experiments on a real-world news
recommendation dataset collected from MSN
News3 logs in one month (Dec. 13, 2018 to Jan.
12, 2019). The detailed statistics are shown in Table 1. The logs in the last week were used for test,
and the rest were used for training. We randomly
sampled 10% of training data for validation.
3

https://www.msn.com/en-us/news

# users# news# impressions

10,00042,255445,230

avg. # words per title# positive samples# negative samples

11.29
489,644
6,651,940

Table 1: Statistics of our dataset.

In our experiments, the word embeddings are
300-dimensional and initialized by the Glove embedding (Pennington et al., 2014). The selfattention networks have 16 heads, and the output of each head is 16-dimensional. The dimension of the additive attention query vectors is 200.
Following (Wu et al., 2019b), the negative sampling ratio K is 4. Adam (Kingma and Ba, 2014)is used for model optimization. We apply 20%
dropout to the word embeddings to mitigate overfitting. 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.
3.2

Performance Evaluation

We evaluate the performance of our approach bycomparing it with several baseline methods, including: (1) LibFM (Rendle, 2012), a matrix
factorization based recommendation method; (2)DSSM (Huang et al., 2013), deep structured semantic model; (3) Wide&Deep (Cheng et al.,2016), a popular neural recommendation method;(4) DeepFM (Guo et al., 2017), another popularneural recommendation method; (5) DFM (Lianet al., 2018), deep fusion model for news recommendation; (6) DKN (Wang et al., 2018), deep
knowledge-aware network for news recommendation; (7) Conv3D (Khattar et al., 2018), a neuralnews recommendation method with 3-D CNNs tolearn user representations; (8) GRU (Okura et al.,2017), a neural news recommendation method using GRU to learn user representations; (9) NRMS,
our approach. In methods (1) and (3-5), we use
one-hot encoded user ID, news ID and the TF-IDF
features extracted from news titles as the model
input. In methods (6-9), we all use news titles forfair comparison. The results of these methods are
summarized in Table 2.
We have several observations from Table 2.
First, neural recommendation methods such as
DSSM and NRMS outperform traditional recommendation methods such as LibFM on news rec-

Methods
LibFM
DSSM
Wide&Deep
DeepFM
DFM
DKN
Conv3D
GRU
NRMS*

AUC
0.56610.59490.5812
0.58300.58610.60320.60510.61020.6275MRR
0.24140.26750.2546
0.25700.26090.27440.27650.28110.2985nDCG@50.26890.28810.27650.28020.2844
0.29670.29870.30350.3217nDCG@100.35520.38000.36740.37070.37420.38730.39040.39520.4139

Table 2: The results of different methods. *The improvement is significant at p < 0.01.

ommendation. This may be because neural networks can learn better representations of news andusers than matrix factorization methods. Thus, it
may be more appropriate to learn news and user
representations via neural networks rather thancraft them manually. Second, among the deeplearning based methods, the methods which exploit the relatedness between news (e.g., Conv3D,
GRU and NRMS) can outperform other methods.
This may be because the news browsed by thesame user usually have relatedness, and capturing
the news relatedness is useful for understanding
these news and modeling user interests. Third, ourapproach performs better than all baseline methods. This is because our approach can capture
the interactions between both words and news via
multi-head self-attention to enhance representation learning of news and users. Besides, our approach employs additive attention to select important words and news for learning informative news
and user representations. These results validate
the effectiveness of our approach.
We also conducted experiments to compare thetime efficiency of our approach with several popular news recommendation methods. The results
are shown in Table 3. From the results, we find
our approach has a smaller parameter size and alower time complexity in learning news and user
representations than existing news recommendation methods. In addition, different from DKN,
our approach does not need to memorize the news
browsing histories of users when computing theclick probability scores. In addition, since ourapproach can be further accelerated by computing the hidden representations of different attention heads in parallel, our approach is more suitable for being deployed in large-scale news recommendation scenarios. These results validate theefficiency of our approach.

Method
DKN
Conv3DGRU
NRMS# Parameters
681 K
575 K
541 K
530 K

News Encoding Time46.4 s29.8 min59.8 s39.7 sUser Encoding Time10.1 min16.7 min148.0 min
6.7 min

Table 3: The number of parameters in NRMS and baseline methods, and their time in encoding 1 million news
and 1 million users. *Word embeddings are excluded.

interactions between words and news are important for understanding news and modeling users.
In addition, the additive attentions are also helpful. This is because different words and news may
usually have different importance in representing
news and users. Thus, selecting important words
and news can help learn more informative news
and user representations. Combining both additive and self-attention can further improve our approach. Thus, these results validate the effectiveness of the attention mechanism in our approach.

4(a) Attention mechanisms at different levels.

(b) Attention mechanisms of different kinds.

Figure 3: Effectiveness of different attention networks.

3.3

Effectiveness of Attention Mechanism

Next we explore the effectiveness of attentions
in our approach. First, we verify the word- andnews-level attentions. The results are shown in
Fig. 3(a). We find the word-level attention is very
useful. This is because modeling the interactions
between words and selecting important words canhelp learn informative news representations. Besides, the news-level attention is also useful. Thisis because capturing the relatedness of news andselecting important news can benefit the learning of user representations. Moreover, combining
both word- and news-level attentions can further
improve the performance of our approach.
We also study the influence of additive and selfattentions on our approach. The results are shownin Fig. 3(b). From these results, we find the selfattentions are very useful. This is because theConclusion and Future WorkIn this paper we propose a neural news recommendation approach with multi-head self-attention.
The core of our approach is a news encoder anda user encoder. In both encoders we apply multihead self-attentions to learn contextual word andnews representations by modeling the interactions
between words and news. In addition, we use
additive attentions to select important words andnews to learn more informative news and user representations. Extensive experiments validate theeffectiveness and efficiency of our approach.
In our future work, we will try to improve
our approach in the following potential directions.
First, in our framework we do not consider the positional information of words and news, but they
may be useful for learning more accurate news anduser representations. We will explore position encoding techniques to incorporate the word position
and the time-stamps of news clicks to further enhance our approach. Second, we will explore how
to effectively incorporate multiple kinds of news
information in our framework, especially long sequences such as news body, which may challenge
the efficiency of typical self-attention networks.

Acknowledgments
The authors would like to thank Microsoft Newsfor providing technical support and data in theexperiments, and Jiun-Hung Chen (Microsoft
News) and Ying Qiao (Microsoft News) for theirsupport and discussions. This work was supported by the National Key Research and Development Program of China under Grant number 2018YFC1604002, the National Natural Science Foundation of China under Grant numbers
U1836204, U1705261, U1636113, U1536201,
and U1536207.

References
Mingxiao An, Fangzhao Wu, Chuhan Wu, Kun Zhang,
Zheng Liu, and Xing Xie. 2019. Neural news recommendation with long-and short-term user representations. In ACL, pages 336–345.
Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen, Tal
Shaked, Tushar Chandra, Hrishi Aradhye, Glen Anderson, Greg Corrado, Wei Chai, Mustafa Ispir, et al.
2016. Wide & deep learning for recommender systems. In DLRS, pages 7–10.
Abhinandan S Das, Mayur Datar, Ashutosh Garg, andShyam Rajaram. 2007. Google news personalization: scalable online collaborative filtering. In
WWW, pages 271–280. ACM.
Huifeng Guo, Ruiming Tang, Yunming Ye, Zhenguo Li, and Xiuqiang He. 2017. Deepfm: afactorization-machine based neural network for ctr
prediction. In AAAI, pages 1725–1731. AAAI Press.
Po-Sen Huang, Xiaodong He, Jianfeng Gao, Li Deng,
Alex Acero, and Larry Heck. 2013. Learning deep
structured semantic models for web search using
clickthrough data. In CIKM, pages 2333–2338.
ACM.
Wouter IJntema, Frank Goossen, Flavius Frasincar,
and Frederik Hogenboom. 2010. Ontology-based
news recommendation. In Proceedings of the 2010
EDBT/ICDT Workshops, page 16.
Dhruv Khattar, Vaibhav Kumar, Vasudeva Varma, andManish Gupta. 2018. Weave&rec: A word embedding based 3-d convolutional network for news recommendation. In CIKM, pages 1855–1858.
Diederik P Kingma and Jimmy Ba. 2014. Adam: A
method for stochastic optimization. arXiv preprint
arXiv:1412.6980.
Vaibhav Kumar, Dhruv Khattar, Shashank Gupta, Manish Gupta, and Vasudeva Varma. 2017. Deep neural architecture for news recommendation. In CLEF
(Working Notes).
Jianxun Lian, Fuzheng Zhang, Xing Xie, andGuangzhong Sun. 2018. Towards better representation learning for personalized news recommendation: a multi-channel deep fusion approach. In IJCAI, pages 3805–3811.

Shumpei Okura, Yukihiro Tagami, Shingo Ono, andAkira Tajima. 2017. Embedding-based news recommendation for millions of users. In KDD, pages
1933–1942. ACM.
Jeffrey Pennington, Richard Socher, and Christopher
Manning. 2014. Glove: Global vectors for word
representation. In EMNLP, pages 1532–1543.
Owen Phelan, Kevin McCarthy, Mike Bennett, andBarry Smyth. 2011. Terms of a feather: Contentbased news recommendation and discovery using
twitter. In ECIR, pages 448–459. Springer.
Steffen Rendle. 2012. Factorization machines withlibfm. TIST, 3(3):57.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob
Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz
Kaiser, and Illia Polosukhin. 2017. Attention is all
you need. In NIPS, pages 5998–6008.
Hongwei Wang, Fuzheng Zhang, Xing Xie, and Minyi
Guo. 2018. Dkn: Deep knowledge-aware network
for news recommendation. In WWW, pages 1835–
1844.
Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang
Huang, Yongfeng Huang, and Xing Xie. 2019a.
Neural news recommendation with attentive multiview learning. In IJCAI, pages 3863–3869.
Chuhan Wu, Fangzhao Wu, Mingxiao An, Jianqiang
Huang, Yongfeng Huang, and Xing Xie. 2019b.
Npa: Neural news recommendation with personalized attention. In KDD, pages 2576–2584. ACM.
Chuhan Wu, Fangzhao Wu, Mingxiao An, Yongfeng
Huang, and Xing Xie. 2019c. Neural news recommendation with topic-aware news representation. In
ACL, pages 1154–1159.
Chuhan Wu, Fangzhao Wu, Junxin Liu, Sixing Wu,
Yongfeng Huang, and Xing Xie. 2018. Detecting tweets mentioning drug name and adverse drug
reaction with hierarchical tweet representation andmulti-head self-attention. In SMM4H, pages 34–37.
Qiannan Zhu, Xiaofei Zhou, Zeliang Song, Jianlong
Tan, and Li Guo. 2019. Dan: Deep attention neuralnetwork for news recommendation. In AAAI, volume 33, pages 5973–5980.