PinnerFormer: Sequence Modeling for User Representation at Pinterest

Nikil Pancha, Andrew Zhai, Jure Leskovec, Charles Rosenberg

Abstract

PinnerFormer is a sequence modeling framework designed to generate high-quality user embeddings at Pinterest by predicting long-term future actions rather than just the immediate next action. By utilizing a novel dense all-action loss and a Transformer-based architecture, Pinterest transitioned from complex real-time infrastructure to a stable daily batch-offline system. This shift resulted in significant user engagement increases, including a 7.5% lift in Repins and a 6% increase in Close-ups.

Introduction

Personalized recommendation systems often face a critical trade-off between model accuracy and infrastructure complexity. Traditional state-of-the-art sequential models typically focus on predicting a user's next action in real-time. However, deploying such models for hundreds of millions of users presents significant challenges. "Stateless" models require expensive re-computation of embeddings after every interaction, while "stateful" models necessitate complex streaming infrastructure prone to data corruption and difficult recovery.

Pinterest's previous solution, PinnerSage, utilized multiple embeddings to capture diverse user interests. While effective for retrieval, managing 20+ embeddings per user created storage and latency bottlenecks for downstream ranking models. PinnerFormer addresses these issues by producing a single, high-quality user embedding computed offline once per day, maintaining the accuracy of real-time systems without the associated overhead.

Methodology

PinnerFormer employs a Transformer-based architecture to process a sequence of a user's past actions over a one-year period, typically capped at the 256 most recent events.

Architecture

The model uses a standard Transformer with causal masking. Each action in the input sequence is represented by a 256-dimensional PinSage embedding, which captures visual and textual content, augmented by metadata such as action type (e.g., click, save), the surface where the action occurred (e.g., Homefeed, Search), and temporal features via Time2Vec.

Figure 1: The PinnerFormer architecture utilizes a Transformer to process user action sequences, outputting embeddings at every time step to be evaluated against future actions.

Dense All-Action Loss

The core innovation of PinnerFormer is the dense all-action loss. Unlike standard models that predict only the immediate next action ($A_{t+1}$), PinnerFormer is trained to predict all positive engagements (Saves, Close-ups, Long-clicks) occurring within a 14-to-28-day future window.

Figure 2: Comparison of different action prediction objectives. Dense All-Action Loss (bottom) trains the model to predict multiple future positive engagements from every step in the sequence.

To handle the massive corpus of billions of Pins, the model utilizes Sampled Softmax with logQ correction. It combines "in-batch" negatives (positive pins from other users) with "random" negatives to help the model distinguish specific user interests from general popularity.

Experimental Setup and Datasets

The model was trained and evaluated using Pinterest’s internal datasets, encompassing over 400 million users and billions of Pins.

  • Training Window: 1 year of user action sequences.
  • Target Window: Positive engagements in the 28 days following the sequence.
  • Evaluation Metric: Recall@10 against a random corpus of 1 million Pins over a 14-day future window.

Key Insights

  • Long-term Horizon Modeling: Predicting a 14-to-28-day future window allows the model to learn stable, intrinsic user interests rather than being swayed by short-term noise.
  • Mitigating Staleness: The performance gap between real-time and daily batch inference is significantly smaller with the dense all-action loss (-8.3%) compared to a standard next-action objective (-13.9%).
  • Efficiency through Single Embeddings: A single Transformer-based embedding is more easily integrated into existing ranking pipelines than multi-embedding models, offering a superior balance of performance and system simplicity.

Results

PinnerFormer demonstrated substantial improvements in both offline metrics and live production environments.

  • Offline Performance: PinnerFormer achieved a Recall@10 of 0.229, significantly outperforming the PinnerSage baseline of 0.046.
  • Online A/B Testing: In Homefeed ranking, PinnerFormer led to a +7.5% increase in Repins and a +6% increase in Close-ups. It also drove gains in Daily and Weekly Active Users (DAU/WAU).
  • Ads Impact: Integration into Ads ranking resulted in a +10% lift in Click-Through Rate (CTR) on the Homefeed.

Conclusion and Future Work

PinnerFormer successfully demonstrates that sophisticated sequence modeling can be deployed efficiently via batch processing without sacrificing performance. Future work includes expanding the model to incorporate a wider variety of user actions, such as search queries, and evaluating PinnerFormer as a standalone candidate generator for retrieval tasks.

Summary updated

BibTeX
@inproceedings{pancha2022pinnerformer,
  author = {Nikil Pancha and Andrew Zhai and Jure Leskovec and Charles Rosenberg},
  title = {{PinnerFormer: Sequence Modeling for User Representation at Pinterest}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2022},
}
Figure