# Adaptive Rank-based Tests for High Dimensional Mean Problems

Yu Zhang and Long Feng
School of Statistics and Data Science, KLMDASR, LEBPS, and LPMC,
Nankai University, No.94 Weijin Road, 300071, Tianjin, China Corresponding
author<EMAIL_ADDRESS>
###### Abstract

The Wilcoxon signed-rank test and the Wilcoxon-Mann-Whitney test are commonly
employed in one sample and two sample mean tests for one-dimensional
hypothesis problems. For high-dimensional mean test problems, we calculate the
asymptotic distribution of the maximum of rank statistics for each variable
and suggest a max-type test. This max-type test is then merged with a sum-type
test, based on their asymptotic independence offered by stationary and strong
mixing assumptions. Our numerical studies reveal that this combined test
demonstrates robustness and superiority over other methods, especially for
heavy-tailed distributions.

Keywords: Asymptotic independence, High dimensional test, Rank-based test.

##  1 Introduction

In the past few decades, hypothesis test for mean has drawn a significant
amount of attention in a wide range of scientific fields, such as chemistry
(Miller, 1991), education (Cheung, 2009), genetics (Ouyang et al., 2022),
economics (Newbold et al., 2013) and many other fields. Hotelling’s $T^{2}$
test is the classic method for mean test problem, which does not work in high
dimensional problem because the sample covariance matrix is not invertible. A
large amount of efforts have been made for replacing the sample covariance
matrix in the classic Hotelling’s $T^{2}$ test statistic. For example, Bai and
Saranadasa (1996), Chen and Qin (2010) replaced the singular matrix with
identity matrix in Hotelling’s $T^{2}$ test. Srivastava and Du (2008) do the
replacement with the diagonal matrix of sample covariance matrix. More
replacement-based work can see the Feng et al. (2015), Feng et al. (2016),
Gregory et al. (2015), Park and Ayyala (2013) and Wang et al. (2015). The
above methods can be viewed as sum-type methods, which consist of summation of
parameter estimators. The mentioned analytics show that the sum-type tests
generally perform well as data are dense, where dense means most of the
parameters are nonzero under the local alternative. However, Cai et al. (2014)
mentioned that sum-type statistics does not perform as well in sparse cases as
in dense cases, where sparse means only a few of the parameters are zero under
the local alternative. To handle the sparse alternatives, Chen et al. (2019),
Feng et al. (2022) and Cai et al. (2014) proposed some max-type tests, which
performs well under sparse alternatives.

In order to adopt appropriate methods for high dimensional hypothesis mean
test, it’s essential to get a rough picture of alternatives. However, we can
not know whether the data are sparse or dense. Recently, many literatures
proposed adaptive methods to overcome this issue, such as Fan et al. (2015),
Xu et al. (2016), He et al. (2021), Feng et al. (2022). For example, Feng et
al. (2022) proposed a data-robust test which combines the sum-type test and
max-type test under Gaussian assumptions, performs pretty well under both
sparse and dense alternatives. It proves the asymptotic independence between
the sum-type statistic and max-type statistic, which motivates us to construct
combination test based on independence between the different type tests.

Indeed, the aforementioned methods are all extensions of the classic $t-$test
for a one-dimensional variable. It’s well-known that the classic $t-$test does
not perform very well for heavy-tailed distributions. Therefore, the Wilcoxon
signed-rank test and the Wilcoxon-Mann-Whitney test are typically used in one
sample and two sample mean tests for one-dimensional hypothesis problems.
Ouyang et al. (2022) expanded these two rank-based methods to high-dimensional
mean problems by summing the test statistics of each variable, which has
proven effective for dense alternatives. For sparse alternatives, we
introduced a new max-type test based on rank statistics and established its
asymptotic distribution. Subsequently, we combined this newly proposed max-
type test with the sum-type test proposed by Ouyang et al. (2022), under the
$\alpha$-fixing and stationary conditions provided by Hsing (1995), for both
one sample mean test and two sample mean test. Our simulation results indicate
that our proposed combination tests not only inherit the robustness of signal
sparsity, but also for the heavy-tailed distributions.

The rest of the paper is organized as follows. In section 2, we review the
moment properties of Wilcoxon signed-rank test, Wilcoxon Mann-Whitney test and
state the theoretical results of our proposed max-type test and combination
test for one sample case and two sample case respectively. Simulation studies
are shown in Section 3. In section 4, we make conclusions about this paper.
Finally we present the technical proof in the Appendix.

##  2 High dimensional mean test

###  2.1 One sample test

Assuming $p$ dimensional vectors $\bm{X}_{1},...,\bm{X}_{n}$ generated
independently from distribution $F(\bm{X}-\bm{\mu})$, where the distribution
of $F$ is continuous and symmetric. For the one sample test problem, the
hypothesis problem can be expressed as:

$H_{0}:\bm{\mu}=0\ \ versus\ \ H_{1}:\bm{\mu}\neq 0.$ (2.1)

In the case of $p=1$, it’s natural to consider the Wilcoxon signed-rank test.
The statistic of Wilcoxon signed-rank is defined as:

$U=\sum_{i=1}^{n}R_{i}I(X_{i}>0).$ (2.2)

here $R_{i}$ denotes the rank of $|X_{i}|$ among $\\{|X_{i}|,i=1,...,n\\}$,
where $|X_{i}|$ is the absolute value of $X_{i}$. Note that
$E_{H_{0}}(U)=n(n+1)/4$, $Var_{H_{0}}(U)=n(n+1)(2n+1)/24$, and
$(U-E_{H_{0}}(U))/\sqrt{Var(U_{H_{0}})}\overset{d}{\rightarrow}N(0,1)$. To
handle the high dimensional problem, Ouyang et al. (2022) proposed a sum-type
statistic based on Wilcoxon signed-rank test, defined by:

$M_{n}=p^{-1}\sum_{i=1}^{p}\\{U_{i}-E_{H_{0}}(U_{i})\\}^{2}.$ (2.3)

where $U_{i}$ is the Wilcoxon signed-rank statistic from the $i$-th component
of $p$ dimensional vector $\bm{X}$. Define
$M_{n}^{i}=\\{U_{i}-E_{H_{0}}(U_{i})\\}^{2}$, $i\in\\{1,...,p\\}$, it can be
derived that $E_{H_{0}}(M_{n}^{i})=n(n+1)(2n+1)/24$ and
$Var_{H_{0}}(M_{n}^{i})=(6n+5n^{2}-30n^{3}-25n^{4}+24n^{5}+20n^{6})/1440$,
then define the
$R_{n}^{i}=(M_{n}^{i}-E_{H_{0}}(M_{n}^{i}))/\sqrt{Var_{H_{0}}(M_{n}^{i})}$ .
They proved the asymptotic normality of $M_{n}$ under the following strong
mixing and stationary assumptions.

######  Assumption 2.1.

Assume that the strong stationary sequence $\\{R_{n}^{i}\\}$ satisfies the
strong mixing condition. Let
$\alpha(r)=sup\\{\mathcal{F}_{k}^{1},\mathcal{F}_{k+r}^{p}\\}$, where
$\mathcal{F}_{m}^{n}=\sigma\\{m\leq R_{n}^{i}\leq n\\}$ and
$\alpha(\mathcal{F},\mathcal{G})=sup\\{|P(A\cap B)-P(A)P(B)|\\}$. The random
sequence $R_{n}^{i}$ is said to be ”strongly mixing”, if $\alpha(r)\rightarrow
0$ as $r\rightarrow\infty.$

######  Assumption 2.2.

Suppose that $\sum_{r=1}^{\infty}\alpha(r)^{\delta/(2+\delta)}<\infty$ for
some $\delta>0$, and for any $k\geq 0$,
$\mathop{\lim}_{p\rightarrow\infty}\sum_{j=1}^{p-k}cov(R_{n}^{j},R_{n}^{j+k})/(p+k)=\gamma(k)$
exists.

Cai et al. (2014) mentioned that sum-of-squares type statistics does not
perform as well in sparse cases and showed that max-type statistic performs
pretty well under sparse alternatives. Now we formally introduce our newly
proposed max-type statistic, defined by:

$V_{n}=\max_{1\leq i\leq p}|V_{n}^{i}|.$ (2.4)

where
$V_{n}^{i}\overset{def}{=}(U_{i}-E_{H_{0}}(U_{i}))/\sqrt{Var_{H_{0}}(U_{i})}$.
To derive the asymptotic distribution of $V_{n}$, additional assumptions need
to be imposed. Thus we assume the following condition:

######  Assumption 2.3.

Let $\sigma_{ij}^{n}=cor(V_{n}^{i},V_{n}^{j})$, then
$\mathop{lim}_{n\rightarrow\infty}\sigma_{ij}^{n}=\sigma_{ij}$, define
$\mathbf{\Sigma}=(\sigma_{ij})_{1\leq i,j\leq p}$. For some $\rho\in(0,1)$,
assume $\sigma_{ij}\leq\rho$ for all $1\leq i,j\leq p$. Suppose
$\\{\delta_{p};p\geq 1\\}$ and $\\{\zeta_{p};p\geq 1\\}$ are positive
constants with $\delta_{p}=o(1/\log p)$ and $\zeta=\zeta_{p}\rightarrow 0$ as
$p\rightarrow\infty$. For $1\leq i\leq p$, define $B_{p,i}=\\{1\leq j\leq
p;|\sigma_{ij}|\geq\delta_{p}\\}$ and $C_{p}=\\{1\leq i\leq p;|B_{p,i}|\geq
p^{\zeta}\\}$. Assuming that $|C_{p}|/p$ as $p\rightarrow\infty$.

Note that Assumption 2.3 is the same as assumption (A1) in Chen and Feng
(2022).

######  Theorem 2.1.

Under the null hypothesis in (2.1), we have following result:

  * (i)

Under assumptions 2.1, 2.2 satisfied,
$T_{sum}^{(1)}=\frac{\sqrt{p}(M_{n}-E_{H_{0}}(M_{n}^{i}))}{\sqrt{Var_{H_{0}}(M_{n}^{i})\tau_{1}^{2}}}\rightarrow
N(0,1)$, where $\tau_{1}^{2}=1+2\mathop{\sum}_{k=1}^{\infty}\gamma_{1}(k)$.

  * (ii)

Under assumption 2.3, let $T_{max}^{(1)}=V_{n}^{2}-2\log p+\log\log p$, we
have:

$|P(T_{max}^{(1)}\leq y)-\exp\\{-\pi^{-\frac{1}{2}}\exp\\{-y/2\\}\\}|=o(1).$
(2.5)

  * (iii)

Under assumptions 2.1-2.3, then $T_{sum}^{(1)}$ and $T_{max}^{(1)}$ are
asymptotically independent.

Theorem 2.1 (i) is from the Theorem 1 in Ouyang et al. (2022), where
assumption 2.1, 2.2 depict the dependent structure among the rank-statistics
of vector $\bm{X}$. When performing a $\alpha$ level hypothesis test based on
$T_{sum}^{(1)}$, it rejects the null hypothesis for
$1-\Phi^{-1}(T_{sum}^{(1)})\leq\alpha$, where $\Phi(x)$ denotes the c.d.f of
standard normal distribution. And for the $T_{max}^{(1)}$ in Theorem 2.1 (ii),
it rejects the null hypothesis when $1-G^{-1}(T_{max}^{(1)})\leq\alpha$, where
$G(x)=\exp\\{-\pi^{-\frac{1}{2}}\exp\\{-x/2\\}\\}$ is the c.d.f of Gumbel
distribution. The technical proof of Theorem 2.1 (ii) is presented in
appendix.

With the asymptotic independence between $T_{sum}^{(1)}$ and $T_{max}^{(1)}$
in Theorem 2.1 (iii), we combine the statistics by using Cauchy combination
method in Liu and Xie (2019) :

$T_{com}^{(1)}=1-C[0.5\tan\\{(0.5-p^{(1)}_{M})\pi\\}+0.5\tan\\{(0.5-p^{(1)}_{S})\pi\\}].$
(2.6)

where

$\displaystyle
p^{(1)}_{S}=1-\Phi(T_{sum}^{(1)}),p^{(1)}_{M}=1-G(T_{max}^{(1)}).$

Here $C(x)$ is the c.d.f of Cauchy distribution. Thus we can perform the
$\alpha$ level hypothesis test based on $T_{com}^{(1)}$ by rejecting null
hypothesis when $T_{com}^{(1)}\leq\alpha$.

Next we consider the power function of $T_{com}^{(1)}$. Long et al. (2023)
proved that Cauchy combination test would be more powerful than minimal
p-value combination test, where minimal p-value combination test rejects the
null hypothesis when $min(p_{S},p_{M})\leq 1-\sqrt{1-\alpha}\approx\alpha/2$.
Thus we have:

$\displaystyle\beta(T_{com}^{(1)},\alpha)$
$\displaystyle=P(T_{com}^{(1)}\leq\alpha)$ $\displaystyle\geq
P(min(p_{S},p_{M})\leq 1-\sqrt{1-\alpha})\approx
P(min(p_{S},p_{M})\leq\alpha/2)$ $\displaystyle\geq
max(\beta(T_{sum}^{(1)},\alpha/2),\beta(T_{max}^{(1)},\alpha/2)).$ (2.7)

