Instructions to use barha/granite-switch-4.1-3b-preview-GGUF 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 barha/granite-switch-4.1-3b-preview-GGUF 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 barha/granite-switch-4.1-3b-preview-GGUF:BF16 # Run inference directly in the terminal: llama cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16 # Run inference directly in the terminal: llama cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
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 barha/granite-switch-4.1-3b-preview-GGUF:BF16 # Run inference directly in the terminal: ./llama-cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
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 barha/granite-switch-4.1-3b-preview-GGUF:BF16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
Use Docker
docker model run hf.co/barha/granite-switch-4.1-3b-preview-GGUF:BF16
- LM Studio
- Jan
- Ollama
How to use barha/granite-switch-4.1-3b-preview-GGUF with Ollama:
ollama run hf.co/barha/granite-switch-4.1-3b-preview-GGUF:BF16
- Unsloth Desktop
- Pi
How to use barha/granite-switch-4.1-3b-preview-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "barha/granite-switch-4.1-3b-preview-GGUF:BF16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use barha/granite-switch-4.1-3b-preview-GGUF with Docker Model Runner:
docker model run hf.co/barha/granite-switch-4.1-3b-preview-GGUF:BF16
- Lemonade
How to use barha/granite-switch-4.1-3b-preview-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull barha/granite-switch-4.1-3b-preview-GGUF:BF16
Run and chat with the model
lemonade run user.granite-switch-4.1-3b-preview-GGUF-BF16
List all available models
lemonade list
- Hermes Agent
How to use barha/granite-switch-4.1-3b-preview-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
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 barha/granite-switch-4.1-3b-preview-GGUF:BF16
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use barha/granite-switch-4.1-3b-preview-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16
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 "barha/granite-switch-4.1-3b-preview-GGUF:BF16" \ --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"
Install from WinGet (Windows)
winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16# Run inference directly in the terminal:
llama cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16Use 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 barha/granite-switch-4.1-3b-preview-GGUF:BF16# Run inference directly in the terminal:
./llama-cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16Build 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 barha/granite-switch-4.1-3b-preview-GGUF:BF16# Run inference directly in the terminal:
./build/bin/llama-cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16Use Docker
docker model run hf.co/barha/granite-switch-4.1-3b-preview-GGUF:BF16Granite Switch 4.1 3B Preview - GGUF (bf16)
GGUF conversion of ibm-granite/granite-switch-4.1-3b-preview, for use with llama.cpp.
- Quantization: bf16 (no quantization loss, same precision as the original checkpoint)
- Converted with:
convert_hf_to_gguf.pyfrom llama.cpp (master) - Original model card / adapters / usage: see ibm-granite/granite-switch-4.1-3b-preview
Files
| File | Description |
|---|---|
granite-switch-4.1-3b-preview-bf16.gguf |
bf16 GGUF, includes base model weights and all 12 embedded LoRA adapters |
Basic usage
llama-cli -m granite-switch-4.1-3b-preview-bf16.gguf -p "Hello"
With no control token, the model runs as the plain base chat model.
Adapter activation
Granite Switch embeds 12 adapters in one checkpoint. An in-graph router selects which adapter is active by detecting a control token in the prompt. The selection is per request (one adapter per generation) — the control token routes the whole sequence to a single adapter slot, then is substituted out before embedding so it does not corrupt the text.
To activate an adapter you place its control token in the prompt at the position the model was trained for. Placement differs by adapter type:
- LoRA adapters — the token goes at the very start, replacing the leading
<|start_of_role|>. Adapters:citations,hallucination_detection,context-attribution. - aLoRA adapters — the token is spliced right before the final
assistant<|end_of_role|>generation prompt (replacing its<|start_of_role|>). Adapters:query_rewrite,query_clarification,answerability,factuality-detection,policy-guardrails,factuality-correction,guardian-core,uncertainty,requirement-check.
| Adapter | Type | Control token | Output |
|---|---|---|---|
| citations | lora | <|citations|> |
citation spans |
| hallucination_detection | lora | <|hallucination_detection|> |
[{"r","f":faithful/partial/unfaithful/NA,"e"}] |
| context-attribution | lora | <|context-attribution|> |
attribution spans |
| query_rewrite | alora | <|query_rewrite|> |
rewritten query |
| query_clarification | alora | <|query_clarification|> |
clarification or CLEAR |
| answerability | alora | <|answerability|> |
answerable / unanswerable |
| factuality-detection | alora | <|factuality-detection|> |
yes / no |
| policy-guardrails | alora | <|policy-guardrails|> |
Yes / No / Ambiguous |
| factuality-correction | alora | <|factuality-correction|> |
corrected text |
| guardian-core | alora | <|guardian-core|> |
yes / no (risk) |
| uncertainty | alora | <|uncertainty|> |
0..9 (certainty) |
| requirement-check | alora | <|requirement-check|> |
yes / no |
Example: hallucination_detection (LoRA — token at start)
<|hallucination_detection|>user<|end_of_role|>Tell me about the moon.<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>The moon is made of green cheese.<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>
Produces the adapter's structured JSON, e.g.
[{"r": 0, "f": "unfaithful", "e": "..."}] instead of a chat reply.
Example: answerability (aLoRA — token before the assistant prompt)
<|start_of_role|>system<|end_of_role|>You are a helpful assistant with access to the following documents...
<documents>
{"doc_id": "1", "text": "The square root of 4 is 2."}
</documents>
...<|end_of_text|>
<|start_of_role|>user<|end_of_role|>What is the square root of 4?<|end_of_text|>
<|answerability|>assistant<|end_of_role|>
Produces answerable (or unanswerable for a question the documents don't cover).
The exact formats above are what the model's own chat template renders. The
reliable way to build them is to render the template with adapter_name set —
tokenizer.apply_chat_template(messages, documents=..., adapter_name="answerability", add_generation_prompt=True, tokenize=False) — rather than hand-constructing them.
Running the adapters with Ollama
Because adapter selection lives in the ggml graph and expects the control token already present in the prompt, the cleanest path through Ollama is a raw request where you supply the fully-rendered prompt yourself:
ollama create granite-switch-4.1-3b-preview -f Modelfile # FROM the bf16 GGUF
curl http://localhost:11434/api/generate -d '{
"model": "granite-switch-4.1-3b-preview",
"raw": true,
"prompt": "<|start_of_role|>user<|end_of_role|><|hallucination_detection|>The moon is made of green cheese.<|end_of_text|>\n<|start_of_role|>assistant<|end_of_role|>",
"stream": false,
"options": {"temperature": 0}
}'
raw: true bypasses Ollama's chat template so the control token reaches the model
verbatim. (The normal /api/chat path works too if you embed the token in the
message content, but it cannot reproduce the aLoRA boundary placement for you —
raw mode is the faithful option.)
A current Ollama build already includes granite-switch support, so no patched Ollama is required — you can also drive the adapters with Mellea against stock Ollama, letting Mellea render the template and place the control tokens.
License
Apache 2.0, inherited from the base model.
- Downloads last month
- 453
16-bit
Model tree for barha/granite-switch-4.1-3b-preview-GGUF
Base model
ibm-granite/granite-switch-4.1-3b-preview
Install (macOS, Linux)
# Start a local OpenAI-compatible server with a web UI: llama serve -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16# Run inference directly in the terminal: llama cli -hf barha/granite-switch-4.1-3b-preview-GGUF:BF16