[GH-ISSUE #1699] Modelfile parameters not set during creation #47471

Closed
opened 2026-04-28 03:53:12 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @tylertitsworth on GitHub (Dec 24, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/1699

I have a model like so: (also providing system details)

$ cat /etc/os-release | head -n 4
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
$ ollama -v
ollama version is 0.1.17
$ ollama show test --modelfile
# Modelfile generated by "ollama show"
# To build a new Modelfile based on this one, replace the FROM line with:
# FROM test:latest

FROM /usr/share/ollama/.ollama/models/blobs/sha256:8f7e99455a86ad490dab19d335d8c2d1d044e2744b923d4e78a4d84fe1457738
TEMPLATE """### System:
{{ .System }}

### User:
{{ .Prompt }}

### Assistant:
"""
SYSTEM """
Given the following extracted parts of a long document and a question, create a final answer with references ("SOURCES"). 
If you don't know the answer, just say that you don't know. Don't try to make up an answer.
ALWAYS return a "SOURCES" part in your answer.
---
Content: {context}
---
"""
PARAMETER repeat_penalty 1.3
PARAMETER temperature 0.4
PARAMETER top_k 20
PARAMETER top_p 0.65

My parameters shown in this output are the same as what I have set in my Modelfile.
However, when I query the API for the parameter values, I see that they are different values for repeat_penalty, temperature, and top_p:

$ ollama show test --parameters
repeat_penalty                 1
temperature                    0
top_k                          20
top_p                          1
$ curl http://localhost:11434/api/show -d '{"name": "test"}'
{
  "modelfile": "# Modelfile generated by \"ollama show\"\n# To build a new Modelfile based on this one, replace the FROM line with:\n# FROM test:latest\n\nFROM /usr/share/ollama/.ollama/models/blobs/sha256:8f7e99455a86ad490dab19d335d8c2d1d044e2744b923d4e78a4d84fe1457738\nTEMPLATE \"\"\"### System:\r\n{{ .System }}\r\n\r\n### User:\r\n{{ .Prompt }}\r\n\r\n### Assistant:\r\n\"\"\"\nSYSTEM \"\"\"\r\nGiven the following extracted parts of a long document and a question, create a final answer with references (\"SOURCES\"). \r\nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\r\nALWAYS return a \"SOURCES\" part in your answer.\r\n---\r\nContent: {context}\r\n---\r\n\"\"\"\nPARAMETER repeat_penalty 1.3\nPARAMETER temperature 0.4\nPARAMETER top_k 21\nPARAMETER top_p 0.65",
  "parameters": "top_p                          1\nrepeat_penalty                 1\ntemperature                    0\ntop_k                          20",
  "template": "### System:\r\n{{ .System }}\r\n\r\n### User:\r\n{{ .Prompt }}\r\n\r\n### Assistant:\r\n",
  "system": "\r\nGiven the following extracted parts of a long document and a question, create a final answer with references (\"SOURCES\"). \r\nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\r\nALWAYS return a \"SOURCES\" part in your answer.\r\n---\r\nContent: {context}\r\n---\r\n",
  "details":
    {
      "format": "gguf",
      "family": "llama",
      "families": ["llama"],
      "parameter_size": "7B",
      "quantization_level": "Q4_0",
    },
}

Cleaning up that JSON using Python:

>>> import requests
>>> defaults = dict(
...     pair.split()
...     for pair in requests.post(
...         "http://localhost:11434/api/show",
...         data='{"name": "test"}',
...         timeout=5
...     )
...     .json()["parameters"]
...     .split("\n")
...     if pair.strip()
... )
>>> defaults
{'top_p': '1', 'repeat_penalty': '1', 'temperature': '0', 'top_k': '20'}

I then changed my top_k value to make sure it just wasn't the same as the model default, and it did modify the value successfully.

If I change my input model from a GGUF model I quantized to neural-chat:latest, the problem is reproduced, just with some other default parameters:

$ ollama show test-neural-chat --parameters
repeat_penalty                 1
stop                           <|im_start|>
stop                           <|im_end|>
temperature                    0
top_k                          20
top_p                          1
num_ctx                        4096

For my sources, I'm following: https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#parameter

Originally created by @tylertitsworth on GitHub (Dec 24, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/1699 I have a model like so: (also providing system details) ```Dockerfile $ cat /etc/os-release | head -n 4 PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" $ ollama -v ollama version is 0.1.17 $ ollama show test --modelfile # Modelfile generated by "ollama show" # To build a new Modelfile based on this one, replace the FROM line with: # FROM test:latest FROM /usr/share/ollama/.ollama/models/blobs/sha256:8f7e99455a86ad490dab19d335d8c2d1d044e2744b923d4e78a4d84fe1457738 TEMPLATE """### System: {{ .System }} ### User: {{ .Prompt }} ### Assistant: """ SYSTEM """ Given the following extracted parts of a long document and a question, create a final answer with references ("SOURCES"). If you don't know the answer, just say that you don't know. Don't try to make up an answer. ALWAYS return a "SOURCES" part in your answer. --- Content: {context} --- """ PARAMETER repeat_penalty 1.3 PARAMETER temperature 0.4 PARAMETER top_k 20 PARAMETER top_p 0.65 ``` My parameters shown in this output are the same as what I have set in my Modelfile. However, when I query the API for the parameter values, I see that they are different values for `repeat_penalty`, `temperature`, and `top_p`: ```bash $ ollama show test --parameters repeat_penalty 1 temperature 0 top_k 20 top_p 1 ``` ```json $ curl http://localhost:11434/api/show -d '{"name": "test"}' { "modelfile": "# Modelfile generated by \"ollama show\"\n# To build a new Modelfile based on this one, replace the FROM line with:\n# FROM test:latest\n\nFROM /usr/share/ollama/.ollama/models/blobs/sha256:8f7e99455a86ad490dab19d335d8c2d1d044e2744b923d4e78a4d84fe1457738\nTEMPLATE \"\"\"### System:\r\n{{ .System }}\r\n\r\n### User:\r\n{{ .Prompt }}\r\n\r\n### Assistant:\r\n\"\"\"\nSYSTEM \"\"\"\r\nGiven the following extracted parts of a long document and a question, create a final answer with references (\"SOURCES\"). \r\nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\r\nALWAYS return a \"SOURCES\" part in your answer.\r\n---\r\nContent: {context}\r\n---\r\n\"\"\"\nPARAMETER repeat_penalty 1.3\nPARAMETER temperature 0.4\nPARAMETER top_k 21\nPARAMETER top_p 0.65", "parameters": "top_p 1\nrepeat_penalty 1\ntemperature 0\ntop_k 20", "template": "### System:\r\n{{ .System }}\r\n\r\n### User:\r\n{{ .Prompt }}\r\n\r\n### Assistant:\r\n", "system": "\r\nGiven the following extracted parts of a long document and a question, create a final answer with references (\"SOURCES\"). \r\nIf you don't know the answer, just say that you don't know. Don't try to make up an answer.\r\nALWAYS return a \"SOURCES\" part in your answer.\r\n---\r\nContent: {context}\r\n---\r\n", "details": { "format": "gguf", "family": "llama", "families": ["llama"], "parameter_size": "7B", "quantization_level": "Q4_0", }, } ``` Cleaning up that JSON using Python: ```python >>> import requests >>> defaults = dict( ... pair.split() ... for pair in requests.post( ... "http://localhost:11434/api/show", ... data='{"name": "test"}', ... timeout=5 ... ) ... .json()["parameters"] ... .split("\n") ... if pair.strip() ... ) >>> defaults {'top_p': '1', 'repeat_penalty': '1', 'temperature': '0', 'top_k': '20'} ``` I then changed my top_k value to make sure it just wasn't the same as the model default, and it did modify the value successfully. If I change my input model from a GGUF model I quantized to `neural-chat:latest`, the problem is reproduced, just with some other default parameters: ```bash $ ollama show test-neural-chat --parameters repeat_penalty 1 stop <|im_start|> stop <|im_end|> temperature 0 top_k 20 top_p 1 num_ctx 4096 ``` For my sources, I'm following: https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#parameter
GiteaMirror added the bug label 2026-04-28 03:53:12 -05:00
Author
Owner

@pdevine commented on GitHub (Mar 12, 2024):

Hey @tylertitsworth sorry for the slow response. The API was just rounding the floats instead of properly displaying them. Thankfully this was actually fixed a while ago:

curl http://localhost:11434/api/show -d '{"name": "pdevine/testmodel"}' -s | jq ".parameters"
"repeat_penalty                 1.3\nstop                           \"[INST]\"\nstop                           \"[/INST]\"\nstop                           \"<<SYS>>\"\nstop                           \"<</SYS>>\""

Going to close out the issue.

<!-- gh-comment-id:1989690500 --> @pdevine commented on GitHub (Mar 12, 2024): Hey @tylertitsworth sorry for the slow response. The API was just rounding the floats instead of properly displaying them. Thankfully this was actually fixed a while ago: ``` curl http://localhost:11434/api/show -d '{"name": "pdevine/testmodel"}' -s | jq ".parameters" "repeat_penalty 1.3\nstop \"[INST]\"\nstop \"[/INST]\"\nstop \"<<SYS>>\"\nstop \"<</SYS>>\"" ``` Going to close out the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#47471