[GH-ISSUE #6968] Adjust templates for FIM models to acknowledge existence of suffix #66457

Open
opened 2026-05-04 05:35:32 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @sestinj on GitHub (Sep 25, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6968

What is the issue?

CodeGemma (for example, it's not the only one) supports both FIM and chat. Ollama uses the FIM template for codegemma:2b and the chat template for codegemma:7b. This feels like the right default decision, but in cases where a suffix is provided, it can be confidently assumed that a FIM format is desired.

The solution to this would be a prompt template that is wrapped in an "if suffix", something like this:

{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
{{- else }}<start_of_turn>user
{{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn>
<start_of_turn>model
{{ .Response }}<end_of_turn>
{{- end }}

One caveat I can see is it would make the prompt template slightly less readable for users browsing the Ollama template library.

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.3.11

Originally created by @sestinj on GitHub (Sep 25, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6968 ### What is the issue? CodeGemma (for example, it's not the only one) supports both FIM and chat. Ollama uses the FIM template for codegemma:2b and the chat template for codegemma:7b. This feels like the right default decision, but in cases where a suffix is provided, it can be confidently assumed that a FIM format is desired. The solution to this would be a prompt template that is wrapped in an "if suffix", something like this: ``` {{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|> {{- else }}<start_of_turn>user {{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn> <start_of_turn>model {{ .Response }}<end_of_turn> {{- end }} ``` One caveat I can see is it would make the prompt template slightly less readable for users browsing the Ollama template library. ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version 0.3.11
GiteaMirror added the bug label 2026-05-04 05:35:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66457