# Graph Neural Networks for Social Recommendation

GraphRec models both social and user-item graphs to recommend items

Fan, Wenqi, Ma, Yao, Li, Qing, He, Yuan, Zhao, Eric, Tang, Jiliang and 1 more · arXiv · 2019-2-19

- **Problem** Social recommenders must merge a social graph with a user-item graph whose edges carry opinions. Earlier GNN recommenders ignored the social graph.
- **Method** GraphRec builds a user factor from item-side and social-side aggregation, using attention to weight items and friends by strength. It then predicts ratings with an MLP.
- **Results** On Ciao with 60% training data, GraphRec reached MAE 0.7540 and RMSE 1.0093, the lowest of nine methods compared.

## Why social recommendation needs a graph view

Social recommendation involves two linked graphs: a social graph of relations between users, and a user-item graph of interactions, in which every user takes part in both. Graph neural networks suit this setting because they update each node by aggregating information from its local neighbourhood, so node features and graph topology are used together.

The first difficulty is that the two graphs describe the same users from different angles, so a model has to merge them into one user representation rather than treat them separately. The second is that a user-item edge carries an opinion as well as the fact of an interaction, and a model that keeps only the interaction loses that signal.

The third is that social ties differ in strength, and giving every friend the same weight can reduce recommendation quality.

Earlier social recommenders such as SoRec and TrustMF tie users together through shared latent factors in matrix factorization. Neural approaches to social recommendation were rare until recently, and the GNN-based recommenders that appeared, such as GCMC and PinSage, worked on the user-item graph without the social graph.

## Building the user representation from two graphs

Item aggregation forms an item-space factor h^I\_i for user u\_i from the items in C(i), each represented by an opinion-aware vector x\_ia. Each x\_ia is an MLP output over the concatenation of the item embedding q\_a and the opinion embedding e\_r for the rating r that u\_i gave to v\_a. The aggregation has the form \\\\( h^I\_i = \\\\sigma(W \\\\cdot \\\\mathrm{Aggregate}\_{items}(\\\\{x\_{ia}\\\\}) + b) \\\\), with sigma a ReLU activation and W and b a weight matrix and bias.

A plain mean over the x\_ia gives every interaction the same weight, which the authors describe as a linear approximation of a localized spectral convolution. The authors replace the uniform weight with an attention weight alpha\_ia for each (v\_a, u\_i) pair. A two-layer attention network takes x\_ia and the user embedding p\_i as input, and its scores are normalized with a softmax over C(i).

Social aggregation forms the social-space factor h^S\_i from the item-space factors h^I\_o of the neighbours o in N(i), so the social graph shapes a user's representation through the item-side information of friends. Attention over neighbours uses the same two-layer form, with h^I\_o and p\_i as input, giving scores beta\*\_io and weights beta\_io = exp(beta\*\_io) / sum over o in N(i) of exp(beta\*\_io).

The authors read beta\_io as the strength of the tie between u\_i and u\_o, which lets strong friends count more than weak ones.

The two factors are concatenated as c1 = \[h^I\_i concatenated with h^S\_i\] and passed through further hidden layers, ending with h\_i = sigma(W\_l c\_{l-1} + b\_l). The result is the final user latent factor h\_i, which carries information from both the interaction graph and the social graph.

## Item modeling and the rating predictor

For item v\_j, user aggregation draws on the users in B(j) who rated it. Each rater contributes an opinion-aware vector f\_jt = g\_u(\[p\_t concatenated with e\_r\]), which is an MLP over the user embedding and the opinion embedding. The same item can be rated differently by different users, and the authors use this variation to capture how the item is perceived.

The item factor z\_j is a weighted sum of the f\_jt followed by a nonlinearity, z\_j = sigma(W sum over t in B(j) of mu\_jt f\_jt + b). Each weight mu\_jt comes from a two-layer attention network that takes f\_jt and the item embedding q\_j, and is normalized with a softmax over B(j).

For rating prediction, h\_i and z\_j are concatenated and fed into an MLP, and the predicted rating is r'\_ij = w^T g\_{l-1}. The rating prediction is the only output of the model, and the same network is applied to any user-item pair at prediction time.

## Training and evaluation setup

