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"
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -23,13 +23,106 @@ GGUF conversion of [ibm-granite/granite-switch-4.1-3b-preview](https://huggingfa
|
|
| 23 |
|---|---|
|
| 24 |
| `granite-switch-4.1-3b-preview-bf16.gguf` | bf16 GGUF, includes base model weights and all 12 embedded LoRA adapters |
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
```bash
|
| 29 |
llama-cli -m granite-switch-4.1-3b-preview-bf16.gguf -p "Hello"
|
| 30 |
```
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## License
|
| 35 |
|
|
|
|
| 23 |
|---|---|
|
| 24 |
| `granite-switch-4.1-3b-preview-bf16.gguf` | bf16 GGUF, includes base model weights and all 12 embedded LoRA adapters |
|
| 25 |
|
| 26 |
+
## Basic usage
|
| 27 |
|
| 28 |
```bash
|
| 29 |
llama-cli -m granite-switch-4.1-3b-preview-bf16.gguf -p "Hello"
|
| 30 |
```
|
| 31 |
|
| 32 |
+
With no control token, the model runs as the plain base chat model.
|
| 33 |
+
|
| 34 |
+
## Adapter activation
|
| 35 |
+
|
| 36 |
+
Granite Switch embeds 12 adapters in one checkpoint. An in-graph router selects
|
| 37 |
+
which adapter is active by detecting a control token in the prompt. The selection
|
| 38 |
+
is **per request (one adapter per generation)** β the control token routes the whole
|
| 39 |
+
sequence to a single adapter slot, then is substituted out before embedding so it
|
| 40 |
+
does not corrupt the text.
|
| 41 |
+
|
| 42 |
+
To activate an adapter you place its control token in the prompt at the position
|
| 43 |
+
the model was trained for. Placement differs by adapter type:
|
| 44 |
+
|
| 45 |
+
- **LoRA adapters** β the token goes at the very start, replacing the leading
|
| 46 |
+
`<|start_of_role|>`. Adapters: `citations`, `hallucination_detection`,
|
| 47 |
+
`context-attribution`.
|
| 48 |
+
- **aLoRA adapters** β the token is spliced right before the final
|
| 49 |
+
`assistant<|end_of_role|>` generation prompt (replacing its `<|start_of_role|>`).
|
| 50 |
+
Adapters: `query_rewrite`, `query_clarification`, `answerability`,
|
| 51 |
+
`factuality-detection`, `policy-guardrails`, `factuality-correction`,
|
| 52 |
+
`guardian-core`, `uncertainty`, `requirement-check`.
|
| 53 |
+
|
| 54 |
+
| Adapter | Type | Control token | Output |
|
| 55 |
+
|---|---|---|---|
|
| 56 |
+
| citations | lora | `<\|citations\|>` | citation spans |
|
| 57 |
+
| hallucination_detection | lora | `<\|hallucination_detection\|>` | `[{"r","f":faithful/partial/unfaithful/NA,"e"}]` |
|
| 58 |
+
| context-attribution | lora | `<\|context-attribution\|>` | attribution spans |
|
| 59 |
+
| query_rewrite | alora | `<\|query_rewrite\|>` | rewritten query |
|
| 60 |
+
| query_clarification | alora | `<\|query_clarification\|>` | clarification or `CLEAR` |
|
| 61 |
+
| answerability | alora | `<\|answerability\|>` | `answerable` / `unanswerable` |
|
| 62 |
+
| factuality-detection | alora | `<\|factuality-detection\|>` | `yes` / `no` |
|
| 63 |
+
| policy-guardrails | alora | `<\|policy-guardrails\|>` | `Yes` / `No` / `Ambiguous` |
|
| 64 |
+
| factuality-correction | alora | `<\|factuality-correction\|>` | corrected text |
|
| 65 |
+
| guardian-core | alora | `<\|guardian-core\|>` | `yes` / `no` (risk) |
|
| 66 |
+
| uncertainty | alora | `<\|uncertainty\|>` | `0`..`9` (certainty) |
|
| 67 |
+
| requirement-check | alora | `<\|requirement-check\|>` | `yes` / `no` |
|
| 68 |
+
|
| 69 |
+
### Example: `hallucination_detection` (LoRA β token at start)
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
<|hallucination_detection|>user<|end_of_role|>Tell me about the moon.<|end_of_text|>
|
| 73 |
+
<|start_of_role|>assistant<|end_of_role|>The moon is made of green cheese.<|end_of_text|>
|
| 74 |
+
<|start_of_role|>assistant<|end_of_role|>
|
| 75 |
+
```
|
| 76 |
+
Produces the adapter's structured JSON, e.g.
|
| 77 |
+
`[{"r": 0, "f": "unfaithful", "e": "..."}]` instead of a chat reply.
|
| 78 |
+
|
| 79 |
+
### Example: `answerability` (aLoRA β token before the assistant prompt)
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
<|start_of_role|>system<|end_of_role|>You are a helpful assistant with access to the following documents...
|
| 83 |
+
<documents>
|
| 84 |
+
{"doc_id": "1", "text": "The square root of 4 is 2."}
|
| 85 |
+
</documents>
|
| 86 |
+
...<|end_of_text|>
|
| 87 |
+
<|start_of_role|>user<|end_of_role|>What is the square root of 4?<|end_of_text|>
|
| 88 |
+
<|answerability|>assistant<|end_of_role|>
|
| 89 |
+
```
|
| 90 |
+
Produces `answerable` (or `unanswerable` for a question the documents don't cover).
|
| 91 |
+
|
| 92 |
+
The exact formats above are what the model's own chat template renders. The
|
| 93 |
+
reliable way to build them is to render the template with `adapter_name` set β
|
| 94 |
+
`tokenizer.apply_chat_template(messages, documents=..., adapter_name="answerability",
|
| 95 |
+
add_generation_prompt=True, tokenize=False)` β rather than hand-constructing them.
|
| 96 |
+
|
| 97 |
+
## Running the adapters with Ollama
|
| 98 |
+
|
| 99 |
+
Because adapter selection lives in the ggml graph and expects the control token
|
| 100 |
+
already present in the prompt, the cleanest path through Ollama is a **raw** request
|
| 101 |
+
where you supply the fully-rendered prompt yourself:
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
ollama create granite-switch-4.1-3b-preview -f Modelfile # FROM the bf16 GGUF
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
```bash
|
| 108 |
+
curl http://localhost:11434/api/generate -d '{
|
| 109 |
+
"model": "granite-switch-4.1-3b-preview",
|
| 110 |
+
"raw": true,
|
| 111 |
+
"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|>",
|
| 112 |
+
"stream": false,
|
| 113 |
+
"options": {"temperature": 0}
|
| 114 |
+
}'
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
`raw: true` bypasses Ollama's chat template so the control token reaches the model
|
| 118 |
+
verbatim. (The normal `/api/chat` path works too if you embed the token in the
|
| 119 |
+
message content, but it cannot reproduce the aLoRA boundary placement for you β
|
| 120 |
+
raw mode is the faithful option.)
|
| 121 |
+
|
| 122 |
+
A current Ollama build already includes granite-switch support, so **no patched
|
| 123 |
+
Ollama is required** β you can also drive the adapters with
|
| 124 |
+
[Mellea](https://mellea.ai/) against stock Ollama, letting Mellea render the
|
| 125 |
+
template and place the control tokens.
|
| 126 |
|
| 127 |
## License
|
| 128 |
|