{"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/pre-training-large-memory-language-models","title":"Pre-training Large Memory Language Models with Internal and External Knowledge","arxiv_id":"2505.15962","date":"2025-05-21","proceeding":null,"authors":["Linxi Zhao","Sofian Zalouk","Christian K. Belardi","Justin Lovelace","Jin Peng Zhou","Kilian Q. Weinberger","Yoav Artzi","Jennifer J. Sun"],"abstract":"Neural language models are black-boxes -- both linguistic patterns and factual knowledge are distributed across billions of opaque parameters. This entangled encoding makes it difficult to reliably inspect, verify, or update specific facts. We propose a new class of language models, Large Memory Language Models (LMLM) with a pre-training recipe that stores factual knowledge in both internal weights and an external database. Our approach strategically masks externally retrieved factual values from the training loss, thereby teaching the model to perform targeted lookups rather than relying on memorization in model weights. Our experiments demonstrate that LMLMs achieve competitive performance compared to significantly larger, knowledge-dense LLMs on standard benchmarks, while offering the advantages of explicit, editable, and verifiable knowledge bases. This work represents a fundamental shift in how language models interact with and manage factual knowledge.","url_abs":"https://arxiv.org/abs/2505.15962v1","url_pdf":"https://arxiv.org/pdf/2505.15962v1.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":"pre-training-large-memory-language-models","repo_url":"https://github.com/kilian-group/lmlm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"memorization","task_name":"Memorization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2505.15962","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2505.15962"}},"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/kilian-group/lmlm","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":8},"by_repo_kind":{"official":{"samples":8,"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":"95803855c12113ac","entry":"add_shared_context_ids","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/annotate/utils.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/annotate/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"95803855c12113ac"}},{"code_sha256_prefix":"a26579611bac7338","entry":"chunk_wiki_text","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/annotate/utils.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/annotate/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a26579611bac7338"}},{"code_sha256_prefix":"802c4b89ef2911cc","entry":"extract_database","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/database/database_manager.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/database/database_manager.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"802c4b89ef2911cc"}},{"code_sha256_prefix":"1c4a4ce0a56f09bb","entry":"extract_lookups","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/database/database_manager.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/database/database_manager.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1c4a4ce0a56f09bb"}},{"code_sha256_prefix":"4dce5964827c7959","entry":"load_and_filter_dataset","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/database/extract_database.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/database/extract_database.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4dce5964827c7959"}},{"code_sha256_prefix":"a5fa7fed5e977268","entry":"register_dataset","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/annotate/dataloader.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/annotate/dataloader.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a5fa7fed5e977268"}},{"code_sha256_prefix":"0dd1a961e4577e50","entry":"truncate_sample_length","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/annotate/utils.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/annotate/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0dd1a961e4577e50"}},{"code_sha256_prefix":"ef77276b20d6ebaf","entry":"update_atomic_knowledge","repo":"kilian-group/lmlm","repo_kind":"official","path":"src/lmlm/database/database_manager.py","file_url":"https://github.com/kilian-group/lmlm/blob/HEAD/src/lmlm/database/database_manager.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ef77276b20d6ebaf"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}