{"id":13774811,"url":"https://github.com/yihong-chen/neural-collaborative-filtering","last_synced_at":"2025-05-11T07:30:51.386Z","repository":{"id":51539420,"uuid":"125520219","full_name":"yihong-chen/neural-collaborative-filtering","owner":"yihong-chen","description":"pytorch version of neural collaborative filtering","archived":false,"fork":false,"pushed_at":"2024-05-05T05:19:05.000Z","size":14643,"stargazers_count":449,"open_issues_count":3,"forks_count":144,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-18T20:43:32.730Z","etag":null,"topics":["collaborative-filtering","deep-learning","matrix-factorization","python","recommender-systems"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yihong-chen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-16T13:31:30.000Z","updated_at":"2024-05-16T08:37:36.000Z","dependencies_parsed_at":"2024-05-05T06:34:46.796Z","dependency_job_id":null,"html_url":"https://github.com/yihong-chen/neural-collaborative-filtering","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihong-chen%2Fneural-collaborative-filtering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihong-chen%2Fneural-collaborative-filtering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihong-chen%2Fneural-collaborative-filtering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yihong-chen%2Fneural-collaborative-filtering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yihong-chen","download_url":"https://codeload.github.com/yihong-chen/neural-collaborative-filtering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253533089,"owners_count":21923361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-filtering","deep-learning","matrix-factorization","python","recommender-systems"],"created_at":"2024-08-03T17:01:30.573Z","updated_at":"2025-05-11T07:30:47.329Z","avatar_url":"https://github.com/yihong-chen.png","language":"Jupyter Notebook","funding_links":[],"categories":["Recommender Systems"],"sub_categories":[],"readme":"# neural-collaborative-filtering\nNeural collaborative filtering(NCF), is a deep learning based framework for making recommendations. The key idea is to learn the user-item interaction using neural networks. Check the follwing paper for details about NCF.\n\n\u003e He, Xiangnan, et al. \"Neural collaborative filtering.\" Proceedings of the 26th International Conference on World Wide Web. International World Wide Web Conferences Steering Committee, 2017.\n\nThe authors of NCF actually published [a nice implementation](https://github.com/hexiangnan/neural_collaborative_filtering) written in tensorflow(keras). This repo instead provides my implementation written in **pytorch**. I hope it would be helpful to pytorch fans. Have fun playing with it!\n\n## Run!\n```bash\npython train.py\n```\nmodify the config in `train.py` to change the hyper-parameters.\n\n## Dataset\n[The Movielens 1M Dataset](http://grouplens.org/datasets/movielens/1m/) is used to test the repo.\n\n## Files\n\n\u003e `data.py`: prepare train/test dataset\n\u003e\n\u003e `utils.py`: some handy functions for model training etc.\n\u003e\n\u003e `metrics.py`: evaluation metrics including hit ratio(HR) and NDCG\n\u003e\n\u003e `gmf.py`: generalized matrix factorization model\n\u003e\n\u003e `mlp.py`: multi-layer perceptron model\n\u003e\n\u003e `neumf.py`: fusion of gmf and mlp\n\u003e\n\u003e `engine.py`: training engine\n\u003e\n\u003e `train.py`: entry point for train a NCF model\n\n## Performance\nThe hyper params are not tuned. Better performance can be achieved with careful tuning, especially for the MLP model. Pretraining the user embedding \u0026 item embedding might be helpful to improve the performance of the MLP model. \n\nExperiments' results with `num_negative_samples = 4` and `dim_latent_factor=8`  are shown as follows\n\n![GMF V.S. MLP](./res/figure/factor8neg4.png)\n\nNote that the MLP model was trained from scratch but the authors suggest that the performance might be boosted by pretrain the embedding layer with GMF model.\n\n![NeuMF pretrain V.S no pretrain](./res/figure/neumf_factor8neg4.png)\n\nThe pretrained version converges much faster.\n\n### L2 regularization for GMF model\nLarge l2 regularization might lead to the bug of  `HR=0.0 NDCG=0.0`\n\n### L2 regularization for MLP model\na bit l2 regulzrization seems to improve the performance of the MLP model\n\n![L2 for MLP](./res/figure/mlp_l2_reg.png)\n\n### MLP with pretrained user/item embedding\nPre-training the MLP model with user/item embedding from the trained GMF gives better result.\n\nMLP network size = [16, 64, 32, 16, 8]\n\n![Pretrain for MLP](./res/figure/mlp_pretrain_hr.png)\n![Pretrain for MLP](./res/figure/mlp_pretrain_ndcg.png)\n\n### Implicit feedback without pretrain\nRatings are set to 1 (interacted) or 0 (uninteracted). Train from scratch.\n![binarize](./res/figure/binarize.png) \n\n## CPU training\nThe code can also run on CPUs and actually pretty fast for small datasets.\n## Requirements\nThe repo works under torch 1.0 (gpu\u0026cpu) and torch 2.3.1(cpu, gpu yet to be tested). You can find the old versions in **tags**.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyihong-chen%2Fneural-collaborative-filtering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyihong-chen%2Fneural-collaborative-filtering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyihong-chen%2Fneural-collaborative-filtering/lists"}