--- base_model: google/gemma-4-E2B-it library_name: peft tags: - lora - jmh - rejection-fine-tuning - mutation-testing - gemma4 - text-generation license: gemma pipeline_tag: text-generation --- # Gemma 4 E2B RFT LoRA — fastutil (mutation) LoRA adapter from **rejection fine-tuning (RFT)** on `google/gemma-4-E2B-it` for JMH benchmark generation on **fastutil** classes with performance-mutation rewards. ## Training summary | | | |---|---| | Base model | [google/gemma-4-E2B-it](https://huggingface.co/google/gemma-4-E2B-it) | | Method | LoRA (r=16, alpha=32) + bf16, 1 epoch SFT on accepted RFT traces | | Corpus | 14 mutation-scored fastutil classes | | Train samples | 15 (+ 1 val) | | Accepted / generated | 17 / 224 (7.6%) | | Max seq len | 16384 (chunked CE loss) | ## Load and use ```python import torch from peft import PeftModel from transformers import AutoModelForCausalLM, AutoTokenizer base = "google/gemma-4-E2B-it" adapter = "bookxd/gemma-4-e2b-rft-fastutil-mutation" tokenizer = AutoTokenizer.from_pretrained(adapter) model = AutoModelForCausalLM.from_pretrained( base, torch_dtype=torch.bfloat16, attn_implementation="sdpa", device_map="auto", ) model = PeftModel.from_pretrained(model, adapter) model.eval() messages = [ {"role": "system", "content": "You write JMH benchmarks..."}, {"role": "user", "content": "Target class: it.unimi.dsi.fastutil.ints.IntArrayList\n..."}, ] inputs = tokenizer.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", chat_template_kwargs={"enable_thinking": True}, ).to(model.device) with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=8192, do_sample=True, temperature=1.0) print(tokenizer.decode(out[0], skip_special_tokens=False)) ``` ## Files - `adapter_model.safetensors` — LoRA weights (~92M params trainable on base) - `adapter_config.json` — PEFT config (base model + target modules) - `tokenizer.json`, `tokenizer_config.json`, `chat_template.jinja` — tokenizer + Gemma 4 thinking template ## Framework versions - PEFT 0.19.1, TRL 1.5.1, Transformers 5.10.1, PyTorch 2.12.1