HKUDS / MAERec

[SIGIR'2023] "MAERec: Graph Masked Autoencoder for Sequential Recommendation"
https://arxiv.org/abs/2305.04619
55 stars 5 forks source link

Questions about thesis datasets #3

Closed zyx1017 closed 1 year ago

zyx1017 commented 1 year ago

除了论文中使用的三个数据集,是否有办法处理其他数据集,使其也能在该模型上运行。比如ML-1M、Yelp和其他数据集。是否能提供数据集预处理的源代码呢? 另外,我对数据集的预处理操作存在些许疑问,除了对数据集进行了5-core操作,还进行了其他什么处理吗?我利用其他开源框架,比如伯乐(DuoRec的实现),始终无法重现论文中提供的数据集情况。

zyx1017 commented 1 year ago

另外,你能提供不同数据集上的超参数设置吗?我正在Toy数据集上做实验,实验结果比论文中报告的结果低得多:HR@10=0.5397,ndcg@10=0.3663。 超参数设置如下:

def ParseArgs(): parser = argparse.ArgumentParser(description='Model Params') parser.add_argument('--lr', default=1e-3, type=float, help='learning rate') parser.add_argument('--data', default='toys', type=str, help='name of dataset') parser.add_argument('--epoch', default=20, type=int, help='number of training epochs') parser.add_argument('--trn_batch', default=256, type=int, help='batch size training') parser.add_argument('--tst_batch', default=256, type=int, help='batch size for testing') parser.add_argument('--con_batch', default=2048, type=int, help='batch size for reconstruction task') parser.add_argument('--test_frequency', default=1, type=int, help='number of epoch to test while training') parser.add_argument('--max_seq_len', default=50, type=int, help='maximnm number of items in an user sequence') parser.add_argument('--num_reco_neg', default=40, type=int, help='number of negative items for reconstruction task') parser.add_argument('--reg', default=1e-6, type=float, help='weight decay regularizer') parser.add_argument('--ssl_reg', default=1e-2, type=float, help='contrastive regularizer') parser.add_argument('--latdim', default=32, type=int, help='embedding size') parser.add_argument('--mask_depth', default=5, type=int, help='k steps for generating transitional path') parser.add_argument('--path_prob', default=0.5, type=float, help='random walk sample probability') parser.add_argument('--num_attention_heads', default=4, type=int, help='number of heads in attention') parser.add_argument('--num_gcn_layers', default=2, type=int, help='number of gcn layers') parser.add_argument('--num_trm_layers', default=2, type=int, help='number of trm layers') parser.add_argument('--load_model', default=None, help='model name to load') parser.add_argument('--num_mask_cand', default=50, type=int, help='number of seeds in patch masking') parser.add_argument('--mask_steps', default=10, type=int, help='steps to train on the same sampled graph') parser.add_argument('--eps', default=0.2, type=float, help='scaled weight for task-adaptive function') parser.add_argument("--attention_probs_dropout_prob", type=float, default=0.3, help="attention dropout p") parser.add_argument("--hidden_dropout_prob", type=float, default=0.3, help="hidden dropout p") parser.add_argument('--save_path', default='tem', help='file name to save model and training record') return parser.parse_args()

HelloElwin commented 1 year ago

你好,谢谢反馈!

第一个问题: 我们后续会上传数据集处理方法,请关注 repo 动态。

第二个问题: 我们在 repo 的代码上实验也发现了这个问题,正在检查是否代码有 bug。在我们的实验代码中 paper 的结果是可以得到的(见下方记录),我们会在检查发现问题后更新 repo。

谢谢!

Test result: h5=0.1006 n5=0.0598 h10=0.1988 n10=0.0912 h20=0.3964 n20=0.1405 h50=0.6251 n50=0.1883
Test result: h5=0.2979 n5=0.2331 h10=0.3280 n10=0.2430 h20=0.3487 n20=0.2482 h50=0.4027 n50=0.2583
2023-01-02 14:59:58.829740: Epoch 0/20, Test: hr@10 = 0.3280, ndcg@10 = 0.2430                   
Test result: h5=0.4460 n5=0.3364 h10=0.5449 n10=0.3685 h20=0.6237 n20=0.3886 h50=0.6878 n50=0.4015
2023-01-02 15:07:50.173155: Epoch 1/20, Test: hr@10 = 0.5449, ndcg@10 = 0.3685                   
Test result: h5=0.4646 n5=0.3530 h10=0.5666 n10=0.3861 h20=0.6477 n20=0.4067 h50=0.7037 n50=0.4181
2023-01-02 15:15:25.057321: Epoch 2/20, Test: hr@10 = 0.5666, ndcg@10 = 0.3861                   
Test result: h5=0.4620 n5=0.3553 h10=0.5525 n10=0.3846 h20=0.6284 n20=0.4039 h50=0.6902 n50=0.4164
2023-01-02 15:22:47.133739: Epoch 3/20, Test: hr@10 = 0.5525, ndcg@10 = 0.3846                   
Test result: h5=0.4733 n5=0.3620 h10=0.5730 n10=0.3943 h20=0.6594 n20=0.4163 h50=0.7226 n50=0.4291
2023-01-02 15:35:49.306544: Epoch 4/20, Test: hr@10 = 0.5730, ndcg@10 = 0.3943                   
Test result: h5=0.4783 n5=0.3656 h10=0.5831 n10=0.3995 h20=0.6778 n20=0.4236 h50=0.7486 n50=0.4380
2023-01-02 15:53:52.193846: Epoch 5/20, Test: hr@10 = 0.5831, ndcg@10 = 0.3995                   
Test result: h5=0.4763 n5=0.3658 h10=0.5797 n10=0.3993 h20=0.6782 n20=0.4242 h50=0.7709 n50=0.4430
2023-01-02 16:12:52.744793: Epoch 6/20, Test: hr@10 = 0.5797, ndcg@10 = 0.3993                   
Test result: h5=0.4667 n5=0.3614 h10=0.5566 n10=0.3906 h20=0.6394 n20=0.4115 h50=0.7177 n50=0.4273
2023-01-02 16:32:05.147821: Epoch 7/20, Test: hr@10 = 0.5566, ndcg@10 = 0.3906                   
Test result: h5=0.4786 n5=0.3683 h10=0.5796 n10=0.4010 h20=0.6814 n20=0.4268 h50=0.7807 n50=0.4469
2023-01-02 16:54:00.512639: Epoch 8/20, Test: hr@10 = 0.5796, ndcg@10 = 0.4010                   
Test result: h5=0.4828 n5=0.3712 h10=0.5902 n10=0.4060 h20=0.7009 n20=0.4340 h50=0.8201 n50=0.4581
2023-01-02 17:17:48.660084: Epoch 9/20, Test: hr@10 = 0.5902, ndcg@10 = 0.4060                   
Test result: h5=0.4788 n5=0.3670 h10=0.5827 n10=0.4007 h20=0.6866 n20=0.4269 h50=0.7919 n50=0.4482
2023-01-02 17:41:57.297021: Epoch 10/20, Test: hr@10 = 0.5827, ndcg@10 = 0.4007                   
Test result: h5=0.4813 n5=0.3693 h10=0.5887 n10=0.4040 h20=0.7001 n20=0.4322 h50=0.8205 n50=0.4565
2023-01-02 18:06:30.819168: Epoch 11/20, Test: hr@10 = 0.5887, ndcg@10 = 0.4040                   
Test result: h5=0.4817 n5=0.3694 h10=0.5907 n10=0.4047 h20=0.7051 n20=0.4336 h50=0.8297 n50=0.4588
2023-01-02 18:30:17.552507: Epoch 12/20, Test: hr@10 = 0.5907, ndcg@10 = 0.4047                   
Test result: h5=0.4809 n5=0.3690 h10=0.5855 n10=0.4029 h20=0.6931 n20=0.4300 h50=0.8073 n50=0.4531
2023-01-02 18:55:26.106688: Epoch 13/20, Test: hr@10 = 0.5855, ndcg@10 = 0.4029                   
Test result: h5=0.4823 n5=0.3706 h10=0.5864 n10=0.4042 h20=0.6968 n20=0.4321 h50=0.8197 n50=0.4569
2023-01-02 19:19:09.100911: Epoch 14/20, Test: hr@10 = 0.5864, ndcg@10 = 0.4042                   
Test result: h5=0.4809 n5=0.3688 h10=0.5905 n10=0.4043 h20=0.7072 n20=0.4338 h50=0.8327 n50=0.4592
2023-01-02 19:41:36.228113: Epoch 15/20, Test: hr@10 = 0.5905, ndcg@10 = 0.4043                   
Test result: h5=0.4824 n5=0.3695 h10=0.5883 n10=0.4038 h20=0.6977 n20=0.4315 h50=0.8159 n50=0.4554
2023-01-02 20:04:14.376868: Epoch 16/20, Test: hr@10 = 0.5883, ndcg@10 = 0.4038                   
Test result: h5=0.4838 n5=0.3705 h10=0.5982 n10=0.4075 h20=0.7231 n20=0.4390 h50=0.8614 n50=0.4669
2023-01-02 20:25:49.133451: Epoch 17/20, Test: hr@10 = 0.5982, ndcg@10 = 0.4075                   
Test result: h5=0.4758 n5=0.3668 h10=0.5732 n10=0.3983 h20=0.6692 n20=0.4226 h50=0.7693 n50=0.4428
2023-01-02 20:47:32.271552: Epoch 18/20, Test: hr@10 = 0.5732, ndcg@10 = 0.3983                   
Test result: h5=0.4796 n5=0.3679 h10=0.5840 n10=0.4017 h20=0.6901 n20=0.4285 h50=0.8003 n50=0.4508
2023-01-02 21:08:50.882182: Epoch 19/20, Test: hr@10 = 0.5840, ndcg@10 = 0.4017                   
Test result: h5=0.4796 n5=0.3679 h10=0.5840 n10=0.4017 h20=0.6901 n20=0.4285 h50=0.8003 n50=0.4508
2023-01-02 21:09:53.262385: Epoch 20/20, Test: hr@10 = 0.5840, ndcg@10 = 0.4017
zyx1017 commented 1 year ago

@HelloElwin 感谢回复!所以说三个数据集用的都是相同的超参数(即默认的)进行实验吗吗?

HelloElwin commented 1 year ago

@zyx1017 是的,用默认超参数即可得到相近的结果,因为在实验的三个数据集中默认设置就是最优超参数或对效果影响不明显(可见超参数实验)。

另:已经更新数据集的格式要求及 i-i 图预处理代码,可以参考运行其他数据集。

zyx1017 commented 1 year ago

@HelloElwin 那就可能repo 的代码确实有点问题,我正在跑books数据集,目前12个epoch最优结果是Best Result: hr@10 = 0.7493, ndcg@10 = 0.5465 ,与论文所报结果hr@10=0.7723,ndcg@10=0.5720有差异。而理论上12个epoch已经接近收敛了。 希望能尽快检查错误并更新repo!感谢

zyx1017 commented 1 year ago

@HelloElwin 您好!文中的实验好像数据集并没有划分验证集,而是只划分了训练集和测试集,并取每次测试集中最优的结果作为最终结果,而一般论文的做法是划分训练集、验证集和测试集,取验证集上表现最优的参数再在测试集上报最终的结果,这样一般这个结果会比测试集最优的低,文中这样做是否存在差异?

zyx1017 commented 1 year ago

@HelloElwin 请问能提供将原始数据处理成seq\neg\tst的方法吗?

zyx1017 commented 1 year ago

@HelloElwin 你好!当我使用--load_model这个超参数加载之前训练完20个epoch的模型时,为什么模型还会接着训练而不是报告前20个epoch的结果? 而且接着训练后的结果比前20个epoch的结果高,但是理论上不是第10个左右的epoch就已经收敛了吗? parser.add_argument('--load_model', default=tem, help='model name to load')

HelloElwin commented 1 year ago

代码已经更新;验证集是用于调整超参数,我们使用验证集获得最优超参数后报告了相应的结果,repo 中的代码不涉及调参功能,所以没有单独划分验证集,注意最后验证集是和训练集一起训练模型,汇报测试集的结果;处理原始数据烦请参考特定的数据集的格式来实现;load_model 是加载模型继续训练,结果可能在小范围内波动。

zyx1017 commented 1 year ago

@HelloElwin 谢谢你的回复! 请问能提供将原始数据处理成seq\neg\tst的方法吗?我想处理自己的数据集

HelloElwin commented 1 year ago

不同数据集的格式不一样,这里没有统一的代码。只需要参考 seq/neg/tst 的格式处理即可,烦请自行实现。

zyx1017 commented 1 year ago

@HelloElwin 我打开seq\neg\tst这几个文件都是乱码,请问怎样才能读到这些文件的格式?能否提供你们处理某个数据集的示例代码作为参考呢

HelloElwin commented 1 year ago

这些不是文本文件,请参考 handler.py 用 Python 打开,时间有限不能帮上所有忙,请自行实现呀。

zyx1017 commented 1 year ago

@HelloElwin 好的!谢谢你

zyx1017 commented 1 year ago

@HelloElwin 你好,更新后的代码你有重新跑过他的效果嘛?我跑了下好像还是跟之前差不多?

HelloElwin commented 1 year ago

你好,请参考 ArXiv 上更新后的实验结果,repo 的代码固定了随机种子和之前的实验效果有略微差距。