To download a specific quantized version of the Qwen3-0.6B-GGUF model and use it, you'll need to follow these steps:
Downloading a Specific GGUF Model
First, you need to download a specific GGUF file rather than the entire model repository. You can use the hf_hub_download function from the huggingface_hub library:
from huggingface_hub import hf_hub_download
# Download a specific GGUF quantized model file
# You can choose different quantization levels (2-bit, 3-bit, 4-bit, etc.)
# For example, let's download the q5_k_m quantized version
model_path = hf_hub_download(
repo_id="unsloth/Qwen3-0.6B-GGUF",
filename="qwen3-0.6b-q5_k_m.gguf", # Choose the quantization level you want
local_dir="./models" # Specify where to save the file
)
print(f"Model downloaded to: {model_path}")
Using the GGUF Model with llama.cpp Python Bindings
GGUF models are typically used with llama.cpp. Here's how to use the model with its Python bindings (llama-cpp-python):
# Install the necessary libraries first:
# pip install llama-cpp-python
from llama_cpp import Llama
# Initialize the model
model = Llama(
model_path="./models/qwen3-0.6b-q5_k_m.gguf", # Path to your downloaded model
n_ctx=32768, # Context size (Qwen3 supports up to 32,768 tokens)
n_gpu_layers=-1, # Use all layers on GPU if available
rope_scaling={"type": "yarn", "factor": 4.0, "original_max_position_embeddings": 32768}
)
# Example chat format
prompt = "Give me a short introduction to large language models."
# Create chat message in Qwen3 format
messages = [{"role": "user", "content": prompt}]
# Format the prompt correctly for Qwen3
formatted_prompt = "<|im_start|>user\n" + prompt + "<|im_end|>\n<|im_start|>assistant\n"
# Generate a response
response = model.create_completion(
formatted_prompt,
max_tokens=2048,
temperature=0.7,
top_p=0.8,
top_k=20,
min_p=0.0,
stop=["<|im_end|>"]
)
print(response['choices']['text'])
Alternative: Using with Command Line Interface
You can also run the model directly from the command line using llama.cpp's server:
# First download llama.cpp and compile it
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# Run the server with the Qwen3 model
./llama-server \
--model ./models/qwen3-0.6b-q5_k_m.gguf \
--ctx-size 32768 \
--rope-scaling yarn \
--rope-scale 4 \
--yarn-orig-ctx 32768 \
--port 8080
Then you can interact with it using curl or any HTTP client.
Notes on Quantization Levels
The repository offers different quantization levels denoted by filenames like:
q2_k: 2-bit quantization
q3_k_s: 3-bit quantization
q4_k_m: 4-bit quantization
q5_k_m: 5-bit quantization
q6_k: 6-bit quantization
q8_0: 8-bit quantization
Lower bit quantization (like 2-bit or 3-bit) results in smaller file sizes but potentially lower quality, while higher bit quantization (like 8-bit) preserves more quality but with larger file sizes[8][9].
For the Qwen3 model, it's recommended to use transformers>=4.51.0 to avoid the KeyError: 'qwen3' error that can occur with older versions[8][10].