Text Generation
Transformers
Safetensors
English
gemma3_text
gemma
quantized
bnb
nf4
conversational
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4") model = AutoModelForCausalLM.from_pretrained("WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4
- SGLang
How to use WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4 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 "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4" \ --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": "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4", "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 "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4" \ --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": "WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4 with Docker Model Runner:
docker model run hf.co/WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4
Gemma-3-1B-IT BitsAndBytesConfig NF4 Quantized
This model is a quantized version of google/gemma-3-1b-it-qat-int4-unquantized using BitsAndBytesConfig with NF4 quantization.
Model Details
- Base Model: google/gemma-3-1b-it-qat-int4-unquantized
- Quantization: BitsAndBytesConfig NF4 (4-bit)
- Quantization Type: NF4 with double quantization
- Compute Dtype: bfloat16
- Storage Dtype: uint8
Quantization Configuration
from transformers import BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_storage=torch.uint8
)
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the quantized model
model = AutoModelForCausalLM.from_pretrained(
"WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4",
device_map="auto",
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4")
# Generate text
inputs = tokenizer("Hello, how are you?", return_tensors="pt")
outputs = model.generate(**inputs, max_length=100)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
Benefits
- Reduced Memory Usage: ~75% reduction in memory footprint compared to full precision
- Faster Inference: Optimized for inference speed
- Maintained Quality: NF4 quantization preserves model quality effectively
Hardware Requirements
- GPU Memory: ~3-4GB VRAM (vs ~12GB for FP16)
- CUDA Compatible: Requires CUDA-capable GPU for optimal performance
- CPU Fallback: Can run on CPU with reduced performance
Quantization Details
This model uses BitsAndBytesConfig for 4-bit quantization:
- NF4 (Normal Float 4) quantization for optimal quality/size trade-off
- Double quantization for additional compression
- Mixed precision with bfloat16 compute dtype
License
This model inherits the Apache 2.0 license from the base model.
- Downloads last month
- 4
Model tree for WaveCut/gemma-3-1b-it-qat-int4-bnb-nf4
Base model
google/gemma-3-1b-pt Finetuned
google/gemma-3-1b-it