Instructions to use biltudas1/Qwen-9B-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use biltudas1/Qwen-9B-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="biltudas1/Qwen-9B-4bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("biltudas1/Qwen-9B-4bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use biltudas1/Qwen-9B-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "biltudas1/Qwen-9B-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "biltudas1/Qwen-9B-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/biltudas1/Qwen-9B-4bit
- SGLang
How to use biltudas1/Qwen-9B-4bit 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 "biltudas1/Qwen-9B-4bit" \ --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": "biltudas1/Qwen-9B-4bit", "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 "biltudas1/Qwen-9B-4bit" \ --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": "biltudas1/Qwen-9B-4bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use biltudas1/Qwen-9B-4bit with Docker Model Runner:
docker model run hf.co/biltudas1/Qwen-9B-4bit
Configuration Parsing Warning:Config file config.json cannot be fetched (too big)
Configuration Parsing Warning:Config file tokenizer_config.json cannot be fetched (too big)
Qwen 3.5 9B - 4-bit NF4
A 4-bit quantized version of Qwen3.5-9B, using BitsAndBytes NF4 quantization.
This repository provides a reduced-memory version of the original model, making it possible to run inference on hardware with more limited GPU memory.
Model Details
| Property | Value |
|---|---|
| Base model | Qwen/Qwen3.5-9B |
| Model size | 9B parameters |
| Quantization | 4-bit |
| Quantization type | NF4 |
| Compute dtype | FP16 |
| Quantization library | BitsAndBytes |
| Framework | Hugging Face Transformers |
Quantization Configuration
The model was quantized using the following configuration:
import torch
from transformers import BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True
)
Hardware Compatibility
The model was successfully loaded and tested on:
- GPU: NVIDIA Tesla T4
- GPU memory: 16 GB VRAM
- Runtime: Google Colab
Actual memory consumption and generation speed may vary depending on the input length, context size, software versions, and runtime configuration.
Usage
Requirements
pip install -U transformers accelerate bitsandbytes torch
Load the model
import torch
from transformers import (
AutoModelForCausalLM,
AutoTokenizer
)
model_id = "biltudas1/Qwen-9B-4bit"
tokenizer = AutoTokenizer.from_pretrained(
model_id,
trust_remote_code=True
)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True
)
model.eval()
Generate text
messages = [
{
"role": "user",
"content": "Explain how an HTTP request works."
}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True
).to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True
)
response = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True
)
print(response)
Limitations
- 4-bit quantization can affect model output quality compared with the original model.
- Actual performance depends on available GPU memory and hardware.
- Longer contexts require additional memory.
- Optional optimized attention and inference kernels may improve performance.
Acknowledgements
All credit for the original model architecture, training, and weights goes to the Qwen team.
This repository contains a quantized derivative of the original model, not a model trained from scratch.
License
Please refer to the original model's license and terms of use before using or redistributing this quantized version.
- Downloads last month
- 26