[GH-ISSUE #12511] No <think> token at start for qwen3 #34067

Closed
opened 2026-04-22 17:18:33 -05:00 by GiteaMirror · 12 comments
Owner

Originally created by @GuillaumeOuint on GitHub (Oct 6, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12511

Originally assigned to: @pdevine on GitHub.

What is the issue?

Since the last update of qwen3:4b-thinking-2507-q4_K_M (4 days ago), there no longer is a <think> token at the start but the </think> is present.
I think the issue is present for other qwen3 models.

Relevant log output

No relevant log output, inference is returning 200.
Using OpenAI compatible endpoint though.

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.12.3

Originally created by @GuillaumeOuint on GitHub (Oct 6, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12511 Originally assigned to: @pdevine on GitHub. ### What is the issue? Since the last update of qwen3:4b-thinking-2507-q4_K_M (4 days ago), there no longer is a ``<think>`` token at the start but the ``</think>`` is present. I think the issue is present for other qwen3 models. ### Relevant log output ```shell No relevant log output, inference is returning 200. Using OpenAI compatible endpoint though. ``` ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.12.3
GiteaMirror added the bug label 2026-04-22 17:18:33 -05:00
Author
Owner

@GuillaumeOuint commented on GitHub (Oct 6, 2025):

And of course, the model update was needed because of an update of ollama (or else the model run very very slow).
So I think this is the right place to report this bug.

<!-- gh-comment-id:3372237045 --> @GuillaumeOuint commented on GitHub (Oct 6, 2025): And of course, the model update was needed because of an update of ollama (or else the model run very very slow). So I think this is the right place to report this bug.
Author
Owner

@rick-github commented on GitHub (Oct 6, 2025):

The update was to modify the template, part of which involved pre-filling the <think> token in the assistant output to force think mode. If an API call is made to the model without "think":true, the output of the model will be entirely in the content field (or response for /api/generate), and the output will not have the leading <think> token. If the API is called with "think":true, then the output of the model will be split in to content/response and thinking fields, with neither <think> or </think> tokens in the output.

<!-- gh-comment-id:3372287222 --> @rick-github commented on GitHub (Oct 6, 2025): The update was to modify the template, part of which involved pre-filling the `<think>` token in the assistant output to force think mode. If an API call is made to the model without `"think":true`, the output of the model will be entirely in the `content` field (or `response` for `/api/generate`), and the output will not have the leading `<think>` token. If the API is called with `"think":true`, then the output of the model will be split in to `content`/`response` and `thinking` fields, with neither `<think>` or `</think>` tokens in the output.
Author
Owner

@GuillaumeOuint commented on GitHub (Oct 6, 2025):

OpenAI endpoints don't have a "think" option, just reasoningEffort. So the change broke the openai endpoints. And thinking was working before, why forcing it in the template ?
@rick-github

<!-- gh-comment-id:3372303342 --> @GuillaumeOuint commented on GitHub (Oct 6, 2025): OpenAI endpoints don't have a "think" option, just reasoningEffort. So the change broke the openai endpoints. And thinking was working before, why forcing it in the template ? @rick-github
Author
Owner

@rick-github commented on GitHub (Oct 6, 2025):

And thinking was working before, why forcing it in the template ?

🤷‍♂️ @pdevine

So the change broke the openai endpoints

You can restore the <think> token by removing it from the template.

$ ollama show --modelfile qwen3:4b-thinking-2507-q4_K_M | grep -v '<think>$' > Modelfile
$ ollama create qwen3:4b-thinking-2507-think-q4_K_M
$ curl -s localhost:11434/v1/chat/completions -d '{"model":"qwen3:4b-thinking-2507-think-q4_K_M","messages":[{"role":"user","content":"hello"}],"stream":false}' | jq -r '.choices[0].message.content'
<think>
Okay, the user said "hello". I need to respond appropriately.
...
Alright, that's a good response.
</think>

Hello! 😊 How can I help you today?
<!-- gh-comment-id:3372361026 --> @rick-github commented on GitHub (Oct 6, 2025): > And thinking was working before, why forcing it in the template ? 🤷‍♂️ @pdevine > So the change broke the openai endpoints You can restore the `<think>` token by removing it from the template. ```console $ ollama show --modelfile qwen3:4b-thinking-2507-q4_K_M | grep -v '<think>$' > Modelfile $ ollama create qwen3:4b-thinking-2507-think-q4_K_M ``` ```console $ curl -s localhost:11434/v1/chat/completions -d '{"model":"qwen3:4b-thinking-2507-think-q4_K_M","messages":[{"role":"user","content":"hello"}],"stream":false}' | jq -r '.choices[0].message.content' <think> Okay, the user said "hello". I need to respond appropriately. ... Alright, that's a good response. </think> Hello! 😊 How can I help you today? ```
Author
Owner

@GuillaumeOuint commented on GitHub (Oct 6, 2025):

That's working, thanks ! I don't close the issue because the issue is still there, manual modification needed so not fixed.

<!-- gh-comment-id:3372544198 --> @GuillaumeOuint commented on GitHub (Oct 6, 2025): That's working, thanks ! I don't close the issue because the issue is still there, manual modification needed so not fixed.
Author
Owner

@pdevine commented on GitHub (Oct 6, 2025):

Hey @GuillaumeOuint , sorry about this. I forced it in the template because it's what the model expects (i.e. it's the correct template and in theory should give better results). The template we published originally was incorrect.

I'll take a look at fixing reasoning effort. It looks like it set to take a string pointer right now which is incorrect.

<!-- gh-comment-id:3373455715 --> @pdevine commented on GitHub (Oct 6, 2025): Hey @GuillaumeOuint , sorry about this. I forced it in the template because it's what the model expects (i.e. it's the correct template and in theory should give better results). The template we published originally was incorrect. I'll take a look at fixing reasoning effort. It looks like it set to take a string pointer right now which is incorrect.
Author
Owner

@gparent commented on GitHub (Oct 10, 2025):

Hey, I'm not wanting to create any noise, but the latest pre-release is giving me 400 Bad Request: registry.ollama.ai/library/qwen3-coder:30b does not support thinking when trying to use qwen3-coder. Is this bug related? I did not want to create a duplicate.

<!-- gh-comment-id:3387883529 --> @gparent commented on GitHub (Oct 10, 2025): Hey, I'm not wanting to create any noise, but the latest pre-release is giving me `400 Bad Request: registry.ollama.ai/library/qwen3-coder:30b does not support thinking` when trying to use qwen3-coder. Is this bug related? I did not want to create a duplicate.
Author
Owner

@pdevine commented on GitHub (Oct 10, 2025):

@gparent I made a slight change to the API when I fixed this which was that if you called the chat/generate endpoints w/ a non-thinking model w/ "think": false it would tell you the model was a non-thinking model. While that's technically correct, it broke the app (which was incorrectly adding that to the API call).

There's a fix for this which I just committed, and we've marked the pre-release as DOA and will bump to the next version (0.12.5).

<!-- gh-comment-id:3388008455 --> @pdevine commented on GitHub (Oct 10, 2025): @gparent I made a slight change to the API when I fixed this which was that if you called the chat/generate endpoints w/ a non-thinking model w/ `"think": false` it would tell you the model was a non-thinking model. While that's technically correct, it broke the app (which was incorrectly adding that to the API call). There's a fix for this which I just committed, and we've marked the pre-release as DOA and will bump to the next version (`0.12.5`).
Author
Owner

@gparent commented on GitHub (Oct 10, 2025):

Thank you, seems like you all have it covered already then so that's perfect. Thank you very much!

<!-- gh-comment-id:3388011808 --> @gparent commented on GitHub (Oct 10, 2025): Thank you, seems like you all have it covered already then so that's perfect. Thank you very much!
Author
Owner

@SurealCereal commented on GitHub (Oct 18, 2025):

I can confirm that this problem also occurs with qwen3:30b from here: https://ollama.com/library/qwen3, which I believe to be Qwen/Qwen3-30B-A3B-Thinking-2507.
There is no opening <think> tag, but there is a closing </think> tag produced.

<!-- gh-comment-id:3418365738 --> @SurealCereal commented on GitHub (Oct 18, 2025): I can confirm that this problem also occurs with `qwen3:30b` from here: https://ollama.com/library/qwen3, which I believe to be [Qwen/Qwen3-30B-A3B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-30B-A3B-Thinking-2507). There is no opening `<think>` tag, but there is a closing `</think>` tag produced.
Author
Owner

@suckseed5 commented on GitHub (Oct 23, 2025):

Hi, is this issue resolved? Only , We need to output think.

<!-- gh-comment-id:3434976239 --> @suckseed5 commented on GitHub (Oct 23, 2025): Hi, is this issue resolved? Only </think>, We need to output think.
Author
Owner

@pdevine commented on GitHub (Oct 23, 2025):

@SurealCereal @suckseed5 With this particular model you will only get the </think> back in the content field if:

  1. you are using an older version of ollama; or
  2. you have specified "think": false

The reason why it has an unmatched <think> tag is because the correct template, as defined by the Qwen team, requires the <think> tag to be specified in the prompt which is passed to the model (i.e. the model doesn't generate it, we pass it to the model in the prompt). This particular model does not allow you to not use thinking, so when you pass in "think": false" it's still going to think, only we don't know what to do with the results so you'll have to just add your own think tag at the beginning of the response.

If you don't want the model to think you need to use the qwen3:30b-a3b-instruct model instead.

I'm going to go ahead and close the issue, but feel free to keep commenting and I can reopen it if I missed something.

<!-- gh-comment-id:3439310099 --> @pdevine commented on GitHub (Oct 23, 2025): @SurealCereal @suckseed5 With this particular model you will only get the `</think>` back in the `content` field if: 1. you are using an older version of ollama; or 2. you have specified `"think": false` The reason why it has an unmatched `<think>` tag is because the correct template, _as defined by the Qwen team_, requires the `<think>` tag to be specified in the prompt which is passed to the model (i.e. the model doesn't generate it, we pass it to the model in the prompt). This particular model does not allow you to _not_ use thinking, so when you pass in `"think": false"` it's still going to think, only we don't know what to do with the results so you'll have to just add your own think tag at the beginning of the response. <b>If you don't want the model to think you need to use the `qwen3:30b-a3b-instruct` model instead.</b> I'm going to go ahead and close the issue, but feel free to keep commenting and I can reopen it if I missed something.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#34067