Ollama Thinking Feature Release

Ollama has introduced a new feature that allows users to enable or disable the "thinking" process of supported AI models. This update provides flexibility in how models process information, enabling users to either see the internal reasoning steps (thinking) separated from the final answer or receive a direct response without the reasoning overhead.

Supported Models

Ollama has implemented this capability for the following models:

  • DeepSeek R1: Fully supported.
  • Qwen 3: Fully supported.
  • Additional models will be added to the thinking models category.

CLI Implementation and Usage

In the Ollama CLI, thinking is enabled by default. Users can control this behavior using specific flags and commands:

Command Line Flags

  • Enable Thinking: Use the --think flag.
  • Disable Thinking: Use the --think=false flag.

Interactive Sessions

Within an active chat session, users can toggle thinking using the following slash commands:

  • Enable: /set think
  • Disable: /set nothink

Scripting and Output Filtering

For users who want the model to perform its reasoning process but do not want the reasoning text to appear in the output, the --hidethinking command is available. For example:

ollama run deepseek-r1:8b --hidethinking "is 9.9 bigger or 9.11?"

API Integration

Both the /api/generate and /api/chat endpoints have been updated to include a new think parameter. This parameter accepts a boolean value (true or false).

When think is set to true, the API response separates the model's thinking process from the final content. This allows developers to build custom user interfaces, such as animating a thinking process in a GUI or creating "thinking bubbles" for NPCs in games. When set to false, the model bypasses the thinking process and outputs content directly.

Library Support

Ollama has updated its official libraries to support the new thinking parameter:

Python Library

Users can enable thinking by passing think=True to the chat function. The response object then contains separate response.message.thinking and response.message.content fields.

JavaScript Library

Similar to the Python library, the JavaScript library supports the think: true option in the chat method. It also supports streaming responses, allowing developers to detect when the model switches from the thinking state to the content state by monitoring the chunk.message.thinking and chunk.message.content fields in the stream.

Sources

Related

  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch