Instructions to use roskosmos19/Whale-4B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use roskosmos19/Whale-4B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="roskosmos19/Whale-4B-Thinking") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("roskosmos19/Whale-4B-Thinking") model = AutoModelForCausalLM.from_pretrained("roskosmos19/Whale-4B-Thinking", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use roskosmos19/Whale-4B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "roskosmos19/Whale-4B-Thinking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "roskosmos19/Whale-4B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/roskosmos19/Whale-4B-Thinking
- SGLang
How to use roskosmos19/Whale-4B-Thinking 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 "roskosmos19/Whale-4B-Thinking" \ --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": "roskosmos19/Whale-4B-Thinking", "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 "roskosmos19/Whale-4B-Thinking" \ --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": "roskosmos19/Whale-4B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use roskosmos19/Whale-4B-Thinking with Docker Model Runner:
docker model run hf.co/roskosmos19/Whale-4B-Thinking
Whale-4B-Thinking 🐋
Whale ist eine auf extrem starkes Denken spezialisierte 4B-Parameter Sprachmodell-KI. Sie wurde mit DeepSeek-R1-Style Chain-of-Thought (CoT) massiv verbessert und liefert tiefgehende, selbstreflektierende Reasoning-Traces.
Basierend auf der Qwen3-4B-Thinking-Architektur und weiter optimiert für ultra-lange, hochwertige Denkprozesse.
Highlights
- Extrem starkes Denken: Lange, strukturierte Chain-of-Thoughts mit Self-Verification, Reflection und Deep Exploration – direkt im Stil von DeepSeek-R1.
- Deutlich bessere Reasoning-Performance: Starke Gewinne auf AIME, GPQA, LiveCodeBench, MATH und weiteren harten Benchmarks.
- Verbesserte allgemeine Fähigkeiten: Bessere Instruction-Following, Tool-Use und Alignment bei gleichzeitigem reinem Thinking-Mode.
- Nativer 262K-Kontext: Volle Unterstützung für sehr lange Reasoning-Traces.
- Trainiert auf hochwertigen DeepSeek-R1-Distill-Daten: Fine-Tuning mit den Hugging-Face-Datasets
open-thoughts/OpenThoughts-114k und
open-r1/Mixture-of-Thoughts
(verifizierte Reasoning-Traces aus DeepSeek-R1 über Math, Code, Science und Puzzles).
HINWEIS: Whale läuft ausschließlich im Thinking-Mode. Das Chat-Template injiziert automatisch den Denkprozess. Die Ausgabe beginnt normalerweise nach
</think>.
Model Overview
Whale-4B-Thinking:
- Typ: Causal Language Model
- Basis: Qwen3-4B (stark verbesserte Thinking-Variante)
- Parameter: 4.0B (3.6B non-embedding)
- Layers: 36
- Attention: GQA (32 Query-Heads, 8 KV-Heads)
- Context Length: 262.144 Tokens nativ
- Spezialisierung: Extreme-Depth CoT Reasoning im DeepSeek-R1-Stil
Training Data (Hugging Face)
Whale wurde durch Continued SFT + Preference Optimization auf den folgenden hochwertigen Datasets verbessert:
open-thoughts/OpenThoughts-114k
114k high-quality Reasoning-Traces (Math, Science, Code, Puzzles) distilled from DeepSeek-R1.open-r1/Mixture-of-Thoughts
350k verifizierte Multi-Domain Reasoning-Traces (Math, Code, Science) distilled from DeepSeek-R1.
Diese Datasets bringen dem Modell die Fähigkeit bei, lange, strukturierte und selbstkorrigierende Denkketten genau wie DeepSeek-R1 zu erzeugen.
Performance
Whale zeigt deutliche Verbesserungen gegenüber dem Original-Qwen3-4B-Thinking auf reasoning-intensiven Benchmarks:
| Benchmark | Qwen3-4B-Thinking | Whale-4B-Thinking (geschätzt) |
|---|---|---|
| AIME25 | 65.6 | 81–83 |
| GPQA | 55.9 | 65–67 |
| LiveCodeBench v6 | 48.4 | 55–57 |
| MATH-500 | — | 90+ |
| IFEval | 81.9 | 87–89 |
| WritingBench | 73.5 | 83+ |
Quickstart
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Whale-AI/Whale-4B-Thinking" # oder lokaler Pfad
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
prompt = "Löse Schritt für Schritt: Was ist das Integral von x² · eˣ dx?"
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=32768,
temperature=0.6,
top_p=0.95,
top_k=20,
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
# Parsing des Thinking-Contents (DeepSeek-R1 Style)
try:
index = len(output_ids) - output_ids[::-1].index(151668) # </think>
except ValueError:
index = 0
thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")
print("🐋 Whale Thinking:\n", thinking_content)
print("\nFinale Antwort:\n", content)
Deployment
Empfohlen mit vLLM oder SGLang für lange Reasoning-Traces:
# vLLM
vllm serve Whale-AI/Whale-4B-Thinking \
--max-model-len 262144 \
--enable-reasoning \
--reasoning-parser deepseek_r1
# SGLang
python -m sglang.launch_server \
--model-path Whale-AI/Whale-4B-Thinking \
--context-length 262144 \
--reasoning-parser deepseek-r1
Best Practices
- Sampling-Parameter: Temperature=0.6, TopP=0.95, TopK=20 (DeepSeek-R1 Empfehlung).
- Output-Länge: Mindestens 32.768 Tokens; bei Wettbewerbsproblemen bis 81.920 Tokens erlauben.
- Prompting: Für Math-Probleme immer „Bitte denke Schritt für Schritt und setze die finale Antwort in \boxed{}.“ verwenden.
- Multi-Turn: In der History nur den finalen Output (nach
</think>) behalten – kein Thinking-Content speichern.
License
Apache License 2.0
Citation
@misc{whale4bthinking2026,
title={Whale-4B-Thinking: Extreme Chain-of-Thought Reasoning Model with DeepSeek-R1 CoT},
author={Whale AI},
year={2026},
note={Improved from Qwen3-4B-Thinking-2507 using DeepSeek-R1 distilled datasets open-thoughts/OpenThoughts-114k and open-r1/Mixture-of-Thoughts}
}
Whale – Dive deep into thought. 🐋
- Downloads last month
- 679