Chapter 15

Beyond Collaborative Filtering

Collaborative filtering asks: given who you are and what you've rated, what else would you like? The real world asks harder questions — what if you're a first-time visitor, or your taste depends on whether it's Saturday night, or the order of your clicks matters more than which ones? This closing chapter maps four families beyond the URM: context-aware (tensor factorisation), session-based, knowledge-based, and sequence-aware (RNN/Transformer).

Reading: ~48 min 0 Source: Polimi Recommender Systems 2024/25 — Beyond Collaborative Filtering
key

The big idea

The URM is only the beginning. Real recommenders must handle context (the user’s situation changes relevance), sessions (anonymous users with a handful of recent clicks), domain knowledge (rules about what goes with what), and sequences (the order of interactions encodes intent). Each extension changes the data representation: matrix → tensor (context), profile → short sequence (session), ratings → knowledge graph (knowledge-based), set → ordered stream (sequence-aware). The core insight: the model is secondary; the data representation is primary.

01 · Situation matters

Context-Aware Recommender Systems

The relevance of a recommendation changes with circumstances: device, location, activity, company.

A context-aware recommendation takes the context of the interaction into account. Context is side information of the event, not a property of the user or the item:

  • Device — smartphone, PC, smart TV.
  • Location — at home, at the office, at the park.
  • Activity — resting, working, exercising.
  • Company — with friends, children, a partner.

The data representation shifts from a matrix (U×IU\times I) to a tensor (U×I×CU\times I\times C), where CC is the set of context conditions — and the sparsity worsens, since each context dimension splits the data thinner. Tensor factorization generalises MF to three (or more) dimensions:

Tensor factorisation
r^uic=k=1Kxukyikzck,minX,Y,Z  RXYZ2+λ(X2+Y2+Z2).\hat r_{uic} = \sum_{k=1}^{K} x_{uk}\,y_{ik}\,z_{ck},\qquad \min_{X,Y,Z}\;\lVert R - X\cdot Y\cdot Z\rVert^2 + \lambda\big(\lVert X\rVert^2+\lVert Y\rVert^2+\lVert Z\rVert^2\big).

Each dimension — user, item, context — gets its own latent factor matrix, and a rating is the sum of triple products over KK factors. Context can also be handled by Factorization Machines (Ch. 12), which treat it as extra one-hot columns — unifying context-aware CF with the FM framework.

key

FM (Ch. 12) revisited

A context-aware FM extends the collaborative feature vector [U+I][U+I] with context bits [U+I+Day+Time][U+I+\text{Day}+\text{Time}]. The factorised interactions then capture user–context and item–context pairs without a full 3-D tensor — the practical bridge between Ch. 12 and this chapter.

02 · No user, just a session

Session-Based Recommender Systems

What if you don’t know who the user is? Guess their intent from a handful of recent clicks.

Session-based recommendation deals with anonymous users — no past history, no user ID. The only signal is the small set of interactions in the current session (often 5–20 clicks), and the goal is to optimise short-term preferences — items that fit the user’s immediate intent, not a long-term taste profile. If past sessions of the same user are known, the problem becomes session-aware recommendation, where long-term preferences can also be optimised by linking sessions. Either way, the core challenge is guessing intent from limited data.

key

Intent is fragile

A user who usually browses electronics suddenly looks at baby products — the session model must pivot immediately, ignoring the long-term history. This is the opposite of collaborative filtering, which assumes stable taste. Session models treat the current clicks as the only signal that matters.

03 · Rules over ratings

Knowledge-Based Recommender Systems

Explicitly encode what goes with what — no learning required, but knowledge engineering is hard.

Knowledge-based recommendation encodes explicit domain knowledge — usually as a knowledge base or graph — and may involve no learning at all: recommendations come from logical inference over the rules. It shines in three settings:

  • Conversational recommendation — chatbots that ask clarifying questions and narrow choices with rules.
  • High-stakes domains — financial or medical recommendations, where a wrong collaborative guess is unacceptable and explicit constraints must hold.
  • Cold-start items — a brand-new camera with no ratings can still be recommended if the knowledge base says it is compatible with the user’s existing gear.
!

The cost is knowledge engineering

Someone must encode the rules — “this memory card fits DSLR cameras”, “this film is a sequel to that one.” That is expensive and brittle: rules break when the domain shifts. Knowledge graphs plus graph neural networks (Ch. 13) offer a middle ground — structured knowledge as edges, learned embeddings on nodes.

04 · Order encodes intent

Sequence-Aware Recommender Systems

