[GH-ISSUE #9783] Request for Modelfile for gemma-3-27b-it-Q4_K_M.gguf #6397

Closed
opened 2026-04-12 17:55:19 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @ZimaBlueee on GitHub (Mar 15, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9783

Hi, I'm new to Ollama and trying to use the gemma-3-27b-it-Q4_K_M.gguf model.

Could someone please provide a working Modelfile for this specific model? I’d like to ensure it’s configured correctly for optimal performance with Ollama.

Any additional tips for a beginner would also be greatly appreciated!

Thank you!

Originally created by @ZimaBlueee on GitHub (Mar 15, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9783 Hi, I'm new to Ollama and trying to use the gemma-3-27b-it-Q4_K_M.gguf model. Could someone please provide a working Modelfile for this specific model? I’d like to ensure it’s configured correctly for optimal performance with Ollama. Any additional tips for a beginner would also be greatly appreciated! Thank you!
Author
Owner

@svkoh commented on GitHub (Mar 15, 2025):

params and template are from https://ollama.com/library/gemma3

if you have less than 24G memory, reduce num_ctx for better performance.

FROM /path/to/gemma-3-27b-it-Q4_K_M.gguf

PARAMETER num_ctx 8192
PARAMETER temperature 0.1
PARAMETER stop "<end_of_turn>"

TEMPLATE """
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if or (eq .Role "user") (eq .Role "system") }}<start_of_turn>user
{{ .Content }}<end_of_turn>
{{ if $last }}<start_of_turn>model
{{ end }}
{{- else if eq .Role "assistant" }}<start_of_turn>model
{{ .Content }}{{ if not $last }}<end_of_turn>
{{ end }}
{{- end }}
{{- end }}
"""
<!-- gh-comment-id:2726499020 --> @svkoh commented on GitHub (Mar 15, 2025): params and template are from [https://ollama.com/library/gemma3](https://ollama.com/library/gemma3) if you have less than 24G memory, reduce num_ctx for better performance. ``` FROM /path/to/gemma-3-27b-it-Q4_K_M.gguf PARAMETER num_ctx 8192 PARAMETER temperature 0.1 PARAMETER stop "<end_of_turn>" TEMPLATE """ {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1 }} {{- if or (eq .Role "user") (eq .Role "system") }}<start_of_turn>user {{ .Content }}<end_of_turn> {{ if $last }}<start_of_turn>model {{ end }} {{- else if eq .Role "assistant" }}<start_of_turn>model {{ .Content }}{{ if not $last }}<end_of_turn> {{ end }} {{- end }} {{- end }} """ ```
Author
Owner

@ZimaBlueee commented on GitHub (Mar 15, 2025):

Thank you!

<!-- gh-comment-id:2726551438 --> @ZimaBlueee commented on GitHub (Mar 15, 2025): Thank you!
Author
Owner

@wqerrewetw commented on GitHub (Mar 18, 2025):

template with tool support

{{- if .Messages }}
{{- if or .System .Tools }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
The following tools are available when needed for specific tasks:
{{ .Tools }}

Only use tools when the task specifically requires their functionality.
For general questions or tasks that don't need external data, respond directly.

When using a tool, format as:
<tool_calls>
<tool_call>
{"name": "function_name", "parameters": {"param1": "value1"}}
</tool_call>
</tool_calls>
{{- end }}
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<start_of_turn>user
{{ .Content }}<end_of_turn>
{{- if $last }}<start_of_turn>model
{{ end }}
{{- else if eq .Role "system" }}<start_of_turn>user
{{ .Content }}<end_of_turn>
{{- if $last }}<start_of_turn>model
{{ end }}
{{- else if eq .Role "assistant" }}<start_of_turn>model
{{- if .ToolCalls }}
<tool_calls>
{{- range .ToolCalls }}
<tool_call>
{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}
</tool_call>
{{- end }}
</tool_calls>
{{- else }}
{{ .Content }}
{{- end }}
{{- if not $last }}<end_of_turn>
{{ end }}
{{- else if eq .Role "tool" }}
<tool_outputs>
<tool_output>
{{ .Content }}
</tool_output>
</tool_outputs>
{{- if and $last (ne .Role "assistant") }}<start_of_turn>model
{{- end }}
{{- end }}
{{- end }}
{{- else }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Prompt }}
<start_of_turn>user
{{ .Prompt }}<end_of_turn>
<start_of_turn>model
{{- end }}
{{ .Response }}
{{- if .Response }}{{ end }}
{{- end }}
<!-- gh-comment-id:2731353986 --> @wqerrewetw commented on GitHub (Mar 18, 2025): template with tool support ``` {{- if .Messages }} {{- if or .System .Tools }} {{- if .System }} {{ .System }} {{- end }} {{- if .Tools }} The following tools are available when needed for specific tasks: {{ .Tools }} Only use tools when the task specifically requires their functionality. For general questions or tasks that don't need external data, respond directly. When using a tool, format as: <tool_calls> <tool_call> {"name": "function_name", "parameters": {"param1": "value1"}} </tool_call> </tool_calls> {{- end }} {{- end }} {{- range $i, $_ := .Messages }} {{- $last := eq (len (slice $.Messages $i)) 1 }} {{- if eq .Role "user" }}<start_of_turn>user {{ .Content }}<end_of_turn> {{- if $last }}<start_of_turn>model {{ end }} {{- else if eq .Role "system" }}<start_of_turn>user {{ .Content }}<end_of_turn> {{- if $last }}<start_of_turn>model {{ end }} {{- else if eq .Role "assistant" }}<start_of_turn>model {{- if .ToolCalls }} <tool_calls> {{- range .ToolCalls }} <tool_call> {"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}} </tool_call> {{- end }} </tool_calls> {{- else }} {{ .Content }} {{- end }} {{- if not $last }}<end_of_turn> {{ end }} {{- else if eq .Role "tool" }} <tool_outputs> <tool_output> {{ .Content }} </tool_output> </tool_outputs> {{- if and $last (ne .Role "assistant") }}<start_of_turn>model {{- end }} {{- end }} {{- end }} {{- else }} {{- if .System }} {{ .System }} {{- end }} {{- if .Prompt }} <start_of_turn>user {{ .Prompt }}<end_of_turn> <start_of_turn>model {{- end }} {{ .Response }} {{- if .Response }}{{ end }} {{- end }} ```
Author
Owner

@svkoh commented on GitHub (May 20, 2025):

This tool can convert huggingface chat template to the Go format used by Ollama: @huggingface/ollama-utils

Online version: https://huggingface.co/spaces/ngxson/debug_ollama_manifest

<!-- gh-comment-id:2893515750 --> @svkoh commented on GitHub (May 20, 2025): This tool can convert huggingface chat template to the Go format used by Ollama: [@huggingface/ollama-utils](https://github.com/huggingface/huggingface.js/blob/main/packages/ollama-utils/README.md) Online version: [https://huggingface.co/spaces/ngxson/debug_ollama_manifest](https://huggingface.co/spaces/ngxson/debug_ollama_manifest)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#6397