Views
No views yet
unsloth/gemma-4-e4b-it (Gemma 4 E4B IT), refined through an iterative autotraining loop to maximize performance in complex reasoning and instruction following. It utilizes the Unsloth framework for efficient 4-bit fine-tuning and is optimized for agentic tool use and mathematical reasoning.gemma-4-e4b-it using a 1-sample snapshot across key benchmarks (local inference with Qwen 3.5 judge):| Benchmark | Base Model (Snapshot) | danger-gemma-e4b | Delta |
|---|---|---|---|
| Arena AI (Text) | 1015 | 1160 | +14.3% |
| Math (Proxy) | 100.0%* | 100.0%* | - |
| Code (Proxy) | 100.0%* | 100.0%* | - |
Note: The following is a reference to the base model's capabilities and intended use.
1from unsloth import FastLanguageModel
2from transformers import TextStreamer
3import torch
4
5# 1. Load the base model and tokenizer
6model, tokenizer = FastLanguageModel.from_pretrained(
7 model_name = "unsloth/gemma-4-e4b-it", # Base model
8 max_seq_length = 4096,
9 dtype = None,
10 load_in_4bit = True,
11)
12
13# 2. Load the LoRA adapter
14model = FastLanguageModel.get_peft_model(
15 model,
16 r = 32,
17 target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
18 "gate_proj", "up_proj", "down_proj",],
19 lora_alpha = 64,
20 lora_dropout = 0,
21 bias = "none",
22 use_gradient_checkpointing = "unsloth",
23 random_state = 3407,
24 use_rslora = False,
25 loftq_config = None,
26)
27model.load_adapter("clevrpwn/danger-gemma-e4b") # Load the fine-tuned weights
28
29# Enable fast inference
30FastLanguageModel.for_inference(model)
31
32# Prepare the prompt
33messages = [
34 {"role": "user", "content": [{"type": "text", "text": "Explain the concept of quantum entanglement."}]}
35]
36prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
37inputs = tokenizer(text=[prompt], return_tensors="pt").to("cuda")
38
39# Recommended: Use streamer for better interactive feel
40streamer = TextStreamer(tokenizer, skip_prompt=True)
41_ = model.generate(**inputs, max_new_tokens=512, streamer=streamer, use_cache=True)