[GH-ISSUE #9666] When answering the question, there was no mention of the SYSTEM prompt in the Modelfile #52819

Closed
opened 2026-04-29 00:59:23 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Cooooder-zc on GitHub (Mar 12, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9666

What is the issue?

I initiate a conversation through the Olama API:
curl -X POST 'http://10.10.4.16:11434/api/chat' -H 'Content-Type: application/json' -d '{
"messages": [
{
"role": "user",
"content": "Introduce xxx platform",
}
],
"model": "myds:a",
"stream": false
}'
The content of the answer does not involve the information in the SYSTEM prompt.

Then I used another API:
curl -X POST 'http://10.10.4.16:11434/api/generate' -H 'Content-Type: application/json' -d '{
"model": "myds:a",
"prompt": "Introduce xxx platform",
"stream": false
}',
The answer includes SYSTEM prompts.

Modelfile:
FROM deepseek-r1:32b
SYSTEM """You are xxxplatform assistant, a professional programming and SQL statement assistant. When answering user questions, please follow the following rules:

  1. You must first answer any questions from users based on the functionality and knowledge of the xxx platform.
  2. Prioritize using the information I provide.
    ###Instructions###
    What is xxx platform
    ###Answer:###
    xxx platform is a ......
    ......
    Other additional information......
  3. Please think and answer according to the following template:
    -Reflection: What are the user's questions? What aspects do I need to think about first</ think>
    -Answer: Based on my knowledge base and the information provided, answer the user's question.
    If the user's question exceeds the scope of the information I provide, please answer based on your knowledge base.
    """

TEMPLATE """{{- if .System }}{{ .System }}{{ end }}
{{- range $i, $_ := .Messages }}
{{- last := eq (len (slice .Messages $i)) 1}}
{{- if eq .Role "user" }}<|User|>{{ .Content }}
{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end_of_sentence|>{{- end }}
{{- end }}
{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}
{{- end }}"""
PARAMETER stop <|begin_of_sentence|>
PARAMETER stop <|end_of_sentence|>
PARAMETER stop <|User|>
PARAMETER stop <|Assistant|>
PARAMETER temperature 0.01
PARAMETER num_ctx 4096

Deepseek-r1:32b was downloaded through Ollama.

Relevant log output


OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.5.12

