Skip to content

implement Attentional Factorization Machines#1134

Merged
zhenghaoz merged 15 commits intomasterfrom
fm
Jan 16, 2026
Merged

implement Attentional Factorization Machines#1134
zhenghaoz merged 15 commits intomasterfrom
fm

Conversation

@zhenghaoz
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 87.09677% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.88%. Comparing base (b567dfd) to head (00e1a42).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
model/ctr/model.go 85.85% 9 Missing and 5 partials ⚠️
worker/pipeline.go 0.00% 3 Missing ⚠️
master/tasks.go 0.00% 2 Missing ⚠️
model/ctr/evaluator.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1134      +/-   ##
==========================================
+ Coverage   71.58%   72.88%   +1.30%     
==========================================
  Files          84       79       -5     
  Lines       15221    15153      -68     
==========================================
+ Hits        10896    11045     +149     
+ Misses       3240     3012     -228     
- Partials     1085     1096      +11     

☔ 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.

Copy link
Contributor

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

This PR implements Attentional Factorization Machines (AFM), a new model architecture that extends factorization machines with attention mechanisms and embedding support. The implementation renames the previous FMV2 model to AFM and adds support for item embeddings through attention layers.

Changes:

  • Replaced FMV2 with AFM model throughout the codebase, including new attention-based embedding processing
  • Updated the CTRSplit interface and related methods to support item embeddings as a third return value
  • Added a new benchmark tool (gorse-benchmark) for evaluating model performance
  • Fixed duplicate item filtering in chat ranking logic

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
model/ctr/model.go Renamed FMV2 to AFM, added attention and linear layers for embedding encoding, updated BatchPredict/BatchInternalPredict signatures to accept embeddings, changed default hyperparameters
common/nn/layers.go Added new Attention layer with attention mechanism using linear transformation, softmax, and element-wise multiplication
dataset/dataset.go Extended CTRSplit interface to include embedding-related methods (Get returns embeddings, added GetItemEmbeddingDim/Index)
model/ctr/data.go Updated Get method to return embeddings, modified Split to preserve embedding data, added helper methods for embedding dimensions/index
model/ctr/evaluator.go Updated evaluation functions to handle embeddings parameter in predictions, fixed import ordering
model/ctr/model_test.go Updated all test cases from NewFMV2 to NewAFM, added nil embeddings parameter to prediction calls
model/ctr/data_test.go Added embedding data to test dataset, updated assertions to verify embedding handling
worker/pipeline.go Updated CTR ranking to pass nil embeddings parameter to BatchPredict
worker/worker_test.go Changed mock model creation from NewFMV2 to NewAFM
master/tasks.go Updated CTR model creation and optimization to use NewAFM instead of NewFMV2
master/rpc_test.go Updated test model creation to use NewAFM
logics/chat.go Added deduplication logic to prevent duplicate items in ranked results
cmd/gorse-benchmark/main.go New benchmark tool for evaluating FM models with GAUC metrics
go.mod, go.sum Updated golang.org/x/term dependency from v0.37.0 to v0.38.0

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

@zhenghaoz zhenghaoz merged commit 135f6c0 into master Jan 16, 2026
11 of 12 checks passed
@zhenghaoz zhenghaoz deleted the fm branch January 16, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants