[Feature request]: Suppress thinking block from thinking models
What do you need?
A lot of new models provide thinking block during their response where they include internal rationing and thoughts, typically using the tags:
example:
It would be nice to be able to a) suppress anything inside a thinking block like this, and b) configure what tags to be excluded from the output, and c) have the option to auto suppress this in the configuration, rather than having to pass a command line argument.
Agreed, suppression at user's discretion would be helpful.
May not be straightforward though. For implementation problems and workarounds, see discussion at don't show the thinking process · Issue 8528 · ollamaollama.
Additionally, not always clear is whether turning off thinking turns off 'display of thinking' or turns off 'deep thinking' altogether. Eg see the explanation under 'Key Features' 'Hybrid thinking modes' at Qwen3 Think Deeper, Act Faster Qwen.
If I understand the Qwen3 text correctly, they are saying turning off thinking doesn't just turn off 'display of thinking' but turns down thinking capacity.
If so, that's a shame because their way of turning off thinking seems to be easily achievable by appending /no_think to the system prompt. I've quick and dirty tested adding '/no_think' to fabric system.md files on a line between the prompt-end and before the INPUT variable but I still see 'thinking'. I'm not inclined to test further because I want all the thinking capacity I can get, just not the display of it.
However, see Goose and Qwen3 for Local Execution - codename goose for a Goose user using this technique.
All this suggests the safest way of implementing the request would be to leave 'thinking' enabled and dump or divert the first 'thinking' part of the model's output. However, per the discussion at don't show the thinking process · Issue 8528 · ollamaollama, identifying the boundary between 'thinking' and 'response' in different models is not straightforward.
100% on this
identifying the boundary between 'thinking' and 'response' in different models is not straightforward.
One option could be having this configurable when choosing a model, or at least as a temporary override. Popular models could have this preconfigured.
What is the think block syntax?
identifying the boundary between 'thinking' and 'response' in different models is not straightforward.
One option could be having this configurable when choosing a model, or at least as a temporary override. Popular models could have this preconfigured.
What is the think block syntax?
Yeah, allow the user to set a start and end tag per model (most thinking models do it this way), which simply filter out the tags and anything in between them.
We still want the model to think, but the output is distracting or makes it directly unusable.
Might also go hand in hand with customized tool use tags per model, where a model.supports tools.
Okay... I'll take care of this one soon too.
The thinking block usually looks like <think> and </think> so it should be easy to filter out.
Thanks folks!
If it helps, since I commented above, I've noticed some Ollama LLMs are now tagging the 'answer' part of their response within the tags:
<answer> </answer>
So their full tag assemblage looks like this:
<thinking> Various thoughts, reasoning </thinking>
<answer> The response to the user's question, task, etc </answer>
I suspect this is a model-developers' move towards integration with - or at least playing nicely with - MCP. If so, more formal rules may eventually appear in the MCP roadmap. Though a skim read suggests the roadmap is currently more about prompt structure than response structure.
Lee
I think there are two issues to address here.
- Suppress thinking from output
- Disable thinking
It would be nice to able to have a flag fabric --thinking or something to toggle thinking on or off. Also maybe a global setting that sets the default. Potentially at the model level?
Knowing what models take the thinking flag might need to tracked.
To be clear: my original feature request was purely about suppressing the output, not disabling the functionality.
The reason being the thinking text gets in the way of parsing the requested output (say, pure code or a command) by another command/LLM/human.
To be clear: my original feature request was purely about suppressing the output, not disabling the functionality.
The reason being the thinking text gets in the way of parsing the requested output (say, pure code or a command) by another command/LLM/human.
I agree, but I think having the option to disable thinking would be nice as it speeds the response up a lot and there are times thinking isn't critical. I think both would have a big benefit, but the suppression is critical as it makes using any Qwen/Deepseek model difficult without it.
I'll put this on the top of my queue.
It’s probably going to be in two sets of changes:
- Strip out the thinking block in the output
- if possible give the option of disabling the thinking altogether
fabric --help | grep think
--suppress-think Suppress text enclosed in thinking tags
--think-start-tag= Start tag for thinking sections (default: <think>)
--think-end-tag= End tag for thinking sections (default: </think>)
Also #1620 for the shell completions scripts
@oemsysadm @officiallymarky @KenMacD Let me know if this is what you wanted and if it's working well for you.
It works, and this is a big help for using DeepSeek/Qwen models.
Since you know when you choose a model in fabric --setup if it is a thinking model, it would make sense to have an option to suppress thinking there, this way all the aliases work properly.
Right now, to surpress think using an alias like summarize, you have to call fabric -p summarize --surpress-think instead of just summarize. I did confirm it did in fact suppress think as expected.
It works, and this is a big help for using DeepSeek/Qwen models.
Since you know when you choose a model in fabric --setup if it is a thinking model, it would make sense to have an option to suppress thinking there, this way all the aliases work properly.
Right now, to surpress think using an alias like summarize, you have to call fabric -p summarize --surpress-think instead of just summarize. I did confirm it did in fact suppress think as expected.
I'm adding support for a ~/.fabric.yml config file, which should resolve this for you. @officiallymarky
This is what the file looks like:
model: qwen3:latest
stream: true
# suppress vendor thinking output
suppressThink: false
thinkStartTag: "<think>"
thinkEndTag: "</think>"
Notice that suppressThink is false.
$ fabric -s 'What is 2+2'
<think>
Okay, the user asked "What is 2+2". Let me start by solving the math problem. 2 plus 2 equals 4. That's straightforward.
Now, I need to present the answer clearly. The user might be testing basic arithmetic, so I should make sure the answer is correct. Maybe they want a simple response, but perhaps they also want an explanation. Since the question is direct, the answer is 4.
I should check if there's any context I'm missing. The user didn't provide any additional information, so it's just a basic addition problem. No need to complicate it.
The response should be in English as specified. Let me confirm the calculation again to avoid mistakes. Yes, 2 + 2 is definitely 4. Alright, time to put it all together.
</think>
**Answer:**
2 + 2 equals **4**.
And with suppressThink set to true:
$ fabric -s 'What is 2+2'
**Answer:**
2 + 2 equals **4**.
Right now, to surpress think using an alias like summarize, you have to call fabric -p summarize --surpress-think instead of just summarize. I did confirm it did in fact suppress think as expected.
@officiallymarky If you're using the standard aliases, this also works:
summarize --suppress-think
@officiallymarky #1624 implements the change and fixes some long-standing subtle bugs in the way a YAML config file was being applied.
@officiallymarky and everyone here, I am moving the config file from ~/.fabric.yaml to ~/.config/fabric/config.yaml at @danielmiessler request.
Just keeping everytihng consistent.