Originally created by @Cooooder-zc on GitHub (Mar 12, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9666 ### What is the issue? I initiate a conversation through the Olama API: curl -X POST 'http://10.10.4.16:11434/api/chat' -H 'Content-Type: application/json' -d '{ "messages": [ { "role": "user", "content": "Introduce xxx platform", } ], "model": "myds:a", "stream": false }' The content of the answer does not involve the information in the SYSTEM prompt. Then I used another API: curl -X POST 'http://10.10.4.16:11434/api/generate' -H 'Content-Type: application/json' -d '{ "model": "myds:a", "prompt": "Introduce xxx platform", "stream": false }', The answer includes SYSTEM prompts. Modelfile: FROM deepseek-r1:32b SYSTEM """You are xxxplatform assistant, a professional programming and SQL statement assistant. When answering user questions, please follow the following rules: 1. You must first answer any questions from users based on the functionality and knowledge of the xxx platform. 2. Prioritize using the information I provide. ###Instructions### What is xxx platform ###Answer:### xxx platform is a ...... ...... Other additional information...... 3. Please think and answer according to the following template: -<think>Reflection: What are the user's questions? What aspects do I need to think about first</ think> -Answer: Based on my knowledge base and the information provided, answer the user's question. If the user's question exceeds the scope of the information I provide, please answer based on your knowledge base. """ TEMPLATE """{{- if .System }}{{ .System }}{{ end }} {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1}} {{- if eq .Role "user" }}<|User|>{{ .Content }} {{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end_of_sentence|>{{- end }} {{- end }} {{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }} {{- end }}""" PARAMETER stop <|begin_of_sentence|> PARAMETER stop <|end_of_sentence|> PARAMETER stop <|User|> PARAMETER stop <|Assistant|> PARAMETER temperature 0.01 PARAMETER num_ctx 4096  Deepseek-r1:32b was downloaded through Ollama. ### Relevant log output ```shell ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.5.12
GiteaMirror added the bug label 2026-04-29 00:59:23 -05:00
Author
Owner

@rick-github commented on GitHub (Mar 12, 2025):

I modified the SYSTEM message to include a mention of COBOL to see if it shows up in the output:

SYSTEM """You are xxx platform assistant, a professional programming and SQL statement assistant written in COBOL. When answering user questions, please follow the following rules:

1. You must first answer any questions from users based on the functionality and knowledge of the xxx platform.
2. Prioritize using the information I provide.
   ###Instructions###
   What is xxx platform
   ###Answer:###
   xxx platform is a ......
   ......
   Other additional information......
3. Please think and answer according to the following template:
    -Reflection: What are the user's questions? What aspects do I need to think about first
    -Answer: Based on my knowledge base and the information provided, answer the user's question.
   If the user's question exceeds the scope of the information I provide, please answer based on your knowledge base.
$ curl -s -X POST 'http://localhost:11434/api/chat' -H 'Content-Type: application/json' -d '{
  "messages": [{ "role": "user", "content": "Introduce xxx platform" } ],
  "model": "myds:a",
  "stream": false
  }' | jq -r .message.content
<think>
Okay, so the user is asking me to introduce the xxx platform. Let me start by recalling what I know about it from the
provided instructions.

First, the xxx platform is a professional programming and SQL statement assistant written in COBOL. That's
interesting because COBOL isn't as commonly used nowadays, but it has its niche, especially in legacy systems
or specific industries like finance.

The main purpose of this platform seems to be assisting users with programming tasks and generating SQL statements.
So, I should highlight how it helps in these areas. Maybe mention the types of support it offers, like debugging, code
optimization, query generation, etc.

I also need to think about who would benefit from using this platform. Probably developers working on COBOL
applications, especially those dealing with databases or needing efficient SQL queries. It might be useful for both
experienced developers looking to save time and newcomers who need guidance.

Another point is the functionality based on the knowledge provided. The assistant must prioritize using the information
given but can fall back on general knowledge if necessary. So, in my introduction, I should stick to what's provided unless
there's a gap that needs filling with additional info.

I should structure the answer clearly, starting with an overview of the platform, its primary functions, who it's for, and any
unique features like real-time assistance or integration capabilities. Maybe also touch on how it can improve productivity
by automating tasks and reducing errors.

Wait, in the example response, they mentioned that if the user's question goes beyond the provided info, I should use
my knowledge base. So, while introducing the platform, I'll rely on what's given but might add a bit about COBOL's
relevance to give context.

I also need to make sure the answer is concise and covers all key aspects without being too verbose. The user probably
wants a clear understanding of what the platform does and how it can help them specifically.

So, putting it all together: introduce the platform as a COBOL-based tool for programming and SQL assistance, mention
its support features, target audience, benefits like efficiency and error reduction, and perhaps hint at its integration capabilities
or real-time help. That should give a comprehensive introduction.
</think>

The xxx platform is a professional programming and SQL statement assistant developed using COBOL. It serves as a
valuable tool for developers by providing assistance in writing, debugging, and optimizing code, particularly focusing on
generating efficient SQL statements. The platform is designed to cater to the needs of professionals working with
COBOL applications, offering features that enhance productivity and reduce errors through automated solutions and
real-time support.
<!-- gh-comment-id:2718015340 --> @rick-github commented on GitHub (Mar 12, 2025): I modified the SYSTEM message to include a mention of COBOL to see if it shows up in the output: ``` SYSTEM """You are xxx platform assistant, a professional programming and SQL statement assistant written in COBOL. When answering user questions, please follow the following rules: 1. You must first answer any questions from users based on the functionality and knowledge of the xxx platform. 2. Prioritize using the information I provide. ###Instructions### What is xxx platform ###Answer:### xxx platform is a ...... ...... Other additional information...... 3. Please think and answer according to the following template: -Reflection: What are the user's questions? What aspects do I need to think about first -Answer: Based on my knowledge base and the information provided, answer the user's question. If the user's question exceeds the scope of the information I provide, please answer based on your knowledge base. ``` ```console $ curl -s -X POST 'http://localhost:11434/api/chat' -H 'Content-Type: application/json' -d '{ "messages": [{ "role": "user", "content": "Introduce xxx platform" } ], "model": "myds:a", "stream": false }' | jq -r .message.content <think> Okay, so the user is asking me to introduce the xxx platform. Let me start by recalling what I know about it from the provided instructions. First, the xxx platform is a professional programming and SQL statement assistant written in COBOL. That's interesting because COBOL isn't as commonly used nowadays, but it has its niche, especially in legacy systems or specific industries like finance. The main purpose of this platform seems to be assisting users with programming tasks and generating SQL statements. So, I should highlight how it helps in these areas. Maybe mention the types of support it offers, like debugging, code optimization, query generation, etc. I also need to think about who would benefit from using this platform. Probably developers working on COBOL applications, especially those dealing with databases or needing efficient SQL queries. It might be useful for both experienced developers looking to save time and newcomers who need guidance. Another point is the functionality based on the knowledge provided. The assistant must prioritize using the information given but can fall back on general knowledge if necessary. So, in my introduction, I should stick to what's provided unless there's a gap that needs filling with additional info. I should structure the answer clearly, starting with an overview of the platform, its primary functions, who it's for, and any unique features like real-time assistance or integration capabilities. Maybe also touch on how it can improve productivity by automating tasks and reducing errors. Wait, in the example response, they mentioned that if the user's question goes beyond the provided info, I should use my knowledge base. So, while introducing the platform, I'll rely on what's given but might add a bit about COBOL's relevance to give context. I also need to make sure the answer is concise and covers all key aspects without being too verbose. The user probably wants a clear understanding of what the platform does and how it can help them specifically. So, putting it all together: introduce the platform as a COBOL-based tool for programming and SQL assistance, mention its support features, target audience, benefits like efficiency and error reduction, and perhaps hint at its integration capabilities or real-time help. That should give a comprehensive introduction. </think> The xxx platform is a professional programming and SQL statement assistant developed using COBOL. It serves as a valuable tool for developers by providing assistance in writing, debugging, and optimizing code, particularly focusing on generating efficient SQL statements. The platform is designed to cater to the needs of professionals working with COBOL applications, offering features that enhance productivity and reduce errors through automated solutions and real-time support. ```
Author
Owner

@Cooooder-zc commented on GitHub (Mar 13, 2025):

When I requested the address '/app/generate', the Ollama log showed:
[time=2025-03-13T10:39:24.946+08:00 level=WARN source=runner.go:130 msg="truncating input prompt" limit=2048 prompt=6823 keep=5 new=2048]

But when I used '/api/chat', the Ollama log did not output this log.

I know that the length of my SYSTEM prompt exceeds the default 2048, and "num_ctx" is not set in the request parameters. In that case, the default 2048 is being used, but why isn't this log output from the address "/api/chat"?

Does this mean that the address '/api/chat' did not use SYSTEM prompt?

I sent the request using Postman.
I have upgraded Ollama to 0.6.0.

Thanks.

<!-- gh-comment-id:2719706407 --> @Cooooder-zc commented on GitHub (Mar 13, 2025): When I requested the address '/app/generate', the Ollama log showed: [time=2025-03-13T10:39:24.946+08:00 level=WARN source=runner.go:130 msg="truncating input prompt" limit=2048 prompt=6823 keep=5 new=2048] But when I used '/api/chat', the Ollama log did not output this log. I know that the length of my SYSTEM prompt exceeds the default 2048, and "num_ctx" is not set in the request parameters. In that case, the default 2048 is being used, but why isn't this log output from the address "/api/chat"? Does this mean that the address '/api/chat' did not use SYSTEM prompt? I sent the request using Postman. I have upgraded Ollama to 0.6.0. Thanks.
Author
Owner

@rick-github commented on GitHub (Mar 13, 2025):

/api/chat drops messages if they don't fit in the context window. You will see this if you set OLLAMA_DEBUG=1 in the server environment and search for 'truncating input messages which exceed context length'. So what has happened is that len(system) + len(user) > 2048, so ollama dropped the system prompt to make room for the user prompt.

<!-- gh-comment-id:2721055358 --> @rick-github commented on GitHub (Mar 13, 2025): `/api/chat` drops messages if they don't fit in the context window. You will see this if you set `OLLAMA_DEBUG=1` in the server environment and search for 'truncating input messages which exceed context length'. So what has happened is that len(system) + len(user) > 2048, so ollama dropped the system prompt to make room for the user prompt.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#52819