微信扫码
添加专属顾问
 
                        我要投稿
Ollama新版带来AI思维链控制功能,让用户自由切换模型的思考模式,打造更灵活的交互体验。 核心内容: 1. 思考模式开关功能详解(CLI/REST API双端支持) 2. 应用场景演示:动画呈现思考过程/NPC气泡对话 3. 支持模型清单与典型使用命令示例
 
                                
Ollama 现在可以启用或禁用思考功能。这使用户可以灵活地针对不同的应用程序和用例选择模型的思考行为。
当开启思考时,输出会将模型的思考和模型的输出分离;当关闭思考时,模型不会思考,直接输出内容。
支持思考的模型:
CLI中缺省是启用思考模式的,如:
ollama run deepseek-r1
如果要禁用思考模式,可以在互动环境时输入***/set nothink***
在互动环节输入:/set think以启用思考模式
也可以直接在执行命令的时候设置思考模式
ollama run deepseek-r1 --think # 开启思考模式ollama run deepseek-r1 --think=false #禁用思考模式
对于直接使用脚本进行推理时,可以使用--hidethinking,这会启用思维模型但只想返回最终的结果,而不包括思考过程。
ollama run deepseek-r1:8b --hidethinking "9.9与9.11哪一个更大?"
Ollama 的生成 API(/api/generate)和聊天 API(/api/chat)均已更新,以支持思考。
新增了一个think参数,可以设置为true或false用于启用模型的思考过程。当该think参数设置为 true 时,输出将把模型的思考与模型的输出分离。这可以帮助用户打造全新的应用体验,例如通过图形界面以动画形式呈现思考过程,或者让游戏中的 NPC 在输出前显示思考气泡。当该think参数设置为 false 时,模型将不会思考,直接输出内容。
使用 Ollama 聊天 API 并启用思考的示例
curl http://localhost:11434/api/chat -d '{  "model": "deepseek-r1",  "messages": [    {      "role": "user",      "content": "how many r in the word strawberry?"    }  ],  "think": true,  "stream": false}'输出
{"model":"deepseek-r1","created_at":"2025-05-29T09:35:56.836222Z","message":    {"role": "assistant",    "content": "The word \"strawberry\" contains **three** instances of the letter 'R' ..."    "thinking": "First, the question is: \"how many r in the word  strawberry?\" I need to count the number of times the letter 'r' appears in the word \"strawberry\". Let me write down the word:...",    "done_reason":"stop",    "done":true,    "total_duration":47975065417,    "load_duration":29758167,    "prompt_eval_count":10,    "prompt_eval_duration":174191542,    "eval_count":2514,    "eval_duration":47770692833    }}请更新到最新的 Ollama Python 库。
pip install ollama
from ollama import chatmessages = [  {    'role': 'user',    'content': 'What is 10 + 23?',  },]response = chat('deepseek-r1', messages=messages, think=True)print('Thinking:\n========\n\n' + response.message.thinking)print('\nResponse:\n========\n\n' + response.message.content)请更新到最新的 Ollama JavaScript 库。
npm i ollama
import ollama from 'ollama'async function main() {  const response = await ollama.chat({    model: 'deepseek-r1',    messages: [      {        role: 'user',        content: 'What is 10 + 23',      },    ],    stream: false,    think: true,  })  console.log('Thinking:\n========\n\n' + response.message.thinking)  console.log('\nResponse:\n========\n\n' + response.message.content + '\n\n')}main()思考式流式响应示例
import ollama from 'ollama'async function main() {  const response = await ollama.chat({    model: 'deepseek-r1',    messages: [      {        role: 'user',        content: 'What is 10 + 23',      },    ],    stream: true,    think: true,  })  let startedThinking = false  let finishedThinking = false  for await (const chunk of response) {    if (chunk.message.thinking && !startedThinking) {      startedThinking = true      process.stdout.write('Thinking:\n========\n\n')    } else if (chunk.message.content && startedThinking && !finishedThinking) {      finishedThinking = true      process.stdout.write('\n\nResponse:\n========\n\n')    }    if (chunk.message.thinking) {      process.stdout.write(chunk.message.thinking)    } else if (chunk.message.content) {      process.stdout.write(chunk.message.content)    }  }}main()暂不支持
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-10-31
OpenAI 公开 Atlas 架构:为 Agent 重新发明浏览器
2025-10-31
Palantir 本体论模式:重塑企业 AI 应用的 “语义根基” 与产业启示
2025-10-31
树莓派这种“玩具级”设备,真能跑大模型吗?
2025-10-30
Cursor 2.0的一些有趣的新特性
2025-10-30
Anthropic 发布最新研究:LLM 展现初步自省迹象
2025-10-30
让Agent系统更聪明之前,先让它能被信任
2025-10-30
Rag不行?谷歌DeepMind同款,文档阅读新助手:ReadAgent
2025-10-29
4大阶段,10个步骤,助你高效构建企业级智能体(Agent)
 
            2025-08-21
2025-08-21
2025-08-19
2025-09-16
2025-10-02
2025-09-08
2025-09-17
2025-08-19
2025-09-29
2025-08-20