Instructions to use Zhantas/DeepGemma-2B-Reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zhantas/DeepGemma-2B-Reasoning with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Zhantas/DeepGemma-2B-Reasoning", dtype="auto") - llama-cpp-python
How to use Zhantas/DeepGemma-2B-Reasoning with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Zhantas/DeepGemma-2B-Reasoning", filename="gemma4_e2b-q4_k_m.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use Zhantas/DeepGemma-2B-Reasoning with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Use Docker
docker model run hf.co/Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use Zhantas/DeepGemma-2B-Reasoning with Ollama:
ollama run hf.co/Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
- Unsloth Studio new
How to use Zhantas/DeepGemma-2B-Reasoning 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 Zhantas/DeepGemma-2B-Reasoning 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 Zhantas/DeepGemma-2B-Reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Zhantas/DeepGemma-2B-Reasoning to start chatting
- Pi new
How to use Zhantas/DeepGemma-2B-Reasoning with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Zhantas/DeepGemma-2B-Reasoning:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Zhantas/DeepGemma-2B-Reasoning with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use Zhantas/DeepGemma-2B-Reasoning with Docker Model Runner:
docker model run hf.co/Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
- Lemonade
How to use Zhantas/DeepGemma-2B-Reasoning with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Zhantas/DeepGemma-2B-Reasoning:Q4_K_M
Run and chat with the model
lemonade run user.DeepGemma-2B-Reasoning-Q4_K_M
List all available models
lemonade list
🧠 DeepGemma-2B-Reasoning
DeepGemma-2B-Reasoning is a deeply fine-tuned version of google/gemma-4-E2B-it, optimized for step-by-step reasoning (Chain-of-Thought). Trained via knowledge distillation on datasets generated by Claude Opus, Qwen3.5, and KIMI.
The model generates internal reasoning inside <thought> / <think> tags before answering, significantly improving logical and mathematical response quality.
🏆 Benchmarks (GSM8K)
| Model | GSM8K (Accuracy) | Improvement |
|---|---|---|
google/gemma-4-E2B-it (Base) |
30.0% | - |
| DeepGemma-2B-Reasoning (Ours) | 44.0% | +14.0% 🚀 |
🛠 Training Details
Training was conducted using Unsloth (QLoRA) on an RTX 4090 (24GB VRAM).
- Method: QLoRA (4-bit quantization, BF16 adapters)
- LoRA Parameters: Rank = 48, Alpha = 48
- Epochs: 2 | Global Steps: 4672 | Learning Rate: 2e-4
- Final Loss: 1.24
🗜️ GGUF Version (llama.cpp)
A quantized Q4_K_M GGUF version is available directly in this repo.
File: gemma4_e2b-q4_k_m.gguf (~4.7 GB)
Quantization: llama.cpp Q4_K_M
Merge: Full LoRA merge before quantization (Unsloth)
⚡ Performance (RTX 4090, llama.cpp, ngl=999)
| Metric | Speed |
|---|---|
| Prompt processing | ~400 tok/s |
| Generation | ~239–262 tok/s |
| Context | 4096 tokens |
Usage (llama.cpp)
./llama-cli -m gemma4_e2b-q4_k_m.gguf \
-p "<start_of_turn>user\nYour question here<end_of_turn>\n<start_of_turn>model\n" \
-n 512 -ngl 999 -c 4096
💻 Usage (Transformers / Unsloth)
from unsloth import FastVisionModel
model, tokenizer = FastVisionModel.from_pretrained(
model_name="Zhantas/DeepGemma-2B-Reasoning",
max_seq_length=2048,
load_in_4bit=True,
)
FastVisionModel.for_inference(model)
question = "I had 3 apples. I ate one, and then bought as many as I had left. How many apples do I have now? Reason step by step."
prompt = f"<start_of_turn>user\n{question}<end_of_turn>\n<start_of_turn>model\n"
inputs = tokenizer(text=prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.3, repetition_penalty=1.1)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
⚠️ Limitations
Prone to "overthinking" on simple tasks. Best suited for logic puzzles, coding, and mathematics.
- Downloads last month
- 181
4-bit