[GH-ISSUE #6797] Add the ability to remove a parameter using a Modelfile #50798

Closed
opened 2026-04-28 17:07:57 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @dpkirchner on GitHub (Sep 13, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6797

There's a model I'm interested in using with ollama that specifies a parameter no longer supported by ollama (or maybe llama.cpp). I'd like to be able to create a replacement with a Modelfile that overrides the parameter by removing it entirely, if possible.

(The specific model is codellama:7b-instruct and the parameter is rope_frequency_base, for what it's worth, but this might be generally useful.)

Originally created by @dpkirchner on GitHub (Sep 13, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6797 There's a model I'm interested in using with ollama that specifies a parameter no longer supported by ollama (or maybe llama.cpp). I'd like to be able to create a replacement with a Modelfile that overrides the parameter by removing it entirely, if possible. (The specific model is `codellama:7b-instruct` and the parameter is `rope_frequency_base`, for what it's worth, but this might be generally useful.)
GiteaMirror added the feature request label 2026-04-28 17:07:57 -05:00
Author
Owner

@rick-github commented on GitHub (Sep 13, 2024):

Can you not just delete the line in the modelfile?

$ ollama show --modelfile codellama:7b-instruct | grep -v rope_frequency_base | sed -e 's/^FROM.*/FROM codellama:7b-instruct/' > Modelfile.norope
$ ollama create codellama:7b-instruct-no-rope -f Modelfile.norope
$ ollama run codellama:7b-instruct-no-rope "write a python script to print numbers 1..10.  don't explain"
```
for i in range(1, 11):
    print(i)
```
<!-- gh-comment-id:2350715139 --> @rick-github commented on GitHub (Sep 13, 2024): Can you not just delete the line in the modelfile? ````console $ ollama show --modelfile codellama:7b-instruct | grep -v rope_frequency_base | sed -e 's/^FROM.*/FROM codellama:7b-instruct/' > Modelfile.norope $ ollama create codellama:7b-instruct-no-rope -f Modelfile.norope $ ollama run codellama:7b-instruct-no-rope "write a python script to print numbers 1..10. don't explain" ``` for i in range(1, 11): print(i) ``` ````
Author
Owner

@dpkirchner commented on GitHub (Sep 14, 2024):

Can you not just delete the line in the modelfile?

$ ollama show --modelfile codellama:7b-instruct | grep -v rope_frequency_base | sed -e 's/^FROM.*/FROM codellama:7b-instruct/' > Modelfile.norope
$ ollama create codellama:7b-instruct-no-rope -f Modelfile.norope
$ ollama run codellama:7b-instruct-no-rope "write a python script to print numbers 1..10.  don't explain"

First thing I tried -- when I do this, the new model still has that rope_frequency_base parameter:

root@desktop:/app/backend# ollama -v
ollama version is 0.3.10
root@desktop:/app/backend# head -n 20 Modelfile.norope 
# Modelfile generated by "ollama show"
# To build a new Modelfile based on this, replace FROM with:
# FROM codellama:7b-instruct

FROM codellama:7b-instruct
TEMPLATE "[INST] <<SYS>>{{ .System }}<</SYS>>

{{ .Prompt }} [/INST]
"
PARAMETER stop [INST]
PARAMETER stop [/INST]
PARAMETER stop <<SYS>>
PARAMETER stop <</SYS>>
LICENSE """LLAMA 2 COMMUNITY LICENSE AGREEMENT	
Llama 2 Version Release Date: July 18, 2023

"Agreement" means the terms and conditions for use, reproduction, distribution and 
modification of the Llama Materials set forth herein.

"Documentation" means the specifications, manuals and documentation 
root@desktop:/app/backend# ollama create codellama:7b-instruct-no-rope -f Modelfile.norope
transferring model data 
using existing layer sha256:3a43f93b78ec50f7c4e4dc8bd1cb3fff5a900e7d574c51a6f7495e48486e0dac 
using existing layer sha256:8c17c2ebb0ea011be9981cc3922db8ca8fa61e828c5d3f44cb6ae342bf80460b 
using existing layer sha256:590d74a5569b8a20eb2a8b0aa869d1d1d3faf6a7fdda1955ae827073c7f502fc 
using existing layer sha256:2e0493f67d0c8c9c68a8aeacdf6a38a2151cb3c4c1d42accf296e19810527988 
using existing layer sha256:8c17c2ebb0ea011be9981cc3922db8ca8fa61e828c5d3f44cb6ae342bf80460b 
using existing layer sha256:590d74a5569b8a20eb2a8b0aa869d1d1d3faf6a7fdda1955ae827073c7f502fc 
creating new layer sha256:cfac7756790d0eccff9c43784590bf23ecadb0466c8093cbb28aae91015ca3f4 
creating new layer sha256:94ab2b590e2fde14c3b139c2d4226be28b4d494dd82e48936bfff01cee4ea48e 
writing manifest 
success 
root@desktop:/app/backend# ollama show --modelfile codellama:7b-instruct-no-rope | grep rope_freq
PARAMETER rope_frequency_base 1e+06
<!-- gh-comment-id:2350725757 --> @dpkirchner commented on GitHub (Sep 14, 2024): > Can you not just delete the line in the modelfile? > > ``` > $ ollama show --modelfile codellama:7b-instruct | grep -v rope_frequency_base | sed -e 's/^FROM.*/FROM codellama:7b-instruct/' > Modelfile.norope > $ ollama create codellama:7b-instruct-no-rope -f Modelfile.norope > $ ollama run codellama:7b-instruct-no-rope "write a python script to print numbers 1..10. don't explain" First thing I tried -- when I do this, the new model still has that `rope_frequency_base` parameter: ``` root@desktop:/app/backend# ollama -v ollama version is 0.3.10 root@desktop:/app/backend# head -n 20 Modelfile.norope # Modelfile generated by "ollama show" # To build a new Modelfile based on this, replace FROM with: # FROM codellama:7b-instruct FROM codellama:7b-instruct TEMPLATE "[INST] <<SYS>>{{ .System }}<</SYS>> {{ .Prompt }} [/INST] " PARAMETER stop [INST] PARAMETER stop [/INST] PARAMETER stop <<SYS>> PARAMETER stop <</SYS>> LICENSE """LLAMA 2 COMMUNITY LICENSE AGREEMENT Llama 2 Version Release Date: July 18, 2023 "Agreement" means the terms and conditions for use, reproduction, distribution and modification of the Llama Materials set forth herein. "Documentation" means the specifications, manuals and documentation root@desktop:/app/backend# ollama create codellama:7b-instruct-no-rope -f Modelfile.norope transferring model data using existing layer sha256:3a43f93b78ec50f7c4e4dc8bd1cb3fff5a900e7d574c51a6f7495e48486e0dac using existing layer sha256:8c17c2ebb0ea011be9981cc3922db8ca8fa61e828c5d3f44cb6ae342bf80460b using existing layer sha256:590d74a5569b8a20eb2a8b0aa869d1d1d3faf6a7fdda1955ae827073c7f502fc using existing layer sha256:2e0493f67d0c8c9c68a8aeacdf6a38a2151cb3c4c1d42accf296e19810527988 using existing layer sha256:8c17c2ebb0ea011be9981cc3922db8ca8fa61e828c5d3f44cb6ae342bf80460b using existing layer sha256:590d74a5569b8a20eb2a8b0aa869d1d1d3faf6a7fdda1955ae827073c7f502fc creating new layer sha256:cfac7756790d0eccff9c43784590bf23ecadb0466c8093cbb28aae91015ca3f4 creating new layer sha256:94ab2b590e2fde14c3b139c2d4226be28b4d494dd82e48936bfff01cee4ea48e writing manifest success root@desktop:/app/backend# ollama show --modelfile codellama:7b-instruct-no-rope | grep rope_freq PARAMETER rope_frequency_base 1e+06 ```
Author
Owner

@rick-github commented on GitHub (Sep 14, 2024):

Ah, I see, the parameter is set in the k/v space of the model. The model appears to work with it set, and ollama ignores it. What's the use case for removing it?

<!-- gh-comment-id:2350739537 --> @rick-github commented on GitHub (Sep 14, 2024): Ah, I see, the parameter is set in the k/v space of the model. The model appears to work with it set, and ollama ignores it. What's the use case for removing it?
Author
Owner

@dpkirchner commented on GitHub (Sep 14, 2024):

It might just be an unexpected warning, however I'm not sure if it's affecting the output of requests. I'm using a vscode extension that sends the request (from debug logs):

time=2024-09-14T00:32:41.496Z level=DEBUG source=routes.go:1363 msg="chat request" images=0 prompt="[INST] <<SYS>>You are a helpful, respectful and honest coding assistant.\nAlways reply using markdown.\nBe clear and concise, prioritizing brevity in your responses.\nFor code refactoring, use markdown with appropriate code formatting.<</SYS>>\n\nWrite a python hello world [/INST]\n"

and the response is Sorry, I don't understand. Please try again.. I was looking for errors and saw the line about the rope option:

time=2024-09-14T00:32:41.805Z level=WARN source=types.go:509 msg="invalid option provided" option=rope_frequency_base

and thought that's why the request is failing. I'm not sure whether or not it is the cause.

If the invalid option is not the cause then I think this request can be closed.

<!-- gh-comment-id:2350743216 --> @dpkirchner commented on GitHub (Sep 14, 2024): It might just be an unexpected warning, however I'm not sure if it's affecting the output of requests. I'm using a vscode extension that sends the request (from debug logs): ``` time=2024-09-14T00:32:41.496Z level=DEBUG source=routes.go:1363 msg="chat request" images=0 prompt="[INST] <<SYS>>You are a helpful, respectful and honest coding assistant.\nAlways reply using markdown.\nBe clear and concise, prioritizing brevity in your responses.\nFor code refactoring, use markdown with appropriate code formatting.<</SYS>>\n\nWrite a python hello world [/INST]\n" ``` and the response is `Sorry, I don't understand. Please try again.`. I was looking for errors and saw the line about the rope option: ``` time=2024-09-14T00:32:41.805Z level=WARN source=types.go:509 msg="invalid option provided" option=rope_frequency_base ``` and thought that's why the request is failing. I'm not sure whether or not it is the cause. If the invalid option is not the cause then I think this request can be closed.
Author
Owner

@rick-github commented on GitHub (Sep 14, 2024):

The invalid option should have no effect on the generation.

I ran the prompt you had several times and didn't see a failure:

$ curl -s localhost:11434/api/chat -d '{"model":"codellama:7b-instruct","messages":[{"role":"system","content":"You are a helpful, respectful and honest coding assistant.\nAlways reply using markdown.\nBe clear and concise, prioritizing brevity in your responses.\nFor code refactoring, use markdown with appropriate code formatting."},{"role":"user","content":"Write a python hello world"}],"stream":false}' | jq
{
  "model": "codellama:7b-instruct",
  "created_at": "2024-09-14T01:54:11.218041687Z",
  "message": {
    "role": "assistant",
    "content": "```python\nprint(\"Hello, World!\")\n```"
  },
  "done_reason": "stop",
  "done": true,
  "total_duration": 289237666,
  "load_duration": 6886725,
  "prompt_eval_count": 74,
  "prompt_eval_duration": 18785000,
  "eval_count": 13,
  "eval_duration": 127262000
}

Is it still failing for you? If not, I think that the failure is just one of those hazards of LLMs, like hallucinations - sometimes they just go off the rails.

<!-- gh-comment-id:2350780313 --> @rick-github commented on GitHub (Sep 14, 2024): The invalid option should have no effect on the generation. I ran the prompt you had several times and didn't see a failure: ```console $ curl -s localhost:11434/api/chat -d '{"model":"codellama:7b-instruct","messages":[{"role":"system","content":"You are a helpful, respectful and honest coding assistant.\nAlways reply using markdown.\nBe clear and concise, prioritizing brevity in your responses.\nFor code refactoring, use markdown with appropriate code formatting."},{"role":"user","content":"Write a python hello world"}],"stream":false}' | jq { "model": "codellama:7b-instruct", "created_at": "2024-09-14T01:54:11.218041687Z", "message": { "role": "assistant", "content": "```python\nprint(\"Hello, World!\")\n```" }, "done_reason": "stop", "done": true, "total_duration": 289237666, "load_duration": 6886725, "prompt_eval_count": 74, "prompt_eval_duration": 18785000, "eval_count": 13, "eval_duration": 127262000 } ``` Is it still failing for you? If not, I think that the failure is just one of those hazards of LLMs, like hallucinations - sometimes they just go off the rails.
Author
Owner

@dpkirchner commented on GitHub (Sep 14, 2024):

That curl works. Maybe it's just a problem with the extension after all. I latched on to the warning prematurely. Thanks for your help!

<!-- gh-comment-id:2351009028 --> @dpkirchner commented on GitHub (Sep 14, 2024): That curl works. Maybe it's just a problem with the extension after all. I latched on to the warning prematurely. Thanks for your help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#50798