Downloads · 30 days
13
12% of all-time downloads
Aledec/gemma4-emirati-family-chatbot-lora
gemma4-emirati-family-chatbot-lora is a text generation model from Aledec. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
A QLoRA fine-tuned adapter for google/gemma-4-E4B-it, specialized in family advice in Emirati Arabic dialect.
Downloads · 30 days
13
12% of all-time downloads
All-time downloads
107
Public
Repo size
195 MB
Likes
0
Public
Click a slice to open those files.
.safetensors162 MB · 83%
From the Hugging Face model README
A QLoRA fine-tuned adapter for google/gemma-4-E4B-it, specialized in family advice in Emirati Arabic dialect.
| Parameter | Value |
|---|---|
| Base model | google/gemma-4-E4B-it (7.5B) |
| Method | QLoRA (PEFT + TRL) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| Learning rate | 5e-5 |
| Epochs | 2 |
| Dataset | 2,479 examples (Emirati Arabic conversations) |
| Trainable params | 40.5M (0.5% of model) |
| Final loss | 0.27 |
| Token accuracy | 93% |
| Training hardware | Apple M3 Max 48GB (MPS) |
| Training time | ~2 hours |
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it", torch_dtype=torch.float16)
tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E4B-it")
# IMPORTANT: Unwrap Gemma4ClippableLinear before loading adapter
from transformers.models.gemma4.modeling_gemma4 import Gemma4ClippableLinear
for name, module in base_model.named_modules():
for attr_name, child in list(module.named_children()):
if isinstance(child, Gemma4ClippableLinear):
setattr(module, attr_name, child.linear)
# Load adapter
model = PeftModel.from_pretrained(base_model, "Aledec/gemma4-emirati-family-chatbot-lora")
For fastest inference, fuse the adapter with the base model and quantize to GGUF:
# Fuse adapter
python scripts/fuse_model.py \
--base-model google/gemma-4-E4B-it \
--adapter-path Aledec/gemma4-emirati-family-chatbot-lora \
--output-path models/fused/gemma4-v1
# Convert and quantize
python llama.cpp/convert_hf_to_gguf.py models/fused/gemma4-v1 --outfile gemma4-f16.gguf --outtype f16
llama.cpp/build/bin/llama-quantize gemma4-f16.gguf gemma4-q5km.gguf Q5_K_M
# Run server
llama.cpp/build/bin/llama-server -m gemma4-q5km.gguf -t 4 -c 2048 --port 8091
| Metric | Value |
|---|---|
| Speed | 53 tok/s |
| Avg tokens/response | 58 |
| GGUF size | 5.3GB |
| Tests passed | 6/6 (original), 21/27 (extended) |
Gemma 4 is multimodal (vision + audio + text). The vision/audio tower layers use Gemma4ClippableLinear (a wrapper around nn.Linear with input/output clipping) which PEFT does not support natively. You must unwrap these layers to their inner nn.Linear before loading the adapter. See the usage example above.
MIT