Instructions to use SH4P3S/apertus-4b-tooluse with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use SH4P3S/apertus-4b-tooluse with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf SH4P3S/apertus-4b-tooluse:Q4_0 # Run inference directly in the terminal: llama cli -hf SH4P3S/apertus-4b-tooluse:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf SH4P3S/apertus-4b-tooluse:Q4_0 # Run inference directly in the terminal: llama cli -hf SH4P3S/apertus-4b-tooluse:Q4_0
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 SH4P3S/apertus-4b-tooluse:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf SH4P3S/apertus-4b-tooluse:Q4_0
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 SH4P3S/apertus-4b-tooluse:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf SH4P3S/apertus-4b-tooluse:Q4_0
Use Docker
docker model run hf.co/SH4P3S/apertus-4b-tooluse:Q4_0
- LM Studio
- Jan
- Ollama
How to use SH4P3S/apertus-4b-tooluse with Ollama:
ollama run hf.co/SH4P3S/apertus-4b-tooluse:Q4_0
- Unsloth Studio
How to use SH4P3S/apertus-4b-tooluse 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 SH4P3S/apertus-4b-tooluse 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 SH4P3S/apertus-4b-tooluse to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for SH4P3S/apertus-4b-tooluse to start chatting
- Pi
How to use SH4P3S/apertus-4b-tooluse with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SH4P3S/apertus-4b-tooluse:Q4_0
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": "SH4P3S/apertus-4b-tooluse:Q4_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use SH4P3S/apertus-4b-tooluse with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SH4P3S/apertus-4b-tooluse:Q4_0
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 SH4P3S/apertus-4b-tooluse:Q4_0
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use SH4P3S/apertus-4b-tooluse with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf SH4P3S/apertus-4b-tooluse:Q4_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "SH4P3S/apertus-4b-tooluse:Q4_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use SH4P3S/apertus-4b-tooluse with Docker Model Runner:
docker model run hf.co/SH4P3S/apertus-4b-tooluse:Q4_0
- Lemonade
How to use SH4P3S/apertus-4b-tooluse with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull SH4P3S/apertus-4b-tooluse:Q4_0
Run and chat with the model
lemonade run user.apertus-4b-tooluse-Q4_0
List all available models
lemonade list
Apertus-4B Tool-Use (Round 2)
QLoRA fine-tune of Apertus-4B for on-device tool calling (llama.cpp, target:
Samsung Galaxy S24). Current model: apertus-4b-r2-Q5_K_M.gguf (round 2)
— use it together with sysprompt.txt and (optionally) tools.gbnf from this
repo. The round-1 files (apertus-4b-Q5_K_M.gguf, apertus-4b-Q4_0.gguf) are
kept for reference only.
What's new in round 2
Fresh QLoRA from base on a patched dataset fixing five trained-in biases:
- Date anchoring: the system prompt now ends with
Current date: <Weekday>, YYYY-MM-DD. The model resolves "tomorrow" / "nächsten Dienstag" against that line — it has no clock of its own. The app/tester MUST inject this line in exactly that format. - Weather for a named place goes directly to
get_weather(noget_current_locationchain). - A concrete URL goes directly to
fetch_url(noweb_searchfirst). - Empty notes hits no longer escape to
web_search. - Asks clarifying questions far more often (patch mix 19% vs 3%).
Setup (Windows; Mac/Linux analogous)
- Download llama.cpp binaries: https://github.com/ggml-org/llama.cpp/releases
→
llama-<build>-bin-win-cpu-x64.zip→ unzip. - Start the server:
llama-server.exe -m apertus-4b-r2-Q5_K_M.gguf -c 4096 -t 4 --port 8080 - Open http://127.0.0.1:8080 in a browser.
- Settings (gear icon):
- System Message: paste the FULL contents of
sysprompt.txt. IMPORTANT: first update the last line to the actual current date, keeping the exact formatCurrent date: <Weekday>, YYYY-MM-DD(e.g.Current date: Monday, 2026-07-13). - Temperature 0.8, top-p 0.9.
- System Message: paste the FULL contents of
How it works
The assistant emits at most one tool call per turn:
<tool_call>{"name": "web_search", "arguments": {"query": "..."}}</tool_call>
Tool results come back as a user message (no custom tool role — the stock chat template works):
<tool_response>{"results": [{"title": "...", "snippet": "...", "url": "https://x.y"}]}</tool_response>
With no real tools attached, you play the tool: reply with an invented
<tool_response>, and the model answers grounded in it. Errors work too:
<tool_response>{"error": "service_unavailable"}</tool_response>.
11 tools: web_search, get_current_location, get_weather,
create_calendar_event, set_timer, create_note, search_notes, read_note,
append_to_note, fetch_url, get_calendar_events (full specs in
sysprompt.txt).
Grammar (optional, advanced)
tools.gbnf is a llama.cpp GBNF grammar that FORCES tool calls to be valid
JSON with correct argument names. The browser UI can't use it; it applies via
the API ("grammar" field in /completion) or llama-cli --grammar-file.
It constrains output to a tool call, so only use it on turns where a tool
call is expected.
Eval snapshot (r2 Q5_K_M + grammar, 121 cases, eval date pinned 2026-09-17)
| metric | score |
|---|---|
| tool-call validity | 100% |
| correct first tool | 93% |
| expected content in answer | 97% |
| forbidden tool avoided | 92% |
| no over-calling | 86% |
| asks when ambiguous | 70% |
| error recovery | 100% |
Good things to try
- "Stell mir einen Timer auf 10 Minuten für die Pasta." → set_timer call
- "Was ist 17 mal 23?" → should answer DIRECTLY, no tool
- "Wie ist das Wetter in Bern?" → get_weather directly (round-2 fix)
- "Wie ist das Wetter gerade hier bei mir?" → get_current_location, then get_weather
- "Trag Zahnarzt für nächsten Dienstag 14 Uhr ein." → create_calendar_event with the date resolved against the Current date line
- "Was hatte ich mir zum Velo notiert?" → search_notes, then read_note
- "Stell mir einen Timer." (no duration) → should ask how long
- German and English both work; Swiss German is not supported by design.
Expectations
- CPU inference: ~4–10 tokens/sec depending on machine. First reply is slower (system prompt processing).
- Known residual weakness: relative-date arithmetic for calendar events is still shaky (event_date_ok 44% in eval) — verify dates it books.
- Downloads last month
- -
4-bit
5-bit
Model tree for SH4P3S/apertus-4b-tooluse
Base model
swiss-ai/Apertus-v1.1-4B