Text Generation
PEFT
Safetensors
lora
jmh
rejection-fine-tuning
mutation-testing
gemma4
conversational
Instructions to use bookxd/gemma-4-e2b-rft-mutation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use bookxd/gemma-4-e2b-rft-mutation with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B-it") model = PeftModel.from_pretrained(base_model, "bookxd/gemma-4-e2b-rft-mutation") - Notebooks
- Google Colab
- Kaggle
Gemma 4 E2B RFT LoRA — merged mutation corpus
Single LoRA adapter from rejection fine-tuning (RFT) on google/gemma-4-E2B-it, trained on the merged accepted-RFT dataset across all mutation-scored projects (Commons Lang + fastutil).
Training summary
| Base model | google/gemma-4-E2B-it |
| Method | LoRA (r=16, alpha=32) + bf16 + SDPA + chunked CE, 1 epoch SFT |
| Projects | Apache Commons Lang (41 train) + fastutil (15 train) |
| Train samples | 56 (+ 2 val) |
| Max seq len | 16384 |
| Hardware | NVIDIA A100 80GB |
Load and use
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "google/gemma-4-E2B-it"
adapter = "bookxd/gemma-4-e2b-rft-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: org.apache.commons.lang3.ArraySorter\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 weightsadapter_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
- Downloads last month
- 29