Skip to content

[ollama-utils] 🤖 Auto-update chat templates (2025-04-28) #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions packages/ollama-utils/src/chat-template-automap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ import type { OllamaChatTemplateMapEntry } from "./types";

/**
* Skipped these models due to error:
* - library/llama3:70b
* - library/mistrallite:7b
* - library/gemma3:12b
* - library/llama3.3:70b-instruct-fp16
* - library/llama3.3:70b
* - library/llama3.1:8b
* - library/llama3.1:70b
* - library/llama3.1:8b-instruct-fp16
* - library/llama3.2-vision:11b
* - library/mistral-nemo:12b-instruct-2407-q2_K
* - library/llava:34b
* - library/deepcoder:1.5b-preview-fp16
* - library/firefunction-v2:70b
* - library/yi-coder:1.5b-base-fp16
* - library/tulu3:70b
* - library/command-a:111b-03-2025-fp16
*/

export const OLLAMA_CHAT_TEMPLATE_MAPPING: OllamaChatTemplateMapEntry[] = [
Expand Down Expand Up @@ -756,6 +768,17 @@ export const OLLAMA_CHAT_TEMPLATE_MAPPING: OllamaChatTemplateMapEntry[] = [
},
},
},
{
model: "library/mistral:7b-instruct-fp16",
gguf: "{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token + ' ' }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}",
ollama: {
template: "[INST] {{ .System }} {{ .Prompt }} [/INST]\n",
tokens: ["[INST]"],
params: {
stop: ["[INST]", "[/INST]"],
},
},
},
{
model: "library/mixtral:8x22b",
gguf: "{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n\n{{- bos_token }}\n{%- for message in loop_messages %}\n {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}\n {{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}\n {%- endif %}\n {%- if message['role'] == 'user' %}\n {%- if loop.last and system_message is defined %}\n {{- '[INST] ' + system_message + '\\n\\n' + message['content'] + '[/INST]' }}\n {%- else %}\n {{- '[INST] ' + message['content'] + '[/INST]' }}\n {%- endif %}\n {%- elif message['role'] == 'assistant' %}\n {{- ' ' + message['content'] + eos_token}}\n {%- else %}\n {{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}\n {%- endif %}\n{%- endfor %}\n",
Expand Down