Pinterest cut its candidate retrieval p90 latency by 85%—from 80ms down to 12ms—while scaling personalized feed recommendations across millions of multi-intent users. 👇
Standard two-tower recommendation models compress a user's entire profile into a single vector embedding. That breaks when someone is simultaneously planning a home renovation, searching for recipes, and saving fashion ideas. A single embedding gets pulled in opposite directions, producing generic results. Running separate conditional queries solved the context problem, but sending individual model requests for every user context quickly exploded compute costs.
Pinterest built Conditional Learned Retrieval (CLR) to evaluate multiple user intentions inside a unified model framework. They merged user action sequences, board contexts, and pin conditions into a shared foundation model, then overhauled their training and serving stacks to handle multi-condition retrieval efficiently.
CLR converts context signals into condition tokens and appends them directly to the user's recent action sequence. A conditioned sequence transformer uses these tokens as queries over user history. A user sequence foundation model (PinFM) encodes the interactions, using a contrastive alignment loss to align condition tokens directly with the candidate pin embedding space.
To avoid building bespoke features for every new condition, Pinterest replaced custom condition pipelines with a unified "Slot Architecture" that buckets inputs into three predefined slots: * `condition_os` slot: Holds dense embeddings for pins, boards, or interest text. * `condition_id` slot: Holds specific categorical identifiers or hierarchical semantic IDs. * `condition_type_id` slot: Maps condition sources into a 32-dimensional learned embedding.
Training this foundation model introduced massive computational overhead, which Pinterest halved by introducing two lossless throughput optimizations: * Request-level training: Groups identical user-condition pairs within a batch to run through the user tower once, re-duplicating output embeddings post-forward pass for loss calculation. * M-Falcon optimization: Flattens multiple conditions for a single user onto one user sequence. A custom block attention mask lets condition tokens attend to the user history, but masks condition tokens from seeing each other.
For serving, Pinterest migrated CLR inference to AWS g6e.4xlarge GPU instances using NVEmbed to package dense models and multi-gigabyte embedding tables into a single artifact. They refactored the serving path into a "1 query → N condition" ranking setup, evaluating all candidate conditions for a user in a single batch request.
The redesigned architecture achieved seven-figure cost savings and reduced p90 model latency from 80ms to 12ms. It doubled offline training throughput, enabled automated condition tuning, and allowed Pinterest to retire legacy heuristic candidate generators across the home feed.
NayaRead shows a summary and links to the original article. The full article is hosted on medium.com.