Skip to content

Add LightGCN support to FlexMF#1033

Merged
mdekstrand merged 23 commits intolenskit:mainfrom
mdekstrand:feature/flexmf-lightgcn
Mar 11, 2026
Merged

Add LightGCN support to FlexMF#1033
mdekstrand merged 23 commits intolenskit:mainfrom
mdekstrand:feature/flexmf-lightgcn

Conversation

@mdekstrand
Copy link
Copy Markdown
Member

@mdekstrand mdekstrand commented Mar 5, 2026

This updates FlexMF to have LightGCN support (for implicit feedback) that is activated with a new convolution_layers configuration setting. Zero layers gets classical matrix factorization.

Closes #1019.

@mdekstrand mdekstrand added this to the 2026.1 milestone Mar 5, 2026
@mdekstrand mdekstrand requested a review from samiravaez March 5, 2026 23:57
@mdekstrand mdekstrand self-assigned this Mar 5, 2026
@mdekstrand mdekstrand added the components LensKit recommendation components label Mar 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 88.77551% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.48%. Comparing base (82d88b3) to head (3bcfe0e).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
src/lenskit/flexmf/_training.py 70.83% 7 Missing ⚠️
src/lenskit/flexmf/_model.py 93.02% 3 Missing ⚠️
src/lenskit/training.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1033      +/-   ##
==========================================
+ Coverage   89.47%   89.48%   +0.01%     
==========================================
  Files         222      222              
  Lines       15372    15441      +69     
==========================================
+ Hits        13754    13818      +64     
- Misses       1618     1623       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mdekstrand mdekstrand force-pushed the feature/flexmf-lightgcn branch 2 times, most recently from ae0021b to 3be27cc Compare March 6, 2026 18:50
Comment thread src/lenskit/flexmf/_model.py
Comment thread src/lenskit/flexmf/_model.py Outdated
@samiravaez
Copy link
Copy Markdown
Contributor

user and item bias are getting default values in different places and I'm not sure which one is used at the end but the paper doesn't use bias terms for scoring as I saw, so I think it makes sense for both defaults to be false

@mdekstrand
Copy link
Copy Markdown
Member Author

@samiravaez

user and item bias are getting default values in different places and I'm not sure which one is used at the end but the paper doesn't use bias terms for scoring as I saw, so I think it makes sense for both defaults to be false

This is a good thing to think about… there is a tradeoff in the configurability and defaults:

  • should the defaults be optimized for "pretty good" or for fidelity to the original paper? (I lean towards "pretty good".)
  • should the defaults be consistent across configurations, or have complex dependencies on other settings? (I lean towards consistent, to make it easier to configure the model and to make it easier to document.)

The original BPR doesn't include a bias term, and I don't remember if the logistic matrix factorization paper did or not.

We should experiment with this some to confirm, but I expect including item biases will usually be better, because the model doesn't have to try to model overall item popularity with the embeddings — the embeddings can focus on modeling user preference after popularity is accounted for. User biases only make sense with the logistic loss function.

I agree that we shouldn't have differing defaults. I pushed a change that removes defaulting entirely from the model class, and the explicit scorer now explicitly passes True.

(At some point, we should probably support convolution layers with explicit feedback too.)

@samiravaez
Copy link
Copy Markdown
Contributor

@samiravaez

user and item bias are getting default values in different places and I'm not sure which one is used at the end but the paper doesn't use bias terms for scoring as I saw, so I think it makes sense for both defaults to be false

This is a good thing to think about… there is a tradeoff in the configurability and defaults:

  • should the defaults be optimized for "pretty good" or for fidelity to the original paper? (I lean towards "pretty good".)
  • should the defaults be consistent across configurations, or have complex dependencies on other settings? (I lean towards consistent, to make it easier to configure the model and to make it easier to document.)

The original BPR doesn't include a bias term, and I don't remember if the logistic matrix factorization paper did or not.

We should experiment with this some to confirm, but I expect including item biases will usually be better, because the model doesn't have to try to model overall item popularity with the embeddings — the embeddings can focus on modeling user preference after popularity is accounted for. User biases only make sense with the logistic loss function.

I agree that we shouldn't have differing defaults. I pushed a change that removes defaulting entirely from the model class, and the explicit scorer now explicitly passes True.

(At some point, we should probably support convolution layers with explicit feedback too.)

I agree on the consistency issue, that makes sense.
But having a different default for each version of FlexMF also makes sense to me. I usually lean toward setting defaults to match the originally proposed method. When people use it, the name kind of suggests that it matches the original paper. And since keeping the model minimal is kind of the core idea of the paper, it makes sense to avoid training extra parameters.

@mdekstrand mdekstrand marked this pull request as ready for review March 9, 2026 16:45
@mdekstrand mdekstrand force-pushed the feature/flexmf-lightgcn branch from 377bd01 to 4ad1bac Compare March 9, 2026 18:45
@mdekstrand mdekstrand merged commit 911c1e1 into lenskit:main Mar 11, 2026
34 checks passed
@mdekstrand mdekstrand deleted the feature/flexmf-lightgcn branch March 11, 2026 16:32
mdekstrand added a commit to mdekstrand/lkpy that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components LensKit recommendation components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add LightGCN to FlexMF

2 participants