{"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/patchrec-multi-grained-patching-for-efficient","title":"Multi-Grained Patch Training for Efficient LLM-based Recommendation","arxiv_id":"2501.15087","date":"2025-01-25","proceeding":null,"authors":["Jiayi Liao","Ruobing Xie","Sihang Li","Xiang Wang","Xingwu Sun","Zhanhui Kang","Xiangnan He"],"abstract":"Large Language Models (LLMs) have emerged as a new paradigm for recommendation by converting interacted item history into language modeling. However, constrained by the limited context length of LLMs, existing approaches have to truncate item history in the prompt, focusing only on recent interactions and sacrificing the ability to model long-term history. To enable LLMs to model long histories, we pursue a concise embedding representation for items and sessions. In the LLM embedding space, we construct an item's embedding by aggregating its textual token embeddings; similarly, we construct a session's embedding by aggregating its item embeddings. While efficient, this way poses two challenges since it ignores the temporal significance of user interactions and LLMs do not natively interpret our custom embeddings. To overcome these, we propose PatchRec, a multi-grained patch training method consisting of two stages: (1) Patch Pre-training, which familiarizes LLMs with aggregated embeddings -- patches, and (2) Patch Fine-tuning, which enables LLMs to capture time-aware significance in interaction history. Extensive experiments show that PatchRec effectively models longer behavior histories with improved efficiency. This work facilitates the practical use of LLMs for modeling long behavior histories. Codes are available at https://github.com/ljy0ustc/PatchRec.","url_abs":"https://arxiv.org/abs/2501.15087v2","url_pdf":"https://arxiv.org/pdf/2501.15087v2.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":"patchrec-multi-grained-patching-for-efficient","repo_url":"https://github.com/ljy0ustc/patchrec","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"recommendation-systems","task_name":"Recommendation Systems"},{"task_slug":"sequential-recommendation","task_name":"Sequential Recommendation"}],"methods":[{"method_slug":"patching","method_name":"Patching"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2501.15087","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2501.15087"}},"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/ljy0ustc/patchrec","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":6},"by_repo_kind":{"official":{"samples":6,"ran":0,"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":0,"samples":[{"code_sha256_prefix":"cf7fde4d9e4d2fa8","entry":"calculate_rank","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"fti_eval.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/fti_eval.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":"cf7fde4d9e4d2fa8"}},{"code_sha256_prefix":"bb6b20e5f73b4cc8","entry":"compute_hr","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"calculate_metrics.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/calculate_metrics.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":"bb6b20e5f73b4cc8"}},{"code_sha256_prefix":"0be4a1e2462bbe27","entry":"compute_ndcg","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"calculate_metrics.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/calculate_metrics.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":"0be4a1e2462bbe27"}},{"code_sha256_prefix":"c123a166cec965e8","entry":"get_data","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/utils.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":"c123a166cec965e8"}},{"code_sha256_prefix":"dbc74734ab6c8fcf","entry":"get_id2title","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/utils.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":"dbc74734ab6c8fcf"}},{"code_sha256_prefix":"7fcc27faf959d335","entry":"get_prompt","repo":"ljy0ustc/patchrec","repo_kind":"official","path":"utils.py","file_url":"https://github.com/ljy0ustc/patchrec/blob/HEAD/utils.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":"7fcc27faf959d335"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}