RecBole-GNN
repository·main·Indexed 41 days ago
https://github.com/rucaibox/recbole-gnnA specialized library for developing and reproducing Graph Neural Network (GNN) based recommendation algorithms. Extending the RecBole framework, it supports General, Sequential, and Social recommendation tasks with efficient graph processing. It implements various models including LightGCN, NGCF, SR-GNN, and DiffNet, and is compatible with PyG, PyTorch, and recbole==1.1.1.
What's inside RecBole-GNN
- RecBole-GNN is a library built on PyTorch and RecBole designed for reproducing and developing recommendation algorithms based on Graph Neural Networks (GNNs). It provides a unified API and input format compatible with RecBole, covering General, Sequential, and Social recommendation tasks. It incorporates GNNs from libraries like PyG and provides efficient graph processing layers and datasets.
View Sequential Model Results
mainPerformance results for sequential recommendation models on the
digineticadataset are documented in the sequential results section.[diginetica](sequential/diginetica.md)Run RecBole-GNN with default settings
mainYou can run the library using the provided
run_recbole_gnn.pyscript to execute the default configuration.python run_recbole_gnn.pyView Social-aware Model Results
mainPerformance results for social-aware recommendation models on the
lastfmdataset are documented in the social results section.[lastfm](social/lastfm.md)Install RecBole-GNN requirements
mainTo use RecBole-GNN, ensure your environment meets the following version requirements:
recbole==1.1.1pyg>=2.0.4pytorch>=1.7.0python>=3.7.0
Note: If you are using
recbole==1.0.1, you must use therecbole1.0.1branch of this repository.recbole==1.1.1 pyg>=2.0.4 pytorch>=1.7.0 python>=3.7.0View General Model Results
mainGeneral model performance results for the
ml-1mdataset can be found in the dedicated results file.[ml-1m](general/ml-1m.md)Configure dataset and training settings for MovieLens-1M
mainWhen working with the MovieLens-1M dataset in RecBole-GNN, use the following configuration parameters to ensure correct data loading, filtering, and training behavior.
Data Loading & Filtering:
- Use
field_separator: "\t"andseq_separator: " "for parsing. - Define
USER_ID_FIELD,ITEM_ID_FIELD, andRATING_FIELDto map dataset columns. - To filter interactions (e.g., removing ratings less than 3), use the
val_intervalkey with a range string like"[3,inf)". - Specify columns to load via
load_coland columns to ignore viaunused_col.
Training & Evaluation:
- Set
epochsfor the total number of training iterations. - Adjust
train_batch_sizeandeval_batch_sizeto manage memory usage. - Use
valid_metricto specify which metric (e.g.,MRR@10) should be used for validation.
# dataset config field_separator: "\t" seq_separator: " " USER_ID_FIELD: user_id ITEM_ID_FIELD: item_id RATING_FIELD: rating NEG_PREFIX: neg_ LABEL_FIELD: label load_col: inter: [user_id, item_id, rating] val_interval: rating: "[3,inf)" unused_col: inter: [rating] # training and evaluation epochs: 500 train_batch_size: 4096 valid_metric: MRR@10 eval_batch_size: 4096000- Use
Configure training and evaluation parameters
mainUse these settings to control the training lifecycle and evaluation process for the LastFM experiment:
epochs: Total number of training epochs (e.g.,5000).train_batch_size: Batch size for training (e.g.,4096).eval_batch_size: Batch size for evaluation (e.g.,409600000).valid_metric: The metric used to determine the best model during validation (e.g.,NDCG@10).stopping_step: Number of steps to wait before stopping early (e.g.,50).embedding_size: The dimension for users' and items' embeddings (e.g.,64). Note: You may need to adjust the argument name to match specific model requirements.
# training and evaluation epochs: 5000 train_batch_size: 4096 eval_batch_size: 409600000 valid_metric: NDCG@10 stopping_step: 50 # embedding dimension embedding_size: 64Configure dataset and social network settings for LastFM
mainWhen working with the LastFM dataset in RecBole-GNN, use the following configuration properties to define field mappings, separators, and social network behavior.
Dataset Configuration:
field_separator: Character used to separate fields (e.g.,\t).seq_separator: Character used to separate sequences (e.g.,).USER_ID_FIELD: The name of the user ID field.ITEM_ID_FIELD: The name of the item ID field.NET_SOURCE_ID_FIELD: The name of the source node ID in the social network.NET_TARGET_ID_FIELD: The name of the target node ID in the social network.LABEL_FIELD: The name of the label field.NEG_PREFIX: Prefix for negative samples.load_col: Mapping for loading columns, specifyinginter(interaction) andnet(network) fields.
Social Network Configuration:
filter_net_by_inter: Boolean to determine if the network should be filtered by interactions.undirected_net: Boolean to treat the social network as undirected.
# dataset config field_separator: "\t" seq_separator: " " USER_ID_FIELD: user_id ITEM_ID_FIELD: artist_id NET_SOURCE_ID_FIELD: source_id NET_TARGET_ID_FIELD: target_id LABEL_FIELD: label NEG_PREFIX: neg_ load_col: inter: [user_id, artist_id] net: [source_id, target_id] # social network config filter_net_by_inter: True undirected_net: TrueConfigure the Diginetica dataset for sequential recommendation
mainTo use the
diginetica-not-mergeddataset in RecBole-GNN, configure the following YAML settings. Note that users and items with fewer than 5 interactions are filtered out. The evaluation uses a leave-one-out strategy with full sort mode.Dataset Configuration
field_separator:\tseq_separator:(space)USER_ID_FIELD:session_idITEM_ID_FIELD:item_idTIME_FIELD:timestampNEG_PREFIX:neg_ITEM_LIST_LENGTH_FIELD:item_lengthLIST_SUFFIX:_listMAX_ITEM_LIST_LENGTH:20POSITION_FIELD:position_idload_col.inter:[session_id, item_id, timestamp]user_inter_num_interval:"[5,inf)"item_inter_num_interval:"[5,inf)"
Training and Evaluation Configuration
epochs:500train_batch_size:4096eval_batch_size:2000valid_metric:MRR@10eval_args:split:{'LS':"valid_and_test"}mode:fullorder:TO(Time Order)
Global Constraints
To ensure fairness across models, restrict the embedding dimension:
embedding_size:64(Note: You may need to adjust the specific argument name depending on the model being used).
# dataset config field_separator: "\t" seq_separator: " " USER_ID_FIELD: session_id ITEM_ID_FIELD: item_id TIME_FIELD: timestamp NEG_PREFIX: neg_ ITEM_LIST_LENGTH_FIELD: item_length LIST_SUFFIX: _list MAX_ITEM_LIST_LENGTH: 20 POSITION_FIELD: position_id load_col: inter: [session_id, item_id, timestamp] user_inter_num_interval: "[5,inf)" item_inter_num_interval: "[5,inf)" # training and evaluation epochs: 500 train_batch_size: 4096 eval_batch_size: 2000 valid_metric: MRR@10 eval_args: split: {'LS':"valid_and_test"} mode: full order: TO train_neg_sample_args: ~ # fairness constraint embedding_size: 64Run RecBole-GNN with specific models and datasets
mainTo customize your experiment, use the
-mflag to specify a model and the-dflag to specify a dataset when running therun_recbole_gnn.pyscript.python run_recbole_gnn.py -m [model] -d [dataset]Overview of implemented GNN models
mainRecBole-GNN implements various Graph Neural Network models categorized by recommendation type:
General Recommendation
(User-item interaction graphs)
NGCFLightGCN(supports sparse tensor acceleration)SSL4RecSGLHMLETNCLDirectAUSimGCLXSimGCLLightGCL
Sequential Recommendation
(Session/sequence graphs)
SR-GNNGC-SANNISER+LESSRTAGNNGCE-GNNSGNN-HN
Social Recommendation
(Social networks)
DiffNetMHCNSEPT
Note: Social recommendation datasets can be obtained from the Social-Datasets repository.