UniSRec icon indicating copy to clipboard operation
UniSRec copied to clipboard

Requesting Guidance on Extracting User and Item Embeddings

Open niluminous opened this issue 9 months ago • 1 comments

Hello,

I am currently working on predicting ratings by calculating the dot product of user embeddings and item embeddings. I am considering using the Universal Sequence Representation module for user sequences and the MOE-enhanced adaptor for item embeddings.

However, I am unsure about how to properly extract these embeddings in UniSREC code. Could anyone provide some guidance or sample code on how to access these embeddings from the mentioned modules?

Thank you in advance for your help!

niluminous avatar Apr 29 '24 05:04 niluminous

Hi, sorry for the late reply!

1. Loading existing checkpoints

Below is an example of loading UniSRec models (either pretrained or fine-tuned).

https://github.com/RUCAIBox/UniSRec/blob/05aa5cba2809112c32808f70d16abc61c05c6538/finetune.py#L37-L40

2. Mapping external IDs to internal IDs

Here is an example of mapping the external user/item IDs (str, stored in .inter files) to internal IDs (int, remapped IDs stored in RecBole framework).

https://github.com/RUCAIBox/RecBole/blob/2b6e209372a1a666fe7207e6c2a96c7c3d49b427/run_example/case_study_example.py#L25

3. Extracting representations

Please refer to the following code:

https://github.com/RUCAIBox/UniSRec/blob/05aa5cba2809112c32808f70d16abc61c05c6538/unisrec.py#L174-L187

hyp1231 avatar Jun 16 '24 06:06 hyp1231