Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Sign-aware Evaluation for Signed Recommendation

Code and data for "What Gets Measured Gets Managed: Sign-aware Recommendation Needs Sign-aware Evaluation" (NeurIPS 2026).

Multi-seed benchmark and evaluation toolkit for signed graph recommendation. Ships with reference numbers for 10 models × 5 datasets × 3 seeds; new models and datasets plug in via simple contracts (see §7).

Datasets. The processed splits of all 5 datasets are in baselines/SIGformer/data/<dataset>/ (train.txt / valid.txt / test.txt, format userId itemId rating; also reachable via the top-level data/ symlink). See §2.

Note on pre-trained embeddings. Per-seed embeddings (eval/embeddings/<model>_<dataset>_s<seed>.pt, ~3.5 GB total) are not included in this repository due to their size; they will be released separately. All reported numbers can be reproduced from scratch via bash scripts/run_all_seeds.sh <N_GPU> followed by the evaluation pipeline in §4.

What's inside

  • 10 models (4 unsigned + 6 signed)
    • Unsigned: LightGCN, LightGCL, XSimGCL, GFormer
    • Signed: SIGformer, SiReN, SiGRec, Pone-GNN, SDCGCL, NFARec
  • 5 datasets: Amazon-CDs, Amazon-Music, Epinions, KuaiRand, KuaiRec
  • 3 seeds: 2024, 42, 2025 (mean±std reported)
  • Signed-aware metrics: NDCG, Recall, SNDCG, SRecall, Hit, SHit, Probe AUC, Valence metrics

1. Setup

1.1. Clone

git clone https://github.com/goldtan/sign-aware-evaluation.git rec
cd rec

All 10 baseline models are vendored under baselines/. No additional cloning needed.

1.2. Dependencies

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

Python ≥ 3.10 (tested with 3.12), CUDA ≥ 12.x. The PyG stack (torch_geometric, torch_scatter, torch_sparse, torch_cluster) is sensitive to the installed PyTorch/CUDA combo — see the comments at the top of requirements.txt for manual install commands.

1.3. Path configuration

The training / evaluation pipeline resolves all paths from each file's own location (__file__ in Python, ${BASH_SOURCE[0]} in shell), so no path rewrite is needed — run scripts/run_all_seeds.sh from a fresh clone and it finds baselines/, eval/embeddings/, outputs/logs/, etc. relative to the repo root.

A handful of peripheral dev/analysis scripts (e.g. baselines/SIGformer/code/plot_*.py, eval/analysis/reeval_hit.py, baselines/GFormer/convert_sigformer_data*.py) still hard-code /workspace/rec/. They are not part of the documented reproduction pipeline. If you want to run them on a different cluster, either clone the repo into /workspace/rec, or apply:

grep -rln "/workspace/rec" --include='*.py' --include='*.sh' | \
  xargs sed -i "s|/workspace/rec|$(pwd)|g"

2. Data

The canonical copy of the 5 benchmark datasets is baselines/SIGformer/data/<dataset>/ (symlinked at the repo root as data/), with train.txt, valid.txt, test.txt in SIGformer format (space-separated userId itemId rating) and an info.txt per dataset.

