CTU logo
NIE-PML · CTU FIT

Deep Learning Methods

Personalised Machine Learning

Matrix Factorization

itemsusers
$X$
$\approx$
$\times$
$\approx$
$U$
$\times$
$V^{\top}$
$X_{ij}$
$\approx$
$\mathbf u_i^{\top}$
$\times$
$\mathbf v_j$
$\mathcal L_{\mathrm{Exp}}=\underset{\colorbox{#fde4e7}{\scriptsize$i,j\in\Omega$}}{\sum}\left(X_{ij}-\mathbf u_i^{\top}\mathbf v_j\right)^2$
$\mathcal L_{\mathrm{Imp}_1}=\underset{\colorbox{#dcf1df}{\scriptsize$i,j$}}{\sum}c_{ij}\left(X_{ij}-\mathbf u_i^{\top}\mathbf v_j\right)^2$
$\mathcal L_{\mathrm{Imp}_2}=-\underset{\colorbox{#dcf1df}{\scriptsize$i,j$}}{\sum}\Bigl[X_{ij}\log\sigma(\mathbf u_i^{\top}\mathbf v_j)+(1-X_{ij})\log\bigl(1-\sigma(\mathbf u_i^{\top}\mathbf v_j)\bigr)\Bigr]$

CF as a Supervised Learning Problem

itemsusers
$X$
Matrix factorization is supervised learning
The recorded entries of $X$ are $N$ interaction points: the data of a supervised problem.
Supervised learning data
Inputs: raw data instances $\mathbf{x}_1, \mathbf{x}_2, \ldots, \mathbf{x}_N$, where $\mathbf{x}_l \in \mathbb{R}^p$.
Labels: annotations $y_1, y_2, \ldots, y_N$, where $y_l \in \mathbb{R}$.
What are the $\mathbf{x}_l$ and the $y_l$ in CF-based matrix factorization?

CF as a Supervised Learning Problem

itemsusers
$X$
MODEL
$i$
$j$
$\text{input }\mathbf{x}_l=(i,j)$
$\text{output }\hat y_l$
Loss
$y_l=X_{ij}$

CF as a Supervised Learning Problem

itemsusers
$X$
Inputs and labels
Each observed point $\mathbf{x}_l$ is a pair (user, item), and its label is the entry it points to: $y_l = X_{\mathbf{x}_l}$.
  • explicit feedback: $y_l \in \{1, 2, 3, 4, 5\}$
  • implicit feedback: $y_l \in \{0, 1\}$
Matrix factorization, rewritten
$$\sum_{(i,j)\in\Omega}\bigl(X_{ij}-\mathbf u_i^{\top}\mathbf v_j\bigr)^2\;=\;\sum_{(i,j)\in\Omega}\bigl(X_{ij}-g(i,j)\bigr)^2$$ So far $g(i,j)$ is a dot product of two table rows (no regularization shown).
Go deep
Replace $g(i,j)$ with a deep architecture: a deep CF problem.

Generalized Matrix Factorization (GMF)

itemsusers
$X$
$i$
$j$
$U$
$V$
$\mathbf u_i$
$\mathbf v_j$
$\mathbf u_i\odot\mathbf v_j$
NN LayersOutput LayerLoss
$[1,1,\cdots,1]$
Deep learning generalizes shallow models
Many deep learning methods can generalize their shallow equivalents. How could we do it? Similarly, a deep matrix factorization method can generalize shallow matrix factorization.

Concatenation + MLP

itemsusers
$X$
$i$
$j$
$U$
$V$
$\mathbf u_i$
$\mathbf v_j$
Concatenation
$[\mathbf u_i;\mathbf v_j]$
NN LayersOutput LayerLoss

NCF

itemsusers
$X$
$i$
$j$
$U^{G}$
$V^{G}$
$U^{M}$
$V^{M}$
$u^{G}_i$
$v^{G}_j$
$u^{M}_i$
$v^{M}_j$
$u^{G}_i\odot v^{G}_j$
$[u^{M}_i;v^{M}_j]$
NN Layers
ConcatenationOutput LayerLoss
Scalability
What if the number of entries in X is large? The network scores one (user, item) pair at a time, so ranking all items for one user needs one pass per item.

Negative Sampling

itemsusers
$X$
Positives
Each observed entry is a positive example: $y_l = 1$.
Negatives
Almost all other entries are unobserved. For each positive, we sample a few unobserved entries and label them $y_l = 0$.
Loss over the sampled set
$$-\sum_{l\in\Omega^*}\Bigl[y_l\log\hat y_l+(1-y_l)\log(1-\hat y_l)\Bigr]$$ $\Omega^*$: the observed entries plus the sampled ones.
Careful
A sampled zero is a training choice, not evidence of dislike.

Wide & Deep: the Deep Part

itemsusers
$X$
useritemcontext
$x_l$
ConcatenationNN LayersOutput LayerLoss

Wide & Deep: the Wide Part

itemsusers
$X$
useritemcontext
$x_l$
Deepcross: user × itemlinearWide+Output LayerLoss

Two Towers

itemsusers
$X$
useritem
$x_l$
user towerNN layers
$u_i$
item towerNN layers
$v_j$
·dot productOutput LayerLoss

Two Towers: Serving

computed in advanceitemitem towerNN layers
$\text{item vectors}$
storedat request timeuseruser towerNN layers
$u_i$
dot productwith all item vectorsbest items

GNNs

itemsusers
$X$
usersitemsusersitems?Feedback

GNN: Prediction and Loss

itemsusers
$X$
usersitemsGNNpredictionLoss
$-\log\hat y\ \ (y=1)$
usersitemsGNNpredictionLoss
$-\log(1-\hat y)\ \ (y=0)$

Sequential-based Recommendation

A Annais browsing…
T-shirt Shorts Sunglasses Backpack Observed Interactions ? Bottle Recommended Item

Convolutional Sequential Models

sequence of itemsnext item
$\text{user}_i$
$U$
$V$
item vectorsfilter outputs
$u_i$
ConcatenationNN layersScoresnext itemLoss

Gated Recurrent Unit Models

sequence of itemsnext item
$V$
$h_0$
initial state
INITIAL STATE• zeros (typical in recommenders)• a learned vector• a user or context vectorGRU
$h_1$
GRU
$h_2$
GRU
$h_3$
GRUthe same weights in every cell
$h_4$
NN layers
Scoresnext itemLoss

Gates

items so farprevious state
$h_{t-1}$
$v_t$
new item and its embeddingproposed state
$\tilde h_t$
gate
$z_t$
keepreplacemixkeep
new state
$h_t$
next cell
UPDATE
$h_t=(1-z_t)\odot h_{t-1}+z_t\odot\tilde h_t$
• z near 0: keep the previous value• z near 1: replace it by the proposed one• in between: a mix of the two(one gate value per coordinate)

Attention-Based Models

sequence of itemsnext item
$V$
++++positionitemqueryembeddingW_QkeyW_KLEARNED MATRICES
$W_Q$
$W_K$
the same for every item
CAUSAL ATTENTIONLower-triangular matrix:an item sees only itselfand the items before it(next-item prediction)1.00.30.70.20.30.50.10.20.30.4softmax of each row:weights add up to 1

Attention-Based Models: Prediction

sequence of itemsnext item
$V$
SELF-ATTENTIONeach position: weighted sum of the valuesof the earlier items, weights from the matrixFEED-FORWARDthe same small network for every positionrepeatedin severalblocksoutputScoresdot product with every itemnext itemLoss

Multimodal Recommender Systems

$j$
item
$i$
userItem picture
$j$
Pre-trainedCV modelmodelembeddingiItem text
$j$
Pre-trainedNLP model
★★★★★★★☆Reviews
$j$
$i$
Pre-trainedNLP model
User side information
$i$
MLP
$j$
Item idEmbeddinglayer
$i$
User idEmbeddinglayer
ML model
$\hat X_{ij}$
predictedrating

Personalised Search

SEARCHI would like to buya new cheap smartphonesearch queryRECOMMENDATION
$i$
userpreferences and history
NLP-basedsearch retrievalmodelRecommenderretrievalmodelsearch scorerecommendation scoreCombiningmodelfinal score

Foundational Models

item textinteractionsbooksmoviesother domainsSentenceTransformerpre-trained LLMfine-tuneditem embeddingsLossthe embeddings should explainwho interacts with whatfine-tune the Transformer with the interactionsAFTER TRAININGnew itemno interactions yetSentenceTransformerrecommend by the similarityof the embeddingscold start,new domains andnew tasks

Behavioural Analysis of Personalisation

ONE USERuserTitanicCasablancaAlien★★★★★★★★★★★★★★★TitanicCasablancaAlien★★★★★★★★★★★★★★★similar: this user gave5 stars to bothdifferent:1 star
MANY USERSevery user gives many triplets
The task
Input: a triplet of items rated by the same user, which is the context.
Output: which of the three items was rated differently from the other two.
Only triplets are used: no user ids and no item features.
Goal: representations of the items and of the context that explain these choices.

Behavioural Analysis of Personalisation

tripletselected itemitem embeddingsEUCLIDEAN DISTANCEoriginal embeddingsPermutational layerand feed-forward networkthe order of thethree items doesnot matter
$\rho$
context vector
distanceLossthe farthest item is the prediction

Behavioural Analysis of Personalisation

Goldeneye0.00.20.40.60.81.0050010001500No EscapeAustin Powers: International Man of MysteryIndependence Day (ID4)Mortal KombatAce Ventura: When Nature CallsGrease 2Girl in the Cadillac
$\gamma_S(a,b)$
ranking of the other items b
Casablanca0.00.20.40.60.81.0050010001500Taxi DriverThe GodfatherMary PoppinsDirty DancingJumanjiMr. Magoo
$\gamma_S(a,b)$
ranking of the other items b
How similar is every other item?
$\gamma_S(a,b)$: the probability that $a$ and $b$ are the most similar pair of a triplet whose third item is drawn at random.

Deep Learning: Positive and Negative Points

Positive points
✓Rich inputs: text, images, sequences and graphs enter the model through learned representations.
✓Non-linear interactions: MLPs and attention can capture patterns that a dot product cannot.
✓One framework: interactions, side information and context are handled in the same model, which helps cold start.
✓Transfer: pre-trained components can be reused across domains and tasks.
Negative points
✕Cost: more computation and memory, and scoring every candidate with a network can be too slow; two towers keep retrieval fast.
✕Strong baselines: a well-tuned matrix factorisation is often hard to beat.
✕Tuning and reproducibility: many hyperparameters, and results depend on the evaluation protocol.
✕Opacity: it is harder to explain a recommendation, and large models need a lot of data.
CTU logo
NIE-PML · CTU FIT

Obrigado!

Questions?