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.
| Component | Role | Effect on embeddings |
|---|---|---|
| Input features | Visual, text and engagement vectors | Ground each pin in its content |
| Importance-based neighborhoods | Random walks select the most relevant neighbors | Focus aggregation on strong relations |
| Importance pooling | Weighted aggregation by visit counts | Stronger neighbors contribute more |
| Stacked convolutions | Two layers of aggregation | Capture multi-hop graph structure |
| Normalized output | Final dense layer and L2 normalization | Enable cosine-style nearest-neighbor search |
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.
| Technique | Problem addressed | Approach |
|---|---|---|
| On-the-fly convolutions | Full-graph operations do not fit in memory | Compute only on sampled neighborhoods |
| Producer-consumer minibatches | GPU idles while graph data is prepared | CPUs sample while GPUs train |
| Shared negative samples | Per-example negatives are costly | Reuse a negative set within each minibatch |
| Hard negative curriculum | Easy negatives teach little | Add harder negatives in later epochs |
| MapReduce inference | Repeated computation for overlapping neighborhoods | Compute each embedding once, then join |
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 compared with related recommendation models
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.
| Method | Signal used | Key difference from PinSage |
|---|---|---|
| Matrix factorization | User-item interactions only | No content features, struggles with new items |
| GraphSAGE | Node features and sampled neighbors | Uniform sampling, not built for billions of nodes |
| LightGCN | Interaction graph without feature transforms | Simpler, transductive, needs IDs for every node |
| Two-tower model | User and item features in separate encoders | Learns user-item fit, no explicit graph |
| Content-only embeddings | Image or text features alone | Ignore how users actually group items |
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.