Views
No views yet
| Models | bfp16 | HQQ 4-bit gs-64 | QAT 4-bit gs-32 |
|---|---|---|---|
| ARC (25-shot) | 0.724 | 0.701 | 0.690 |
| HellaSwag (10-shot) | 0.839 | 0.826 | 0.792 |
| MMLU (5-shot) | 0.730 | 0.724 | 0.693 |
| TruthfulQA-MC2 | 0.580 | 0.585 | 0.550 |
| Winogrande (5-shot) | 0.766 | 0.774 | 0.755 |
| GSM8K (5-shot) | 0.874 | 0.862 | 0.808 |
| Average | 0.752 | 0.745 | 0.715 |
1#use transformers up to 52cc204dd7fbd671452448028aae6262cea74dc2
2#pip install git+https://github.com/huggingface/transformers@52cc204dd7fbd671452448028aae6262cea74dc2
3
4import torch
5backend = "gemlite"
6compute_dtype = torch.bfloat16
7cache_dir = None
8model_id = 'mobiuslabsgmbh/gemma-3-12b-it_4bitgs64_bfp16_hqq_hf'
9
10#Load model
11from transformers import Gemma3ForConditionalGeneration, AutoProcessor
12
13processor = AutoProcessor.from_pretrained(model_id, cache_dir=cache_dir)
14model = Gemma3ForConditionalGeneration.from_pretrained(
15 model_id,
16 torch_dtype=compute_dtype,
17 attn_implementation="sdpa",
18 cache_dir=cache_dir,
19 device_map="cuda",
20)
21
22#Optimize
23from hqq.utils.patching import prepare_for_inference
24prepare_for_inference(model.language_model, backend=backend, verbose=True)
25
26
27############################################################################
28#Inference
29messages = [
30 {
31 "role": "system",
32 "content": [{"type": "text", "text": "You are a helpful assistant."}]
33 },
34 {
35 "role": "user",
36 "content": [
37 {"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
38 {"type": "text", "text": "Describe this image in detail."}
39 ]
40 }
41]
42
43inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt").to(model.device, dtype=compute_dtype)
44
45input_len = inputs["input_ids"].shape[-1]
46
47with torch.inference_mode():
48 generation = model.generate(**inputs, max_new_tokens=128, do_sample=False)[0][input_len:]
49 decoded = processor.decode(generation, skip_special_tokens=True)
50
51print(decoded)
52
53