NVIDIA-Merlin / NVIDIA-Merlin/Transformers4Rec
[QST] How to use session-level (single) and item-level (sequence) features together in next item prediction task?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 165
- Avg merge
- 1m
- Merged PRs (30d)
- 2
Description
❓ Questions & Help
Existing examples in session-based/sequential recommendations only use item-level, sequence-based features.
However, in many real-world scenarios, we do have access to either user/session features (e.g. user demographics or session contextual information)
For item-level sequence features, one uses tr.TabularSequenceFeatures
I am curious about how to combine tr.TabularSequenceFeatures with user-/session- level features tr.TabularFeatures and feed to PredictionTask via an aggregator.
Details
To be more specific, taking this notebook as an example
In cell 5, we define an input module for item-level sequence.
inputs = tr.TabularSequenceFeatures.from_schema(
schema,
max_sequence_length= sequence_length,
masking = 'causal',
)
and then define a GRU model to process sequences
body = tr.SequentialBlock(
inputs,
tr.MLPBlock([d_model]),
tr.Block(torch.nn.GRU(input_size=d_model, hidden_size=d_model, num_layers=1), [None, 20, d_model])
)
However, if we have various user/session level features, say processed by NVT with column name *-first, e.g. age-first, gender-first, ...
Q: How should I integrate these features into the model above?
What I expected to have:
seq_inputs = tr.TabularSequenceFeatures.from_schema(
schema,
max_sequence_length= sequence_length,
masking = 'causal',
)
seq_body = tr.SequentialBlock(
seq_inputs,
tr.MLPBlock([d_model]),
tr.Block(torch.nn.GRU(input_size=d_model, hidden_size=d_model, num_layers=1), [None, 20, d_model])
)
context_inputs = tr.TabularFeatures.from_schema(
schema_context
)
context_body = tr.SequentialBlock(
context_inputs,
tr.MLPBlock([d_model]),
)
body = tr.BlockAggregator([seq_body, context_body])
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/tutorial/03-Session-based-recsys.ipynb and the TabularSequenceFeatures and TabularFeatures APIs shown in the issue. Determine how sequence and session inputs can be combined for the PredictionTask, then document or demonstrate a working integration whose behavior is validated in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100