CoolFace
Modelpublic

stamsam/Gemma_4_Gem_e4b_multimodal-NF4

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes17downloads
Model Card

<div align="center"><img src="Gem%20e4b.png" alt="Gemma 4 Gem E4B" width="80%"><br><br><b>Format: 4-bit NF4</b> | <b>Base: google/gemma-4-E4B-it</b> | <b>4.5B effective / ~8B incl. embeddings</b></div>

Gemma 4 Gem E4B Multimodal

A fine-tuned version of google/gemma-4-E4B-it optimized for local coding, tool use, instruction following, and structured output. Trained on an H100 via 5-stage distillation pipeline (SFT + DPO + HF curriculum augmentation).

Hard fails reduced by 76% vs stock E4B (17 → 4 on full40 benchmark).

Model Details

This model includes the original vision and audio encoders from google/gemma-4-E4B-it, allowing it to process images, audio, and text inputs. The text backbone has been fine-tuned; vision/audio encoders are from the base model.

PropertyValue
Base Modelgoogle/gemma-4-E4B-it (4.5B effective / ~8B incl. embeddings)
Training5-stage CUDA pipeline (SFT → DPO → HF Curriculum)
Quantization4-bit NF4 (bitsandbytes) — full BF16 base on request
Context2048 tokens
FormatChatML-style with `<turn>` markers

Training Datasets

  • —stage_elite_blend (1,920 rows) — Openthoughts/Hermes/XLam gold-standard reasoning
  • —Agentic CoT Coding SFT (429 rows) — Multi-step coding agent tasks
  • —Glaive Function Calling v2 (1,000 rows) — Tool-use and JSON schema compliance

Benchmark Results

Comparison against stock google/gemma-4-E4B-it (4-bit):

BenchmarkStock E4BGemma 4 Gem E4BImprovement
full40253/400 (6.33, 17 HF)259/400 (6.47, 4 HF)+6 pts, -13 HF
code_smoke—89/120 (7.42, 1 HF)beats gate
json_hard—30/30 (10.0, 0 HF)perfect
falsepremisesmoke—87/110 (7.91, 0 HF)clean
math_smoke—41/60 (6.83, 0 HF)clean

Leaderboard Context

Modelfull40Hard Fails
Gemma 4 Gem E4B2594 🏆
Gemma 4 31B (cloud)26115
Chimera v4 (Gemma E2B)25814
Stock E4B (4-bit)25317
Granite 4.1 8B27614
Phi-4 Mini22320

Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "stamsam/Gemma_4_Gem_e4b_multimodal_4-bit-NF4"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_path,
    device_map="auto",
    torch_dtype="auto",
    trust_remote_code=True,
)

messages = [{"role": "user", "content": "Write a function to deduplicate a list"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Training Details

  • —Hardware: NVIDIA H100 80GB SXM
  • —Framework: PyTorch 2.11 + PEFT + bitsandbytes 4-bit QLoRA
  • —LoRA config: r=8, alpha=16, targetmodules=q/k/v/o/gate/up/downproj
  • —Training time: ~30 minutes total across all stages