When the sequence of interactions carries information that the set does not.

Sequence-aware recommendation treats the order of interactions as the primary signal — the next track should match the mood of the last few; the next episode follows the one just watched; a memory card follows a new camera; the next place to visit depends on the last. The URM is no longer adequate: it treats interactions as a set, losing all order. Instead the input is a sequence of items per session and the target is the next item. Three families of approach:

  • Co-occurrence / Markov chains — simple transition probabilities: if users often buy B after A, recommend B.
  • Nearest neighbours — find past sessions similar to the current one and recommend from them.
  • Sequence learning — RNNs and attention/Transformer models that learn a hidden state summarising the sequence so far.

The RNN approach learns item embeddings xtx_t and maintains a hidden state hth_t that remembers past inputs:

RNN hidden state
ht=f ⁣(xtWx+ht1Wh+bh),yt=f ⁣(htWy).h_t = f\!\big(x_t\,W_x + h_{t-1}\,W_h + b_h\big),\qquad y_t = f\!\big(h_t\,W_y\big).

The hidden state hth_t summarises x1,,xtx_1,\dots,x_t, and the output yty_t predicts the next item xt+1x_{t+1}. Training runs step by step: given x1,,xtx_1,\dots,x_t predict xt+1x_{t+1}, then extend the session with the true xt+1x_{t+1} and predict xt+2x_{t+2}, and so on — the model learns transition patterns across sessions.

05 · Exam intel

What the exam tests

Name the four families and why the URM is insufficient for each; write the tensor-factorisation equation; distinguish session-based vs session-aware vs collaborative; explain when knowledge-based is preferred (cold-start, high-stakes); and write the RNN hidden-state equation for next-item prediction.

Q

Worked question — recommend the next song

A music service wants to recommend the next song. (a) Why is collaborative filtering insufficient? (b) Session-based or sequence-aware? (c) Write the RNN update. (d) How does training differ from MF?

  • (a) CF treats songs as a set and ignores order; the transition from one song to the next carries intent that the set does not.
  • (b) Sequence-aware — the order within a listening session matters. Session-based alone (a set of songs in the session) still misses the transition information.
  • (c) ht=f(xtWx+ht1Wh+bh)h_t = f(x_t W_x + h_{t-1} W_h + b_h), yt=f(htWy)y_t = f(h_t W_y): xtx_t is the song embedding at position tt, hth_t the hidden state summarising x1..tx_{1..t}, yty_t the predicted next song.
  • (d) MF trains on all (u,i)(u,i) pairs at once; the RNN trains step by step — feed x1x_1, predict x2x_2; feed the true x2x_2, predict x3x_3; the session is extended with ground truth at each step.

Traps: confusing session-based (anonymous, short-term) with CF (profiles, long-term — the difference is whether a user ID exists); assuming context always needs a tensor (FM handles it with extra columns); forgetting knowledge-based may involve no learning; and treating sequence-aware as “CF with timestamps” — it is the order within a session, not the timestamp of each interaction.

06 · Exam · past papers

Past-paper questions

Where this chapter is examined

No standalone past-paper question targets Chapter 15 directly. Its most exam-relevant idea — context-aware recommendation — is examined as sub-questions inside the Factorization Machines chapter (Ch. 12), where context appears as extra one-hot feature columns. To rehearse this material, revisit the FM exam cards, or open the AI tutor and ask it to quiz you on this chapter.

07 · Self-check

Three questions before you move on

How does tensor factorisation for context-aware recommendation differ from matrix factorisation (Ch. 8)?

A 'session-based' recommender differs from collaborative filtering primarily because:

The RNN hidden-state equation h_t = f(x_t W_x + h_{t-1} W_h + b_h) for sequence-aware recommendation encodes:

08 · Recap

One-screen summary

Chapter 15 — four families to remember

  1. Context-aware: URM → tensor U×I×CU\times I\times C. Tensor factorisation r^uic=kxukyikzck\hat r_{uic}=\sum_k x_{uk}y_{ik}z_{ck}, or FM with extra context columns (Ch. 12).
  2. Session-based: anonymous users, only the current session. Guess short-term intent from limited data; session-aware if past sessions are known.
  3. Knowledge-based: explicit domain rules, often no learning. Good for cold-start, conversational, and high-stakes domains. Cost: knowledge engineering.
  4. Sequence-aware: order matters. RNN ht=f(xtWx+ht1Wh+bh)h_t = f(x_t W_x + h_{t-1}W_h + b_h) predicts the next item xt+1x_{t+1}, trained step by step over sessions.