{"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/kblam-knowledge-base-augmented-language-model","title":"KBLaM: Knowledge Base augmented Language Model","arxiv_id":"2410.10450","date":"2024-10-14","proceeding":null,"authors":["Xi Wang","Liana Mikaelyan","Taketomo Isazawa","James Hensman"],"abstract":"In this paper, we propose Knowledge Base augmented Language Model (KBLaM), a new method for augmenting Large Language Models (LLMs) with external knowledge. KBLaM works with a knowledge base (KB) constructed from a corpus of documents, transforming each piece of knowledge in the KB into continuous key-value vector pairs via pre-trained sentence encoders with linear adapters and integrating them into pre-trained LLMs via a specialized rectangular attention mechanism. Unlike Retrieval-Augmented Generation, KBLaM eliminates external retrieval modules, and unlike in-context learning, its computational overhead scales linearly with KB size rather than quadratically. Our approach enables integrating a large KB of more than 10K triples into an 8B pre-trained LLM of only 8K context window on one single A100 80GB GPU and allows for dynamic updates without model fine-tuning or retraining. Experiments demonstrate KBLaM's effectiveness in various tasks, including question-answering and open-ended reasoning, while providing interpretable insights into its use of the augmented knowledge.","url_abs":"https://arxiv.org/abs/2410.10450v1","url_pdf":"https://arxiv.org/pdf/2410.10450v1.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":"kblam-knowledge-base-augmented-language-model","repo_url":"https://github.com/microsoft/KBLaM","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":null,"task_name":"8k"},{"task_slug":null,"task_name":"GPU"},{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"retrieval-augmented-generation","task_name":"Retrieval-augmented Generation"},{"task_slug":"sentence","task_name":"Sentence"},{"task_slug":"model","task_name":"model"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"base","method_name":"BASE"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.10450","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.10450"}},"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/microsoft/KBLaM","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran_draft_wrong":2,"ran":7,"unverified":2},"by_repo_kind":{"official":{"samples":12,"ran":10,"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":"30d7eec482ebf6b1","entry":"repeat_kv","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/models/phi3_model.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/models/phi3_model.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"30d7eec482ebf6b1"}},{"code_sha256_prefix":"bac65c3dafaec040","entry":"apply_rotary_pos_emb","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/models/phi3_model.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/models/phi3_model.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bac65c3dafaec040"}},{"code_sha256_prefix":"b637ec4d09efd87a","entry":"augment_row","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/data_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b637ec4d09efd87a"}},{"code_sha256_prefix":"5ae367d48b7472b4","entry":"flatten_results","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/convert.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/convert.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5ae367d48b7472b4"}},{"code_sha256_prefix":"1678f5c073a8f27c","entry":"generate_multi_entity_qa","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/data_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1678f5c073a8f27c"}},{"code_sha256_prefix":"f4e9b9d1039240fe","entry":"get_tensor_config","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/train_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/train_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f4e9b9d1039240fe"}},{"code_sha256_prefix":"0a99bb4b105d8a29","entry":"kb_to_embd","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/train_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/train_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0a99bb4b105d8a29"}},{"code_sha256_prefix":"8449c385fd07972f","entry":"load_entities","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/data_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8449c385fd07972f"}},{"code_sha256_prefix":"93e612ddac75f8b5","entry":"preprocess_embds","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/train_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/train_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"93e612ddac75f8b5"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/models/phi3_model.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/models/phi3_model.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"334ab7b8c7440f2c","entry":"get_projector","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/kb_encoder.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/kb_encoder.py","link_basis":"first_harvest_node","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":"334ab7b8c7440f2c"}},{"code_sha256_prefix":"aa519f4c344d1787","entry":"softmax","repo":"microsoft/KBLaM","repo_kind":"official","path":"src/kblam/utils/eval_utils.py","file_url":"https://github.com/microsoft/KBLaM/blob/HEAD/src/kblam/utils/eval_utils.py","link_basis":"first_harvest_node","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":"aa519f4c344d1787"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}