We consider the power function under sparse and dense cases. In dense cases,
the power function of $T_{sum}^{(1)}$ converges to 1 when
$n\mu_{i}^{2}=O(p^{\alpha})$ with $\alpha\geq-1/2$ by Theorem 2 in Ouyang et
al. (2022). In sparse cases, with the similar argument in Feng et al. (2022),
the power function of $T_{max}^{(1)}$ converges to 1 provided the signal
condition $\max_{1\leq i\leq p}\mu_{i}\gtrsim\sqrt{\log p/n}$ with $\log
p=o(n)$.

######  Theorem 2.2.

The power function of $T_{max}^{(1)}$ converges to 1 provided the signal
condition $\max_{1\leq i\leq p}\mu_{i}\gtrsim\sqrt{\log p/n}$ with $\log
p=o(n)$.

Since the difference between the $\beta(T_{sum}^{(1)},\alpha/2)$ and
$\beta(T_{sum}^{(1)},\alpha)$ should be negligible when $\alpha$ is relatively
small and the same for $\beta(T_{sum}^{(1)},\alpha)$, we can conclude that the
power function of $T_{com}^{(1)}$ converges to 1 in both sparse and dense
conditions according to (2.7).

###  2.2 Two sample test

For the two-sample testing problem, we suppose there are $n$ samples
$\\{\bm{X}_{1},...,\bm{X}_{n}\\}$ drawn from distribution
$F(\bm{X}-\bm{\mu}_{1})$ and $m$ samples $\\{\bm{Y}_{1},...,\bm{Y}_{m}\\}$
from distribution $F(\bm{Y}-\bm{\mu}_{2})$. We focus on testing the hypothesis
problem

$H_{0}:\bm{\mu}_{1}=\bm{\mu}_{2}\ \ versus\ \
H_{1}:\bm{\mu}_{1}\neq\bm{\mu}_{2}.$ (2.8)

In $p=1$, the Wilcoxon-Mann-Whitney(WMW) statistic is defined as:

$U^{xy}=\sum_{i=1}^{n}R_{i}^{xy}-n(n+1)/2.$ (2.9)

Here $R_{i}^{xy}$ denotes the the rank of $X_{i}$ in the union of the sample
$\\{X_{1},...,X_{n},Y_{1},...,Y_{m}\\}$. And $E_{H_{0}}(U^{xy})=mn/2$. Similar
to the statistic in (2.3), Ouyang et al. (2022) also proposed a sum-type
statistic for two sample test, which is defined as:

$M_{n}^{xy}=p^{-1}\sum_{i=1}^{p}(U_{i}^{xy}-E_{H_{0}}(U_{i}^{xy}))^{2}.$
(2.10)

where $U_{i}^{xy}$ is the WMW statistic of the i-th component in two sample
test. Define $\gamma_{n}^{i}=\\{U_{i}^{xy}-E_{H_{0}}(U_{i}^{xy})\\}^{2}$,
$i\in\\{1,...,p\\}$ and we have $E_{H_{0}}(\gamma_{n}^{i})=mn(m+n+1)/12$ and
$Var_{H_{0}}(\gamma_{n}^{i})=\\{mn(5(m+n)+8)-3(m+n)(m+n+1)\\}(m+n+1)mn/360$,
then define the
$\rho_{n}^{i}=(\gamma_{n}^{i}-E_{H_{0}}(\gamma_{n}^{i}))/\sqrt{Var_{H_{0}}(\gamma_{n}^{i})}$
. With similar argument above, asymptotic normality of $M_{n}^{xy}$ is proved.

Then we introduce our max-type statistic for two sample problem, defined as:

$V_{n}^{xy}=\max_{1\leq i\leq p}|\nu_{n}^{i}|.$ (2.11)

where
$\nu_{n}^{i}\overset{def}{=}(U_{i}^{xy}-E_{H_{0}}(U_{i}^{xy}))/\sqrt{Var_{H_{0}}(U_{i}^{xy})}=(U_{i}^{xy}-mn/2)/\sqrt{mn(m+n+1)/12}$.
With the assumption 2.3 satisfied, we can derive the asymptotic distribution
of $V_{n}^{xy}$. Thus we have the following theorem:

######  Theorem 2.3.

Under the null hypothesis in (2.8), we have following result:

  * (i)

When assumptions 2.1, 2.2 are satisfied with $R_{n}^{i}$ replaced by
$\rho_{n}^{i}$,
$T_{sum}^{(2)}=\frac{\sqrt{p}(M_{n}^{xy}-E_{H_{0}}(\gamma_{n}^{i}))}{\sqrt{Var_{H_{0}}(\gamma_{n}^{i})\tau_{2}^{2}}}\rightarrow
N(0,1)$, where $\tau_{2}^{2}=1+2\mathop{\sum}_{k=1}^{\infty}\gamma_{2}(k)$.

  * (ii)

With assumption 2.3 and $V_{n}^{i}$ replaced by $\nu_{n}^{i}$, let
$T_{max}^{(2)}=(V_{n}^{xy})^{2}-2\log p+\log\log p$, we have:

$|P(T_{max}^{(2)}\leq y)-\exp\\{-\pi^{-\frac{1}{2}}\exp\\{-y/2\\}\\}|=o(1).$
(2.12)

  * (iii)

With assumption 2.1 and $R_{n}^{i}$ replaced by $\rho_{n}^{i}$, then
$T_{sum}^{(2)}$ and $T_{max}^{(2)}$ are asymptotically independent.

Theorem 2.2 (i) is from the Theorem 3 in Ouyang et al. (2022). $T_{sum}^{(2)}$
performs a $\alpha$ level hypothesis test by rejecting the null hypothesis for
$1-\Phi^{-1}(T_{sum}^{(2)})\leq\alpha$. And for the $T_{max}^{(2)}$ in Theorem
2.3 (ii), it performs a $\alpha$ level hypothesis test by rejecting the null
hypothesis for $1-G^{-1}(T_{max}^{(2)})\leq\alpha$. The technical proof of
Theorem 2.3 (ii) is presented in the appendix.

Since Theorem 2.3 (iii) provides the asymptotic independence between
$T_{sum}^{(2)}$ and $T_{max}^{(2)}$, we propose a Cauchy combination test
$T_{com}^{(2)}$ for two sample test, defined as:

$T_{com}^{(2)}=1-C[0.5\tan\\{(0.5-p^{(2)}_{M})\pi\\}+0.5\tan\\{(0.5-p^{(2)}_{S})\pi\\}].$
(2.13)

where

$\displaystyle
p_{S}^{(2)}=1-\Phi(T_{sum}^{(2)}),p_{M}^{(2)}=1-G(T_{max}^{(2)}).$

Thus we perform the $\alpha$ level hypothesis test based on $T_{com}^{(2)}$ by
rejecting null hypothesis when $T_{com}^{(2)}\leq\alpha$.

Then we consider the power function of $T_{com}^{(2)}$. With the discussion in
(2.7), we consider
$max(\beta(T_{sum}^{(2)},\alpha/2),\beta(T_{max}^{(2)},\alpha/2))$ directly.
In dense cases, by the Theorem 4 in Ouyang et al. (2022), power function of
$T_{sum}^{(2)}$ converges to 1 when $n(\mu_{1i}-\mu_{2i})^{2}=O(p^{\alpha})$
with $\alpha\geq-1/2$, here $\mu_{ki}$ denotes the ith coordinate of
$\mu_{k}$, $k$=1,2. In sparse cases, the power function of $T_{max}^{(2)}$
converges to 1 provided the signal condition $\max_{1\leq i\leq
p}(\mu_{1i}-\mu_{2i})\gtrsim\sqrt{(m+n)\log p/mn}$ with $\log p=o(mn/(m+n))$.

######  Theorem 2.4.

The power function of $T_{max}^{(2)}$ converges to 1 provided the signal
condition $\max_{1\leq i\leq p}(\mu_{1i}-\mu_{2i})\gtrsim\sqrt{(m+n)\log
p/mn}$ with $\log p=o(mn/(m+n))$.

Thus we can conclude that the power function of $T_{com}^{(2)}$ converges to 1
in either sparse or dense conditions.

##  3 Simulation

In this section, we carried out series of simulations to evaluate the
performance of our proposed method. We incorporated various methods into our
study:

  * •

our max-type method $T_{max}^{(1)}$ in one sample, $T_{max}^{(2)}$ in two
sample, referred as MAX1;

  * •

sum-type method $T_{sum}^{(1)}$ for one sample, $T_{sum}^{(2)}$ for two sample
in Ouyang et al. (2022), referred as SUM1;

  * •

our combination test $T_{com}^{(1)}$ for one sample, $T_{com}^{(2)}$ for two
sample, referred as COM1;

  * •

max-type method proposed by Feng et al. (2022) , referred as MAX2;

  * •

sum-type method proposed by Srivastava and Du (2008), referred as SUM2;

  * •

combination test proposed by Feng et al. (2022), referred as COM2.

###  3.1 one sample test

Following the setting in Ouyang et al. (2022) and Feng et al. (2022), we
generate $n$ samples $\\{\bm{x}_{1},...,\bm{x}_{n}\\}$ with mean vector
$\bm{\mu}=(\mu_{1},...,\mu_{p})$ and covariance matrix $\mathbf{\Sigma}$. We
consider data from two distributions: multivariate normal distribution and the
multivariate $t$ distribution $t_{3}$. We generate data with dimension
$n=100,200$ and sample sizes $p=200,400,600$. In order to compare the
performance of above methods under different dependent structures, we consider
the following three scenarios:

(1)Independent structure: $\mathbf{\Sigma}=I_{(p\times p)}$.

(2)AR(1) model with weak correlation: $\mathbf{\Sigma}=(0.3^{|i-j|})_{1\leq
i,j\leq p}$.

(3)AR(1) model with strong correlation: $\mathbf{\Sigma}=(0.6^{|i-j|})_{1\leq
i,j\leq p}$.

We first check the performance of empirical sizes under null cases,i.e.
$\bm{\mu}=0$. Table 1, Table 2, table 3 display the empirical size under
scenario (1), scenario (2), scenario (3), respectively. Each result is
obtained by 1000 simulations. The simulated results show that MAX1, SUM1, COM1
perform pretty well under diverse scenarios, while MAX2, SUM2, COM2 behave
quite conservative with $t_{3}$ distribution.

For power comparison, we follow the setting in Feng et al. (2022) and set
$n$=100, $p$=200. For the alternative cases, $\bm{\mu}$ is set to
$(0,0,0...,\sqrt{0.5/m},...,\sqrt{0.5/m})$, where $m$ denotes the number of
nonzero components. Figure 1 displays the POWER curves of the above methods as
the number of nonzero component $m$ increases under three scenarios with
multivariate normal distribution and multivariate $t_{3}$ distribution. For
the multivariate $t_{3}$ distribution, the power of both MAX1 and MAX2 methods
decreases as $m$ increases. This is expected as max-type tests are more
effective in sparse cases. On the other hand, the power of SUM1 and SUM2
methods remains stable, as we have fixed the signal
$\bm{\mu}^{T}\mathbf{\Sigma}\bm{\mu}$. Our findings indicate that both MAX1
and SUM1 tests are more powerful than their counterparts, MAX2 and SUM2,
respectively. As a result, COM1 outperforms COM2 in all cases. This is not
surprising as rank-based tests have been shown to outperform the classic
$t-$test for heavy-tailed distributions. The COM1 test exhibits superior
performance in nearly all tests. When the signal is very sparse, i.e., $m<5$,
COM1 performs similarly to MAX1. When the signal is very dense, i.e., $m>10$,
COM1 performs similarly to SUM1. However, for $5\leq m\leq 10$, COM1
outperforms both MAX1 and SUM1. These results align with theoretical
predictions and highlight the superiority of the COM1 method. It is worth
mentioning that under normal distribution, COM1 did not perform as well as
COM2 while the difference between COM1 and COM2 is not significant, which is
natural since COM2 is proposed based on the assumption of normality.

