[GH-ISSUE #13359] Model files are sensitive to whitespace #8823

Open
opened 2026-04-12 21:36:25 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ijstokes on GitHub (Dec 6, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/13359

What is the issue?

It appears that Modelfile syntax is whitespace sensitive. This is surprising. It would seem to me that any contiguous sequence of one or more whitespace characters should be permitted for parsing of Modelfile content. Specifically, it would seem to me the following two should be identical:

FROM        gemma2:2b

SYSTEM      """
            You are a sentiment classifier.
            Classify each input as exactly one of the following:
            POSITIVE, NEGATIVE, NEUTRAL, UNCLEAR
            """

PARAMETER temperature 0.5
PARAMETER num_ctx     1024

MESSAGE user        I had a great day
MESSAGE assistant   POSITIVE
MESSAGE user        That hockey game was insane
MESSAGE assistant   UNCLEAR
MESSAGE user        We need to go shopping this week
MESSAGE assistant   NEUTRAL
MESSAGE user        That was one of the worst movies ever
MESSAGE assistant   NEGATIVE
FROM        gemma2:2b

SYSTEM      """
            You are a sentiment classifier.
            Classify each input as exactly one of the following:
            POSITIVE, NEGATIVE, NEUTRAL, UNCLEAR
            """

PARAMETER   temperature 0.5
PARAMETER   num_ctx     1024

MESSAGE     user        I had a great day
MESSAGE     assistant   POSITIVE
MESSAGE     user        That hockey game was insane
MESSAGE     assistant   UNCLEAR
MESSAGE     user        We need to go shopping this week
MESSAGE     assistant   NEUTRAL
MESSAGE     user        That was one of the worst movies ever
MESSAGE     assistant   NEGATIVE

However both MESSAGE and PARAMETER appear to only allow a single space character after those keywords.

Relevant log output

Variously I got the error messages:


$ ollama create sentiment2 -f sentiment2.modelfile
Error: (line 12): message role must be one of "system", "user", or "assistant"


and


$ ollama create sentiment2 -f sentiment2.modelfile
gathering model components
Error: unknown parameter ''

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.13.0

Originally created by @ijstokes on GitHub (Dec 6, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/13359 ### What is the issue? It appears that Modelfile syntax is whitespace sensitive. This is surprising. It would seem to me that any contiguous sequence of one or more whitespace characters should be permitted for parsing of Modelfile content. Specifically, it would seem to me the following two should be identical: ``` FROM gemma2:2b SYSTEM """ You are a sentiment classifier. Classify each input as exactly one of the following: POSITIVE, NEGATIVE, NEUTRAL, UNCLEAR """ PARAMETER temperature 0.5 PARAMETER num_ctx 1024 MESSAGE user I had a great day MESSAGE assistant POSITIVE MESSAGE user That hockey game was insane MESSAGE assistant UNCLEAR MESSAGE user We need to go shopping this week MESSAGE assistant NEUTRAL MESSAGE user That was one of the worst movies ever MESSAGE assistant NEGATIVE ``` ``` FROM gemma2:2b SYSTEM """ You are a sentiment classifier. Classify each input as exactly one of the following: POSITIVE, NEGATIVE, NEUTRAL, UNCLEAR """ PARAMETER temperature 0.5 PARAMETER num_ctx 1024 MESSAGE user I had a great day MESSAGE assistant POSITIVE MESSAGE user That hockey game was insane MESSAGE assistant UNCLEAR MESSAGE user We need to go shopping this week MESSAGE assistant NEUTRAL MESSAGE user That was one of the worst movies ever MESSAGE assistant NEGATIVE ``` However both `MESSAGE` and `PARAMETER` appear to only allow a single space character after those keywords. ### Relevant log output ```shell Variously I got the error messages: $ ollama create sentiment2 -f sentiment2.modelfile Error: (line 12): message role must be one of "system", "user", or "assistant" and $ ollama create sentiment2 -f sentiment2.modelfile gathering model components Error: unknown parameter '' ``` ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.13.0
GiteaMirror added the bug label 2026-04-12 21:36:25 -05:00
Author
Owner

@pdevine commented on GitHub (Dec 10, 2025):

I'm worried about change the SYSTEM command (or anything which takes triple quotes) because what if you needed to start a line in the block with whitespace?

<!-- gh-comment-id:3635116059 --> @pdevine commented on GitHub (Dec 10, 2025): I'm worried about change the SYSTEM command (or anything which takes triple quotes) because what if you needed to start a line in the block with whitespace?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8823