Text Generation
PEFT
Safetensors
lora
jmh
rejection-fine-tuning
mutation-testing
gemma4
conversational
Instructions to use bookxd/gemma-4-e2b-rft-commons-lang-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-commons-lang-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-commons-lang-mutation") - Notebooks
- Google Colab
- Kaggle
Gemma 4 E2B RFT LoRA — Apache Commons Lang (mutation)
LoRA adapter from rejection fine-tuning (RFT) on google/gemma-4-E2B-it for JMH benchmark generation on Apache Commons Lang classes with performance-mutation rewards.
Training summary
| Base model | google/gemma-4-E2B-it |
| Method | LoRA (r=16, alpha=32) + bf16, 1 epoch SFT on accepted RFT traces |
| Corpus | 19 mutation-scored Commons Lang classes |
| Train samples | 41 (+ 1 val) |
| Accepted / generated | 54 / 304 (17.8%) |
| Max seq len | 16384 (chunked CE loss) |
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-commons-lang-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 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
- Downloads last month
- 19