运行模型

运行指定模型

模型服务是由模型镜像启动的进程,用于处理用户请求。

运行模型

在终端直接执行如下命令即可运行命令,如果模型不存在也会自动下载该模型。

ollama run qwen3.5:9b

运行成功后,就可以进行对话了。

如果想退出对话,使用 Ctrl + d快捷键, 或者输入 /bye

% ollama run qwen3.5:9b
>>>
>>> 你好
Thinking...
Thinking Process:

1.  **Analyze the Request:**
    *   Input: "你好" (Nǐ hǎo) - Chinese for "Hello".
    *   Intent: Greeting.
    *   Language: Chinese.
    *   Expected Response: A polite greeting in return, offering assistance.

2.  **Determine the appropriate tone:**
    *   Friendly, polite, helpful.
    *   Match the user's language (Chinese).

3.  **Draft possible responses:**
    *   Simple: 你好!有什么我可以帮你的吗? (Hello! Is there anything I can help you with?)
    *   Warm: 你好呀!很高兴见到你。今天有什么我可以帮你的吗? (Hello! Nice to meet you. Is there anything I can help you with today?)
    *   Professional: 您好,我是 Qwen3.5,很高兴为您服务。请问有什么可以帮您? (Hello, I am Qwen3.5, glad to serve you. How may I assist you?)

4.  **Select the best response:**
    *   Since I'm an AI assistant, being polite and offering help is standard.
    *   Keep it natural.
    *   "你好!有什么我可以帮你的吗?" is good.
    *   Maybe add a bit of warmth.

5.  **Final Polish (Internal Monologue):**
    *   The user said "你好". I should reply with "你好" and offer help.
    *   Let's keep it concise but friendly.

6.  **Final Output Construction:**
    *   "你好!有什么我可以帮你的吗?" or "你好呀!欢迎使用我的服务,请问今天有什么可以帮您的?"
    *   Let's go with a balanced, friendly version.

    *   Selected: 你好!很高兴为你服务。今天有什么我可以帮助你的吗?

7.  **Output Generation** (matching the thought process).
...done thinking.

你好!很高兴见到你。👋

有什么我可以帮你的吗?无论是回答问题、创作文字,还是协助分析文档,我都在这里随时待命哦。

>>> Send a message (/? for help)

禁用思考

方法1: 启动时添加 --think=false 参数

如果不想启动思考,你可以使用 --think=false 参数来禁用它。

% ollama run qwen3.5:9b --think=false
>>> 早上好
早上好!☀️ 新的一天开始了,愿你心情愉快、充满活力。有什么我可以帮你的吗?无论是回答问题、寻找灵感,还是需要一点小建议,随时告诉我哦!😊

方法2: 添加 /set nothink 命令

在聊天窗口中,输入 /set nothink 命令来禁用思考。

 % ollama run qwen3.5:9b
>>> /set nothink
Set 'nothink' mode.
>>> 你好
你好!有什么我可以帮你的吗?😊

方法3: 通过 API 调用控制

在使用 Ollama 的 API 进行聊天请求时,可以在请求体中设置 “think”: false 来关闭思考。

{
  "model": "qwen3.5:9b",
  "messages": [
    {"role": "user", "content": "你好"}
  ],
  "think": false
}

查看运行中的模型

通过 ollama run 运行启动中的模型,通过 ollama ps命令可以查看

% ollama ps
NAME          ID              SIZE      PROCESSOR    CONTEXT    UNTIL
qwen3.5:9b    6488c96fa5fa    8.6 GB    100% GPU     4096       4 minutes from now

停止模型

通过 ollama stop 命令可以停止模型

% ollama stop qwen3.5:9b