Table 1: Sizes of one sample tests with Scenario (1) Distribution | Normal | $t_{3}$
---|---|---
p | 200 400 600 | 200 400 600
n=100 MAX1 | 0.036 0.033 0.033 | 0.030 0.031 0.040
SUM1 | 0.055 0.060 0.067 | 0.046 0.068 0.057
COM1 | 0.059 0.055 0.066 | 0.043 0.065 0.059
MAX2 | 0.082 0.065 0.088 | 0.022 0.035 0.036
SUM2 | 0.063 0.071 0.076 | 0.001 0.000 0.000
COM2 | 0.067 0.063 0.085 | 0.013 0.012 0.015
n=200 MAX1 | 0.043 0.035 0.035 | 0.031 0.042 0.040
SUM1 | 0.061 0.046 0.044 | 0.053 0.049 0.065
COM1 | 0.066 0.044 0.041 | 0.069 0.065 0.059
MAX2 | 0.060 0.055 0.065 | 0.035 0.033 0.036
SUM2 | 0.058 0.052 0.055 | 0.004 0.000 0.000
COM2 | 0.062 0.055 0.058 | 0.014 0.015 0.014
Table 2: Sizes of one sample tests with Scenario (2) distribution | Normal | $t_{3}$
---|---|---
p | 200 400 600 | 200 400 600
n=100 MAX1 | 0.038 0.034 0.033 | 0.027 0.023 0.029
SUM1 | 0.044 0.041 0.040 | 0.041 0.030 0.045
COM1 | 0.053 0.046 0.040 | 0.039 0.036 0.039
MAX2 | 0.070 0.074 0.086 | 0.026 0.033 0.041
SUM2 | 0.060 0.059 0.061 | 0.005 0.000 0.000
COM2 | 0.064 0.066 0.077 | 0.012 0.013 0.020
n=200 MAX1 | 0.037 0.037 0.037 | 0.039 0.039 0.032
SUM1 | 0.042 0.041 0.053 | 0.052 0.041 0.035
COM1 | 0.057 0.053 0.059 | 0.069 0.055 0.042
MAX2 | 0.054 0.055 0.062 | 0.034 0.023 0.031
SUM2 | 0.056 0.066 0.063 | 0.004 0.000 0.000
COM2 | 0.048 0.057 0.055 | 0.019 0.007 0.016
Table 3: Sizes of one sample tests with Scenario(3) distribution | Normal | $t_{3}$
---|---|---
p | 200 400 600 | 200 400 600
n=100 MAX1 | 0.043 0.030 0.036 | 0.032 0.036 0.032
SUM1 | 0.044 0.064 0.074 | 0.065 0.062 0.044
COM1 | 0.070 0.064 0.068 | 0.070 0.064 0.049
MAX2 | 0.069 0.066 0.083 | 0.031 0.031 0.041
SUM2 | 0.064 0.062 0.064 | 0.006 0.000 0.000
COM2 | 0.070 0.068 0.079 | 0.022 0.019 0.017
n=200 MAX1 | 0.041 0.030 0.038 | 0.035 0.033 0.046
SUM1 | 0.074 0.065 0.068 | 0.055 0.057 0.079
COM1 | 0.074 0.068 0.072 | 0.068 0.069 0.074
MAX2 | 0.055 0.043 0.057 | 0.031 0.030 0.029
SUM2 | 0.056 0.059 0.059 | 0.009 0.003 0.001
COM2 | 0.060 0.053 0.054 | 0.017 0.018 0.015
Figure 1: POWER curves of MAX1,SUM1,COM1,MAX2,SUM2,COM2 as the number of
nonzero component $m$ increases under three scenarios with two distribution in
one sample test. A, B, C for $t_{3}$ distribution under scenario (1), scenario
(2), scrnario (3), respectively. D, E, F for normal distribution under
scenario (1), scenario (2), scrnario (3), respectively.

###  3.2 Two sample test

In this part we present the numerical results of two sample test. Similar to
the setting in one sample test, we generate $n$ samples
$\\{\bm{x}_{1},...,\bm{x}_{n}\\}$ with mean vector
$\bm{\mu}_{1}=(\mu_{11},...,\mu_{1p})$, $n$ samples
$\\{\bm{y}_{1},...,\bm{y}_{n}\\}$ with mean vector
$\bm{\mu}_{2}=(\mu_{21},...,\mu_{2p})$ with the same covariance matrix
$\mathbf{\Sigma}$ as $\bm{x}_{i}$. We consider data from two distributions:
multivariate normal distribution and multivariate $t$ distribution $t_{3}$. We
generate data with dimension $p=200,400,600$ and sample sizes $n=100,200$ .
Here we only present the results of scenario (2) to avoid tautology, i.e.
$\mathbf{\Sigma}=(0.3^{|i-j|})_{1\leq i,j\leq p}$. The performance of each
test under the other two structure of covariance matrix are similar. So we
omit it here.

We display the performance of empirical sizes of each test in Table 4. The
simulated results indicate that MAX1, SUM1, COM1, MAX2, SUM2, COM2 perform
pretty well under both multivariate normal distribution. However, for the
multivariate $t_{3}$-distribution, the sizes of the mean-based test
procedures–MAX2,SUM2,COM2 are lower than the nominal level. While, our
proposed test procedures MAX2 and COM2 can control the empirical sizes in all
cases, which show the robustness of our methods.

For the two sample test, we let
$\bm{\mu}_{1}=(0,0,0...,\sqrt{0.5/m},...,\sqrt{0.5/m})$ and set
$\bm{\mu}_{2}=0$, where $m$ denotes the number of nonzero components . Here we
only present the simulation results of scenario (2) with multivariate normal
distribution and $t_{3}$ distribution. Figure 2 displays the POWER curves of
the above methods as the number of nonzero component $m$ increases under
scenario (2). It can be seen that under normal conditions, the difference
between COM1 and COM2 is not significant, while for the multivariate
$t_{3}$-distribution, COM1 outperforms COM2 significantly. Hence we conclude
that COM1 maintains the robustness from COM2 proposed by Feng et al. (2022)
and outperforms COM2 substantially.

Table 4: Sizes of two sample tests with Scenario (2) distribution | Normal | $t_{3}$
---|---|---
$p$ | 200 400 600 | 200 400 600
$n=100$ MAX1 | 0.032 0.033 0.045 | 0.037 0.037 0.021
SUM1 | 0.063 0.450 0.055 | 0.061 0.063 0.048
COM1 | 0.069 0.050 0.063 | 0.049 0.054 0.042
MAX2 | 0.050 0.055 0.071 | 0.028 0.042 0.024
SUM2 | 0.059 0.046 0.056 | 0.001 0.000 0.000
COM2 | 0.044 0.051 0.072 | 0.013 0.023 0.010
$n=200$ MAX1 | 0.049 0.035 0.050 | 0.038 0.034 0.050
SUM1 | 0.062 0.058 0.071 | 0.060 0.060 0.069
COM1 | 0.076 0.053 0.067 | 0.054 0.048 0.074
MAX2 | 0.060 0.053 0.065 | 0.028 0.030 0.038
SUM2 | 0.054 0.048 0.056 | 0.001 0.001 0.001
COM2 | 0.057 0.052 0.055 | 0.010 0.012 0.014
Figure 2: POWER curves of MAX1,SUM1,COM1,MAX2,SUM2,COM2 as the number of
nonzero component $m$ increases under scenario (2) with two distributions in
two sample test. A for $t_{3}$ distribution, B for normal distribution.

##  4 Conclusion

In this study, we introduce a rank-based testing method that exhibits
robustness to both signal sparsity and heavy-tailed distributions. Our
theoretical findings and simulation experiments collectively highlight the
advantages of the methods we propose. Moreover, He et al. (2021) suggested a
set of U-statistics as an unbiased estimator for the $L_{q}$-norms of the mean
in high-dimensional mean testing problems, demonstrating that U-statistics of
varying finite orders are asymptotically independent and normally distributed.
The question of how to develop a rank-based U-statistic family for high-
dimensional mean testing problems is intriguing and warrants further
exploration.

## Appendix

We present the detailed proof of Theorem 2.1 (ii), (iii) and Theorem 2.2,
where Theorem 2.1 (ii) adopts a similar method to Chen and Feng (2022). And
the proof of Theorem 2.3 (ii), (iii) and Theorem 2.4 can be derived similarly.

### Appendix A: Proof of Theorem 2.1

#### Proof of Theorem 2.1 (ii)

Define $z=(2\log p-\log\log p+y)^{\frac{1}{2}}$. Under the null cases, we can
rewrite the expression in 2.2 as:

$U=\sum_{i=1}^{n}R_{i}I(X_{i}>0)=\sum_{j=1}^{n}jW_{j}$

here $W_{j}=I(|X_{j}|\ corresponds\ to\ some\ positive\ X_{j^{\prime}})$. Then
by the above representation of $U$ and Hajek-Sidak’s CLT, we have

$P(|V_{i}|>z)=2\\{1-\Phi(z)\\}(1+o(1))\sim\frac{1}{\sqrt{\pi}}\frac{e^{-\frac{y}{2}}}{p}.$

Thus,

$p(\mathop{\max}_{i\in C_{p}}|V_{i}|>z)\leq|C_{p}|P(|V_{i}|>z)\rightarrow 0.$

Set $D_{p}=\\{1\leq i\leq p;|B_{p,i}|\leq p^{\zeta}\\}$. By assumption,
$|D_{p}|/p\rightarrow 1\ as\ p\rightarrow\infty.$ Since

$P(\mathop{\max}_{i\in D_{p}}|V_{i}|>z)\leq P(\mathop{\max}_{1\leq i\leq
p}|V_{i}|>z)\leq P(\mathop{\max}_{i\in D_{p}}|V_{i}|>z)+P(\mathop{\max}_{i\in
C_{p}}|V_{i}|>z),$

it’s enough to show

$\mathop{\lim}_{p\rightarrow\infty}P(\mathop{\max}_{i\in
D_{p}}|V_{i}|>z)=1-\exp(-\pi^{-\frac{1}{2}}\exp\\{-y/2\\}).$

Here define:

$\alpha_{t}=\sum^{*}P(|V_{i1}|>z,...,|V_{it}|>z).$

for $1\leq t\leq p$, where the sum runs over all $i_{1}\leq...\leq i_{t}$, and
$i_{1},...,i_{t}\in D_{p}$. First we prove

$\mathop{\lim}_{p\rightarrow\infty}\alpha_{t}=\frac{1}{t!}\pi^{-\frac{t}{2}}e^{-\frac{ty}{2}}$
(4.1)

for each $t\geq 1$.

By the representation of $V_{i}$, for $1\leq j\leq n$, $W_{j}$ is bounded by a
constant when $n$ is sufficiently large. Thus we can apply the Theorem1.1 in
Zaitsev (1987) and get the following inequalities:

$\displaystyle\sum^{*}P(|Z_{i1}|>z+\epsilon_{n}/\log
p,...,|Z_{it}|>z+\epsilon_{n}/\log p)-(\begin{array}[]{c}|D_{p}|\\\
p\end{array})c_{1}t^{5/2}\exp(\frac{-n^{1/2}\epsilon_{n}}{c_{2}t^{3}(\log
p)})$ $\displaystyle\leq\sum^{*}P(|V_{i1}|>z,...,|V_{it}|>z)$
$\displaystyle\leq\sum^{*}P(|Z_{i1}|>z+\epsilon_{n}/\log
p,...,|Z_{it}|>z+\epsilon_{n}/\log p)+(\begin{array}[]{c}|D_{p}|\\\
p\end{array})c_{1}t^{5/2}\exp(\frac{-n^{1/2}\epsilon_{n}}{c_{2}t^{3}(\log
p)})$

Here $(Z_{i1},...,Z_{it})$ has the same covariance matrix with
$(V_{i1},...,V_{it})$ and follows normal distribution with zero mean. By the
proof of Theorem 2 in Feng et al. (2022a), we have

$\displaystyle\sum^{*}P(|Z_{i1}|>z+\epsilon_{n}/\log
p,...,|Z_{it}|>z+\epsilon_{n}/\log
p)\rightarrow\frac{1}{t!}\pi^{-\frac{t}{2}}e^{-\frac{ty}{2}}$
$\displaystyle\sum^{*}P(|Z_{i1}|>z-\epsilon_{n}/\log
p,...,|Z_{it}|>z-\epsilon_{n}/\log
p)\rightarrow\frac{1}{t!}\pi^{-\frac{t}{2}}e^{-\frac{ty}{2}}$

with $\epsilon_{n}\rightarrow 0$ and $p\rightarrow\infty$. While we have:

$(\begin{array}[]{c}|D_{p}|\\\
t\end{array})c_{1}t^{5/2}\exp(\frac{-n^{1/2}\epsilon_{n}}{c_{2}t^{3}(\log
p)^{1/2}})\leq C(\begin{array}[]{c}p\\\
t\end{array})t^{5/2}\exp(\frac{-n^{1/2}\epsilon_{n}}{c_{2}t^{3}(\log
p)^{1/2}})$

for $\epsilon_{n}\rightarrow 0$ slowly enough . Hence we get (4.1) proved.

Then by Bonferroni inequality,

$\sum_{t=1}^{2k}(-1)^{t-1}\alpha_{t}\leq P(\mathop{\max}_{i\in
D_{p}}|V_{i}|>z)\leq\sum_{t=1}^{2k+1}(-1)^{t-1}\alpha_{t}.$ (4.2)

Let $k\rightarrow\infty$ and $p\rightarrow\infty$ , using the Taylor expansion
making the proof completed.

#### Proof of Theorem 2.1 (iii)

When assumption 2.3 holds, all the conditions required for Theorem 1.1 in
Hsing (1995) are met. Thus the asymptotic independence between the
$T_{max}^{(1)}$ and $T_{sum}^{(1)}$ is derived.

### Appendix B: Proof of Theorem 2.2

Hettmansperger (1984) presented the moment properties of $U_{i}$ under local
alternatives in Theorem 2.5.1:

$\displaystyle E_{H_{1}}(U_{i})$
$\displaystyle=\frac{n(n-1)p_{2i}}{2}+np_{1i}$ $\displaystyle
Var_{H_{1}}(U_{i})$
$\displaystyle=np_{1i}(1-p_{1i})+\frac{n(n-1)p_{2i}(1-p_{2i})}{2}+2n(n-1)(p_{3i}-p_{1i}p_{2i})+n(n-1)(n-2)(p_{4i}-p_{2i}^{2}),$

