Skip to content

Add FPMC model and model selection for NextItemRecommender#698

Merged
hieuddo merged 5 commits into
PreferredAI:masterfrom
hieuddo:fpmc-model
Jun 4, 2026
Merged

Add FPMC model and model selection for NextItemRecommender#698
hieuddo merged 5 commits into
PreferredAI:masterfrom
hieuddo:fpmc-model

Conversation

@hieuddo
Copy link
Copy Markdown
Member

@hieuddo hieuddo commented Jun 2, 2026

Description

  • Add FPMC model
  • Model selection by val_score
  • Model selection for GRU4Rec
  • Fix Diginetica session-based data loader

On the Diginetica dataset, the original data format and purpose were for session-aware recommendation. So for each user, beside the leave-one-session-per-user eval/test session, we also have the training session for that user (e.g., HGRU4Rec may feed those training sessions into a user-RNN, feed the test session into session-RNN, and combine those two). So for session-based, to minimize the changes in data loader and iteration, we add new URLs to load val/test set specifically for session-based.

Related Issues

Checklist:

  • I have added tests.
  • I have updated the documentation accordingly.
  • I have updated README.md (if you are adding a new model).
  • I have updated examples/README.md (if you are adding a new example).
  • I have updated datasets/README.md (if you are adding a new dataset).

Copilot AI review requested due to automatic review settings June 2, 2026 06:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the FPMC (Factorizing Personalized Markov Chains) next-item model, introduces an opt-in best-on-validation model selection mechanism shared by sequential models (also wired into GRU4Rec), and switches the Diginetica load_val/load_test defaults to a clean session-based held-out split (with a mode="session-aware" opt-in to recover the previous cumulative files).

Changes:

  • New FPMC model (cornac/models/fpmc/) with a Torch implementation, registration in cornac.models, README entry, and a Diginetica example.
  • New shared val_score helper in cornac/models/seq_utils/selection.py and best/last model_selection plumbing in both FPMC and GRU4Rec.
  • cornac/datasets/diginetica.py load_val/load_test gain a mode parameter (default 'session-based' pointing to new *_sbr.zip URLs); test expectations updated accordingly.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
README.md Adds FPMC row to the models table.
cornac/datasets/diginetica.py Adds mode arg to load_val/load_test; new _sbr URLs.
cornac/models/init.py Exposes FPMC from the package.
cornac/models/fpmc/init.py Re-exports FPMC.
cornac/models/fpmc/recom_fpmc.py New FPMC recommender with training loop and best-on-val selection.
cornac/models/fpmc/fpmc.py Torch module computing <UI,IU> + <IL,LI> + bias.
cornac/models/fpmc/requirements.txt torch>=1.12.0.
cornac/models/gru4rec/recom_gru4rec.py Adds model_selection, val_eval_every, val_k, val_metric; restores best state.
cornac/models/seq_utils/init.py Re-exports val_score.
cornac/models/seq_utils/selection.py Helper that delegates to next_item_evaluation.ranking_eval.
examples/fpmc_diginetica.py Quick-start example for FPMC on Diginetica.
tests/cornac/datasets/test_diginetica.py Updates expected sizes for the new session-based defaults and asserts session-aware sizes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hieuddo
Copy link
Copy Markdown
Member Author

hieuddo commented Jun 2, 2026

Some quick results for GRU4Rec and FPMC:

Validation

Model MRR NDCG@10 NDCG@20 Recall@10 Recall@20 Time (s)
SPop 0.2376 0.2490 0.2537 0.2926 0.3119 0.5376
GRU4Rec 0.3310 0.3714 0.3780 0.5080 0.5338 0.4983
FPMC 0.1834 0.2117 0.2236 0.3183 0.3666 0.3962

Test

Model MRR NDCG@10 NDCG@20 Recall@10 Recall@20 Train (s) Test (s)
SPop 0.2344 0.2432 0.2474 0.2776 0.2943 0.0014 0.5280
GRU4Rec 0.3024 0.3421 0.3454 0.4749 0.4883 27.2797 0.5028
FPMC 0.1752 0.2005 0.2119 0.2977 0.3411 22.0645 0.3781

@hieuddo hieuddo requested review from lthoang and qtuantruong June 2, 2026 07:52
@lthoang lthoang added the models New models, changes to models label Jun 3, 2026
@hieuddo hieuddo merged commit 90ab89f into PreferredAI:master Jun 4, 2026
19 checks passed
@hieuddo hieuddo deleted the fpmc-model branch June 4, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models New models, changes to models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants