Instructions to use AdvRahul/Axion-Thinking-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use AdvRahul/Axion-Thinking-4B with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="AdvRahul/Axion-Thinking-4B", filename="qwen3-4b-thinking-2507-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 AdvRahul/Axion-Thinking-4B with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf AdvRahul/Axion-Thinking-4B:Q4_K_M # Run inference directly in the terminal: llama-cli -hf AdvRahul/Axion-Thinking-4B:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf AdvRahul/Axion-Thinking-4B:Q4_K_M # Run inference directly in the terminal: llama-cli -hf AdvRahul/Axion-Thinking-4B: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 AdvRahul/Axion-Thinking-4B:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf AdvRahul/Axion-Thinking-4B: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 AdvRahul/Axion-Thinking-4B:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf AdvRahul/Axion-Thinking-4B:Q4_K_M
Use Docker
docker model run hf.co/AdvRahul/Axion-Thinking-4B:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use AdvRahul/Axion-Thinking-4B with Ollama:
ollama run hf.co/AdvRahul/Axion-Thinking-4B:Q4_K_M
- Unsloth Studio new
How to use AdvRahul/Axion-Thinking-4B 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 AdvRahul/Axion-Thinking-4B 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 AdvRahul/Axion-Thinking-4B to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for AdvRahul/Axion-Thinking-4B to start chatting
- Pi new
How to use AdvRahul/Axion-Thinking-4B with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf AdvRahul/Axion-Thinking-4B: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": "AdvRahul/Axion-Thinking-4B:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use AdvRahul/Axion-Thinking-4B with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf AdvRahul/Axion-Thinking-4B: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 AdvRahul/Axion-Thinking-4B:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use AdvRahul/Axion-Thinking-4B with Docker Model Runner:
docker model run hf.co/AdvRahul/Axion-Thinking-4B:Q4_K_M
- Lemonade
How to use AdvRahul/Axion-Thinking-4B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull AdvRahul/Axion-Thinking-4B:Q4_K_M
Run and chat with the model
lemonade run user.Axion-Thinking-4B-Q4_K_M
List all available models
lemonade list
AdvRahul/Axion-Thinking-4B
A safety-enhanced model with transparent reasoning capabilities, based on Qwen3-4B-Thinking-2507. ๐ก
Axion-Thinking-4B is a fine-tuned version of the powerful Qwen/Qwen3-4B-Thinking-2507 model, designed to provide both state-of-the-art reasoning and enhanced safety. This model excels at complex tasks by first generating a step-by-step "thought process" before delivering a final answer.
๐ Model Details
- Model Creator: AdvRahul
- Base Model: Qwen/Qwen3-4B-Thinking-2507
- Fine-tuning Focus: Enhanced Safety & Harmlessness
- Special Feature: Explicit Chain-of-Thought (CoT) Reasoning via an automatic
<think>process. - Architecture: Qwen3
- Context Length: 262,144 tokens
- License: Tongyi Qianwen LICENSE AGREEMENT
๐ Model Description
Transparent Reasoning Meets Enhanced Safety
Axion-Thinking-4B combines two powerful features for building advanced and trustworthy AI applications:
- Transparent Reasoning: This model is a "Thinking" model. When given a complex prompt, it first generates its step-by-step thought process. This chain-of-thought, which concludes with a
</think>tag, is invaluable for debugging, understanding the model's logic, and verifying its reasoning path. - Enhanced Safety: On top of this powerful reasoning ability,
Axion-Thinking-4Bhas undergone extensive red-team testing with advanced protocols. This fine-tuning improves its safety alignment, reducing the generation of harmful, biased, or inappropriate content in both its thought process and final answer.
This makes the model an excellent choice for applications where both high performance on complex tasks and a high degree of safety and transparency are required.
๐ป How to Use
Using this model requires a specific step to parse its output, separating the thought process from the final answer.
Quickstart with transformers
The following code demonstrates how to run the model and correctly parse its unique output structure.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Your safety-tuned model name
model_name = "AdvRahul/Axion-Thinking-4B"
# Load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
# Prepare the model input
prompt = "A bat and a ball cost โน110 in total. The bat costs โน100 more than the ball. How much does the ball cost?"
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)
# Conduct text completion
generated_ids = model.generate(
**model_inputs,
max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
# === CRUCIAL: Parse the 'thinking' content ===
try:
# Find the index of the closing </think> token (ID: 151668)
think_end_index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:
# If the token isn't found, assume no thinking content
think_end_index = 0
# Decode the thinking part and the final answer separately
thinking_content = tokenizer.decode(output_ids[:think_end_index], skip_special_tokens=True).strip()
final_content = tokenizer.decode(output_ids[think_end_index:], skip_special_tokens=True).strip()
print("๐ค Thinking Content:\n", thinking_content)
print("\nโ
Final Content:\n", final_content)
Best Practices for Multi-Turn Chat
Important: In multi-turn conversations, the historical model output fed back into the prompt should only include the final answer, not the thinking content. The official chat template is designed to handle this, but developers using custom frameworks must ensure this practice is followed to maintain conversation quality.
โ ๏ธ Ethical Considerations and Limitations
Safety-Tuned, Not Perfect: While this model is fine-tuned for safety, no AI is completely free from risk. Developers must implement their own safety layers and content moderation.
Monitor the Thoughts: The transparent reasoning process is a powerful feature but also requires monitoring. The "thinking" content should be subject to the same safety and content policies as the final output.
Inherited Biases: The model may still reflect biases from the base model's training data. The ability to inspect the chain-of-thought can help in identifying and mitigating such biases.
- Downloads last month
- 4
4-bit
Model tree for AdvRahul/Axion-Thinking-4B
Base model
Qwen/Qwen3-4B-Thinking-2507