Each baseline also vendors its own copy of the same splits under baselines/<model>/data/ (or Datasets/, dataset/ depending on the model's convention), converted to that model's input format where needed.

Datasets other than the 5 above are not shipped with this repo. Extra NFARec correlation/adjacency matrices (up to 18 GB for amazon-cds) are regenerated on first run.


3. Training

3.1. One seed, all models, all datasets

bash scripts/run_seed.sh <SEED> <N_GPU>
# e.g. bash scripts/run_seed.sh 42 4

3.2. All seeds (42, 2025), all models, all datasets

bash scripts/run_all_seeds.sh <N_GPU>

The script walks through models in order (SIGformer → SiReN → SiGRec → Pone-GNN → SDCGCL → NFARec → LightGCN → LightGCL → XSimGCL → GFormer), distributes datasets across GPUs, and skips any (model, dataset, seed) tuple whose embedding already exists at eval/embeddings/<model>_<dataset>_s<seed>.pt.

Per-dataset offset / threshold is set correctly per paper convention:

Dataset Offset for signed models
amazon-cds, amazon-music, epinions (rating 1-5) 4
KuaiRand, KuaiRec (binary 0/1) 1

3.3. Catchup chains (when a subset fails)

bash scripts/chain_signaware.sh <GPU> <SEED>   # skips embeddings that exist
bash scripts/chain_ponegnn.sh   <GPU> <SEED>   # Pone-GNN only
bash scripts/chain_siren.sh     <GPU> <SEED>   # SiReN only (amazon/epinions)

3.4. Output locations during training

  • Embeddings (inline save): eval/embeddings/<model>_<dataset>_s<seed>.pt
  • Checkpoints: baselines/<model>/checkpoints/ or similar per-model locations
  • Training logs: outputs/logs/seed_<seed>/<tag>.log

For GFormer / LightGCL the training step only saves a checkpoint; embedding extraction is automatic in run_all_seeds.sh via eval/extract/extract_<model>.py. To extract manually:

python -u eval/extract/extract_lightgcl.py --seed=42

4. Evaluation

4.1. Per-seed metric table

EVAL_SEED=2024 python -u eval/compute_all_tables.py
# → writes results/json/phase1_s2024.json

Repeat for EVAL_SEED=42 and EVAL_SEED=2025.

Each JSON contains, per <model>_<dataset> key, all metrics: NDCG, Recall, SNDCG, SRecall, Hit, SHit, neg-infiltration, Probe AUC, Rel.AUC, Val.AUC, Med.V-AUC, Overlap.

4.2. Multi-seed mean ± std

python3 eval/aggregate_multiseed.py
# → results/json/multiseed_summary.json

5. Repo layout

rec/
├── baselines/                  # 10 model source trees (all vendored)
│   ├── Unsigned: LightGCN/, LightGCL/, SELFRec/ (XSimGCL), GFormer/
│   └── Signed: SIGformer/, SiReN/, SiGRec/,
│                Pone-GNN/, SDCGCL/, NFARec/
├── bench/wrappers/             # optional uniform wrapper interfaces
├── config/                     # dataset/model yaml configs
├── data/                       # symlink → baselines/SIGformer/data (canonical datasets)
├── eval/
│   ├── compute_all_tables.py   # per-seed evaluation
│   ├── aggregate_multiseed.py  # mean ± std aggregation
│   ├── extract/*.py            # checkpoint → embedding
│   ├── analysis/*.py           # one-off analyses (gamma sweep etc.)
│   ├── metrics.py, data.py
│   └── embeddings/             # .gitignored
├── scripts/
│   ├── run_all_seeds.sh, run_seed.sh
│   ├── chain_{signaware, ponegnn, siren}.sh
│   └── extract_*.py / run_parallel_*.sh
├── outputs/logs/               # .gitignored
└── models/                     # symlinks → baselines/*

6. Reproducing the paper numbers

# 1. train (everything, ~several days on 4 GPUs)
bash scripts/run_all_seeds.sh 4

# 2. evaluate each seed
for s in 2024 42 2025; do
  EVAL_SEED=$s python -u eval/compute_all_tables.py
done

# 3. aggregate + markdown
python3 eval/aggregate_multiseed.py
python3 eval/generate_md_tables.py
# → results/md_sections/*.md ready for inclusion in manuscript

7. Extending to new models and datasets

The evaluation pipeline in eval/ is model-agnostic: it consumes saved embeddings and produces every metric table. Any new model or dataset that follows the contracts below is picked up automatically.

7.1. Adding a new model

Save final user/item embeddings to the toolkit's path convention:

import torch
torch.save(
    {'user_emb': user_emb, 'item_emb': item_emb},
    f'eval/embeddings/<your_model>_<dataset>_s<seed>.pt',
)
# user_emb: (num_users, d),  item_emb: (num_items, d)
# IDs must match the dataset's train.txt ordering.

Then re-run §4 — your model shows up alongside the 10 baselines in every metric table. Add the model key to MODELS in eval/compute_all_tables.py and to UNSIGNED or SIGNED in eval/generate_md_tables.py to include it in the paper-style markdown tables.

7.2. Adding a new dataset

  1. Data files. Place train.txt, valid.txt, test.txt (SIGformer format: space-separated userId itemId rating) into each baseline's dataset directory (baselines/<model>/data/<dataset>/ or the model's equivalent dataset/ / Datasets/ convention).
  2. Offset / threshold. Pick the signed threshold that matches the rating scale (4 for 1–5 ratings, 1 for binary 0/1) and set it in every signed model's per-dataset config.
  3. Whitelist. Add the dataset folder name to the allow-list at the bottom of .gitignore so it is tracked by git.
  4. Registry. Add the dataset name to DS5 in eval/generate_md_tables.py (and pass it via --datasets=<name> when invoking eval/compute_all_tables.py, or add it to that script's default dataset list).

Once those four steps are done, the standard commands in §3 and §4 work unchanged on the new dataset.


8. Known limitations

  • NFARec amazon-cds: requires ≥ 80 GB GPU (H100) due to N×N correlation matrix. On 24 GB GPUs only 1 seed (s2024) is available; the paper reports that cell with n_seeds=1.

9. Licenses

9.1. Baseline code

Model License Source
SIGformer No license StupidThree/SIGformer
LightGCN No license gusye1234/LightGCN-PyTorch
LightGCL No license HKUDS/LightGCL
XSimGCL (SELFRec) No license Coder-Yu/SELFRec
GFormer Apache 2.0 HKUDS/GFormer
SiReN No license cw-seo/SiReN-reco
Pone-GNN No license Young0222/Pone-GNN
SiGRec No public repo Huang et al., IPM 2023
SDCGCL No license LQgdwind/nips25-sdcgcl
NFARec No license WangXFng/NFARec

9.2. Datasets

Dataset License Source
Amazon Reviews (CDs, Music) No formal license (citation required) Amazon Reviews 2018
Epinions No formal license (citation required) SNAP
KuaiRand CC BY-SA 4.0 chongminggao/KuaiRand
KuaiRec CC BY-SA 4.0 chongminggao/KuaiRec

10. Citation

This work has been accepted to NeurIPS 2026:

What Gets Measured Gets Managed: Sign-aware Recommendation Needs Sign-aware Evaluation. NeurIPS 2026.

A BibTeX entry will be added once the proceedings are published.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages