Instructions to use helenk/gemma-4-E4B-finetune with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use helenk/gemma-4-E4B-finetune with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="helenk/gemma-4-E4B-finetune") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("helenk/gemma-4-E4B-finetune") model = AutoModelForMultimodalLM.from_pretrained("helenk/gemma-4-E4B-finetune") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use helenk/gemma-4-E4B-finetune with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use helenk/gemma-4-E4B-finetune with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "helenk/gemma-4-E4B-finetune" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "helenk/gemma-4-E4B-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/helenk/gemma-4-E4B-finetune
- SGLang
How to use helenk/gemma-4-E4B-finetune with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "helenk/gemma-4-E4B-finetune" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "helenk/gemma-4-E4B-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "helenk/gemma-4-E4B-finetune" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "helenk/gemma-4-E4B-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use helenk/gemma-4-E4B-finetune with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for helenk/gemma-4-E4B-finetune to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for helenk/gemma-4-E4B-finetune to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for helenk/gemma-4-E4B-finetune to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="helenk/gemma-4-E4B-finetune", max_seq_length=2048, ) - Docker Model Runner
How to use helenk/gemma-4-E4B-finetune with Docker Model Runner:
docker model run hf.co/helenk/gemma-4-E4B-finetune
OfflineAid — Gemma 4 E4B fine-tune (merged fp16 safetensors)
Stage-1 fine-tune of unsloth/gemma-4-E4B-it for the OfflineAid Mac-side pack-builder agent — an offline AI assistant for Australian consumer-safety scenarios (anti-scam, disaster, travel) targeting the Kaggle Gemma 4 Good Hackathon.
This repo contains the fully merged fp16 safetensors (4 shards, ~16 GB) produced by peft.PeftModel.merge_and_unload() from the LoRA adapter at helenk/gemma-4-E4B-lora. For the Q4_K_M GGUF quantization that ships with Ollama, see helenk/gemma-4-E4B-finetune-GGUF.
Tier A held-out eval (vs stock + RAG)
Held-out: 111 rows stratified per-language (37 EN + 37 ZH + 37 AR) from the 1,113-row helenkwok/offlineaid corpus, seed=3407. Q4_K_M-quantized version evaluated against stock gemma4-stock (also Q4_K_M) via Ollama. Greedy decoding, explicit "Answer in {language}" directive.
| Language | Metric | stock + RAG | ft + RAG | Δ |
|---|---|---|---|---|
| EN | ROUGE-L F1 | 0.688 | 0.699 | +0.011 |
| EN | Format-OK % | 91.9% | 94.6% | +2.7 pp |
| ZH | ROUGE-L F1 | 0.229 | 0.227 | −0.002 |
| ZH | Format-OK % | 45.9% | 62.2% | +16.3 pp |
| AR | ROUGE-L F1 | 0.085 | 0.139 | +63% |
| AR | Format-OK % | 21.6% | 54.1% | +32.4 pp (2.5×) |
| all | ROUGE-L F1 | 0.334 | 0.355 | +0.021 |
| all | Format-OK % | 53.2% | 70.3% | +17.0 pp |
Format-OK = pred is non-empty AND contains at least one character in the expected script (CJK for ZH, Arabic for AR, ASCII for EN). The honest multilingual signal — ROUGE-L is lexically blind to two valid translations of the same English source.
Training
- Method: Unsloth LoRA on Kaggle T4 (1× T4, ~7 min)
- Adapter source:
helenk/gemma-4-E4B-lora - Base:
unsloth/gemma-4-E4B-it - LoRA config: r=16, α=16, dropout=0, target =
q,k,v,o,gate,up,down_proj, vision layers off - Chat template:
gemma-4-thinking - Loss:
train_on_responses_only(mask user + evidence turn, train only on answer tokens) - Data:
helenkwok/offlineaidv3 — 1,002-row train split (90/10 stratified per-language EN/ZH/AR from 1,113-row total, seed=3407). Each row is{instruction, input (= verbatim evidence_quote from .gov.au source), output (grounded answer in target language), language}. - Hyperparams: 2 epochs, batch 8 (per_device 2 × grad_accum 4), lr 2e-5, warmup 5, fp16, weight decay 0.01, seed 3407
- Notebook:
scripts/render_finetune_variant.pyrenders one canonical notebook to E2B and E4B variants; canonical atnotebooks/_canonical-finetune.ipynb.
Merge recipe
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("unsloth/gemma-4-E4B-it", torch_dtype="float16", device_map="cpu")
# Unsloth wraps Linear layers in Gemma4ClippableLinear — strip before peft injection
# (see scripts/merge_e4b_lora.py for the unwrap helper)
model = PeftModel.from_pretrained(base, "helenk/gemma-4-E4B-lora").merge_and_unload()
model.save_pretrained("gemma-4-E4B-offlineaid-merged", safe_serialization=True, max_shard_size="5GB")
AutoTokenizer.from_pretrained("helenk/gemma-4-E4B-lora").save_pretrained("gemma-4-E4B-offlineaid-merged")
Full script: scripts/merge_e4b_lora.py.
Intended use
Stage 3 of the OfflineAid pipeline — Mac-side pack-builder agent loop (Ollama via pydantic-ai). Pixel 7 production deployment uses the stock gemma-4-E2B-it.litertlm plus retrieval, not this fine-tune; see the project writeup for the architectural rationale.
License
Inherits Google's Gemma Terms of Use. Training data (helenkwok/offlineaid) is CC-BY-4.0.
Sibling repos
- LoRA adapter (~50 MB):
helenk/gemma-4-E4B-lora - Q4_K_M GGUF for Ollama (~5 GB):
helenk/gemma-4-E4B-finetune-GGUF - Smaller E2B variant:
helenk/gemma-4-E2B-finetune
- Downloads last month
- 10