Views
No views yet
bitsandbytes quantized weights for Google's Gemma 4 E2B (Instruct).transformers and bitsandbytes libraries. Crucially, unlike GGUF and other third-party formats that often require stripping out or separating vision and audio projectors, this native Hugging Face quantization fully retains the model's native multimodal capabilities. You can process text, images, and audio directly in PyTorch with highly efficient GPU execution.| Model Directory | Bit-Rate | Quantization Type | Description |
|---|---|---|---|
gemma-4-E2B-it-q4 | 4-bit | NF4 (NormalFloat4) | Recommended. Maximum VRAM savings while maintaining high reasoning and full multimodal (vision/audio) capabilities. |
llama.cpp. You can load and run these directly using the transformers library, keeping all multimodal pipelines completely intact.pip install transformers accelerate bitsandbytes1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Define the local path or repo ID
5model_id = "./gemma-4-E2B-it-q4"
6
7# Load the tokenizer (Note: For multimodal tasks, you would also load the AutoProcessor here)
8tokenizer = AutoTokenizer.from_pretrained(model_id)
9
10# Load the pre-quantized 4-bit model
11# device_map="auto" will automatically dispatch layers to your GPU
12model = AutoModelForCausalLM.from_pretrained(
13 model_id,
14 device_map="auto",
15 torch_dtype=torch.float16
16)
17
18# Format the prompt using the chat template
19messages = [
20 {"role": "system", "content": "You are a helpful expert assistant."},
21 {"role": "user", "content": "Explain quantum entanglement in simple terms."}
22]
23
24inputs = tokenizer.apply_chat_template(
25 messages,
26 return_tensors="pt",
27 add_generation_prompt=True
28).to(model.device)
29
30# Generate response
31outputs = model.generate(
32 inputs,
33 max_new_tokens=512,
34 do_sample=True,
35 temperature=1.0
36)
37
38# Decode and print
39response = tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
40print(response)