The model minimizes the squared error over the observed ratings, Loss = 1/(2\|O\|) times the sum over observed (i, j) of (r'\_ij minus r\_ij) squared, where \|O\| is the number of observed ratings. RMSprop is used instead of plain SGD, and each step uses one randomly chosen training instance. The user embeddings, item embeddings and opinion embeddings are randomly initialized and learned jointly during training, rather than using one-hot vectors.

Dropout is applied during training to reduce overfitting, and it is turned off at test time so the full network makes predictions. The opinion embedding matrix has one vector per rating level, so a 5-star scale gives five vectors for the scores 1 to 5.

The experiments use Ciao and Epinions, drawn from two consumer review sites whose users rate items and add friends. Ciao has 7,317 users and 283,319 ratings, and Epinions has 18,088 users and 764,352 ratings, with ratings on a scale from 1 to 5.

Each dataset is split with x% for training, and (1 minus x%) divided by 2 each for validation and testing, with x set to 80% or 60%. Training stops early when the validation RMSE has not improved for 5 successive epochs.

MAE and RMSE measure predictive accuracy, and smaller values mean better accuracy. Nine methods are compared: PMF, SoRec, SoReg, SocialMF, TrustMF, NeuMF, DeepSoR and GCMC+SN, together with GraphRec. NeuMF was originally built for ranking, and the authors changed its loss to squared loss for rating prediction. GCMC+SN uses node2vec embeddings of the social connections as user side information, because the raw social matrix is sparse and high-dimensional.

## Accuracy against the baselines

In all four settings, Ciao and Epinions at 60% and at 80% training data, GraphRec has the lowest MAE and the lowest RMSE among the nine methods in Table 3.

On Ciao with 60% training data, GraphRec reached MAE 0.7540 and RMSE 1.0093. The closest baseline on RMSE was GCMC+SN at 1.0221, and on MAE it was TrustMF at 0.7681. On Ciao with 80% training data, GraphRec reached MAE 0.7387 and RMSE 0.9794, against 0.7526 MAE and 0.9931 RMSE for GCMC+SN, the closest baseline on RMSE.

On Epinions with 80% training data, GraphRec reached MAE 0.8168 and RMSE 1.0631, against 0.8383 MAE for DeepSoR and 1.0711 RMSE for GCMC+SN. On Epinions with 60% training data, GraphRec reached MAE 0.8441 and RMSE 1.0878, against 0.8520 MAE for DeepSoR and 1.1004 RMSE for GCMC+SN.

Among the baselines, the social matrix factorization methods beat PMF, which uses only ratings, and the neural methods DeepSoR and GCMC+SN beat those matrix factorization methods in most settings. The authors attribute GraphRec's advantage over DeepSoR and GCMC+SN to its components for combining ratings and social information, and to the way it models both interactions and opinions in the user-item graph.

These comparisons cover only the two datasets, Ciao and Epinions, and only the 60% and 80% training splits.

## What removing each component changes

GraphRec-SN drops the social-space user latent factor, so the user factor comes from item aggregation alone. GraphRec-Opinion removes the opinion embedding from the opinion-aware representations used in item and user modeling.

GraphRec-SN performs worse than the full GraphRec, which the authors take as evidence that the social-space factor helps learn user latent factors.

Removing the opinions degrades rating prediction clearly. On average, the relative reduction in RMSE is 3.50% on Ciao and 2.64% on Epinions, and in MAE it is 5.84% and 5.02%. The authors read this as showing that opinions on interactions carry information that improves both user and item latent factors.

The attention study compares GraphRec with GraphRec-alpha, GraphRec-beta, GraphRec-alpha and beta together, and GraphRec-mu. Each one swaps the attention in one aggregation step for a mean-based aggregator. GraphRec-alpha and GraphRec-mu, which remove the item attention and the user attention, perform worse than GraphRec. Removing the social attention in GraphRec-beta lowers performance significantly, which the authors take as support for treating social friends unequally.

The attention results appear as plotted curves in Figure 4, and the text does not give their numerical values, so the size of each drop is not stated in numbers here.

## Sensitivity to the embedding size

The embedding size was tested over 8, 16, 32, 64, 128 and 256 on Ciao and Epinions. Performance first improves as the embedding size grows, and the gain from 8 to 64 is significant according to the authors. At embedding size 256, GraphRec's performance degrades relative to size 64.

The authors note that a large embedding carries more representational power but raises the model's complexity, so the size must balance accuracy against cost.

## Limitations

Only the social graph is brought into the model. Rich attributes of users and items are not used, although the authors note such attributes are common in real systems. Ratings and social information are both treated as static, and the authors plan dynamic graph neural networks as future work.

Evaluation covers two datasets, Ciao and Epinions, with 60% and 80% training splits and a 5-epoch early stopping rule. The baselines' hyperparameters follow their original papers and were then tuned, and the GCMC+SN baseline uses node2vec embeddings rather than the raw social matrix.

## Paper info

- **Authors**: Fan, Wenqi, Ma, Yao, Li, Qing, He, Yuan, Zhao, Eric, Tang, Jiliang, Yin, Dawei
- **Venue**: arXiv · Preprint
- **First published**: 2019-2-19
- **Added**: 2026-11-12
- **Updated**: 2019-11-23
- **Version**: v2
- **arXiv**: 1902.07243
- **Category**: cs.IR · cs.LG · cs.SI
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1902.07243v2) · [PDF ↗](https://arxiv.org/pdf/1902.07243v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Fan, Wenqi, Ma, Yao, Li, Qing, He, Yuan, Zhao, Eric, Tang, Jiliang, Yin, Dawei (2019). Graph Neural Networks for Social Recommendation. arXiv:1902.07243v2. https://arxiv.org/abs/1902.07243v2

**BibTeX**

```
@misc{wenqi2019graph,
  title = {{Graph Neural Networks for Social Recommendation}},
  author = {Fan, Wenqi and Ma, Yao and Li, Qing and He, Yuan and Zhao, Eric and Tang, Jiliang and Yin, Dawei},
  year = {2019},
  eprint = {1902.07243},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1902.07243v2}
}
```

## Related papers

- [Federated Social Recommendation with Graph Neural Network](https://refivu.com/en/papers/ce54fcd7-f119-4f48-9809-3fe4f5cc05cd-federated-social-recommendation-with-graph-neural-network.md)
- [IANN: A Unified Framework for Equivariant InterAtomic Neural Networks with User-Friendly Implementation](https://refivu.com/en/papers/4c633944-8862-4ee4-bd77-a5c9f417f6fd-iann-a-unified-framework-for-equivariant-interatomic-neural.md)
- [Wasserstein GAN](https://refivu.com/en/papers/6fbb2587-49dc-4b1a-9bb9-ee89b40b9221-wasserstein-gan.md)
- [FuXi: A cascade machine learning forecasting system for 15-day global weather forecast](https://refivu.com/en/papers/22238201-8e26-4b50-bb73-ade13aa387ac-fuxi-a-cascade-machine-learning-forecasting-system-for.md)
- [Image Captioning with Semantic Attention](https://refivu.com/en/papers/1d01d0ec-7423-41cc-9a8a-b002bc483a11-image-captioning-with-semantic-attention.md)
- [Connecting the Dots: Multivariate Time Series Forecasting with Graph Neural Networks](https://refivu.com/en/papers/f0231d70-9d15-48d0-aa7c-c83cefdf69ab-connecting-the-dots-multivariate-time-series-forecasting.md)

## Other paper commentary

- [Graph Convolutional Networks for Text Classification](https://refivu.com/en/papers/3f1e8027-a608-4e71-87f0-2bdbf0fd5a7f-graph-convolutional-networks-for-text-classification.md)
- [Two-Stream Adaptive Graph Convolutional Networks for Skeleton-Based Action Recognition](https://refivu.com/en/papers/34b4bb2a-43de-4874-9031-6b02160d4003-two-stream-adaptive-graph-convolutional-networks-for.md)
- [Simplifying Graph Convolutional Networks](https://refivu.com/en/papers/e44b1726-1294-4944-949a-e3035e872bc5-simplifying-graph-convolutional-networks.md)
- [KGAT: Knowledge Graph Attention Network for Recommendation](https://refivu.com/en/papers/c8788d47-0620-4271-bfbc-99d522ade86e-kgat-knowledge-graph-attention-network-for-recommendation.md)
- [Deeper Insights into Graph Convolutional Networks for Semi-Supervised Learning](https://refivu.com/en/papers/a2134edc-a5ef-48b2-9ec4-982cfed2a085-deeper-insights-into-graph-convolutional-networks-for-semi.md)
- [World Models](https://refivu.com/en/papers/69defaf1-9e14-4e62-a47b-93dd3012554e-world-models.md)
- [Complex Embeddings for Simple Link Prediction](https://refivu.com/en/papers/d25530db-c5cb-4ff1-b0b6-d2231ef2615f-complex-embeddings-for-simple-link-prediction.md)
- [PennyLane: Automatic differentiation of hybrid quantum-classical computations](https://refivu.com/en/papers/7de2ab55-3dd6-408b-8267-8c552d218275-pennylane-automatic-differentiation-of-hybrid-quantum.md)
- [4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural Networks](https://refivu.com/en/papers/bb10cb3b-b1cc-4119-9de1-8503fdbd27ff-4d-spatio-temporal-convnets-minkowski-convolutional-neural.md)
- [Mixed Precision Training](https://refivu.com/en/papers/65eb5ae7-5d07-475b-869d-fe6a7fb2c613-mixed-precision-training.md)
- [Feature Squeezing: Detecting Adversarial Examples in Deep Neural Networks](https://refivu.com/en/papers/12afca27-3173-4d16-a76b-cb72a4fa0438-feature-squeezing-detecting-adversarial-examples-in-deep.md)
- [Unsupervised Image-to-Image Translation Networks](https://refivu.com/en/papers/23eee1aa-7651-4535-93bf-d37262ee5dff-unsupervised-image-to-image-translation-networks.md)

## Terms in this paper

- [dropout](https://refivu.com/en/terms/db73f75bbdd3-dropout)
- [RMSProp](https://refivu.com/en/terms/a1984fdf7b1d-rmsprop)
- [RMSE](https://refivu.com/en/terms/ad2579cf164a-rmse)
- [MAE](https://refivu.com/en/terms/15fbae569b33-mae)
- [Epinions](https://refivu.com/en/terms/42c2e665658e-epinions)
- [Ciao](https://refivu.com/en/terms/6acba8f0d87a-ciao)
- [GraphRec](https://refivu.com/en/terms/5b1c9f58710a-graphrec)
- [NeuMF](https://refivu.com/en/terms/3238e677aa02-neumf)
- [social recommendation](https://refivu.com/en/terms/c3be31a29546-social-recommendation)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/3f172e45-3e51-4657-9b43-76ed2fb286e9-graph-neural-networks-for-social-recommendation)
