Text Generation
Transformers
Safetensors
English
gemma4
image-text-to-text
reasoning
chain-of-thought
distillation
lora
unsloth
fine-tuned
thinking
conversational
Instructions to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="naazimsnh02/gemma-4-e4b-opus-reasoning-v2") 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("naazimsnh02/gemma-4-e4b-opus-reasoning-v2") model = AutoModelForMultimodalLM.from_pretrained("naazimsnh02/gemma-4-e4b-opus-reasoning-v2") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "naazimsnh02/gemma-4-e4b-opus-reasoning-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "naazimsnh02/gemma-4-e4b-opus-reasoning-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/naazimsnh02/gemma-4-e4b-opus-reasoning-v2
- SGLang
How to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 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 "naazimsnh02/gemma-4-e4b-opus-reasoning-v2" \ --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": "naazimsnh02/gemma-4-e4b-opus-reasoning-v2", "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 "naazimsnh02/gemma-4-e4b-opus-reasoning-v2" \ --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": "naazimsnh02/gemma-4-e4b-opus-reasoning-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 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 naazimsnh02/gemma-4-e4b-opus-reasoning-v2 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 naazimsnh02/gemma-4-e4b-opus-reasoning-v2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for naazimsnh02/gemma-4-e4b-opus-reasoning-v2 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="naazimsnh02/gemma-4-e4b-opus-reasoning-v2", max_seq_length=2048, ) - Docker Model Runner
How to use naazimsnh02/gemma-4-e4b-opus-reasoning-v2 with Docker Model Runner:
docker model run hf.co/naazimsnh02/gemma-4-e4b-opus-reasoning-v2
Update README.md
Browse files
README.md
CHANGED
|
@@ -29,8 +29,6 @@ model-index:
|
|
| 29 |
|
| 30 |
A reasoning-enhanced fine-tune of [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it), distilled from Claude Opus 4.6 reasoning traces with supplementary math Chain-of-Thought data.
|
| 31 |
|
| 32 |
-
The model produces structured `<think>...</think>` reasoning blocks before delivering a final answer, encouraging step-by-step problem solving across general reasoning, coding, and mathematics tasks.
|
| 33 |
-
|
| 34 |
## Model Details
|
| 35 |
|
| 36 |
| | |
|
|
@@ -91,7 +89,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 91 |
)
|
| 92 |
tokenizer = AutoTokenizer.from_pretrained("naazimsnh02/gemma-4-e4b-opus-reasoning-v2")
|
| 93 |
|
| 94 |
-
messages = [{"role": "user", "content": "
|
| 95 |
inputs = tokenizer.apply_chat_template(
|
| 96 |
messages,
|
| 97 |
add_generation_prompt=True,
|
|
@@ -104,20 +102,6 @@ output = model.generate(**inputs, max_new_tokens=1024, temperature=1.0, top_p=0.
|
|
| 104 |
print(tokenizer.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
|
| 105 |
```
|
| 106 |
|
| 107 |
-
### Expected Output Format
|
| 108 |
-
|
| 109 |
-
```
|
| 110 |
-
<think>
|
| 111 |
-
Let me work through this step by step.
|
| 112 |
-
25 * 37
|
| 113 |
-
= 25 * (40 - 3)
|
| 114 |
-
= 1000 - 75
|
| 115 |
-
= 925
|
| 116 |
-
</think>
|
| 117 |
-
|
| 118 |
-
The answer is **925**.
|
| 119 |
-
```
|
| 120 |
-
|
| 121 |
## Limitations & Disclaimers
|
| 122 |
|
| 123 |
- **This is a reasoning-focused model, not a benchmark-optimized release.** It has not been evaluated on standard benchmarks (MMLU, GSM8K, HumanEval, etc.). Performance on such benchmarks is unknown and may differ from the base model.
|
|
|
|
| 29 |
|
| 30 |
A reasoning-enhanced fine-tune of [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it), distilled from Claude Opus 4.6 reasoning traces with supplementary math Chain-of-Thought data.
|
| 31 |
|
|
|
|
|
|
|
| 32 |
## Model Details
|
| 33 |
|
| 34 |
| | |
|
|
|
|
| 89 |
)
|
| 90 |
tokenizer = AutoTokenizer.from_pretrained("naazimsnh02/gemma-4-e4b-opus-reasoning-v2")
|
| 91 |
|
| 92 |
+
messages = [{"role": "user", "content": "A train travels 60 km/h. How long does it take to cover 255 km?"}]
|
| 93 |
inputs = tokenizer.apply_chat_template(
|
| 94 |
messages,
|
| 95 |
add_generation_prompt=True,
|
|
|
|
| 102 |
print(tokenizer.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
|
| 103 |
```
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
## Limitations & Disclaimers
|
| 106 |
|
| 107 |
- **This is a reasoning-focused model, not a benchmark-optimized release.** It has not been evaluated on standard benchmarks (MMLU, GSM8K, HumanEval, etc.). Performance on such benchmarks is unknown and may differ from the base model.
|