KBLaM
A research method, from Microsoft, for augmenting a language model with an external knowledge base without a separate retrieval step, so the added computation grows linearly rather than quadratically.
KBLaM, Knowledge Base Augmented Language Models, is the official implementation of a research method for adding external knowledge to a language model. Unlike Retrieval-Augmented Generation, it does not use a separate retrieval module, and unlike in-context learning, its computational cost scales linearly with the size of the knowledge base instead of quadratically.
The repository supports Meta-Llama-3-8B-Instruct, Llama-3.2-1B-Instruct and Phi-3-mini-4k-instruct out of the box, with adapters for adding further models, and includes scripts for constructing a synthetic knowledge base and question-answer pairs, generating knowledge-base embeddings, and training the model. It is distributed as Jupyter notebooks and Python scripts under the MIT license, and its findings were published at ICLR 2025.