Text Generation
PEFT
Safetensors
Russian
English
gemma4
lora
reasoning
math
agent
tool-use
function-calling
multimodal
russian
unsloth
conversational
4-bit precision
bitsandbytes
Instructions to use rrchat/Cerberus-E4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rrchat/Cerberus-E4B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it") model = PeftModel.from_pretrained(base_model, "rrchat/Cerberus-E4B") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: google/gemma-4-E4B-it
|
| 3 |
+
library_name: peft
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- gemma4
|
| 7 |
+
- lora
|
| 8 |
+
- peft
|
| 9 |
+
- reasoning
|
| 10 |
+
- math
|
| 11 |
+
- agent
|
| 12 |
+
- tool-use
|
| 13 |
+
- function-calling
|
| 14 |
+
- multimodal
|
| 15 |
+
- russian
|
| 16 |
+
- unsloth
|
| 17 |
+
license: apache-2.0
|
| 18 |
+
language:
|
| 19 |
+
- ru
|
| 20 |
+
- en
|
| 21 |
+
datasets:
|
| 22 |
+
- open-r1/OpenR1-Math-220k
|
| 23 |
+
- nvidia/Nemotron-Post-Training-Dataset-v2
|
| 24 |
+
- nvidia/Nemotron-SFT-Agentic-v2
|
| 25 |
+
- HuggingFaceTB/smoltalk2
|
| 26 |
+
- Vikhrmodels/GrandMaster-PRO-MAX
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
<div align="center">
|
| 30 |
+
<img src="cerberusbanner.png" alt="Cerberus 4B Banner" width="100%" style="border-radius: 10px; margin-bottom: 20px;">
|
| 31 |
+
</div>
|
| 32 |
+
|
| 33 |
+
# Cerberus 4B: Multi-Task Reasoning & Agentic Model (Preview)
|
| 34 |
+
|
| 35 |
+
**Cerberus 4B** is an open-weights, multi-task reasoning and agentic language model fine-tuned on top of Google's [`gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it) architecture (~7.5B total parameters with frozen vision and audio towers, 4B active language backbone).
|
| 36 |
+
|
| 37 |
+
Cerberus is designed for advanced bilingual step-by-step reasoning (English & Russian), precise function calling via native Gemma 4 tool schemas, and versatile dual-channel generation.
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## Highlights & Capabilities
|
| 42 |
+
|
| 43 |
+
* **Dual-Channel Generation:** Seamlessly toggles between long, deliberate step-by-step thought traces (`<|channel>thought\n...<channel|>`) and concise, direct responses (`instant`).
|
| 44 |
+
* **Advanced Mathematical Reasoning:** Shows a **+16.7%** accuracy improvement over the Google Gemma 4 base model on challenging competition-level mathematics (MATH-500).
|
| 45 |
+
* **Native Tool Calling (Agentic):** Trained with strict adherence to Gemma 4's native function calling protocol (`<|turn>model\n<|tool_call>...<|call:function_name{...}>`), ensuring structured execution for multi-turn agents.
|
| 46 |
+
* **Deep Russian Language Alignment:** Native-grade Russian math and logical reasoning without falling back to clumsy machine translation.
|
| 47 |
+
* **Multimodal Architecture Compatibility:** Trained with LoRA targeting the language reasoning backbone while keeping vision (ViT SigLIP, 280 soft tokens) and audio (Conformer, 16 kHz) encoders intact for drop-in GGUF `mmproj` support.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## Benchmark Results (vs. Base Model)
|
| 52 |
+
|
| 53 |
+
All evaluations were conducted in greedy / deterministic mode comparing Cerberus 4B directly against `google/gemma-4-E4B-it`:
|
| 54 |
+
|
| 55 |
+
| Benchmark | Base Model (`Gemma-4-E4B-it`) | Cerberus 4B | Delta (vs. Base) | Generation Mode |
|
| 56 |
+
| :--- | :---: | :---: | :---: | :--- |
|
| 57 |
+
| **MATH-500** | 43.3% | **60.0%** | **+16.7%** | Thinking Mode (`<thought>`) |
|
| 58 |
+
| **MATH-500** | 35.0% | **48.0%** | **+13.0%** | Instant Mode (Direct calculation) |
|
| 59 |
+
| **MMLU-Redux** | 62.0% | **63.0%** | **+1.0%** | Multi-discipline academic knowledge |
|
| 60 |
+
| **IFEval** | 90.8% | **90.5%** | **Parity (~90%)** | Complex system constraint following |
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## Quickstart (Hugging Face Transformers)
|
| 65 |
+
|
| 66 |
+
Cerberus 4B is released as an official PEFT LoRA adapter for `google/gemma-4-E4B-it`.
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
import torch
|
| 70 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 71 |
+
from peft import PeftModel
|
| 72 |
+
|
| 73 |
+
base_model_id = "google/gemma-4-E4B-it"
|
| 74 |
+
adapter_model_id = "rrchat/cerberus-4b-preview"
|
| 75 |
+
|
| 76 |
+
# Load tokenizer and base model
|
| 77 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
| 78 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 79 |
+
base_model_id,
|
| 80 |
+
torch_dtype=torch.bfloat16,
|
| 81 |
+
device_map="auto"
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
# Apply Cerberus LoRA adapter
|
| 85 |
+
model = PeftModel.from_pretrained(base_model, adapter_model_id)
|
| 86 |
+
|
| 87 |
+
# 1. Thinking Mode Prompt (Step-by-step reasoning)
|
| 88 |
+
prompt = "Find the number of positive integers n <= 1000 such that gcd(n, 36) = 1."
|
| 89 |
+
formatted_input = f"<|turn>user\n{prompt}<turn|>\n<|turn>model\n<|channel>thought\n"
|
| 90 |
+
|
| 91 |
+
inputs = tokenizer(formatted_input, return_tensors="pt").to(model.device)
|
| 92 |
+
outputs = model.generate(
|
| 93 |
+
**inputs,
|
| 94 |
+
max_new_tokens=2048,
|
| 95 |
+
temperature=0.8,
|
| 96 |
+
top_p=0.95,
|
| 97 |
+
do_sample=True
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=False)
|
| 101 |
+
print(response)
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## Recommended Generation Presets
|
| 107 |
+
|
| 108 |
+
To ensure optimal generation quality across different tasks:
|
| 109 |
+
|
| 110 |
+
* **For Deliberate Reasoning (`Thinking` mode):**
|
| 111 |
+
* Sampling: `do_sample=True`, `temperature=0.8`, `top_p=0.95`, `top_k=64`.
|
| 112 |
+
* For `llama.cpp` / GGUF: Enable the dynamic DRY sampler (`--dry-multiplier 0.8 --dry-base 1.75 --dry-allowed-length 2`) to eliminate n-gram loops during long thinking traces.
|
| 113 |
+
* **For Direct Answers, Code & Function Calling (`Instant` mode):**
|
| 114 |
+
* Sampling: Greedy decoding (`do_sample=False`, `temperature=0.0`) for maximum determinism and syntax reliability.
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
## GGUF & Quantized Models
|
| 119 |
+
|
| 120 |
+
Looking for standalone quantized GGUF weights for local execution on llama.cpp, LM Studio, or Ollama?
|
| 121 |
+
Pre-quantized GGUF files (including `Q4_K_M`, `Q5_K_M`, `Q8_0`, `BF16`, and multimodal `mmproj`) are available at:
|
| 122 |
+
👉 **[`rrchat/Cerberus-4B-Preview-GGUF`](https://huggingface.co/rrchat/Cerberus-4B-Preview-GGUF)**
|
| 123 |
+
|
| 124 |
+
---
|
| 125 |
+
|
| 126 |
+
## Dataset Attribution & Licensing
|
| 127 |
+
|
| 128 |
+
Cerberus was trained on a carefully curated, decontaminated multi-source dataset. In accordance with dataset terms and open research best practices, we gratefully acknowledge the following data creators:
|
| 129 |
+
|
| 130 |
+
1. **NVIDIA Nemotron:**
|
| 131 |
+
* Contains synthetic data derived from [`nvidia/Nemotron-Post-Training-Dataset-v2`](https://huggingface.co/datasets/nvidia/Nemotron-Post-Training-Dataset-v2) and [`nvidia/Nemotron-SFT-Agentic-v2`](https://huggingface.co/datasets/nvidia/Nemotron-SFT-Agentic-v2).
|
| 132 |
+
* *Attribution Notice:* This work contains content derived from NVIDIA Nemotron Post-Training and SFT Agentic datasets, developed by NVIDIA Corporation and licensed under the NVIDIA Open Synthetic Data License.
|
| 133 |
+
2. **Hugging Face Open-R1:**
|
| 134 |
+
* Mathematical reasoning traces sourced from [`open-r1/OpenR1-Math-220k`](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) (Apache-2.0 License).
|
| 135 |
+
3. **Hugging Face SmolTalk:**
|
| 136 |
+
* General dialogue and structured conversation samples from [`HuggingFaceTB/smoltalk2`](https://huggingface.co/datasets/HuggingFaceTB/smoltalk2) (Apache-2.0 License).
|
| 137 |
+
4. **Vikhr Models (GrandMaster):**
|
| 138 |
+
* Russian-language STEM and complex instructions sourced from [`Vikhrmodels/GrandMaster-PRO-MAX`](https://huggingface.co/datasets/Vikhrmodels/GrandMaster-PRO-MAX) (Apache-2.0 License).
|
| 139 |
+
5. **Base Model:**
|
| 140 |
+
* Built on [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it), developed by Google DeepMind and governed by the Gemma Terms of Use.
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## License
|
| 145 |
+
|
| 146 |
+
This model adapter is released under the **[Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0)**. Use of the underlying base model remains subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
|