where

$\displaystyle p_{1i}=F_{i}(\mu_{i}),\ p_{2i}=\int
F_{i}(2\mu_{i}+x)f_{i}(x)dx,p_{3i}=(p_{1i}^{2}+p_{2i})/2,p_{4i}=\int\\{F_{i}(2\mu_{i}+x)\\}^{2}f_{i}(x)dx,$

and $F_{i}(x),f_{i}(x)$ are the marginal c.d.f and p.d.f of $i-$th component
of $\bm{X}$. Thus, if $\mu_{i}=C\sqrt{\log p/n}$, we have
$E_{H_{1}}(U_{i})=\frac{n(n+1)}{4}+n(n-1)\mu_{i}\int
f^{2}_{i}(x)dx+o(n^{2}\mu_{i})$ and
$Var_{H_{1}}(U_{i})=Var_{H_{0}}(U_{i})(1+o(1))$.

Taking the same procedure as the proof of Theorem 2.1(ii), we have

$\displaystyle P\left(\max_{1\leq i\leq
p}\left(\frac{U_{i}-E_{H_{1}}(U_{i})}{\sqrt{Var_{H_{1}}(U_{i})}}\right)^{2}-(2\log
p-\log\log p)\leq x\right)\to G(x)$

Hence we have:

$\displaystyle P\left(\max_{1\leq i\leq
p}\left(\frac{U_{i}-E_{H_{1}}(U_{i})}{\sqrt{Var_{H_{1}}(U_{i})}}\right)^{2}\leq(2\log
p-1/2\log\log p)\right)\to 1,$

when taking $x=1/2\log\log p$. By the triangle inequality, we have:

$\displaystyle\max_{1\leq i\leq
p}\left(\frac{U_{i}-E_{H_{0}}(U_{i})}{\sqrt{Var_{H_{0}}(U_{i})}}\right)^{2}\geq$
$\displaystyle\max_{1\leq i\leq
p}\left(\frac{E_{H_{0}}(U_{i})-E_{H_{1}}(U_{i})}{\sqrt{Var_{H_{0}}(U_{i})}}\right)^{2}-\max_{1\leq
i\leq
p}\left(\frac{U_{i}-E_{H_{1}}(U_{i})}{\sqrt{Var_{H_{0}}(U_{i})}}\right)^{2}$
$\displaystyle\geq$ $\displaystyle\max_{1\leq i\leq
p}\left(\frac{n(n-1)\mu_{i}\int
f_{i}^{2}(x)dx+o(n^{2}\mu_{i})}{\sqrt{Var_{H_{0}}(U_{i})}}\right)^{2}-(2\log
p-1/2\log\log p),$

with probability approaching 1. Hence $T_{max}^{(1)}$ is consistent provided
$\max_{1\leq i\leq p}\mu_{i}\gtrsim\sqrt{\log p/n}$.

### Appendix C: Proof of Theorem 2.3

The proof of Theorem2.2 (ii) can be similarly derived as for Theorem2.1 (ii)
with the asymptotic normality of $U_{i}^{xy}$ and thus the details are omitted
here. The proof of Theorem2.2 (ii) can be similarly derived as for Theorem 2.2
(ii).

### Appendix D: Proof of Theorem 2.4

Hettmansperger (1984) presented the moment properties of $\nu_{i}$ under local
alternatives in Theorem 3.5.1:

$\displaystyle E_{H_{1}}(\nu_{i})=mnp_{1}$ $\displaystyle
Var_{H_{1}}(\nu_{i})=mn(p_{1}-p_{1}^{2})+mn(n-1)(p_{2}-p_{1}^{2})+mn(m-1)(p_{3}-p_{1}^{2}),$
$\displaystyle where\ \ \ \ \ \qquad\qquad
p_{1}=\int(1-F(x-\mu_{2}))f(x-\mu_{1})dx,\qquad\qquad\qquad\qquad,$
$\displaystyle p_{2}=\int\\{1-F(x-\mu_{2})\\}^{2}f(x-\mu_{1})dx,$
$\displaystyle p_{3}=\int F(x-\mu_{1})^{2}f(x-\mu_{2})dx.$ (4.3)

With the similar discussion in the proof of Theorem 2.2, $T_{max}^{(2)}$ is
consistent provided that $\max_{1\leq i\leq
p}(\mu_{1i}-\mu_{2i})\gtrsim\sqrt{(m+n)\log p/mn}$.

## References

  * (1)
  * Bai and Saranadasa (1996) Bai, Z. and Saranadasa, H. (1996), ‘Effect of high dimension: by an example of a two sample problem’, Statistica Sinica pp. 311–329.
  * Cai et al. (2014) Cai, T., Liu, W. and Xia, Y. (2014), ‘Two-sample test of high dimensional means under dependence’, Journal of the Royal Statistical Society Series B: Statistical Methodology 76(2), 349–372.
  * Chen and Feng (2022) Chen, D. and Feng, L. (2022), ‘Rank based tests for high dimensional white noise’, arXiv preprint arXiv:2204.08402 .
  * Chen et al. (2019) Chen, S. X., Li, J. and Zhong, P.-S. (2019), ‘Two-sample and anova tests for high dimensional means’, The Annals of Statistics 47(3), 1443–1474.
  * Chen and Qin (2010) Chen, S. X. and Qin, Y.-L. (2010), ‘A two-sample test for high-dimensional data with applications to gene-set testing’.
  * Cheung (2009) Cheung, D. (2009), ‘Students’ attitudes toward chemistry lessons: The interaction effect between grade level and gender’, Research in Science Education 39, 75–91.
  * Fan et al. (2015) Fan, J., Liao, Y. and Yao, J. (2015), ‘Power enhancement in high-dimensional cross-sectional tests’, Econometrica 83(4), 1497–1541.
  * Feng et al. (2022) Feng, L., Jiang, T., Li, X. and Liu, B. (2022), ‘Asymptotic independence of the sum and maximum of dependent random variables with applications to high-dimensional tests’, arXiv preprint arXiv:2205.01638 .
  * Feng et al. (2016) Feng, L., Zou, C. and Wang, Z. (2016), ‘Multivariate-sign-based high-dimensional tests for the two-sample location problem’, Journal of the American Statistical Association 111(514), 721–735.
  * Feng et al. (2015) Feng, L., Zou, C., Wang, Z. and Zhu, L. (2015), ‘Two-sample behrens-fisher problem for high-dimensional data’, Statistica Sinica pp. 1297–1312.
  * Gregory et al. (2015) Gregory, K. B., Carroll, R. J., Baladandayuthapani, V. and Lahiri, S. N. (2015), ‘A two-sample test for equality of means in high dimension’, Journal of the American Statistical Association 110(510), 837–849.
  * He et al. (2021) He, Y., Xu, G., Wu, C. and Pan, W. (2021), ‘Asymptotically independent u-statistics in high-dimensional testing’, The Annals of Statistics 49(1), 154–181.
  * Hettmansperger (1984) Hettmansperger, T. P. (1984), Statistical inference based on ranks, John Wiley & Sons.
  * Hsing (1995) Hsing, T. (1995), ‘A note on the asymptotic independence of the sum and maximum of strongly mixing stationary random variables’, The Annals of Probability pp. 938–947.
  * Liu and Xie (2019) Liu, Y. and Xie, J. (2019), ‘Cauchy combination test: a powerful test with analytic p-value calculation under arbitrary dependency structures’, Journal of the American Statistical Association .
  * Long et al. (2023) Long, M., Li, Z., Zhang, W. and Li, Q. (2023), ‘The cauchy combination test under arbitrary dependence structures’, The American Statistician 77(2), 134–142.
https://doi.org/10.1080/00031305.2022.2116109

  * Miller (1991) Miller, J. N. (1991), ‘Basic statistical methods for analytical chemistry. part 2. calibration and regression methods. a review’, Analyst 116(1), 3–14.
  * Newbold et al. (2013) Newbold, P., Carlson, W. L. and Thorne, B. M. (2013), Statistics for business and economics, Pearson.
  * Ouyang et al. (2022) Ouyang, Y., Liu, J., Tong, T. and Xu, W. (2022), ‘A rank-based high-dimensional test for equality of mean vectors’, Computational Statistics & Data Analysis 173, 107495.
  * Park and Ayyala (2013) Park, J. and Ayyala, D. N. (2013), ‘A test for the mean vector in large dimension and small samples’, Journal of Statistical Planning and Inference 143(5), 929–943.
  * Srivastava and Du (2008) Srivastava, M. S. and Du, M. (2008), ‘A test for the mean vector with fewer observations than the dimension’, Journal of Multivariate Analysis 99(3), 386–402.
  * Wang et al. (2015) Wang, L., Peng, B. and Li, R. (2015), ‘A high-dimensional nonparametric multivariate test for mean vector’, Journal of the American Statistical Association 110(512), 1658–1669.
  * Xu et al. (2016) Xu, G., Lin, L., Wei, P. and Pan, W. (2016), ‘An adaptive two-sample test for high-dimensional means’, Biometrika 103(3), 609–624.


# Time Lag Aware Sequential Recommendation

Lihua Chen  School of Computer ScienceSichuan University, China
<EMAIL_ADDRESS>,  Ning Yang  School of Computer ScienceSichuan University,
China<EMAIL_ADDRESS>and  Philip S. Yu  Department of Computer
ScienceUniversity of Illinois at Chicago, USA<EMAIL_ADDRESS>
(2022)

###### Abstract.

Although a variety of methods have been proposed for sequential
recommendation, it is still far from being well solved partly due to two
challenges. First, the existing methods often lack the simultaneous
consideration of the global stability and local fluctuation of user
preference, which might degrade the learning of a user’s current preference.
Second, the existing methods often use a scalar based weighting schema to fuse
the long-term and short-term preferences, which is too coarse to learn an
expressive embedding of current preference. To address the two challenges, we
propose a novel model called Time Lag aware Sequential Recommendation
(TLSRec), which integrates a hierarchical modeling of user preference and a
time lag sensitive fine-grained fusion of the long-term and short-term
preferences. TLSRec employs a hierarchical self-attention network to learn
users’ preference at both global and local time scales, and a neural time gate
to adaptively regulate the contributions of the long-term and short-term
preferences for the learning of a user’s current preference at the aspect
level and based on the lag between the current time and the time of the last
behavior of a user. The extensive experiments conducted on real datasets
verify the effectiveness of TLSRec.

Sequential Recommendation, Hierarchical Self-Attention, Time Lag Aware

††copyright: acmcopyright††journalyear: 2022††conference: CIKM ’22;
978-1-4503-XXXX-X/18/06††isbn: ;††ccs: Information systems Recommender systems

##  1\. Introduction

In recent years, sequential recommendation, also known as session-based or
sequence-aware recommendation, has been attracting increasing interest of
researchers (Quadrana2018; Fang2019). Sequential recommender systems aim to
capture the time-sensitive preference (or needs) of users by modeling the
sequential dependency between their behaviors based on their historical
interaction data (e.g., click, purchase, and check-in) that are collected
sequentially by online platforms such as e-commerce websites and location-
based networks. The information about the sequential dependency and time-
sensitive preference can be used for applications where items need to be
recommended based on a user’s previous interactions. For example, a sequential
recommender system can timely recommend AirPod to a user after she/he
purchases an iPhone.

###  1.1. Related Work

A variety of methods have been proposed for sequential recommendation. Early
works are often based on Markov chain which assumes each interaction highly
depends on its previous ones (Quadrana2018; Rendle2010; He2016;
xie2021adversarial; xia2021self). Recently, inspired by the impressive success
of deep learning techniques in the fields of natural language processing and
computer vision, lots of deep learning based models have also been proposed
for sequential recommendation and achieved the state-of-the-art performance
(Zhang2019; Fang2019). Early deep learning based methods utilize recurrent
neural networks (RNN) to characterize the dynamics of interaction sequences
(Hidasi2016; Hidasi2018; Cui2020), which however suffers from inability to
capture the long-term dependency between interactions, i.e., one interaction
likely depends not only on the recent interactions but also on early ones. To
overcome this drawback, another line of deep learning based methods employs
attention mechanism (Vaswani2017; Li2017; Ting2018; Ying2018; Sun2019;
ChenCIKM2019; Li2020; Tanjim2020; Ren2020; Wu2020; Li2021) and graph neural
network (GNN) (hsu2021retagnn; chang2021sequential; wang2020next; xia2021self)
to model sequential dependency relationships between interactions and identify
relevant items.

###  1.2. Challenges

Notwithstanding the improvements on sequential recommendation, it is still far
from being well solved partly due to the following two challenges.

  * •

Unification of Stability and Fluctuation of Preferences In sequential
recommender systems, user behaviors are often organized into sessions or
transactions and basically driven by a mix of two factors, long-term
preference and short-term preference. The long-term preference reflects a
user’s general interest which usually changes slowly and keeps relative stable
across sessions, while the short-term preference represents a user’s taste in
a session which might deviate from her/his long-term preference (Jannach2015;
Song2016; Feng2019). For example, a user usually prefers to ”classic music”,
but probably in some days she/he is particularly fond of ”rock and roll”
because of the influence of her/his friends. However, the existing methods for
sequential recommendation often treat the user preference as a flat
distribution over sessions, without distinguishing its global stability and
local fluctuation, which might degrade the learning of user preference. We
need a method which can capture the stability of long-term preference at
global time scale, as well as the fluctuation of short-term preference at
local time scale.

  * •

Fine-grained Fusion of Long-term and Short-term Preferences To make effective
sequential recommendations, it is extremely important to simultaneously
capture users’ long-term preferences across different sessions and their
short-term preferences in recent sessions, so that the current preference of
users can be learned. Recently, some sequential recommendation models have
been proposed for fusing the embeddings of long-term preference and short-term
preference with static weights as hyper-parameters (Song2016; An2019) or using
dynamic attentional coefficients produced by an attention network (Feng2019).
However, no matter whether the static weights or the dynamic attentional
coefficients they use, in the existing models a preference embedding vector is
weighted by a scalar, which implicitly assumes that different dimensions in
the same preference embedding have the same importance. We argue that such
scalar based weighting scheme is too coarse for learning an expressive fused
preference embedding, as in real world, a user’s behaviors might depend more
on some aspects than on other aspects of preference. For example, a user might
buy a science fiction book because the genre aspect of her/his long-term
preference to movie is science fiction and she/he currently likes reading. In
this example, the genre aspect should be weighted more than other aspects of
the long-term preference. Therefore, we need a more fine-grained fusing
mechanism that can adaptively capture the different contributions of different
aspects of long-term preference and short-term preference for the fusion of
them.

###  1.3. Contributions

To address the above challenges, we propose a novel model called Time Lag
aware Sequential Recommendations (TLSRec), which integrates a hierarchical
modeling of user preference and a time lag sensitive fine-grained fusion of
the long-term and short-term preferences. At first, in contrast with the
traditional sequential recommendation methods that capture the long-term
preference directly from the flat sequence of interactions without considering
the preference fluctuation between local sessions, TLSRec can simultaneously
model the global stability and local fluctuation of a user’s preference with a
hierarchical self-attention network consisting of a short-erm preference
learning layer and a long-term preference learning layer. Such unified
modeling offers TLSRec the ability to understand a user’s preference at both
local and global time scales. Particularly, in order to capture the preference
fluctuation between local sessions, TLSRec learns a session embedding for each
session to encode a user’s preference local to a session, with a self-
attention module at the short-term preference learning layer. At the same
time, in order to capture the intrinsic stable preference of a user, TLSRec
will pool the session embeddings into a long-term preference embedding with a
multi-head self-attention module at the long-term preference learning layer.
Due to the different self-attention heads, not only the long-term dependency
between sessions but also the interactions between dimensions of session
embeddings can be perceived by the long-term preference embedding to enhance
its ability to capture the stable intrinsic preference.

To overcome the challenge of fine-grained fusion of the long-term preference
and short-term preference for sequential recommendations, inspired by the idea
of the gates in long short-term memory (LSTM) (hochreiter1997long; Chen2019),
we propose a neural time gate for TLSRec to learn a fused preference embedding
aware of time lag. Compared with traditional methods which weigh the long-term
preference and short-term preference with manually defined scalars as vector-
wise weights, the proposed neural time gate has two advantages. First, it
offers TLSRec the ability to adaptively regulate the contributions of the
long-term preference and the short-term preference based on the time lag. The
idea here is that which preference accounts more for a user’s next behavior
heuristically depends on the time lag, i.e., how long has it been since
her/his last behavior. As we will see in later experiments, the neural time
gate will learn to act in accordance with the intuition that the longer
(shorter) the time lag, the more the impact of a user’s long-term (short-term)
preference on her/his next behavior. Second, in contrast with the existing
works, the neural time gate offers a fusion of the long-term preference and
short-term preference at a finer granularity level. Unlike the existing works,
the neural time gate will generate a gating vector instead of a scalar, whose
dimensions serve as dimension-wise weights to differentially weigh the
corresponding dimensions of the long-term embedding and short-term embedding.
Due to the gate based fusion of the long-term preference and short-term
preference, TLSRec can learn a more representative and comprehensive hybrid
embedding for current preference. Finally, the contributions of this paper can
be summarized as follows:

  * •

We propose a novel model called Time Lag aware Sequential Recommendations
(TLSRec), which can capture the stability and fluctuation of user preference,
and learn a fused preference embedding with a fined-grained fusion of the
long-term preference and short-term preference.

  * •

We propose a hierarchical self-attention network to unite the learning of the
long-term preference and short-term preference, which leads to a better
comprehension of the stability of user preference at global time scale as well
as the fluctuation of user preference at local time scale.

  * •

We propose a neural time gate to offer a gate based fine-grained fusion of the
long-term preference and short-term preference at the dimension level, by
which a more representative and more comprehensive fused preference embedding
can be learned.

  * •

We extensively evaluate TLSRec on real-world datasets. The experimental
results demonstrate the general improvements of TLSRec over the baselines, as
well as the effectiveness of the proposed hierarchical self-attention network
and neural time gate.

##  2\. Preliminaries

Let $\mathcal{U}$ be a set of $N$ users and $\mathcal{V}$ a set of $M$ items.
The interactions of user $u\in\mathcal{U}$ sorted chronologically is organized
as a sequence of $T$ sessions
$\mathcal{S}^{u}=\langle\mathcal{S}^{u}_{1},\mathcal{S}^{u}_{2},\cdots,\mathcal{S}^{u}_{T}\rangle$.
Each session
$\mathcal{S}^{u}_{i}=\\{v^{u}_{i,1},v^{u}_{i,2},\cdots,v^{u}_{i,|\mathcal{S}^{u}_{i}|}\\}$
is a subset of $\mathcal{V}$, where $v^{u}_{i,j}\in\mathcal{V}$ ($1\leq
j\leq|\mathcal{S}^{u}_{i}|$) is the $j$th item user $u$ interacts with in the
session $\mathcal{S}^{u}_{i}$. Let $t(v)$ be the time when the interaction
with item $v\in\mathcal{V}$ happens, and then for any
$v^{u}_{i}\in\mathcal{S}^{u}_{i}$ and any $v^{u}_{j}\in\mathcal{S}^{u}_{j}$,
$t(v^{u}_{i})<t(v^{u}_{j})$ if $i<j$.

Given a user $u\in\mathcal{U}$ and her/his historical sessions
$\mathcal{S}^{u}=\langle\mathcal{S}^{u}_{1},\mathcal{S}^{u}_{2},$
$\cdots,\mathcal{S}^{u}_{T}\rangle$, we want to recommend $k$ items that $u$
will most probably interact with in the next session $\mathcal{S}^{u}_{T+1}$.
This problem can be formulated as a ranking problem of all items for user $u$
based on the rating prediction $\hat{r}_{u,v}$ of user $u$ over item
$v\in\mathcal{V}$.

Figure 1. The architecture of TLSRec.

##  3\. Proposed Model

###  3.1. Overview of TLSRec

The architecture of TLSRec is shown in Figure 1. As we can see from Figure 1,
given as inputs the historical session sequence
$\langle\mathcal{S}^{u}_{1},\mathcal{S}^{u}_{2},\cdots,\mathcal{S}^{u}_{T}\rangle$
of a specific user $u$, the lag $\Delta t$ between the time when the
recommendation is made and the time of the last interaction of $u$, and a
candidate item $v$, TLSRec is supposed to produce the predicted rating
$\widehat{r}_{u,v}$ of $u$ on $v$.

First, TLSRec uses an $M$-dimensional one-hot vector to encode an item, and
transforms each item $v^{u}_{i,j}$ in each session $\mathcal{S}^{u}_{i}$ to
its corresponding item embedding $\bm{e}^{u}_{i,j}\in\mathbb{R}^{d}$ through
the item embedding layer, where $d$ is the dimensionality of embeddings,
$1\leq i\leq T$, and $1\leq j\leq|\mathcal{S}^{u}_{i}|$.

Then at the short-term preference learning layer, the item embeddings in a
session $\mathcal{S}^{u}_{i}$ will be aggregated into its corresponding
session embedding $\bm{s}^{u}_{i}\in\mathbb{R}^{d}$ with a self-attention
module shared across sessions. The session embedding $\bm{s}^{u}_{i}$ encodes
user $u$’s short-term preference which is local to session
$\mathcal{S}^{u}_{i}$, and the differences between them reflect the
fluctuation of user preference among short time periods. At the same time,
note that the current short-term preference embedding
$\bm{z}^{u}_{\text{short}}$ is just the same as the last session embedding
$\bm{s}^{u}_{T}$, as the current preference of a user is often revealed by the
interactions in her/his most recent session (Yu2016; Ying2018).

The task of the long-term preference learning layer is to generate the long-
term preference embedding $\bm{z}^{u}_{\text{long}}\in\mathbb{R}^{d}$ by
fusing the session embeddings with a multi-head self-attention module. As we
have mentioned before, the multiple self-attentional heads enable TLSRec to
capture the interactions between dimensions of session embeddings, which leads
to the more representative and comprehensive attentional session embeddings
$\bm{z}^{u}_{i}\in\mathbb{R}^{d}$ at the global time scale. Meanwhile, as the
same as the existing transformer-based models do (Vaswani2017; Kang2018;
Ren2020), TLSRec will incorporate the session embeddings with a learnable
position embedding $\bm{p}_{i}\in\mathbb{R}^{d}$ ($1\leq i\leq T$) before
feeding them into the multi-head self-attention module, so that the temporal
dependency between sessions can be perceived by the long-term preference
embedding. At last, the attentional session embeddings $\bm{z}^{u}_{i}$ are
fused into the long-term preference embedding $\bm{z}^{u}_{\text{long}}$ via a
vanilla attention module, by which the long-term preference can be aware of
the different contributions of different sessions.

Once the long-term preference embedding $\bm{z}^{u}_{\text{long}}$ and the
short-term preference embedding $\bm{z}^{u}_{\text{short}}$ are prepared,
TLSRec will merge them through the neural time gate to generate the final
preference embedding $\bm{z}_{u}$. For regulating the contributions of the
long-term preference and the short-term preference, the neural time gate will
generate an intermediate gate vector $\bm{g}\in\mathbb{R}^{d}$ based on the
time embedding $\bm{y}\in\mathbb{R}^{d}$ of the time lag $\Delta t$ to
adaptively weight the dimensions of $\bm{z}^{u}_{\text{long}}$ and
$\bm{z}^{u}_{\text{short}}$. At last, TLSRec will make the rating prediction
$\widehat{r}_{u,v}$ based on the inner product of the preference embedding
$\bm{z}_{u}$ and the item embedding $\bm{e}_{v}$ of the candidate item $v$.

###  3.2. Hierarchical Self-Attention Network

####  3.2.1. Item Embedding

For any item $v\in\mathcal{V}$, we obtain its embedding
$\bm{e}_{v}\in\mathbb{R}^{d}$ by a lookup over a learnable matrix
$\bm{W}^{\text{I}}\in\mathbb{R}^{d\times M}$, i.e.,
$\bm{e}_{v}=\bm{W}^{\text{I}}\bm{v}$, where $\bm{v}\in\mathbb{R}^{M}$ is a
one-hot vector representing the item $v$. For the items
$\\{v^{u}_{i,1},v^{u}_{i,2},\cdots,v^{u}_{i,m}\\}$ of session
$\mathcal{S}^{u}_{i}$ of a user $u$, we horizontally assemble their item
embeddings into an item embedding matrix
$\bm{E}_{i}=[\bm{e}^{u}_{i,j}]_{j=1}^{m}\in\mathbb{R}^{d\times m}$, where
$m=|\mathcal{S}_{i}|$ and the $j$th column $\bm{e}^{u}_{i,j}\in\mathbb{R}^{d}$
($1\leq j\leq m$) is the embedding of item $v^{u}_{i,j}$.

####  3.2.2. Short-term Preference Learning

Given a user $u\in\mathcal{U}$ and her/his historical session sequence
$\mathcal{S}^{u}=\langle\mathcal{S}^{u}_{1},\mathcal{S}^{u}_{2},\cdots,$
$\mathcal{S}^{u}_{T}\rangle$, the task of the short-term preference learning
layer is to generate the session embeddings $\bm{s}^{u}_{i}$ representing
$u$’s preference local to each session $\mathcal{S}^{u}_{i}$, $1\leq i\leq T$,
using a self-attention module. For this purpose, each item embedding
$\bm{e}^{u}_{i,j}$ in session $\mathcal{S}^{u}_{i}$ will first be transformed
to three vectors, a query vector $\bm{q}_{i,j}\in\mathbb{R}^{d}$, a key vector
$\bm{k}_{i,j}\in\mathbb{R}^{d}$, and a value vector
$\bm{v}_{i,j}\in\mathbb{R}^{d}$, $1\leq j\leq m$, via the following
operations:

(1)
$\bm{Q}^{\text{S}}_{i}=\bm{W}^{\text{Q}}_{\text{S}}\bm{E}_{i},\bm{K}^{\text{S}}_{i}=\bm{W}^{\text{K}}_{\text{S}}\bm{E}_{i},\bm{V}^{\text{S}}_{i}=\bm{W}^{\text{V}}_{\text{S}}\bm{E}_{i},$

