A heterogeneous graph contains multiple node or relationship types. In recommendation, users and movies form distinct node types connected by user–movie rating edges. section 12.2.3 section 12.2.4
A practical PyG pipeline handles the graph in explicit stages:
- Create a HeteroData object with user and movie nodes, movie features, rating edges, and reverse edges for bidirectional message passing. section 12.2.3 section 12.2.4
- Split rating edges into disjoint message-passing and supervision sets, reserving validation and testing edges and generating negative examples. section 12.2.3
- Sample neighborhood subgraphs with LinkNeighborLoader when the full graph exceeds CPU or GPU memory. section 12.2.3
- Generate user and movie embeddings, update them with a heterogeneous GNN, and use a dot product to score candidate links. section 12.2.4
Movie recommendation
User embeddings are learned from node identities, while movie representations combine genre features with learned embeddings. Heterogeneous message passing exchanges information across user–movie ratings before dot-product decoding estimates interaction likelihood. section 12.2.4
Figure 12.8 The data processing pipeline for the MovieLens dataset, including incremental ID mapping, genre encoding, and edge creation. The heterogeneous graph data comprises two node types (users and movies) and one edge type (user-rates-movie). Edges are split into training (80%), validation (10%), and testing (10%) sets, with negative examples generated for validation and testing. A mini-batch loader then prepares subgraphs for GNN input, ensuring scalability for large graphs that exceed memory capacity.
Trace the MovieLens preparation pipeline from identifier mapping and genre encoding through edge splitting and mini-batch subgraph construction. section 12.2.3


