[PR #245] [MERGED] allow specifying zero values in modelfile #10059

Closed
opened 2026-04-12 22:50:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/245
Author: @BruceMacD
Created: 7/31/2023
Status: Merged
Merged: 8/2/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/persist-specified-opts


📝 Commits (2)

  • daa0d1d allow specifying zero values in modelfile
  • 1c5a877 read runner parameter options from map

📊 Changes

5 files changed (+101 additions, -25 deletions)

View changed files

📝 api/types.go (+79 -1)
📝 go.mod (+0 -1)
📝 go.sum (+0 -2)
📝 server/images.go (+18 -17)
📝 server/routes.go (+4 -4)

📄 Description

Previously specifying a zero value in a Modelfile configuration parameters would cause specified value to be overwritten by the default value.

Ex:

FROM llama2
PARAMETER num_gpu 0

This gets overridden at runtime to 1, since the empty (zero) fields are omitted from the Options struct JSON.

This change fixes this behavior by setting default parameters at model create time.

$ ollama create ai-cat -f ./Modelfile
# defaults are set now and written to file

Backwards compatibility for Modelfiles created previously is supported through loading the specified parameters into a DefaultOptions struct then merging them.


🔄 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/245 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 7/31/2023 **Status:** ✅ Merged **Merged:** 8/2/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/persist-specified-opts` --- ### 📝 Commits (2) - [`daa0d1d`](https://github.com/ollama/ollama/commit/daa0d1de7a55bb7dc993645169b02a535d3a40a8) allow specifying zero values in modelfile - [`1c5a877`](https://github.com/ollama/ollama/commit/1c5a8770ee1759fe9b3baadf41b231deba00e588) read runner parameter options from map ### 📊 Changes **5 files changed** (+101 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+79 -1) 📝 `go.mod` (+0 -1) 📝 `go.sum` (+0 -2) 📝 `server/images.go` (+18 -17) 📝 `server/routes.go` (+4 -4) </details> ### 📄 Description Previously specifying a zero value in a Modelfile configuration parameters would cause specified value to be overwritten by the default value. Ex: ``` FROM llama2 PARAMETER num_gpu 0 ``` This gets overridden at runtime to 1, since the empty (zero) fields are omitted from the Options struct JSON. This change fixes this behavior by setting default parameters at model create time. ``` $ ollama create ai-cat -f ./Modelfile # defaults are set now and written to file ``` Backwards compatibility for Modelfiles created previously is supported through loading the specified parameters into a DefaultOptions struct then merging them. --- <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-12 22:50:50 -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#10059