PinSage

On this page 6

PinSage is a graph convolutional network (GCN) developed by Pinterest and Stanford researchers that produces item embeddings for web-scale recommender systems. It learns a vector for each pin by combining the pin’s own visual and text features with information aggregated from its neighborhood in a graph of pins and boards, so that pins users group together end up close in embedding space.

Presented at the KDD conference in 2018, PinSage was one of the first graph neural networks deployed in production at billions of nodes. Its training graph contained roughly 3 billion nodes and 18 billion edges, far beyond what earlier GCN implementations could handle. The model adapted GraphSAGE and introduced engineering techniques that made graph learning practical for industrial recommendation.

How PinSage builds embeddings from the pin-board graph

PinSage operates on a bipartite graph in which pins form one node set and boards form the other, with an edge whenever a user saves a pin to a board. Boards act as human-curated collections, so two pins sharing many boards are likely semantically related even when they look different.

Each pin starts with content features: visual embeddings from a convolutional image model, text embeddings from titles and descriptions, and engagement signals. A localized convolution then aggregates the features of selected neighbors, transforms them with a learned dense layer and combines the result with the pin’s own representation. Stacking two such layers lets information flow from multi-hop neighborhoods.

The table below lists the main components of the architecture and their role.

ComponentRoleEffect on embeddings
Input featuresVisual, text and engagement vectorsGround each pin in its content
Importance-based neighborhoodsRandom walks select the most relevant neighborsFocus aggregation on strong relations
Importance poolingWeighted aggregation by visit countsStronger neighbors contribute more
Stacked convolutionsTwo layers of aggregationCapture multi-hop graph structure
Normalized outputFinal dense layer and L2 normalizationEnable cosine-style nearest-neighbor search
Core components of PinSage

Random-walk sampling and training at scale

Standard GCNs multiply over the full graph adjacency matrix, which is impossible at billions of nodes. PinSage instead defines each node’s neighborhood through short random walks: it simulates walks starting from the pin and keeps the nodes with the highest normalized visit counts, typically a few dozen. This bounds memory per node and filters out noisy, high-degree connections.

Training uses a max-margin ranking loss. Positive pairs come from pins that users engaged with consecutively, and the model learns to score the positive item above negatives by a fixed margin. The authors added curriculum training with hard negatives: later epochs include negatives that are related to the query but less relevant than the positive, forcing finer distinctions.

TechniqueProblem addressedApproach
On-the-fly convolutionsFull-graph operations do not fit in memoryCompute only on sampled neighborhoods
Producer-consumer minibatchesGPU idles while graph data is preparedCPUs sample while GPUs train
Shared negative samplesPer-example negatives are costlyReuse a negative set within each minibatch
Hard negative curriculumEasy negatives teach littleAdd harder negatives in later epochs
MapReduce inferenceRepeated computation for overlapping neighborhoodsCompute each embedding once, then join
Engineering techniques that made PinSage scalable

After training, embeddings for all pins are generated offline with a distributed pipeline and loaded into an approximate nearest-neighbor index. Related-pin recommendations then become a fast vector lookup rather than a graph computation at request time.

PinSage sits between content-based filtering and collaborative filtering: it uses item content as input but refines it with collaborative signals carried by the graph. The comparison below places it among neighboring approaches in recommender systems.

MethodSignal usedKey difference from PinSage
Matrix factorizationUser-item interactions onlyNo content features, struggles with new items
GraphSAGENode features and sampled neighborsUniform sampling, not built for billions of nodes
LightGCNInteraction graph without feature transformsSimpler, transductive, needs IDs for every node
Two-tower modelUser and item features in separate encodersLearns user-item fit, no explicit graph
Content-only embeddingsImage or text features aloneIgnore how users actually group items
PinSage among item representation methods

A key property is that PinSage is inductive: because embeddings are computed from features and neighbors rather than looked up by ID, the model can embed newly created pins once they acquire a few board connections. This partially mitigates the cold start problem for items.

Results, uses and limitations

In offline evaluation and in A/B tests on Pinterest, PinSage outperformed visual-only, annotation-only and earlier production baselines on related-pin recommendation, with human raters preferring its results in head-to-head comparisons. Its embeddings were reused across several surfaces, including related pins, home feed candidates and ads, which is typical of a strong shared item representation.

The approach has clear limitations. The embeddings describe items, not users, so personalization requires another model on top. Embeddings are refreshed in batch, which means fast-changing trends lag behind. Quality depends on board curation, and popular items may dominate random walks, reinforcing popularity bias unless sampling is adjusted.

  • Best fit: large catalogs with rich item features and a natural co-occurrence graph.
  • Weaker fit: small datasets, where simpler collaborative filtering often performs comparably.
  • Successor work: Pinterest later combined graph signals with sequence models in user representations such as PinnerSage and PinnerFormer.

The idea in brief

On Pinterest, people save pictures into collections called boards. A board about cozy kitchens might hold wooden shelves, green tiles and copper pots. Those items look different, yet they belong together. PinSage learns that kind of connection.

It looks at each picture and also at its neighbors on many boards. Then it gives each picture a numeric fingerprint. Pictures with similar fingerprints get recommended together. Shared human collections teach the system what fits.

A practical scenario

A home-decor marketplace with about 40 million product images wants better “similar items” suggestions. Its first system uses image embeddings alone, so a rattan chair only retrieves other rattan chairs. The team builds a bipartite graph of products and user wishlists, samples neighborhoods with short random walks and trains a PinSage-style model with hard negatives.

After deployment, the rattan chair also retrieves matching side tables, linen cushions and jute rugs that shoppers often save together. Embeddings are recomputed nightly and served from an approximate nearest-neighbor index. In an A/B test, the graph-based suggestions raise click-through on the similar-items module and increase the share of sessions that include a second product category, while new listings receive useful neighbors within a day of their first saves.