Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RMP] Tensorflow support for session based recommendations integration in Merlin #433

Closed
36 of 37 tasks
viswa-nvidia opened this issue Jul 5, 2022 · 13 comments
Closed
36 of 37 tasks

Comments

@viswa-nvidia
Copy link

viswa-nvidia commented Jul 5, 2022

Problem:

Session-based and sequential-based models are an active research area for providing personalized recommendations. Transformers4Rec library was built to support the definition of such architectures and the results of our experiments conducted in the T4Rec paper showed the effectiveness of Transformers in modeling short sequences observed in session-based tasks. The T4Rec library was also used to win various RecSys challenges. We also observe a growing interest and active engagement from customers in using Transformers4Rec.

T4Rec was not actively updated for several months as the team shifted its focus to developing the Merlin Model library. MM does not currently support sequential and session-based recsys architectures. MM should support these sequential architectures and provide all necessary support to our users so that they can build such effective models.

Goal:

  • Port the Transformers4Rec TF API to MM.
  • The main blocks are: Masking, Transformer, RNN, and NextItemPredictionTask
  • Provide an example that demonstrates < @jsohn-nvidia to clarify>

Definition of Done

Have an example that serves TF session based model in conjunction with a NVT workflow where the session based models scores the whole catalog

Constraints:

  • T4Rec TF API is not as stable and complete as torch API. The main missing points are:
    - Two out of the 4 masking classes are missing: PLM and RTD
    - Support for training techniques embedding in HuggingFace trainer class: multi-gpu, early stopping, checkpoints saving...
    - Conduct experiments with real-world datasets (like the one conducted in the T4Rec paper with the Pytorch API)

Starting Point:

Training

Proposed API:

inputs = InputBlock(
  schema=con_schema + seq_schema,
  post=BroadcastToSequence(con_schema, seq_schema)
)
model = RetrievalModel(
  XLNetEncoder(inputs, n_head=4, n_layer=2),
  CategoricalOutput(inputs.select_by_tag(Tags.ITEM_ID))
)

topk = TopKEncoder(model)
topk.evaluate(...)

loader = mm.Loader(
  dataset, 
  batch_size=1000,
  transforms=PredictMasked(seq_schema, target=Tags.ITEM_ID)
)

model.fit(loader)

Inputs

Add support for sequential-inputs & shared embeddings
@edknv, @oliverholworthy & @marcromeyn

Masking

Add training strategies for sequence models
@gabrielspmoreira

RetrievalModel

Make RetrievalModel more generic to session-based use-cases + allow encoders being served
@marcromeyn

Outputs

Improve model-outputs to handle session-based recsys
@marcromeyn & @sararb

Port Sequence Architectures

Add sequence-encoding blocks like transformers
@sararb

Fixes for the GTC tutorial on session-based recommendation

Inference support

Save schema on model save

Systems

Documentation

Examples

Small scale (see #352)

Blocker

@EvenOldridge EvenOldridge added this to the Merlin 22.09 milestone Jul 13, 2022
@sararb sararb changed the title [RMP]Session based recommendations integration in to T4R and MM [RMP]Session based recommendations integration in MM Jul 14, 2022
@viswa-nvidia viswa-nvidia changed the title [RMP]Session based recommendations integration in MM [ERMP]Session based recommendations integration in MM Jul 20, 2022
@viswa-nvidia viswa-nvidia changed the title [ERMP]Session based recommendations integration in MM [RMP]Session based recommendations integration in MM Jul 29, 2022
@viswa-nvidia viswa-nvidia changed the title [RMP]Session based recommendations integration in MM [RMP]Session based recommendations integration in Merlin Jul 29, 2022
@EvenOldridge EvenOldridge changed the title [RMP]Session based recommendations integration in Merlin [RMP] Tensorflow support for session based recommendations integration in Merlin Jul 29, 2022
@EvenOldridge
Copy link
Member

@sararb @gabrielspmoreira can you flesh this out as best as possible in @marcromeyn's absence.

@EvenOldridge
Copy link
Member

@gabrielspmoreira what does the architecture look like for the system for session based? Are we planning to use session generation to feed into a candidate generation stage?

@gabrielspmoreira
Copy link
Member

@

@gabrielspmoreira what does the architecture look like for the system for session based? Are we planning to use session generation to feed into a candidate generation stage?

@EvenOldridge the session-based recommendation works as a next-item prediction task. It can be seen as a retrieval model, where the query tower users a sequential model (e.g. RNN, Transformer) and outputs a query representation/vector. During inference, such vectors can be used to retrieve the similar items from ANN the same way a retrieval model does.
So we believe we wouldn't need anything special on Merlin Systems related to the output of a session-based recommendation model. The main different is in the input, as such sequential models expect list features as input. NVTabular already supports processing and storing such list features as you know, but there might be some challenges on Systems building the Triton ensemble with list features support.

@viswa-nvidia
Copy link
Author

@karlhigley , is the systems section here updated. Pleaes review

@karlhigley
Copy link
Contributor

It is up to date with the current state of our knowledge of the work

@viswa-nvidia
Copy link
Author

viswa-nvidia commented Aug 29, 2022

@marcromeyn , in one of the meetings, I made a note that this task is dependent on some tasks covered in RMP479-EMBEDDINGS initiative [RMP] Enable users to pass embedding tables directly into the input block in order to more easily support new functionality (non-trainable embeddings, different dimensions, model parallel, etc) . Is this correct ? which are these tasks. ? @EvenOldridge for vis.

@viswa-nvidia
Copy link
Author

@rnyak , please link the systems - multi hot related development

@viswa-nvidia
Copy link
Author

@oliverholworthy , please add the input output schema related tickets to this ticket

@oliverholworthy
Copy link
Member

@viswa-nvidia For the saving method:

This is the parent issue for that:

We have implemented the save method to save input schema, but currently missing output schema.

@oliverholworthy
Copy link
Member

Also identified an error in Merlin Models that may impact ability to serve Transformer-based models that affects issues with saving a model after loading.

NVIDIA-Merlin/models#878

@viswa-nvidia
Copy link
Author

@karlhigley , please add the Triton related PR ( serving signatures haven't matched up with what model expects ) in the ticket.

@viswa-nvidia
Copy link
Author

@rnyak to follow up with @radekosmulski for blocker ( 23.04 )

@EvenOldridge
Copy link
Member

It was pointed out to me that we should be consistent about when we consider something done or not so I'm going to reopen this and move it to 22.05. @bbozkaya You've had the only remaining ticket (review the API) on your todo for the past two weeks with no progress. Is this something you're able to take on so that we can close the ticket. If not let us know and we can reassign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants