Text Generation
Transformers
Safetensors
English
bitnet
chat
large-language-model
conversational
custom_code
8-bit precision
Instructions to use microsoft/bitnet-b1.58-2B-4T with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/bitnet-b1.58-2B-4T with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/bitnet-b1.58-2B-4T", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/bitnet-b1.58-2B-4T", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("microsoft/bitnet-b1.58-2B-4T", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use microsoft/bitnet-b1.58-2B-4T with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/bitnet-b1.58-2B-4T" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/bitnet-b1.58-2B-4T", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/bitnet-b1.58-2B-4T
- SGLang
How to use microsoft/bitnet-b1.58-2B-4T with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "microsoft/bitnet-b1.58-2B-4T" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/bitnet-b1.58-2B-4T", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "microsoft/bitnet-b1.58-2B-4T" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/bitnet-b1.58-2B-4T", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/bitnet-b1.58-2B-4T with Docker Model Runner:
docker model run hf.co/microsoft/bitnet-b1.58-2B-4T
Upload Iβm.py
9
#45 opened about 2 months ago
by
Pandabytebamboo
Install & run microsoft/bitnet-b1.58-2B-4T easily using llmpm
#44 opened 2 months ago
by
sarthak-saxena
Edge deployment considerations
#43 opened 4 months ago
by
Cagnicolas
https://huggingface.co/microsoft/bitnet-b1.58-2B-4T
1
#40 opened 8 months ago
by
Platinum2015
how to train it?
#39 opened 9 months ago
by
laelhalawani
Missing tokenizer.model
1
#38 opened 12 months ago
by
Z-KN
Request: DOI
#37 opened about 1 year ago
by
Harmanum
Galaxy S24 Ultra
2
#36 opened about 1 year ago
by
SSGHJKKNBVCXZWQ134578000JJBBBBNNNMKLL
Run inference with lm-evaluation-harness generated strange accuracy results
π 1
#34 opened about 1 year ago
by
pengaaa
asd-bitnet-b1.58-2B-4T
#33 opened about 1 year ago
by
Axdar
Unable to load. model
β 6
3
#31 opened about 1 year ago
by
ppdencolorado
configuration_bitnet missing
7
#30 opened about 1 year ago
by
KashyapR
wfgfbnhm
#29 opened about 1 year ago
by
vdhiren0805
Eval numbers for Llama 3.2 1B in Table 1 don't match Meta's results
3
#28 opened about 1 year ago
by
AlexA5432
βββWhen can you support vllm with cpu-only inference?
π₯ 3
#27 opened about 1 year ago
by
bigmao2012
Context limit of 4096 tokens
π₯ 3
#25 opened about 1 year ago
by
huggingface-meta
Run in 2bit
1
#23 opened about 1 year ago
by
LLMToaster
Upload WHL Binaries for Bitnet Windows and Mac
#21 opened about 1 year ago
by
wa999
Explainer video on BitNet
π 1
1
#20 opened about 1 year ago
by
ritheshSree
Misleading information
1
#19 opened about 1 year ago
by
nmtan2001
run without anything
1
#18 opened about 1 year ago
by
rakmik
it run good
1
#17 opened about 1 year ago
by
rakmik
More training details?
2
#15 opened about 1 year ago
by
elepedus
Create configuration_bitnet.py
βπ 10
#14 opened about 1 year ago
by
kema221
Add Hugging Face paper link and clarify repos
π 1
#13 opened about 1 year ago
by
nielsr
Important confirmation: about the deviation from the model that was originally uploaded
5
#12 opened about 1 year ago
by
AXCXEPT
Upload IMG_7727.jpeg
1
#11 opened about 1 year ago
by
Qwekuchicago
Please work with llama.cpp before releasing new models.
2
#10 opened about 1 year ago
by
bradhutchings
Missing configuration_bitnet.py.
π 6
5
#9 opened about 1 year ago
by
here4code
ONNX version
π₯π 5
#8 opened about 1 year ago
by
eek
Ollama support
π 22
6
#7 opened about 1 year ago
by
BB8-dev
Will the fine-tuning code be provided?
β 4
4
#6 opened about 1 year ago
by
AXCXEPT
Base / pretrained model
1
#5 opened about 1 year ago
by
mesh-ops
configuration_bitnet.py missing
πβ 12
15
#4 opened about 1 year ago
by
lefromage
Local Installation Video and Testing - Step by Step
π₯ 2
#2 opened about 1 year ago
by
fahdmirzac
Technical Report Link Missing
1
#1 opened about 1 year ago
by
G-reen