Views
No views yet
google/medgemma-1.5-4b-it quantised to 4-bit NF4 using bitsandbytes, generated on Kaggle 2×T4 in AIR-LLM style.| Mode | Min VRAM |
|---|---|
| Single GPU 4-bit | ~4 GB |
| CPU fallback | ~6 GB RAM |
1from transformers import AutoProcessor, AutoModelForImageTextToText, BitsAndBytesConfig
2import torch
3
4bnb = BitsAndBytesConfig(
5 load_in_4bit=True, bnb_4bit_quant_type="nf4",
6 bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.float16,
7)
8processor = AutoProcessor.from_pretrained("aab20abdullah/medgemma-1.5-4b-it-4bit-nf4")
9model = AutoModelForImageTextToText.from_pretrained(
10 "aab20abdullah/medgemma-1.5-4b-it-4bit-nf4", quantization_config=bnb, device_map="auto"
11)
12model.eval()
13
14messages = [{"role": "user", "content": [{"type": "text", "text": "What is aspirin?"}]}]
15prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
16inputs = processor(text=prompt, return_tensors="pt").to(model.device)
17with torch.inference_mode():
18 out = model.generate(**inputs, max_new_tokens=256)
19print(processor.decode(out[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))For educational / research use only. Not medical advice.