KBLaM: Knowledge Base Augmented Language Models for Enhanced LLMs
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
KBLaM, developed by Microsoft, is the official implementation of "Knowledge Base Augmented Language Models" presented at ICLR 2025. This innovative method enhances Large Language Models by directly integrating external knowledge bases, offering an efficient alternative to traditional Retrieval-Augmented Generation (RAG) and in-context learning. It eliminates external retrieval modules and scales computationally linearly with knowledge base size, rather than quadratically.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
KBLaM, developed by Microsoft, is the official implementation of "Knowledge Base Augmented Language Models" (ICLR 2025). This project introduces a novel approach to augmenting Large Language Models (LLMs) with external knowledge. Unlike Retrieval-Augmented Generation (RAG), KBLaM eliminates the need for external retrieval modules, and it offers a significant advantage over in-context learning by ensuring its computational overhead scales linearly with the knowledge base size, rather than quadratically. This makes KBLaM a promising solution for integrating vast amounts of knowledge into LLMs more efficiently.
Installation
Getting started with KBLaM is straightforward. You can install the package directly from the repository:
pip install -e .
To utilize Llama models, you will need to generate a token from Hugging Face and log in via the command line:
pip install huggingface_hub
huggingface-cli login
Examples
KBLaM provides tools for synthetic dataset construction and model training. For dataset generation, you'll need an Azure OpenAI endpoint. You can construct synthetic knowledge bases and question-answer pairs using dataset_generation/gen_synthetic_data.py and generate KB embeddings with dataset_generation/generate_kb_embeddings.py. Supported embeddings include text-embedding-ada-002 and all-MiniLM-L6-v2.
An example of model training is provided:
python train.py --dataset_dir <Your dataset directory> --train_dataset synthetic --N 120000 --B 20 --total_steps 601 --encoder_spec OAI --use_oai_embd --key_embd_src key --use_data_aug --use_cached_embed
It is recommended to use the --use_cached_embed argument to prevent recomputation of embeddings, which can be time-consuming.
Why Use KBLaM
KBLaM offers a compelling alternative for enhancing LLMs with knowledge. Its core strength lies in its ability to directly integrate knowledge without external retrieval, leading to improved efficiency and scalability. The method trains adapters over the knowledge part, leaving the base LLM unmodified for text input. This means if no knowledge base is provided, the model behaves exactly like the base model. KBLaM is intended for research purposes, focusing on accuracy of retrieval, refusal rate, and alignment of answers with the knowledge base. It currently supports popular models like meta-llama/Meta-Llama-3-8B-Instruct, meta-llama/Llama-3.2-1B-Instruct, and microsoft/Phi-3-mini-4k-instruct.
Links
- GitHub Repository: https://github.com/microsoft/KBLaM
- arXiv Paper: KBLaM: Knowledge Base Augmented Language Models
- Hugging Face - Llama-3-8B-Instruct: https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct
- Hugging Face - Phi-3-mini-4k-instruct: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct
Related repositories
Similar repositories that may be relevant next.

rag-zero-to-hero-guide: Your Comprehensive Path to Mastering RAG
July 7, 2026
This repository offers a comprehensive guide to Retrieval-Augmented Generation (RAG), covering everything from fundamental concepts to advanced techniques. It includes detailed courses on RAG basics and evaluation, alongside an extensive toolkit of frameworks, libraries, and research papers. Ideal for AI engineers and LLM enthusiasts, this resource provides a structured learning path for building and optimizing RAG systems.

Jsonformer: Bulletproof Structured JSON Generation from Language Models
June 27, 2026
Jsonformer is a powerful library designed to generate syntactically correct and schema-conforming JSON from language models. It addresses the common challenge of unreliable JSON output by focusing on generating only content tokens, making the process more efficient and robust. This approach ensures bulletproof structured data generation for various applications.

Qwen3-VL: A Powerful Multimodal Large Language Model Series
June 15, 2026
Qwen3-VL is a cutting-edge multimodal large language model series from Alibaba Cloud's Qwen team. It offers significant advancements in visual and text understanding, extended context length, and enhanced agent capabilities. This model is designed for flexible deployment, scaling from edge to cloud.

rag-from-scratch: Building Retrieval Augmented Generation Systems
April 30, 2026
This repository by LangChain AI offers a comprehensive guide to understanding and implementing Retrieval Augmented Generation (RAG) from scratch. It includes a series of Jupyter notebooks and an accompanying video playlist, making complex RAG concepts accessible for practical application. The resource highlights RAG's advantages over fine-tuning for factual recall in Large Language Models (LLMs).
Source repository
Open the original repository on GitHub.
12 counted GitHub visits