Configuring IBM Granite Models for "Thinking Mode" in OpenWebUI
IBM Granite 3.2 models introduce a controllable "thinking mode" that enables more explicit reasoning and step-by-step explanations in responses. In OpenWebUI, you can activate this mode by injecting a special control message into the conversation. Here’s how to configure and use it:
How "Thinking Mode" Works
- Granite 3.2 models recognize a message with
"role": "control" and "content": "thinking" as a signal to enable their reasoning capabilities for the next user request.
- This approach is supported by both IBM and Ollama, and is designed to be toggled on or off at the request level, allowing for dynamic control of the model's reasoning depth[4][16][5].
Step-by-Step Setup in OpenWebUI
1. Ensure Granite 3.2 Model is Installed and Running
- Use Ollama or another supported backend to serve the Granite 3.2 model (e.g.,
granite3.2:8b-instruct-q8_0).
- Confirm the model is accessible via the OpenAI-compatible API endpoint (typically
http://localhost:11434)[6][9][17].
2. Add the Granite Model to OpenWebUI
- In OpenWebUI, go to the Admin panel.
- Under the "Models" section, add a new model entry pointing to your Granite 3.2 instance.
- Set the model ID (e.g.,
granite3.2:8b-instruct-q8_0) and API endpoint accordingly[6][15].
3. Enable "Thinking Mode" via Control Message
- The key to activating thinking mode is to prepend a message to the conversation with:
{"role": "control", "content": "thinking"}
- The next user message should follow this control message. For example:
[
{"role": "control", "content": "thinking"},
{"role": "user", "content": "How do I get to the airport if my car won't start?"}
]
- The model will then respond with its thought process and reasoning steps[16][5].
4. Automate with a Filter or Function (Optional)
- The OpenWebUI community provides a "Granite Thinking Filter" function that can automatically insert the control message for you[2][12].
- To use it:
- Go to the Functions tab in the Admin panel.
- Add a new function and paste the filter code (available on the OpenWebUI community site).
- Enable the function for your Granite model.
- Configure when to inject the "thinking" control message (e.g., always, or via a toggle in the UI)[2][4].
5. Using the Feature in Practice
- When "thinking mode" is enabled, the model’s responses will include explicit reasoning or step-by-step explanations.
- You can toggle this mode per request or globally, depending on your workflow and the filter/function configuration[4][5].
Example: Manual API Call
If you want to test directly via API (e.g., with curl):
curl -s http://localhost:11434/api/chat -d '{
"model": "granite3.2:8b-instruct-q8_0",
"messages": [
{"role": "control", "content": "thinking"},
{"role": "user", "content": "How many times does the letter r occur in the word strawberry?"}
],
"stream": false
}'
The response will include the model's thought process and answer[5][16].
Troubleshooting & Notes
- Not all frontends support the "control" role natively. If OpenWebUI does not, use the Granite Thinking Filter or modify the system prompt as a workaround[5][2].
- The "thinking" control message is not a system prompt but an extra message in the conversation history[5][16].
- You can also revert to default behavior by sending
{"role": "control", "content": "default"} before the user message[5].
- For advanced setups, you can customize when and how the control message is injected using Python scripts or OpenWebUI functions[2][12].
Summary Table
| Step | Action |
|---|
| 1. Model Setup | Serve Granite 3.2 via Ollama or compatible backend |
| 2. OpenWebUI Integration | Add Granite model in Admin panel, set API endpoint |
| 3. Enable Thinking Mode | Insert {"role": "control", "content": "thinking"} before user messages |
| 4. Automate (Optional) | Use Granite Thinking Filter function in OpenWebUI |
| 5. Test & Use | Send queries; model will respond with explicit reasoning when thinking mode is active |
References:
- [Ollama Granite 3.2 documentation][16]
- [OpenWebUI Granite Thinking Filter][2][12]
- [Community discussions and API examples][4][5]
This setup enables you to leverage the advanced reasoning capabilities of IBM Granite models within OpenWebUI, with fine-grained control over when and how "thinking mode" is applied.