{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/bert4rec-sequential-recommendation-with","title":"BERT4Rec: Sequential Recommendation with Bidirectional Encoder Representations from Transformer","arxiv_id":"1904.06690","date":"2019-04-14","proceeding":null,"authors":["Fei Sun","Jun Liu","Jian Wu","Changhua Pei","Xiao Lin","Wenwu Ou","Peng Jiang"],"abstract":"Modeling users' dynamic and evolving preferences from their historical behaviors is challenging and crucial for recommendation systems. Previous methods employ sequential neural networks (e.g., Recurrent Neural Network) to encode users' historical interactions from left to right into hidden representations for making recommendations. Although these methods achieve satisfactory results, they often assume a rigidly ordered sequence which is not always practical. We argue that such left-to-right unidirectional architectures restrict the power of the historical sequence representations. For this purpose, we introduce a Bidirectional Encoder Representations from Transformers for sequential Recommendation (BERT4Rec). However, jointly conditioning on both left and right context in deep bidirectional model would make the training become trivial since each item can indirectly \"see the target item\". To address this problem, we train the bidirectional model using the Cloze task, predicting the masked items in the sequence by jointly conditioning on their left and right context. Comparing with predicting the next item at each position in a sequence, the Cloze task can produce more samples to train a more powerful bidirectional model. Extensive experiments on four benchmark datasets show that our model outperforms various state-of-the-art sequential models consistently.","url_abs":"https://arxiv.org/abs/1904.06690v2","url_pdf":"https://arxiv.org/pdf/1904.06690v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/FeiSun/BERT4Rec","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/UlionTse/mlgb","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"unanswered"}},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/tunghia1890/BERT4Rec_TF2x","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok"}},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/xinyooo/ALBERT4Rec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/PaddlePaddle/PaddleRec/tree/master/models/rank/bert4rec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"paddle","reach":null},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/jaywonchung/BERT4Rec-VAE-Pytorch","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"GPL-3.0"}},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/jinweiluo/BERT4Rec_AC","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"paddle","reach":null},{"paper_slug":"bert4rec-sequential-recommendation-with","repo_url":"https://github.com/vatsalsaglani/bert4rec","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"recommendation-systems","task_name":"Recommendation Systems"},{"task_slug":"sequential-recommendation","task_name":"Sequential Recommendation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/collaborative-filtering-on-movielens-1m","task":"Recommendation Systems","dataset":"MovieLens 1M","model":"BERT4Rec","rank_in_archive_order":30,"of":31,"metrics":{"HR@10 (full corpus)":"0.2843","NDCG@10 (full corpus)":"0.1537"},"uses_additional_data":false},{"leaderboard":"/sota/collaborative-filtering-on-movielens-20m","task":"Recommendation Systems","dataset":"MovieLens 20M","model":"BERT4Rec","rank_in_archive_order":17,"of":18,"metrics":{"HR@10 (full corpus)":"0.2816","nDCG@10 (full corpus)":"0.1703"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=1904.06690","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1904.06690"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/FeiSun/BERT4Rec","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/xinyooo/ALBERT4Rec","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jinweiluo/BERT4Rec_AC","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/PaddlePaddle/PaddleRec/tree/master/models/rank/bert4rec","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/UlionTse/mlgb","reach":{"status":"unanswered"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jaywonchung/BERT4Rec-VAE-Pytorch","reach":{"status":"ok","spdx":"GPL-3.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tunghia1890/BERT4Rec_TF2x","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/vatsalsaglani/bert4rec","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":1,"ran_violates":1,"unverified":4},"by_repo_kind":{"official":{"samples":5,"ran":1,"repositories":1},"listed":{"samples":1,"ran":1,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":1,"samples":[{"code_sha256_prefix":"bf6088a6a68ef09c","entry":"convert_by_vocab","repo":"FeiSun/BERT4Rec","repo_kind":"official","path":"vocab.py","file_url":"https://github.com/FeiSun/BERT4Rec/blob/HEAD/vocab.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bf6088a6a68ef09c"}},{"code_sha256_prefix":"7373b3408ee13c1c","entry":"str2bool","repo":"jinweiluo/BERT4Rec_AC","repo_kind":"listed","path":"ml1m.py","file_url":"https://github.com/jinweiluo/BERT4Rec_AC/blob/HEAD/ml1m.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7373b3408ee13c1c"}},{"code_sha256_prefix":"c6bb4fb1768a7890","entry":"data_partition","repo":"FeiSun/BERT4Rec","repo_kind":"official","path":"util.py","file_url":"https://github.com/FeiSun/BERT4Rec/blob/HEAD/util.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c6bb4fb1768a7890"}},{"code_sha256_prefix":"50fd1894a0a439a6","entry":"gelu","repo":"FeiSun/BERT4Rec","repo_kind":"official","path":"modeling.py","file_url":"https://github.com/FeiSun/BERT4Rec/blob/HEAD/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"50fd1894a0a439a6"}},{"code_sha256_prefix":"3daeda6c430de0b5","entry":"get_activation","repo":"FeiSun/BERT4Rec","repo_kind":"official","path":"modeling.py","file_url":"https://github.com/FeiSun/BERT4Rec/blob/HEAD/modeling.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3daeda6c430de0b5"}},{"code_sha256_prefix":"50958618b65e514e","entry":"get_assignment_map_from_checkpoint","repo":"FeiSun/BERT4Rec","repo_kind":"official","path":"modeling.py","file_url":"https://github.com/FeiSun/BERT4Rec/blob/HEAD/modeling.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"50958618b65e514e"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}