[来源关键摘录] Official inference framework (bitnet.cpp) for 1-bit LLMs offering fast and lossless inference on CPUs.
[正文前段节选] Skip to content
Navigation Menu
Appearance settings
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
Repository navigation
NotificationsYou must be signed in to change notification settings
Star42.4k (42.4k)You must be signed in to star a repository
Official inference framework for 1-bit LLMs
Code of conduct
Security policy
Custom properties
376 watching
Report repository
BranchesTags
Open more actions menu
Latest commit
Folders and files
Last commit message
Last commit date
preset_kernels
CMakeLists.txt
CODE_OF_CONDUCT.md
requirements.txt
run_inference.py
run_inference_server.py
setup_env.py
View all files
Repository files navigation
07/23/2026: 📣 We released VibeASR.cpp — a real-time multilingual ASR inference engine on CPU using BitNet I2_S quantization, achieving RTF < 1 with very few threads on x86 (AVX2) and ARM (NEON) platforms. [Code] [Models] [Report]
07/20/2026: 📣 We released BitNet-embedding-0.6B and BitNet-embedding-270M on Hugging Face — the first 1-bit embedding models that deliver competitive embedding quality with significantly faster inference on CPUs.
1.42x to 2.28x speedup over F16 on BitNet-embedding-0.6B prefill (8 threads)
1.32x to 1.74x speedup over F16 on BitNet-embedding-270M prefill (8 threads)
Supports I2_S conversion with optimized kernels on x86 CPUs
Lossless inference with 2 bits per weight
07/16/2026: 📣 Released BitNet Embeddings 0.6B/270M: I2_S Conversion and Inference Optimization — detailed guide for converting and running BitNet embedding models with optimized I2_S kernels.
01/15/2026: 📣 Released BitNet CPU Inference Optimization — parallel kernel implementations with configurable tiling and embedding quantization support, achieving 1.15x to 2.1x additional speedup over the original implementation.
05/20/2025: 📣 Released BitNet Official GPU inference kernel — extending 1-bit inference beyond CPUs.
04/14/2025: 📣 Released BitNet Official 2B Parameter Model on Hugging Face — the first official BitNet b1.58 model trained with 4T tokens.
02/18/2025: 📑 Bitnet.cpp: Efficient Edge Inference for Ternary LLMs — system-level paper on bitnet.cpp's architecture and design.
11/08/2024: 📑 BitNet a4.8: 4-bit Activations for 1-bit LLMs — enabling 4-bit activations for further efficiency gains.
10/21/2024: 📑 1-bit AI Infra: Part 1.1, Fast and Lossless BitNet b1.58 Inference on CPUs — the technical report behind bitnet.cpp.
10/17/2024: 📣 bitnet.cpp 1.0 released.
03/21/2024: 📑 The-Era-of-1-bit-LLMs: Training Tips, Code, FAQ
02/27/2024: 📑 The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits — the foundational paper introducing BitNet b1.58.
10/17/2023: 📑 BitNet: Scaling 1-bit Transformers for Large Language Models — the original BitNet paper.
bitnet.cpp is the official inference framework for 1-bit LLMs (e.g., BitNet b1.58). It offers a suite of optimized kernels that support fast and lossless inference of 1.58-bit models on CPU and GPU (NPU support coming next).
Try it out via this online demo, or build and run it on your own CPU or GPU.
bitnet.cpp achieves speedups of 1.37x to 5.07x on ARM CPUs, with larger models experiencing greater performance gains. Additionally, it reduces energy consumption by 55.4% to 70.0%, further boosting overall efficiency. On x86 CPUs, speedups range from 2.37x to 6.17x with energy reductions between 71.9% to 82.2%. Furthermore, bitnet.cpp can run a 100B BitNet b1.58 model on a single CPU, achieving speeds comparable to human reading (5-7 tokens per second), significantly enhancing the potential for running LLMs on local devices. Please refer to the technical report for more details.
Model Releases
1. BitNet-b1.58-2B-4T - 1-bit Large Language Model
BitNet-b1.58-2B-4T is the first official BitNet b1.58 model with 2.4B parameters, trained on 4 trillion tokens. It is a ternary (1.58-bit) language model that delivers competitive performance with full-precision models of similar size while enabling significantly faster and more energy-efficient inference.
Fast CPU Inference: Achieves up to 6.17x speedup on x86 CPUs and 5.07x on ARM CPUs compared to full-precision models.
Energy Efficient: Reduces energy consumption by up to 82.2% on x86 and 70.0% on ARM.
GPU Support: Official GPU inference kernel available for accelerated deployment.
Chat-Ready: Supports conversational mode for interactive use.
🤗 Hugging Face | 🔗 Online Demo | 📄 Technical Report
2. BitNet-embedding-0.6B - 1-bit Embedding Model
BitNet-embedding-0.6B is a 0.6B-parameter 1-bit embedding model that achieves competitive embedding quality with significantly faster CPU inference. It is the first model to demonstrate that ternary weights can deliver strong performance on embedding tasks.
1.42x to 2.28x speedup over F16 on prefill (8 threads, x86)
Lossless Quality: Competitive embedding quality with 2 bits per weight
I2_S Kernel: Supports optimized I2_S conversion on x86 CPUs
🤗 Hugging Face | 📄 I2_S Guide
3. BitNet-embedding-270M - Lightweight 1-bit Embedding Model
BitNet-embedding-270M is a compact 270M-parameter 1-bit embedding model designed for resource-constrained environments, offering fast inference with minimal memory footprint.
1.32x to 1.74x speedup over F16 on prefill (8 threads, x86)
Lightweight: Only 270M parameters for edge deployment scenarios
Supported Models
Official Models
BitNet-b1.58-2B-4T
BitNet-embedding-0.6B
BitNet-embedding-270M
Community Models
bitnet_b1_58-large
bitnet_b1_58-3B
Llama3-8B-1.58-100B-tokens
Falcon3 Family
Falcon-E Family
❗️We use existing 1-bit LLMs available on Hugging Face to demonstrate the inference capabilities of bitnet.cpp. We hope the release of bitnet.cpp will inspire the development of 1-bit LLMs in large-scale settings in terms of model size and training tokens.
Installation
Requirements
python>=3.10
For Windows users, install Visual Studio 2022. In the installer, toggle on at least the following options(this also automatically installs the required additional tools like CMake):
Desktop-development with C++
C++-CMake Tools for Windows
Git for Windows
C++-Clang Compiler for Windows
MS-Build Support for LLVM-Toolset (clang)
For Debian/Ubuntu users, you can download with Automatic installation script
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
conda (highly recommend)
Build from source
If you are using Windows, please remember to always use a Developer Command Prompt / PowerShell for VS2022 for the following commands. Please refer to the FAQs below if you see any issues.
Clone the repo
git clone --recursive https://github.com/microsoft/BitNet.git
Install the dependencies
# (Recommended) Create a new conda environment
conda create -n bitnet-cpp python=3.10
conda activate bitnet-cpp
pip install -r requirements.txt
Build the project
# Manually download the model and run with local path
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s
usage: setup_env.py [-h] [--hf-repo {1bitLLM/bitnet_b1_58-large,1bitLLM/bitnet_b1_58-3B,HF1BitLLM/Llama3-8B-1.58-100B-tokens,tiiuae/Falcon3-1B-Instruct-1.58bit,tiiuae/Falcon3-3B-Instruct-1.58bit,tiiuae/Falcon3-7B-Instruct-1.58bit,tiiuae/Falcon3-10B-Instruct-1.58bit}] [--model-dir MODEL_DIR] [--log-dir LOG_DIR] [--quant-type {i2_s,tl1}] [--quant-embd]
[--use-pretuned]
Setup the environment for running inference
optional arguments:
-h, --help show this help message and exit
[...内容已截断,完整版请查看原文或 Wayback 快照]