gorkemergune/ayarlicazhocam_finetune_v2
Viewer • Updated • 2.16k • 10
How to use gorkemergune/ayarlicazhocam-gemma-4-e4b with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it")
model = PeftModel.from_pretrained(base_model, "gorkemergune/ayarlicazhocam-gemma-4-e4b")QLoRA (4-bit) LoRA adapter for google/gemma-4-E4B-it — the personal AI assistant
ayarlicazhocam. Trained locally on an RTX 5070 (12 GB). This is the v2 iteration; see the
training repo and
BENCHMARK_REPORT_V2.md
for an honest before/after analysis.
reasoning channel), trained on ~20% of examples so both modes work.| tool-calling | mihenk-benchmark (80Q) | |
|---|---|---|
| base | 17% | 75.0% |
| this adapter | 92% | 67.5% (−7.5; mostly short-answer verbosity, see report) |
Trade-off is honest: persona/tool specialization slightly regressed the general reasoning benchmark, concentrated in the terse short-answer format (MC only −2.5).
import torch
from transformers import Gemma4ForConditionalGeneration, AutoProcessor, BitsAndBytesConfig
from peft import PeftModel
SKIP=["vision_tower","audio_tower","embed_vision","embed_audio","lm_head"]
bnb=BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,bnb_4bit_use_double_quant=True,
llm_int8_skip_modules=SKIP,llm_int8_enable_fp32_cpu_offload=True)
dm={"model.language_model":0,"lm_head":0,"model.vision_tower":"cpu","model.audio_tower":"cpu",
"model.embed_vision":"cpu","model.embed_audio":"cpu","model.language_model.embed_tokens_per_layer":"cpu"}
m=Gemma4ForConditionalGeneration.from_pretrained("google/gemma-4-E4B-it",quantization_config=bnb,device_map=dm,torch_dtype=torch.bfloat16)
m=PeftModel.from_pretrained(m,"gorkemergune/ayarlicazhocam-gemma-4-e4b")
tok=AutoProcessor.from_pretrained("google/gemma-4-E4B-it").tokenizer
enc=tok.apply_chat_template([{"role":"user","content":"Sen kimsin?"}],
add_generation_prompt=True,enable_thinking=False,return_tensors="pt",return_dict=True).to(0)
print(tok.decode(m.generate(**enc,max_new_tokens=120)[0][enc["input_ids"].shape[1]:],skip_special_tokens=True))
Note on naming: the original target was gemma-4-12B; E4B was used first to de-risk on a 12 GB GPU. Named -e4b for accuracy. 12B is future work.