[PR #14108] feat: add PARAMETER think support for Modelfile #25059

Open
opened 2026-04-19 17:58:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14108
Author: @sanchez314c
Created: 2/6/2026
Status: 🔄 Open

Base: mainHead: feature/parameter-think


📝 Commits (1)

  • 63081de feat: add PARAMETER think support for Modelfile

📊 Changes

3 files changed (+62 additions, -0 deletions)

View changed files

📝 cmd/cmd.go (+25 -0)
📝 parser/parser.go (+15 -0)
📝 server/routes.go (+22 -0)

📄 Description

Summary

Adds support for PARAMETER think false|true|high|medium|low in Modelfiles, allowing thinking-capable models to persist a default thinking mode.

Problem: Currently, thinking-capable models always auto-enable thinking when no explicit think value is provided in the request. There's no way to create a model variant that defaults to thinking disabled. Users must pass think: false in every API request or use --think=false on every CLI invocation. This is especially problematic for apps like Open WebUI that don't expose the think parameter.

Solution: Allow PARAMETER think in Modelfiles with a clear priority chain:

  1. Request-level think (API/CLI flag) — highest priority, always wins
  2. Model-level PARAMETER think — used when request doesn't specify
  3. Auto-enable — fallback for thinking-capable models (existing behavior preserved)

Example Usage

# Create a no-think variant
FROM nemotron-3-nano:30b
PARAMETER think false
ollama create nemotron-3-nano:30b-nothink -f Modelfile
ollama run nemotron-3-nano:30b-nothink  # No thinking by default
ollama run nemotron-3-nano:30b           # Still thinks as before

API requests can still override:

{"model": "nemotron-3-nano:30b-nothink", "think": true}

Changes

  • parser/parser.go: Intercepts think parameter before FormatParams() (since it's not in the Options struct), validates values, and stores it as a model parameter
  • server/routes.go: Both GenerateHandler and ChatHandler check m.Options["think"] when req.Think is nil, before falling back to auto-enabling thinking
  • cmd/cmd.go: inferThinkingOption() checks the model's stored parameters for a think default before auto-enabling thinking client-side

Backward Compatibility

  • Models without PARAMETER think behave exactly as before (thinking auto-enabled)
  • Existing --think=false CLI flag and "think": false API parameter still work
  • Request-level always overrides model-level
  • No changes to the Options struct or FormatParams() — the think parameter is handled separately, consistent with how ThinkValue is already a separate field on request types

Test Matrix

Model Request think Result
Standard model (none) Thinking ON (unchanged)
Standard model false Thinking OFF (unchanged)
PARAMETER think false model (none) Thinking OFF (new)
PARAMETER think false model true Thinking ON (override works)

Fixes #10961


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14108 **Author:** [@sanchez314c](https://github.com/sanchez314c) **Created:** 2/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/parameter-think` --- ### 📝 Commits (1) - [`63081de`](https://github.com/ollama/ollama/commit/63081ded2aec9cf0cb4284494013893c81b9015b) feat: add PARAMETER think support for Modelfile ### 📊 Changes **3 files changed** (+62 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+25 -0) 📝 `parser/parser.go` (+15 -0) 📝 `server/routes.go` (+22 -0) </details> ### 📄 Description ## Summary Adds support for `PARAMETER think false|true|high|medium|low` in Modelfiles, allowing thinking-capable models to persist a default thinking mode. **Problem**: Currently, thinking-capable models always auto-enable thinking when no explicit `think` value is provided in the request. There's no way to create a model variant that defaults to thinking disabled. Users must pass `think: false` in every API request or use `--think=false` on every CLI invocation. This is especially problematic for apps like Open WebUI that don't expose the think parameter. **Solution**: Allow `PARAMETER think` in Modelfiles with a clear priority chain: 1. **Request-level** `think` (API/CLI flag) — highest priority, always wins 2. **Model-level** `PARAMETER think` — used when request doesn't specify 3. **Auto-enable** — fallback for thinking-capable models (existing behavior preserved) ## Example Usage ``` # Create a no-think variant FROM nemotron-3-nano:30b PARAMETER think false ``` ```bash ollama create nemotron-3-nano:30b-nothink -f Modelfile ollama run nemotron-3-nano:30b-nothink # No thinking by default ollama run nemotron-3-nano:30b # Still thinks as before ``` API requests can still override: ```json {"model": "nemotron-3-nano:30b-nothink", "think": true} ``` ## Changes - **parser/parser.go**: Intercepts `think` parameter before `FormatParams()` (since it's not in the `Options` struct), validates values, and stores it as a model parameter - **server/routes.go**: Both `GenerateHandler` and `ChatHandler` check `m.Options["think"]` when `req.Think` is nil, before falling back to auto-enabling thinking - **cmd/cmd.go**: `inferThinkingOption()` checks the model's stored parameters for a think default before auto-enabling thinking client-side ## Backward Compatibility - Models without `PARAMETER think` behave exactly as before (thinking auto-enabled) - Existing `--think=false` CLI flag and `"think": false` API parameter still work - Request-level always overrides model-level - No changes to the `Options` struct or `FormatParams()` — the think parameter is handled separately, consistent with how `ThinkValue` is already a separate field on request types ## Test Matrix | Model | Request `think` | Result | |-------|----------------|--------| | Standard model | *(none)* | Thinking ON (unchanged) | | Standard model | `false` | Thinking OFF (unchanged) | | `PARAMETER think false` model | *(none)* | **Thinking OFF** (new) | | `PARAMETER think false` model | `true` | Thinking ON (override works) | Fixes #10961 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 17:58:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25059