Text Generation
Transformers
Safetensors
English
qwen3
8-bit precision
bitsandbytes
quantized
conversational
Instructions to use Demondiablo/Qwen3-4B-Instruct-2507-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Demondiablo/Qwen3-4B-Instruct-2507-8bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Demondiablo/Qwen3-4B-Instruct-2507-8bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Demondiablo/Qwen3-4B-Instruct-2507-8bit") model = AutoModelForCausalLM.from_pretrained("Demondiablo/Qwen3-4B-Instruct-2507-8bit", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Demondiablo/Qwen3-4B-Instruct-2507-8bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Demondiablo/Qwen3-4B-Instruct-2507-8bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Demondiablo/Qwen3-4B-Instruct-2507-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Demondiablo/Qwen3-4B-Instruct-2507-8bit
- SGLang
How to use Demondiablo/Qwen3-4B-Instruct-2507-8bit 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 "Demondiablo/Qwen3-4B-Instruct-2507-8bit" \ --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": "Demondiablo/Qwen3-4B-Instruct-2507-8bit", "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 "Demondiablo/Qwen3-4B-Instruct-2507-8bit" \ --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": "Demondiablo/Qwen3-4B-Instruct-2507-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Demondiablo/Qwen3-4B-Instruct-2507-8bit with Docker Model Runner:
docker model run hf.co/Demondiablo/Qwen3-4B-Instruct-2507-8bit
Qwen3-4B-Instruct-2507-8bit
8-bit quantized version of Qwen/Qwen3-4B-Instruct-2507 using bitsandbytes LLM.int8(). Runs on a single consumer GPU with ~5-6 GB VRAM.
Quantization Details
| Field | Value |
|---|---|
| Quantization method | bitsandbytes |
| Precision | 8-bit weights (load_in_8bit: true) |
llm_int8_threshold |
6.0 |
| Base model | Qwen/Qwen3-4B-Instruct-2507 |
File size (model.safetensors) |
4.42 GB |
| Estimated VRAM | ~5.5 GB |
Model Specs (from config.json)
- Architecture:
Qwen3ForCausalLM(qwen3) - Parameters: 4B
- Hidden size: 2560, Layers: 36, Heads: 32, KV heads: 8
- Context length: 262,144 tokens
- Vocab size: 151,936
- Base dtype:
bfloat16 - Tie word embeddings: true
How to Use
Transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "Demondiablo/Qwen3-4B-Instruct-2507-8bit"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
load_in_8bit=True,
device_map="auto",
torch_dtype=torch.float16,
)
messages = [{"role": "user", "content": "Hello, who are you?"}]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
This model uses
bitsandbytes8-bit quantization. Install it withpip install bitsandbytes.
vLLM
vLLM does not support bitsandbytes 8-bit directly. Use the AWQ 4-bit version for vLLM, or use Transformers / llama.cpp for this 8-bit build.
License
Apache 2.0. See the original model card for full details.
- Downloads last month
- 55
Model tree for Demondiablo/Qwen3-4B-Instruct-2507-8bit
Base model
Qwen/Qwen3-4B-Instruct-2507