Instructions to use clevrpwn/danger-gemma-e4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use clevrpwn/danger-gemma-e4b with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-4-e4b-it") model = PeftModel.from_pretrained(base_model, "clevrpwn/danger-gemma-e4b") - Transformers
How to use clevrpwn/danger-gemma-e4b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="clevrpwn/danger-gemma-e4b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("clevrpwn/danger-gemma-e4b", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use clevrpwn/danger-gemma-e4b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "clevrpwn/danger-gemma-e4b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "clevrpwn/danger-gemma-e4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/clevrpwn/danger-gemma-e4b
- SGLang
How to use clevrpwn/danger-gemma-e4b 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 "clevrpwn/danger-gemma-e4b" \ --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": "clevrpwn/danger-gemma-e4b", "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 "clevrpwn/danger-gemma-e4b" \ --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": "clevrpwn/danger-gemma-e4b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use clevrpwn/danger-gemma-e4b 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 clevrpwn/danger-gemma-e4b 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 clevrpwn/danger-gemma-e4b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for clevrpwn/danger-gemma-e4b to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="clevrpwn/danger-gemma-e4b", max_seq_length=2048, ) - Docker Model Runner
How to use clevrpwn/danger-gemma-e4b with Docker Model Runner:
docker model run hf.co/clevrpwn/danger-gemma-e4b
| base_model: unsloth/gemma-4-e4b-it | |
| library_name: peft | |
| pipeline_tag: text-generation | |
| tags: | |
| - base_model:adapter:unsloth/gemma-4-e4b-it | |
| - lora | |
| - sft | |
| - transformers | |
| - trl | |
| - unsloth | |
| - gemma4 | |
| - thinking | |
| # danger-gemma-e4b | |
| This model is a fine-tuned version of `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. | |
| ## Model Highlights | |
| - **Iterative Refinement:** Trained through multiple iterations with hyperparameter tuning guided by Qwen 3.5 9B. | |
| - **Enhanced Reasoning:** Significant performance in mathematical problem-solving and logical deduction. | |
| - **Improved Instruction Following:** Higher helpfulness and detail in long-form responses compared to the base model. | |
| - **Agentic Capability:** Optimized for tool-calling structures and structured reasoning blocks. | |
| ## Evaluation Results (Direct Comparison) | |
| Evaluated against the base `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: High success on small sample math/code tasks suggests strong core capability in both. In larger samples (n=5), the fine-tune consistently maintained 90%+ in Math reasoning.* | |
| ### Observed Behavior | |
| The model demonstrates a strong "thinking" behavior, often providing detailed step-by-step breakdowns before arriving at a final answer. While this improves accuracy, it may require specific extraction logic for MCQ tasks that expect only a single token. | |
| ## Training Procedure | |
| The model underwent an automated fine-tuning loop with the following trajectory: | |
| ### Iteration History | |
| - **Initial Phase:** Focus on instruction following (Arena-Hard) with high learning rate (1e-4). | |
| - **Refinement Phase:** Adjustment of LoRA alpha (from 32 to 64) and training steps (up to 8000) to stabilize reasoning. | |
| - **Final Phase:** Lowered learning rate (5e-05) for precision tuning of reasoning outputs. | |
| ### Final Training Hyperparameters | |
| - **Learning Rate:** 5e-05 | |
| - **LoRA Rank (r):** 32 | |
| - **LoRA Alpha:** 64 | |
| - **Batch Size:** 2 | |
| - **Gradient Accumulation Steps:** 4 | |
| - **Optimizer:** AdamW (8-bit) | |
| - **LR Scheduler:** Linear | |
| - **Training Steps:** 8000 | |
| - **Weight Decay:** 0.01 | |
| ### Framework Versions | |
| - PEFT 0.18.1 | |
| - Unsloth 2026.4.4 | |
| - Transformers 5.5.0 | |
| - PyTorch 2.10.0+cu130 | |
| --- | |
| ## Original Model Card: Gemma 4 E4B IT | |
| > **Note:** The following is a reference to the base model's capabilities and intended use. | |
| ### Model Description | |
| Gemma 4 is the next generation of open models from Google. Gemma 4 models are built from the same research and technology used to create the Gemini models. | |
| **Model type:** Text-to-text, Decoder-only | |
| **Language(s):** English | |
| **License:** Gemma Terms of Use | |
| --- | |
| ## How to Get Started | |
| ```python | |
| from unsloth import FastLanguageModel | |
| from transformers import TextStreamer | |
| import torch | |
| # 1. Load the base model and tokenizer | |
| model, tokenizer = FastLanguageModel.from_pretrained( | |
| model_name = "unsloth/gemma-4-e4b-it", # Base model | |
| max_seq_length = 4096, | |
| dtype = None, | |
| load_in_4bit = True, | |
| ) | |
| # 2. Load the LoRA adapter | |
| model = FastLanguageModel.get_peft_model( | |
| model, | |
| r = 32, | |
| target_modules = ["q_proj", "k_proj", "v_proj", "o_proj", | |
| "gate_proj", "up_proj", "down_proj",], | |
| lora_alpha = 64, | |
| lora_dropout = 0, | |
| bias = "none", | |
| use_gradient_checkpointing = "unsloth", | |
| random_state = 3407, | |
| use_rslora = False, | |
| loftq_config = None, | |
| ) | |
| model.load_adapter("clevrpwn/danger-gemma-e4b") # Load the fine-tuned weights | |
| # Enable fast inference | |
| FastLanguageModel.for_inference(model) | |
| # Prepare the prompt | |
| messages = [ | |
| {"role": "user", "content": [{"type": "text", "text": "Explain the concept of quantum entanglement."}]} | |
| ] | |
| prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | |
| inputs = tokenizer(text=[prompt], return_tensors="pt").to("cuda") | |
| # Recommended: Use streamer for better interactive feel | |
| streamer = TextStreamer(tokenizer, skip_prompt=True) | |
| _ = model.generate(**inputs, max_new_tokens=512, streamer=streamer, use_cache=True) | |
| ``` | |