RUCAIBox / RecBole

A unified, comprehensive and efficient recommendation library
https://recbole.io/
MIT License
3.35k stars 603 forks source link

[🐛BUG] Sequential Model Inference Problem #1798

Open Woo-Yeol opened 1 year ago

Woo-Yeol commented 1 year ago

Describe the bug

I'm using the RecBole framework, and I'm having a problem with the code that converts the user-item interaction matrix to a CSR-formatted matrix in the reference function of the sequential model, and I'm not getting the reference to proceed properly.

While debugging, I found the following issue.

The code to convert the dataset object to a CSR matrix cannot be executed because the dataset object does not have a column named item_length, and that column is created when proceeding with the data_prepagation() function, not with create_dataset().

Also, the output of the data_prepagation() function is a data loader object, so the function cannot be executed normally.

Here is the code: https://github.com/RUCAIBox/RecBole/blob/master/run_example/sequential-model-fixed-missing-last-item.ipynb

I have since written code that references the above code to train a model on my custom movie lens dataset, and I am getting the error again because the item_length column is missing.

How can you resolve the following issues?


Expected behavior A clear and concise description of what you expected to happen.

If I'm approaching this the wrong way, I'd like to ask for advice, and if there's something wrong with the code, I'd like to ask for improvements.


Screenshots If applicable, add screenshots to help explain your problem.

Traceback (most recent call last):
  File "inference.py", line 64, in <module>
    prediction = generate_predict_seq(
  File "/opt/ml/input/code/level2_movierecommendation-recsys-04/utils.py", line 116, in generate_predict_seq
    temp = predict_for_all_item(user, dataset, test_data, model, config)
  File "/opt/ml/input/code/level2_movierecommendation-recsys-04/utils.py", line 40, in predict_for_all_item
    uid_series = dataset.token2id(dataset.uid_field, [external_user_id])
  File "/opt/ml/input/code/level2_movierecommendation-recsys-04/.venv/lib/python3.8/site-packages/recbole/data/dataloader/abstract_dataloader.py", line 112, in __getattribute__
    return super().__getattribute__(__name)
AttributeError: 'TrainDataLoader' object has no attribute 'token2id'

Desktop (please complete the following information):

Sherry-XLL commented 1 year ago

Hello @Woo-Yeol! Thanks for your attention to RecBole!

Generally speaking, after the dataset is processed, we will call the dataset's inter_matrix function to create a sparse matrix such as coo and csr as follows. At this time, the output result does not depend on the item_length column.

https://github.com/RUCAIBox/RecBole/blob/a757b7c31bfa407c82847b4a06c8580fa1a6b45e/recbole/model/general_recommender/lightgcn.py#L47-L48

Please provide the detailed code of the issue you mentioned so that we can better solve your problem.