使用 System One 对文本进行分类、回答是/否问题,或根据评分标准对文本进行打分。

查看 决策模型完整列表。

设置

启动 Ollama v0.35.0 或更高版本,然后下载 Nimble:

setup.sh
ollama pull nimble

Nimble、Tev1、Clef 和 Clef Flash 均为决策模型。Clef 模型还可以判断图像,并且需要 v0.35.1 或更高版本。

本地请求不需要 API key。

从终端提问

ollama run 用于回答关于状态(state)的问题:状态可以是文本或 JSON,通过管道输入或在模型名称后提供。使用 --ask 提出每个问题。除非你跟随指定了供选择的标签(--choice)或用于打分的等级(--level),否则答案将是“是”或“否”。

examples.sh
# Ask a yes/no question
ollama run nimble --ask "Is a refund being requested?" < ticket.txt

# Choose a label
ollama run nimble --ask "Which team should handle this?" \
  --choice billing="Payments and refunds" \
  --choice technical="Software problems" < ticket.txt

# Score on a scale, from the lowest level to the highest
ollama run nimble --ask "How urgent is this?" \
  --level "Routine" \
  --level "Soon" \
  --level "Immediate" < ticket.txt

# Ask several questions at once
ollama run nimble --ask "Is a refund being requested?" \
  --ask "Which team should handle this?" \
  --choice billing="Payments and refunds" \
  --choice technical="Software problems" \
  --ask "How urgent is this?" \
  --level "Routine" \
  --level "Soon" \
  --level "Immediate" < ticket.txt

# Use a JSON file as the state, and refer to its fields in backticks
ollama run nimble --ask 'Is a refund being requested in `body`?' < ticket.json

# Judge an image with Clef
ollama run clef ./receipt.png --ask "Is this a restaurant receipt?"

# Print the full response
ollama run nimble --ask "Is a refund being requested?" --format json < ticket.txt

每个答案独占一行。“是/否”答案显示更可能的结果及其概率,标签答案显示其概率,打分答案显示最可能的等级、其概率以及量表上的得分:

Is a refund being requested?    yes      97%
Which team should handle this?  billing  91%
How urgent is this?             Soon     64%  1.2 / 2

如果没有提供状态,ollama run nimble 将打开一个交互式提示符。你的第一条消息作为状态,之后每一行都是关于该状态的“是/否”问题,因此你可以一次粘贴多个问题;使用 /clear 重新开始。如果使用 --ask,每条消息都是一个新状态,用于回答那些问题。

选择标签

将输入放入 state,并在 criteria 中描述可能的答案:

choice.sh
curl http://localhost:11434/v1/systemone \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "nimble",
    "state": "Our checkout has returned 500 errors since 9am.",
    "questions": {
      "label": {
        "type": "choice",
        "instructions": "Which label fits this ticket?",
        "criteria": {
          "billing": "Payments and refunds",
          "bug": "Software errors",
          "account": "Login and account access"
        }
      }
    }
  }'

响应示例:

{
  "model": "nimble",
  "answers": {
    "label": {
      "type": "choice",
      "choice": "bug",
      "probabilities": {"billing": 0.0125, "bug": 0.9781, "account": 0.0093},
      "confidence": 0.8906
    }
  },
  "usage": {"input_tokens": 174, "output_tokens": 1}
}

判断图像

Clef 和 Clef Flash 可以结合状态读取图像。在 images 中发送 base64 编码的 PNG、JPEG 或 WebP 文件;它们由所有问题共享,并按请求顺序排列。不接受 URL 和 data URLs。state 仍然是必需的——它包含决策所需的上下文。

image.sh
curl http://localhost:11434/v1/systemone \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "clef-flash",
    "state": "A user took this screenshot and wants to know what it shows.",
    "images": ["<base64-encoded image>"],
    "questions": {
      "has_ollama": {
        "type": "noul",
        "instructions": "Does this image contain Ollama?"
      },
      "app": {
        "type": "choice",
        "instructions": "Which application is shown in this screenshot?",
        "criteria": {
          "vscode": "Visual Studio Code",
          "terminal": "A terminal emulator",
          "browser": "A web browser",
          "other": "A different application"
        }
      }
    }
  }'

响应示例:

{
  "model": "clef-flash",
  "answers": {
    "has_ollama": {"type": "noul", "noul": 0.959},
    "app": {
      "type": "choice",
      "choice": "vscode",
      "probabilities": {"vscode": 0.966, "other": 0.017, "browser": 0.010, "terminal": 0.007},
      "confidence": 0.868
    }
  },
  "usage": {"input_tokens": 677, "output_tokens": 0}
}

使用云端模型

Clef 也可以在 Ollama’s cloud 上运行,需要付费计划或购买 usage credits。在模型名称后添加 :cloud,即可通过已登录 ollama.com 的本地 Ollama 服务器(v0.40.5 或更高版本)发送请求:

cloud.sh
curl http://localhost:11434/v1/systemone \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "clef:cloud",
    "state": "Our checkout has returned 500 errors since 9am.",
    "questions": {
      "urgent": {
        "type": "noul",
        "instructions": "Does this ticket need attention within the hour?"
      }
    }
  }'

或者使用 API key 直接调用 ollama.com:

cloud-direct.sh
curl https://ollama.com/v1/systemone \
  -H "Authorization: Bearer $OLLAMA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "clef",
    "state": "Our checkout has returned 500 errors since 9am.",
    "questions": {
      "urgent": {
        "type": "noul",
        "instructions": "Does this ticket need attention within the hour?"
      }
    }
  }'

云端请求最多接受 64 个问题,问题名称由最多 100 个 ASCII 字母、数字、_、. 或 - 组成,并支持最多 4 张图片,每张图片大小不超过 4 MiB 且像素数不超过 16 megapixels,总大小限制为 8 MiB。输入受限于模型的 65,536-token 上下文窗口;更长的输入将被拒绝。用量按每个 input token 以 listed price 计费。

问题类型

类型标准结果
choice2–26 个带有描述的命名选项最可能的选项以及每个选项的概率
noul"false" 和 "true" 的描述true 的概率,范围从 0 到 1
score2–10 个描述,按从低到高排序基于零索引级别的概率加权平均值

对于以下紧急程度标准:

score = 0 × P(Routine) + 1 × P(Soon) + 2 × P(Immediate)

对于 choice 和 score,confidence 衡量模型倾向于某个答案而非其他答案的程度,范围从 0 到 1。较高的值并不保证答案是正确的。

提出多个问题

在一个请求中组合多种问题类型。在此示例中,两个问题都使用同一个工单:

multiple.sh
curl http://localhost:11434/v1/systemone \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "nimble",
    "state": {"ticket": "I was charged twice. Please refund the extra payment."},
    "questions": {
      "refund": {
        "type": "noul",
        "instructions": "Is the customer requesting a refund?",
        "criteria": {
          "false": "No refund is requested",
          "true": "The customer requests a refund"
        }
      },
      "urgency": {
        "type": "score",
        "instructions": "How urgently does this ticket need a response?",
        "criteria": [
          "Routine: no time pressure",
          "Soon: a customer is inconvenienced",
          "Immediate: a critical service is unavailable"
        ]
      }
    }
  }'

这返回了退款概率 0.9989 和 0–2 量表上的紧急程度评分 0.8308(四舍五入)。结果可能因模型和配置而异。

有关请求字段、限制、错误和 token 用量的信息,请参阅 API reference。