where $\bm{Q}^{\text{S}}_{i}=[\bm{q}_{i,j}]_{j=1}^{m}\in\mathbb{R}^{d\times
m}$, $\bm{K}^{\text{S}}_{i}=[\bm{k}_{i,j}]_{j=1}^{m}\in\mathbb{R}^{d\times
m}$, $\bm{V}^{\text{S}}_{i}=[\bm{v}_{i,j}]_{j=1}^{m}\in\mathbb{R}^{d\times
m}$, and $\bm{W}^{\text{Q}}_{\text{S}}\in\mathbb{R}^{d\times d}$,
$\bm{W}^{\text{K}}_{\text{S}}\in\mathbb{R}^{d\times d}$,
$\bm{W}^{\text{V}}_{\text{S}}\in\mathbb{R}^{d\times d}$ are the projection
matrices that will be learned. Then we generate the attentional item
embeddings $\widehat{\bm{e}}^{u}_{i,j}$ ($1\leq j\leq m$) using the self-
attention mechanism (Vaswani2017):

(2)
$\widehat{\bm{E}}_{i}=\text{SelfAttention}(\bm{Q}^{\text{S}}_{i},\bm{K}^{\text{S}}_{i},\bm{V}^{\text{S}}_{i})=\bm{V}^{\text{S}}_{i}\widehat{\bm{A}},$

where
$\widehat{\bm{E}}_{i}=[\widehat{\bm{e}}^{u}_{i,j}]_{j=1}^{m}\in\mathbb{R}^{d\times
m}$, and
$\widehat{\bm{A}}=\text{softmax}\Big{(}\frac{({\bm{Q}^{\text{S}}_{i}})^{\text{T}}{\bm{K}^{\text{S}}_{i}}}{\sqrt{d}}\Big{)}\in\mathbb{R}^{m\times
m}$ is the self-attention matrix. The cell $\widehat{a}_{j,l}$ at the $j$th
row and $l$th column of $\widehat{\bm{A}}$ represents the attention score of
the $j$th item $v^{u}_{i,j}$ to the $l$th item $v^{u}_{i,l}$ in session
$\mathcal{S}^{u}_{i}$, and can be computed as
$\widehat{a}_{j,l}=\frac{\text{exp}(a_{j,l})}{\sum_{k=1}^{m}a_{j,k}}$, where
$a_{j,l}=\frac{{\bm{q}_{i,j}}^{\text{T}}\bm{k}_{i,l}}{\sqrt{d}}$ is the
unnormalized attention score. Finally, the session embedding $\bm{s}^{u}_{i}$
is generated by summing up over the attentional item embeddings
$\widehat{\bm{e}}^{u}_{i,j}$ ($1\leq j\leq m$):

(3) $\bm{s}^{u}_{i}=\sum_{j=1}^{m}\widehat{\bm{e}}^{u}_{i,j}.$

As we will see later, the last session embedding $\bm{s}^{u}_{T}$ will be used
as the current short-term preference embedding $\bm{z}^{u}_{\text{short}}$
since it represents a user’s current preference which might deviate from
her/his long-term preference.

####  3.2.3. Long-term Preference Learning

The task of the long-term preference learning layer is to generate the long-
term embedding $\bm{z}^{u}_{\text{long}}\in\mathbb{R}^{d}$ encoding the long-
term preference of user $u$ at the global time scale, by using a multi-head
self-attention module to fuse her/his local preferences represented by the
session embeddings $\bm{s}^{u}_{i}\in\mathbb{R}^{d}$ ($1\leq i\leq T$) which
are outputs of the session embedding layer. As self-attention mechanism is not
aware of the temporal positions of inputs, therefore to capture the temporal
dependency between session embeddings, we first enhance each session embedding
$\bm{s}^{u}_{i}$ by injecting a learnable position embedding
$\bm{p}_{i}\in\mathbb{R}^{d}$ as follow:

(4) $\widehat{\bm{S}}=\bm{S}+\bm{P},$

where
$\widehat{\bm{S}}=[\widehat{\bm{s}}^{u}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times
T}$ is the enhanced session embedding matrix,
$\bm{S}=[\bm{s}^{u}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times T}$ is the original
session embedding matrix, $\bm{P}=[\bm{p}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times
T}$ is the position embedding matrix, and
$\widehat{\bm{s}}^{u}_{i}=\bm{s}^{u}_{i}+\bm{p}_{i}$.

Now we are going to generate the attentional session embedding matrix
$\bm{Z}=[\bm{z}^{u}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times T}$, where each
column $\bm{z}^{u}_{i}\in\mathbb{R}^{d}$ is the attentional session embedding
corresponding to $\widehat{\bm{s}}^{u}_{i}$. We first define the basic multi-
head self-attention function for matrix
$\widehat{\bm{S}}=[\widehat{\bm{s}}^{u}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times
T}$ as

(5)
$\text{MultiHeadSelfAttention}(\widehat{\bm{S}})=\bm{W}^{\text{O}}\text{Concat}(\bm{H}_{1};\cdots;\bm{H}_{h}),$

where $\text{Concat}(\bm{H}_{1};\cdots;\bm{H}_{h})\in\mathbb{R}^{d\times T}$
represents the vertical concatenation of the $h$ heads
$\bm{H}_{j}\in\mathbb{R}^{\frac{d}{h}\times T}$ ($1\leq j\leq h$), and
$\bm{W}^{\text{O}}\in\mathbb{R}^{d\times d}$ is a learnable projection matrix.
Similar to Equation (1), in order to generate each header $\bm{H}_{j}$, we
build the query vector, the key vector, and the value vector for each enhanced
session embedding via the following transformations:

(6)
$\bm{Q}^{\text{H}}_{j}=\bm{W}^{\text{Q}}_{j}\widehat{\bm{S}},\bm{K}^{\text{H}}_{j}=\bm{W}^{\text{K}}_{j}\widehat{\bm{S}},\bm{V}^{\text{H}}_{j}=\bm{W}^{\text{V}}_{j}\widehat{\bm{S}}.$

Then as same as Equation (2), each attention head $\bm{H}_{j}$ is obtained by
the self-attention mechanism:

(7)
$\begin{split}\bm{H}_{j}&=\text{SelfAttention}(\bm{Q}^{\text{H}}_{j},\bm{K}^{\text{H}}_{j},\bm{V}^{\text{H}}_{j})\\\
&=\bm{V}^{\text{H}}_{j}\text{softmax}\Big{(}\frac{(\bm{Q}^{\text{H}}_{j})^{\text{T}}\bm{K}^{\text{H}}_{j}}{\sqrt{d/h}}\Big{)},\end{split}$

where $h$ is the number of heads and $\bm{W}^{\text{Q}}_{j}$,
$\bm{W}^{\text{K}}_{j}$,
$\bm{W}^{\text{V}}_{j}\in\mathbb{R}^{\frac{d}{h}\times d}$ are the learnable
transformation matrices. Note that due to the sequential nature, it is
supposed that the $i$th attentional session embedding $\bm{z}_{i}$ depends
only on previous $i-1$ sessions. Therefore, we will mask the connection
between $\bm{q}_{i}$ and $\bm{k}_{j}$ if $i<j$, by substituting zero for
$\bm{q}_{i}^{\text{T}}\bm{k}_{j}$, where $\bm{q}_{i}$ and $\bm{k}_{j}$ are the
$i$th column of $\bm{Q}$ (the query vector of $\bm{z}^{u}_{i}$) and the $j$th
column of $\bm{K}$ (the key vector of $\bm{z}^{u}_{j}$), respectively.

As the transformer-based models do (Vaswani2017), to stabilize and accelerate
the training of the multi-head self-attention network, we add a residual
connection followed via a normalization:

(8)
$\text{Norm}\Big{(}\text{MultiHeadAttention}(\widehat{\bm{S}})+\widehat{\bm{S}}\Big{)}.$

For a matrix $\bm{X}=[\bm{x}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times T}$, the
normalization function is defined as

(9)
$\text{Norm}(\bm{X})=[\text{norm}(\bm{x}_{i})]_{i=1}^{T},\text{norm}(\bm{x})=\bm{\alpha}\otimes\frac{\bm{x}-\mu}{\sqrt{\sigma^{2}+\epsilon}}+\bm{\beta},$

where $\bm{\alpha}\in\mathbb{R}^{d}$ and $\bm{\beta}\in\mathbb{R}^{d}$ are
learnable scaling factors and bias terms, $\otimes$ represents element-wise
product, $\mu$ and $\sigma^{2}$ are the mean and variance of $\bm{x}$,
respectively, and $\epsilon$ is a positive constant in case the illegal
division incurred by zero variance.

To capture non-linear interactions between the latent dimensions, we further
apply a feed-forward network FFN to the output of Equation (8). Then the final
attentional session embedding matrix can be obtained by:

(10)
$\bm{Z}=\text{FFN}\Bigg{(}\text{Norm}\Big{(}\text{MultiHeadAttention}(\widehat{\bm{S}})+\widehat{\bm{S}}\Big{)}\Bigg{)},$

where the feed-forward network is defined as

(11)
$\begin{split}\text{FFN}(\bm{X}&=[\bm{x}_{i}]_{i=1}^{T}\in\mathbb{R}^{d\times
T})=[\text{ffn}(\bm{x}_{i})]_{i=1}^{T},\\\
\text{ffn}(\bm{x}\in\mathbb{R}^{d})&=\bm{W}^{\text{F}}_{2}\max(0,\bm{W}^{\text{F}}_{1}\bm{x}+\bm{b}_{1})+\bm{b}_{2},\end{split}$

where $\bm{W}^{\text{F}}_{1}\in\mathbb{R}^{4d\times d}$,
$\bm{W}^{\text{F}}_{2}\in\mathbb{R}^{d\times 4d}$,
$\bm{b}_{1}\in\mathbb{R}^{4d}$, and $\bm{b}_{2}\in\mathbb{R}^{d}$ are the
learnable transformation matrices and bias terms. Note that Equation (10)
constitutes a multi-head self-attention block, and in practice we can stack
more than one multi-head self-attention block (i.e., iteratively apply
Equation (10)) to enhance the expressiveness of the attentional session
embeddings.

Once the attentional session embeddings $\bm{z}^{u}_{i}$ are obtained through
Equation (10), we can finally generate the long-term preference embedding
$\bm{z}^{u}_{\text{long}}$ via a vanilla attention module:

(12)
$\bm{z}^{u}_{\text{long}}=\sum_{i=1}^{T}\omega_{i}\bm{z}^{u}_{i},\omega_{i}=\frac{\exp\Big{(}\bm{f}^{\text{T}}_{u}\phi(\bm{W}_{\text{L}}\bm{z}^{u}_{i}+\bm{b}_{\text{L}})\Big{)}}{\sum_{i=1}^{T}\exp\Big{(}\bm{f}^{\text{T}}_{u}\phi(\bm{W}_{\text{L}}\bm{z}^{u}_{i}+\bm{b}_{\text{L}})\Big{)}},$

where $\omega_{i}$ is the attentional coefficient of $\bm{z}^{u}_{i}$, $\phi$
is the ReLU activation function, $\bm{W}_{\text{L}}\in\mathbb{R}^{d\times d}$
and $\bm{b}_{\text{L}}\in\mathbb{R}^{d}$ are the learned transformation matrix
and bias terms, respectively, and $\bm{f}_{u}\in\mathbb{R}^{d}$ is the
embedding of user $u$. Similar to item embedding, $\bm{f}_{u}$ is also
obtained by a lookup over a learnable user embedding matrix
$\bm{W}^{\text{U}}\in\mathbb{R}^{d\times N}$:
$\bm{f}_{u}=\bm{W}^{\text{U}}\bm{u}$, where $\bm{u}\in\mathbb{R}^{N}$ is the
one-hot encoding of user $u$.

###  3.3. Neural Time Gate

Now the long-term preference embedding $\bm{z}^{u}_{\text{long}}$ and the
short-term preference embedding $\bm{z}^{u}_{\text{short}}$ have been prepared
by the hierarchical self-attention network. Next we will produce the final
preference embedding used for rating prediction, by fusing
$\bm{z}^{u}_{\text{long}}$ and $\bm{z}^{u}_{\text{short}}$ via the proposed
neural time gate.

The task of the neural time gate is to adjust the contributions of the long-
term preference embedding and the current short-term preference embedding at
dimension level, based on the lag $\Delta t$ between the time of last
interaction and the time when a recommendation needs to be made. To encode the
time lag into an intermediate embedding, we first discretize it by its
multiples of the minimum time gap $\Delta_{\text{min}}$ bewteen any two
successive interactions of a give user. In this idea, the discretized time lag
$\delta\in\mathbb{N}$ is computed as

(13) $\delta=\min(\lceil\frac{\Delta t}{\Delta_{\text{min}}}\rceil,C),$

where $C\in\mathbb{N}$ represents the maximal value of $\delta$. By Equation
(13), the $\Delta t$ is mapped to a positive number not more than $C$. Then we
can get the time embedding $\bm{y}\in\mathbb{R}^{d}$ by a lookup over a
learnable embedding matrix $\bm{Y}\in\mathbb{R}^{d\times C}$ as follow:

