# Enhancing Ad Relevance: Integrating Real-Time Context into Sequential Recommender Models

[Pinterest](https://yomu.fyi/company/pinterest) · Pinterest Engineering · May 8, 2026

**Type:** Problem & solution

## Summary

Pinterest's sequential ads candidate generator inferred user embeddings offline from historical offsite conversions, which lacked real-time browsing context. Consequently, less than 1% of impressions on the Related Pins surface were attributed to this generator because its retrieved candidates struggled in downstream ranking. To resolve this limitation, engineers developed the Contextual Sequential Two Tower Model, integrating a context layer directly into the query tower alongside user demographic features. Offline training utilized synthetic context derived from positive conversion labels paired with high dropout rates to preserve sequence reliance, while serving split into offline Transformer inference and online context computation. Offline evaluations showed a 3x to 10x increase in Recall@K, and production deployment lifted median candidate relevance by 275% to 300% and overall ROAS by approximately 0.7%.

## Context

Pinterest's sequential ads candidate generator relied on offline user embeddings inferred from historical offsite conversions. This design lacked real-time online browsing context, causing candidates to struggle in downstream ranking on contextual surfaces like Related Pins, where the model generated less than 1% of impressions.

## Approach / What changed

Pinterest created the Contextual Sequential Two Tower Model, which concatenates the offline Transformer sequence encoder output with a real-time context layer and user demographics before passing them to an MLP. Offline training synthesizes pseudo-context from positive conversion labels with high dropout on the context layer. Serving runs hybrid inference, calculating Transformer states offline and computing the context layer with the MLP online.

## Takeaways

- Offline evaluation of the contextual model demonstrated a 3x to 10x increase in Recall@K over the production baseline on Related Pins.
- Median relevance of retrieved candidates increased by roughly 275% to 300%, doubling the volume of retrieved candidates delivered to impression.
- Overall ads relevance metric rose by 1.08%, driving a ~0.7% lift in Return on Ad Spend (ROAS) overall and ~1.4% in top revenue countries.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Recommendation Systems](https://yomu.fyi/topic/recommendation-systems)

[Read original post](https://medium.com/pinterest-engineering/enhancing-ad-relevance-integrating-real-time-context-into-sequential-recommender-models-bc3a2f9b682e)
