NVIDIA-Merlin / Transformers4Rec

Transformers4Rec is a flexible and efficient library for sequential and session-based recommendation and works with PyTorch.
https://nvidia-merlin.github.io/Transformers4Rec/main
Apache License 2.0
1.07k stars 142 forks source link

[QST] Extracting User Representation Vectors from Pre-trained Next Item Prediction Model #766

Open jeihyunsung opened 7 months ago

jeihyunsung commented 7 months ago

❓ Questions & Help

Details

I'm currently using the Transformers4Rec for a Next Item Prediction task. I've successfully pre-trained my model, and now I wish to extract user representation vectors from this model on a user-level basis for further analysis.

Despite my efforts, I've been unable to figure out how to correctly extract the hidden vectors that represent users from the pre-trained model. Could you kindly provide some guidance or instructions on how to accomplish this?

More specifically, I've found that when I inspect the tensor in the body of the 'head' before it enters the 'NextItemPredictionTask' module in the model, it outputs the vector for all elements in the 100-length sequence after padding. My goal, however, is to extract the vector located at the variable-length final position within this sequence.

Any assistance on this matter would be greatly appreciated. Thank you.

### Tasks