(14) $\bm{y}=\bm{Y}\bm{\delta},$

where $\bm{\delta}\in\mathbb{R}^{C}$ is the one-hot vector of the discretized
time lag. Then the normalized gating vector $\bm{g}\in\mathbb{R}^{d}$ can be
computed by the Sigmoid function

(15)
$\bm{g}=\text{sigmoid}(\bm{W}_{l}\bm{z}^{u}_{\text{long}}+\bm{W}_{s}\bm{z}^{u}_{\text{short}}+\bm{W}_{\delta}\bm{y}+\bm{b}_{g}),$

where $\bm{W}_{l}$, $\bm{W}_{s}$, $\bm{W}_{\delta}\in\mathbb{R}^{d\times d}$
and $\bm{b}_{g}\in\mathbb{R}^{d}$ are the learnable weight matrices and bias
vector, respectively. Finally, the fused preference embedding of the given
user $u$ is obtained by the following fusion based on $\bm{g}$:

(16)
$\bm{z}_{u}=\bm{g}\otimes\bm{z}^{u}_{\text{short}}+(\bm{1}-\bm{g})\otimes\bm{z}^{u}_{\text{long}},$

where $\otimes$ represents element-wise product. Note that $\bm{g}$ is a
vector rather than a scalar, which enables the neural time gate to regulate
the contributions of the long-term preference and short-term preference at the
dimension granularity.

###  3.4. Rating Prediction

Finally, we adopt a dot product of the fused preference embedding $\bm{z}_{u}$
and the item embedding $\bm{e}_{v}$ as the prediction of the normalized rating
that user $u$ gives to item $v$, i.e.,

(17) $\widehat{r}_{u,v}=\text{sigmoid}(\bm{z}^{\text{T}}_{u}\bm{e}_{v}).$

###  3.5. Model Learning

####  3.5.1. Training Set Building

We first build a training set $\mathcal{O}^{u}$ for each user $u$, where each
instance $o\in\mathcal{O}^{u}$ is a sequence of $T+1$ sessions, i.e
$o=\langle\mathcal{S}^{u}_{1},\cdots,\mathcal{S}^{u}_{T},\mathcal{S}^{u}_{T+1}\rangle$.
During the training, the first $T$ sessions
$\mathcal{S}^{u}_{1},\cdots,\mathcal{S}^{u}_{T}$ are used as input of the
model, while the last session $\mathcal{S}^{u}_{T+1}$ serves as ground truth
for the supervision of the training. For a training data set, a user’s
sessions are divided whenever the time interval between two successive
interactions is more than a chosen threshold.

Since the length of different session sequences might be different, for a
sequence with length greater than $T$, we use a sliding window of width $T$ to
split it into subsequences of the fixed length $T+1$, while for a sequence
with length less than or equal to $T$, we use the first session to pad to the
left to the sequence until its length becomes $T+1$. Similarly, the length of
a session (i.e. the number of items contained in a session) might also be
different from each other. For a session whose length is less than the length
of the longest session, we will repeatedly pad that session with its last item
until its length becomes $m$, where $m=\max_{u\in\mathcal{U},1\leq i\leq
T}(|\mathcal{S}^{u}_{i}|)$.

####  3.5.2. Model Optimization

As our goal is to recommend a ranked list of items, we are more interested in
the relative ranking order of the rating predictions rather than their
absolute values. For a training instance
$o=\langle\mathcal{S}_{1},\cdots,\mathcal{S}_{T},$ $\mathcal{S}_{T+1}\rangle$,
let $\mathcal{V}_{o}^{+}=\mathcal{S}_{T+1}$ be the ground truth. For each item
$v\in\mathcal{V}_{o}^{+}$, we sample an unobserved item
$v^{\prime}\notin\mathcal{V}_{o}^{+}$ to form a negative sample set
$\mathcal{V}_{o}^{-}$. We expect the predicted rating of an item
$v\in\mathcal{V}_{o}^{+}$ will be greater than that of an item
$v^{\prime}\in\mathcal{V}_{o}^{-}$, i.e.,
$\widehat{r}_{u,v}>\widehat{r}_{u,v^{\prime}}$. For this purpose, we define a
pair-wise loss function based on the principle of Bayesian Personalized
Ranking (BPR) (Rendle2009):

(18)
$L(\bm{\Theta})=-\sum_{u\in\mathcal{U}}\sum_{o\in\mathcal{O}^{u}}\sum_{v\in\mathcal{V}_{o}^{+},v^{\prime}\in\mathcal{V}_{o}^{-}}\log\sigma(\widehat{r}_{u,v}-\widehat{r}_{u,v^{\prime}})+\lambda\parallel\bm{\Theta}\parallel_{2}^{2},$

where $\Theta$ represents all the learnable parameters and $\lambda$ is a
nonnegative parameter controlling the contribution of the regularization term.
In the experiments, we will apply Adam algorithm (Diederik2015) to optimize
our model.

Table 1. The statistics of datasets Dataset |  #Users |  #Items |  #Interactions |  Avg. #sessions per user |  Avg. length per session |  Density
---|---|---|---|---|---|---
Amazon Book |  4,621 |  170,474 |  517,556 |  12 |  9 |  0.0006
Amazon Video |  1,709 |  12,434 |  64,298 |  8 |  5 |  0.0030
Movielens-1M |  5,492 |  3,692 |  970,346 |  29 |  6 |  0.0478
Lastfm |  953 |  22,372 |  16,641,736 |  950 |  18 |  0.7805

##  4\. Experiments

###  4.1. Experimental Setting

####  4.1.1. Datasets

We conduct the experiments on four real-world datasets whose statistics are
summarized in Table 1. In this paper, we only consider implicit feedbacks
(e.g. clicks), and hence explicit feedbacks (e.g. ratings) in datasets are
simply regarded as implicit interactions. As has mentioned before, in order to
split an interaction sequence into sessions, on each dataset we will
investigate the distribution of the time gaps between any two successive
interactions, and choose as the threshold the time gap that accounts for the
most part of the distribution. On each dataset, we randomly select 70%of the
data as training set, 10% as validation set, and the remaining 20% as testing
set, and repeat such procedure 10 times and report the average results.

  * •

Amazon Book Amazon Book is a dataset collected from Amazon, which contains
517,556 ratings to 170,474 books given by 4,621 users. By investigating the
distribution of the time gaps between any two successive interactions, we find
that most time gaps are less than 2 days. Therefore, in Amazon Book, we split
a historical interaction sequence into sessions whenever the time interval
between two successive interactions is more than 2 days.

  * •

Amazon Video Amazon Video is another dataset collected from Amazon, which
contains 64,298 ratings to 12,434 videos given by 1,709 users. In Amazon
Video, the sessions are extracted using the same time gap threshold as in
Amazon Book.

  * •

MovieLens-1M MovieLens-1M is a user-movie dataset collected from MovieLens
website, which contains 970,346 ratings to 3,692 movies given by 5,492 users.
For MovieLens-1M, the time gap threshold is set to 2 hours with the same
method as for the Amazon datasets.

  * •

Lastfm Lastfm is a freely-available collection of audio features and metadata
for a million contemporary popular music tracks (Bertin-Mahieux2011),
consisting of tuples of user, timestamp, artist, and song listened to. As
Lastfm contains an overwhelming amount of songs, which causes an expensive
requirement of huge amount of memory, we treat the artists instead of the
songs as items, with the same approach as taken by (Ruocco2017), and we obtain
16,641,736 interactions of 953 users with 22,372 artists. Finally, we split an
interaction sequence into sessions for Lastfm using the same time gap
threshold as for MovieLens-1M.

####  4.1.2. Baseline Methods

We compare TLSRec with ten state-of-the-art methods for sequential
recommendation, including two RNN based models (DREAM and II-RNN), six
attention based models (NARM, ANAM, SHAN, SASRec, BERT4Rec, and TiSASRec), and
two GNN based models (SURGE and RetaGNN).

  * •

DREAM (Yu2016) DREAM is an RNN based model for next basket recommendation,
which not only learns a dynamic representation for a user but also captures
global sequential features among baskets (sessions) to gain a comprehensive
understanding of users’ purchase interests and consequently recommend items
that each user most probably purchase in the next visit.

  * •

II-RNN (Ruocco2017) II-RNN is a hierarchical RNN model for sequential
recommendation, which not only models a user’s short-term preference by an
intra-session RNN layer, but introduces an inter-session RNN layer to capture
the dependency between sessions as well.

  * •

NARM (Li2017) NARM is an attention based model for session-based
recommendation, which uses a hybrid encoder with an attention mechanism to
model the user’s sequential behavior and capture users’ intent in the current
session.

  * •

ANAM (Ting2018) ANAM is an attribute-aware model for next basket (session)
recommendation, which adopts an attention mechanism to explicitly model user’s
evolving preference for items, and utilizes a hierarchical architecture to
incorporate the attribute information of items.

  * •

SHAN (Ying2018) SHAN is a sequential recommendation model based on a two-layer
hierarchical attention network, where the first attention layer learns user
long-term preferences based on the historical purchased items, while the
second one generates user’s final representation by fusing the user’s long-
term preference and short-term preference.

  * •

SASRec (Kang2018) SASRec uses a self-attention mechanism combined with
position embeddings to capture the semantics of user’s long-term preference,
which can identify relevant items by adaptively assigning weights to previous
items at each time step.

  * •

BERT4Rec (Sun2019) BERT4Rec employs a deep bidirectional self-attention
mechanism to model user behavior sequences, with the optimization objective to
predicting the random masked items in the sequence by jointly conditioning on
their left and right context.

  * •

TiSASRec (Li2020): TiSASRec is a time interval aware model for sequential
recommendation, which incorporates the information of the relative time
interval between any two items into a self-attention mechanism to weight the
different items during the learning of user preference.

  * •

SURGE (chang2021sequential): SURGE is a GNN-based model which integrates
implicit feedbacks with explicit ones in long-term user behaviors into
clusters in the graph by re-constructing loose item sequences into tight item-
item interest graphs based on metric learning.

  * •

DHCN (xia2021self): DHCN models session-based data as a hypergraph and
captures the high-order relations among items and the cross-session
information with a dual channel hypergraph convolutional network.

####  4.1.3. Evaluation Metrics

We choose the widely used Hit rate and MAP (Mean Absolute Precision) to
evaluate the performance of TLSRec. Let $\mathcal{S}_{u}$ and
$\widehat{\mathcal{S}}_{u}$ be the ground truth session and the set of the
predicted top-$k$ ranked items, and then the Hit rate and MAP can be defined
as follows:

(19)
$\text{Hit}@k=\frac{1}{|\mathcal{U}|}\sum_{u\in\mathcal{U}}\mathbb{I}\big{(}|\mathcal{S}_{u}\cap\widehat{\mathcal{S}}_{u}|>0\big{)},$

(20)
$\text{MAP}@k=\frac{1}{|\mathcal{U}|}\bigg{(}\sum_{u\in\mathcal{U}}\sum_{i\in\mathcal{S}_{u}\cap\widehat{\mathcal{S}}_{u}}\frac{\sum_{j\in\mathcal{S}_{u}\cap\widehat{\mathcal{S}}_{u}}\mathbb{I}(\gamma_{uj}<\gamma_{ui})+1}{\gamma_{ui}}\bigg{)},$

where $|\widehat{\mathcal{S}}_{u}|=k$, $\mathbb{I}(x)=1$ if $x$ is true,
otherwise $\mathbb{I}(x)=0$, and $\gamma_{ui}$ is the predicted rank of item
$i$ for user $u$.

####  4.1.4. Hyper-parameter Setting

To divide interactions into sessions, we set the time gap threshold $\epsilon$
to $48$ hours for Amazon Book and Amazon Video, and $2$ hours for MovieLens-1M
and Lastfm. To build the training and testing instances, we set the number $T$
of sessions in an instance to $10$, $8$, $6$, and $4$ for Amazon Book, Amazon
Video, Movielens-1M, and Lastfm, respectively. The embedding dimensionality
$d$ is set to $64$ for Amazon Book, Movielens-1M, and Lastfm, and $32$ for
Amazon Video. At last, the number of heads in multi-head self-attention
network in long-term preference learning layer is set to $8$ for all datasets.
On all datasets, the learning rate, batch size, and the dropout rate are set
to 0.001, 128, and 0.5, respectively. At the same time, the optimal hyper-
parameters of baselines are fine-tuned on validation sets.

###  4.2. Performance Comparison with Baselines

Table 2. Hit$@k$ comparison with baselines Methods | Amazon Book | Amazon Video | Movielens-1M | Lastfm
---|---|---|---|---
| $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$
DREAM | 0.0440 | 0.0609 | 0.0553 | 0.0644 | 0.3837 | 0.4713 | 0.7323 | 0.7861
II-RNN | 0.0668 | 0.0907 | 0.0821 | 0.0966 | 0.4902 | 0.5854 | 0.6311 | 0.6864
NARM | 0.0634 | 0.0838 | 0.0339 | 0.0449 | 0.4208 | 0.5066 | 0.7097 | 0.7585
ANAM | 0.0651 | 0.0971 | 0.0819 | 0.1019 | 0.3381 | 0.4123 | 0.7287 | 0.7991
SHAN | 0.0480 | 0.0632 | 0.0627 | 0.0899 | 0.3337 | 0.4237 | 0.5556 | 0.6100
SASRec | 0.1209 | 0.1663 | 0.1884 | 0.2458 | 0.4476 | 0.5413 | 0.8065 | 0.8260
BERT4Rec | 0.0902 | 0.1335 | 0.1744 | 0.2167 | 0.3917 | 0.4922 | 0.6515 | 0.7748
TiSASRec | 0.1842 | 0.2356 | 0.2133 | 0.2680 | 0.5025 | 0.5850 | 0.7630 | 0.8253
SURGE | 0.2219 | 0.3103 | 0.1961 | 0.2048 | 0.5077 | 0.5110 | 0.7915 | 0.8060
DHCN | 0.1991 | 0.2736 | 0.2308 | 0.2780 | 0.5301 | 0.5922 | 0.7551 | 0.8180
TLSRec | 0.3438 | 0.4161 | 0.2423 | 0.2884 | 0.5640 | 0.6522 | 0.8086 | 0.8439
Table 3. MAP$@k$ comparison with baselines Methods | Amazon Book | Amazon Video | Movielens-1M | Lastfm
---|---|---|---|---
| $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$
DREAM | 0.0020 | 0.0021 | 0.0027 | 0.0028 | 0.0214 | 0.0230 | 0.0661 | 0.0769
II-RNN | 0.0025 | 0.0035 | 0.0031 | 0.0038 | 0.0271 | 0.0311 | 0.0899 | 0.0928
NARM | 0.0031 | 0.0033 | 0.0023 | 0.0028 | 0.0185 | 0.0214 | 0.0731 | 0.0784
ANAM | 0.0021 | 0.0031 | 0.0038 | 0.0047 | 0.0184 | 0.0214 | 0.0674 | 0.0713
SHAN | 0.0018 | 0.0019 | 0.0061 | 0.0066 | 0.0188 | 0.0214 | 0.0690 | 0.0700
SASRec | 0.0055 | 0.0062 | 0.0145 | 0.0163 | 0.0352 | 0.0436 | 0.0892 | 0.0966
BERT4Rec | 0.0033 | 0.0047 | 0.0092 | 0.0166 | 0.0279 | 0.0402 | 0.0755 | 0.0834
TiSASRec | 0.0062 | 0.0073 | 0.0155 | 0.0172 | 0.0372 | 0.0437 | 0.0981 | 0.1046
SURGE | 0.0091 | 0.0104 | 0.0096 | 0.0138 | 0.0366 | 0.0411 | 0.0905 | 0.1006
DHCN | 0.0075 | 0.0776 | 0.0082 | 0.0170 | 0.0233 | 0.0392 | 0.0808 | 0.0984
TLSRec | 0.0130 | 0.0144 | 0.0167 | 0.0175 | 0.0381 | 0.0438 | 0.1044 | 0.1097

The results of the comparison with baseline methods are shown in Tables 2 and
3. It can be seen that TLSRec outperforms the two RNN based models, DREAM, and
II-RNN, in terms of Hit$@k$ and MAP$@k$. The RNN based models often suffer
from the problem of long-term dependency, which causes they prefer to memorize
the preference more reflected by recent sessions than by distant sessions. As
the recent sessions dominate the learning of user preference, the RNN based
models are more susceptible to the fluctuates of users’ short-term preference
and cannot sufficiently capture the long-term preference that is more stable.
In contrast to the RNN based models, TLSRec learns an embedding for long-term
preference by pooling local preference embeddings of sessions with a
hierarchical self-attention network, which enables TLSRec to perceive the
long-term dependency between sessions and smooth out the preference
fluctuates, and consequently better understand the stable long-term preference
of a user.

We also observe that TLSRec outperforms the six attention based models.
Essentially, NARM, ANAM, SASRec, and TiSASRec only learn the short-term
preference of a user by fusing the embeddings of the recent interactions with
an attention network, which lack the knowledge about the user’s long-term
preference and consequently tend to be hindered by the fluctuates of the
user’s preference. In contrast, TLSRec can learn not only the short-term
preference but the long-term preference as well, particularly with a
hierarchical self-attention network which makes it able to capture the
dependency between sessions. Although SHAN and BERT4Rec consider both long-
term preference and short-term preference, however it learns the current
preference by fusing them with scalar coefficients produced by an attention
mechanism, which makes it unable to weight the contributions of the two
preferences at a finer granularity level like TLSRec does.

It can be also observed that GNN based models are inferior to TLSRec. Although
the GNN based models can capture the high-order interactions between items
among sessions, they often essentially focus on the learning of the current
session without differentiating the impacts of the long-term and short-term
preferences

Unlike the baseline methods, TLSRec uses a gate vector produced by a neural
time gate based on the time distance to fuse the long-term preference and
short-term preference embeddings, which benefits the learning of the current
preference from two perspectives. First, the contributions of the long-term
preference and short-term preference are reasonably regulated by the distance
to current time, and the shorter it is, the more proportion the short-term
preference accounts for. Second, the dimensions of the gate vector play the
role weighting the dimensions of the preference embeddings during their
fusion, which offers a finer-grained fusion.

###  4.3. Ablation Experiments

Now we investigate the effectiveness of the hierarchical self-attention
network, the neural time gate, and the multi-head self-attention mechanism in
the long-term preference learning. For this purpose, we will compare TLSRec
with its variants as follows:

  * •

TLSRec-S Compared with TLSRec, TLSRec-S removes the self-attention network
before the average pooling function for the generation of session embeddings
in short-term preference learning layer.

  * •

TLSRec-L Symmetrically, TLSRec-L removes self-attention network before the
vanilla attention network for the generation of the long-term preference
embedding.

  * •

TLSRec-M Compared with TLSRec, TLSRec-M replaces the multi-head self-attention
network with a single-head self-attention network in the long-term preference
learning layer.

  * •

TLSRec-G+A TLSRec-G+A is a variant of TLSRec where the neural time gate is
replaced with a pooling function which generates the current preference
embedding $\bm{z}_{u}$ by averaging the long-term preference embedding and the
short-term preference embedding.

  * •

TLSRec-G+S TLSRec-G+S is a variant of TLSRec where the neural time gate is
replaced with a self-attention mechanism. TLSRec-G+S first generates the
attentional long-term embedding and short-term embedding with attention to
each other, and then generates the current preference embedding $\bm{z}_{u}$
with the sum of them.

  * •

TLSRec-G+M TLSRec-G+M is a variant of TLSRec where the neural time gate is
replaced with a multi-head attention mechanism. TLSRec-G+M generates the
current preference embedding similarly to TLSRec-G+S, with the exception of
using the multi-head attention to generate the attentional long-term and
short-term embeddings. In TLSRec-G+M, the number of attention heads is set to
the same value in TLSRec.

Table 4. Hit$@k$ comparison with the variants Methods | Amazon Book | Amazon Video | Movielens-1M | Lastfm
---|---|---|---|---
| $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$
TLSRec-S | 0.2741 | 0.3530 | 0.1567 | 0.2073 | 0.5111 | 0.6057 | 0.7604 | 0.8064
TLSRec-L | 0.3034 | 0.3692 | 0.1789 | 0.2221 | 0.5466 | 0.6319 | 0.7679 | 0.8160
TLSRec-M | 0.3039 | 0.3736 | 0.1875 | 0.2344 | 0.5611 | 0.6495 | 0.8060 | 0.8435
TLSRec-G+A | 0.2989 | 0.3677 | 0.1702 | 0.2134 | 0.5317 | 0.6263 | 0.8053 | 0.8427
TLSRec-G+S | 0.3070 | 0.3712 | 0.1770 | 0.2315 | 0.5534 | 0.6476 | 0.8035 | 0.8427
TLSRec-G+M | 0.3213 | 0.3894 | 0.1965 | 0.2448 | 0.5634 | 0.6514 | 0.8065 | 0.8436
TLSRec | 0.3438 | 0.4161 | 0.2423 | 0.2884 | 0.5640 | 0.6522 | 0.8086 | 0.8439
Table 5. MAP$@k$ comparison with the variants Methods | Amazon Book | Amazon Video | Movielens-1M | Lastfm
---|---|---|---|---
| $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$ | $k=20$ | $k=30$
TLSRec-S | 0.0077 | 0.0087 | 0.0119 | 0.0127 | 0.0245 | 0.0300 | 0.0928 | 0.0975
TLSRec-L | 0.0113 | 0.0130 | 0.0130 | 0.0139 | 0.0367 | 0.0421 | 0.0822 | 0.0866
TLSRec-M | 0.0117 | 0.0131 | 0.0159 | 0.0169 | 0.0372 | 0.0428 | 0.0962 | 0.1018
TLSRec-G+A | 0.0110 | 0.0121 | 0.0149 | 0.0157 | 0.0360 | 0.0416 | 0.1016 | 0.1078
TLSRec-G+S | 0.0110 | 0.0121 | 0.0159 | 0.0166 | 0.0362 | 0.0418 | 0.1016 | 0.1077
TLSRec-G+M | 0.0119 | 0.0133 | 0.0163 | 0.0171 | 0.0376 | 0.0430 | 0.1028 | 0.1094
TLSRec | 0.0130 | 0.0144 | 0.0167 | 0.0175 | 0.0381 | 0.0438 | 0.1044 | 0.1097

The results are shown in Tables 4 and 5. We can see that compared with TLSRec,
the performance of each variant significantly declines, which verifies the
effectiveness of different components of TLSRec. Particularly, the comparison
between TLSRec, TLSRec-S and TLSRec-L shows the performance gain incurred by
the proposed hierarchical self-attention network, which verifies its ability
to better capture the dependency between items for the short-term preference
learning and the dependency between sessions for the long-term preference
learning. At the same time, we can also note that TLSRec performs much better
than TLSRec-M, which is due to the ability of the multiple attention heads to
enhance the long-term preference learning by perceiving the finer-grained
interactions between dimensions of session preference embeddings. At last, we
see that compared with TLSRec-G+A, TLSRec-G+S and TLSRec-G+M, the performance
of TLSRec is remarkably improved because of the advantages of the proposed
neural time gate. First, the results demonstrate the effectiveness of using
the time lag aware gate vector to adaptively regulate the contributions of the
long-term preference and short-term preference for the learning of the current
preference. Second, the results also show that the fine-grained fusion of the
long-term and short-term embeddings with dimension-wise weights offered by the
neural time gate is superior to the coarse fusion with manually predefined
vector-wise weights.

###  4.4. Case Study

(a) User ID ’237’ (b) User ID ’1492’

Figure 2. Visualization of the self-attention coefficients between sessions.

(a) User ID ’237’ (b) User ID ’1492’

Figure 3. Visualization of the time gate vectors.

Now we further illustrate TLSRec’s ability to capture the interactions between
sessions and its ability to regulate the contributions of long-term preference
and short-term preference. For this purpose, we randomly sample two users with
IDs ’237’ and ’1492’ from Movielens-1M and visualize their self-attention
coefficients between sessions and their gate vectors over different time lags
in Figures 2 and 3, respectively.

In Figures 2(a) and 2(b), one cell $(S_{i},S_{j})$ at the row $S_{i}$ and
column $S_{j}$ ($i\leq j$) represents the attention given by $S_{i}$ to
$S_{j}$ that is generated by Equation (5), and the darker the color, the
greater the attention. From Figure 2 we can see that there does exist
influence between sessions, and to reveal the real preference for a session,
TLSRec assigns different attention weights to its previous sessions, by which
even the influence of early sessions can be captured.

In Figures 3(a) and 3(b), a row of the matrices is a time gate vectors
corresponding to a specific time lag, along with the average over its
dimensions that is shown as the corresponding component in the average column.
At first, we can see that the colors of the dimensions of the same time gate
vector are different from each other, and again the darker the color, the
larger the value. This observation shows that by the time gate vector TLSRec
can evaluate the contributions of the short-term preference and long-term
preference at the fine-grained dimension granularity for the learning of the
current preference, since the $i$th dimension $\bm{g}(i)$ of the time gate
vector and $1-\bm{g}(i)$ are the weights of the $i$th dimension of the short-
term preference embedding and the long-term preference embedding,
respectively, during the fusion in Equation (16). From Figures 3(a) and 3(b),
we can also note that the average weight over the dimensions of a time gate
vector decays with the increase of the time lag. This result confirms our
intuition that the longer the distance between the time of the last behavior
and the time when a recommendation is made, the less the impact of the short-
term preference of a user on her/his current preference.

##  5\. Conclusion

In this paper, we propose a novel model called Time Lag aware Sequential
Recommendation (TLSRec). To capture the global stability and local fluctuation
of a user’s preference, TLSRec is able to model a user’s long-term preference
and short-term preference with a hierarchical self-attention network.
Meanwhile, due to the neural time gate, TLSRec can fulfill a fusion of the
long-term and short-term preferences with a time lag sensitive regulation at
the aspect level for the learning of a user’s current preference. At last, the
extensive experiments conducted on real datasets demonstrate the effectiveness
of TLSRec.

###### Acknowledgements.

This work is supported by National Natural Science Foundation of China under
grant 61972270, and NSF under grants III-1763325, III-1909323, III-2106758,
and SaTC-1930941.