How Session-Based Models Work
SESSION AS A SEQUENCE
A session is a sequence of user actions: page views, clicks, searches, add-to-cart events. Session-based models treat this sequence like a sentence and predict what comes next. If the last 5 actions were viewing laptop, laptop case, laptop stand, mouse, keyboard, the model predicts accessories or peripherals. The key insight is that recent actions reveal current intent better than lifetime purchase history.
ARCHITECTURE PATTERNS
Common architectures use recurrent neural networks or transformers to encode the action sequence. Each action becomes a vector (embedding), and the model processes these vectors in order to produce a session embedding representing current intent. This session embedding is compared against item embeddings to rank candidates. Inference happens on every new action, adding 10 to 30ms latency per request.
FEATURE ENGINEERING
Beyond the action sequence, models incorporate context features: time since last action (users who pause 5 minutes might be comparing prices), action type weights (purchases signal stronger than views), recency decay (actions 2 minutes ago matter more than 20 minutes ago), and category patterns (3 electronics views in a row versus scattered browsing).
COMBINING WITH HISTORICAL PROFILES
Production systems blend session signals with long term preferences. A typical approach weights them: score = 0.6 × session_score + 0.4 × historical_score. Early in a session (few actions), historical dominates. As session grows, session signal takes over.