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
File size: 2,137 Bytes
97c41ab | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ---
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 — 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](https://huggingface.co/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
```python
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 weights
- `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
|