[GH-ISSUE #4312] llama3 instruct template will have different outputs depending on system tokens #64726

Open
opened 2026-05-03 18:36:45 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Sneakr on GitHub (May 10, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4312

What is the issue?

Issue:
The absense or presence of a system token produces different outputs, based on my findings:
https://github.com/ggerganov/llama.cpp/issues/7062#issuecomment-2100500582

This is even more important for fine tunes on the instruct models as it can break everything.

Official ollama - llama3 template removes tokens if no system message is present:
https://github.com/ollama/ollama/blob/main/docs/modelfile.md
https://ollama.com/library/llama3:instruct/blobs/8ab4849b038c

The corrected template should be:
TEMPLATE """<|start_header_id|>system<|end_header_id|> {{ .System }} <|eot_id|>{{ if .Prompt }} <|start_header_id|>user<|end_header_id|> {{ .Prompt }} <|eot_id|>{{ end }} <|start_header_id|>assistant<|end_header_id|> {{ .Response }} <|eot_id|>"""

Edit:
I've made an official thread and awaiting response:
https://github.com/meta-llama/llama3/issues/203

Originally created by @Sneakr on GitHub (May 10, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4312 ### What is the issue? Issue: The absense or presence of a system token produces different outputs, based on my findings: https://github.com/ggerganov/llama.cpp/issues/7062#issuecomment-2100500582 This is even more important for fine tunes on the instruct models as it can break everything. Official ollama - llama3 template removes tokens if no system message is present: https://github.com/ollama/ollama/blob/main/docs/modelfile.md https://ollama.com/library/llama3:instruct/blobs/8ab4849b038c The corrected template should be: `TEMPLATE """<|start_header_id|>system<|end_header_id|> {{ .System }} <|eot_id|>{{ if .Prompt }} <|start_header_id|>user<|end_header_id|> {{ .Prompt }} <|eot_id|>{{ end }} <|start_header_id|>assistant<|end_header_id|> {{ .Response }} <|eot_id|>"""` Edit: I've made an official thread and awaiting response: https://github.com/meta-llama/llama3/issues/203
GiteaMirror added the bug label 2026-05-03 18:36:45 -05:00
Author
Owner

@Sneakr commented on GitHub (May 11, 2024):

So meta just changed the template page without answering my issue :) Atleast give some credit where credit is due.

<!-- gh-comment-id:2106025821 --> @Sneakr commented on GitHub (May 11, 2024): So meta just changed the template page without answering my issue :) Atleast give some credit where credit is due.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#64726