mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-01 15:51:00 +00:00
Add replacement templates for OLMoE and granite-3.1 (#3471)
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com> Signed-off-by: Jared Van Bortel <jared@nomic.ai> Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
02e12089d3
commit
1b84182030
@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
### Added
|
||||
- Whitelist Granite (non-MoE) model architecture (by [@ThiloteE](https://github.com/ThiloteE) in [#3487](https://github.com/nomic-ai/gpt4all/pull/3487))
|
||||
|
||||
### Changed
|
||||
- Substitute prettier default templates for OLMoE 7B 0924/0125 and Granite 3.1 3B/8B (by [@ThiloteE](https://github.com/ThiloteE) in [#3471](https://github.com/nomic-ai/gpt4all/pull/3471))
|
||||
|
||||
### Fixed
|
||||
- Fix several potential crashes ([#3465](https://github.com/nomic-ai/gpt4all/pull/3465))
|
||||
- Fix visual spacing issues with deepseek models ([#3470](https://github.com/nomic-ai/gpt4all/pull/3470))
|
||||
|
@ -113,11 +113,31 @@ const std::unordered_map<std::string_view, std::string_view> CHAT_TEMPLATE_SUBST
|
||||
{%- elif message['role'] == 'system' %}
|
||||
{{- '<|system|>\n' + message['content'] + eos_token }}
|
||||
{%- elif message['role'] == 'assistant' %}
|
||||
{{- '<|assistant|>\n' + message['content'] + eos_token }}
|
||||
{{- '<|assistant|>\n' + message['content'] + eos_token }}
|
||||
{%- endif %}
|
||||
{%- if loop.last and add_generation_prompt %}
|
||||
{{- '<|assistant|>' }}
|
||||
{%- endif %}
|
||||
{%- endfor %})TEMPLATE",
|
||||
},
|
||||
// granite-3.1-3b-a800m-instruct-Q4_0.gguf, granite-3.1-8b-instruct-Q4_0.gguf (nomic-ai/gpt4all#3471)
|
||||
{
|
||||
// original
|
||||
R"TEMPLATE({%- if messages[0]['role'] == 'system' %}{%- set system_message = messages[0]['content'] %}{%- set loop_messages = messages[1:] %}{%- else %}{%- set system_message = "Knowledge Cutoff Date: April 2024. You are Granite, developed by IBM." %}{%- if tools and documents %}{%- set system_message = system_message + " You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request. Write the response to the user's input by strictly aligning with the facts in the provided documents. If the information needed to answer the question is not available in the documents, inform the user that the question cannot be answered based on the available data." %}{%- elif tools %}{%- set system_message = system_message + " You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request." %}{%- elif documents %}{%- set system_message = system_message + " Write the response to the user's input by strictly aligning with the facts in the provided documents. If the information needed to answer the question is not available in the documents, inform the user that the question cannot be answered based on the available data." %}{%- else %}{%- set system_message = system_message + " You are a helpful AI assistant." %}{%- endif %}{%- if controls and 'citations' in controls and documents %}{%- set system_message = system_message + ' In your response, use the symbols <co> and </co> to indicate when a fact comes from a document in the search result, e.g <co>0</co> for a fact from document 0. Afterwards, list all the citations with their corresponding documents in an ordered list.' %}{%- endif %}{%- if controls and 'hallucinations' in controls and documents %}{%- set system_message = system_message + ' Finally, after the response is written, include a numbered list of sentences from the response that are potentially hallucinated and not based in the documents.' %}{%- endif %}{%- set loop_messages = messages %}{%- endif %}{{- '<|start_of_role|>system<|end_of_role|>' + system_message + '<|end_of_text|> ' }}{%- if tools %}{{- '<|start_of_role|>tools<|end_of_role|>' }}{{- tools | tojson(indent=4) }}{{- '<|end_of_text|> ' }}{%- endif %}{%- if documents %}{{- '<|start_of_role|>documents<|end_of_role|>' }}{%- for document in documents %}{{- 'Document ' + loop.index0 | string + ' ' }}{{- document['text'] }}{%- if not loop.last %}{{- ' '}}{%- endif%}{%- endfor %}{{- '<|end_of_text|> ' }}{%- endif %}{%- for message in loop_messages %}{{- '<|start_of_role|>' + message['role'] + '<|end_of_role|>' + message['content'] + '<|end_of_text|> ' }}{%- if loop.last and add_generation_prompt %}{{- '<|start_of_role|>assistant' }}{%- if controls %}{{- ' ' + controls | tojson()}}{%- endif %}{{- '<|end_of_role|>' }}{%- endif %}{%- endfor %})TEMPLATE",
|
||||
// replacement
|
||||
R"TEMPLATE({%- if messages[0]['role'] == 'system' %}
|
||||
{%- set system_message = messages[0]['content'] %}
|
||||
{%- set loop_messages = messages[1:] %}
|
||||
{%- else %}
|
||||
{%- set system_message = "Knowledge Cutoff Date: April 2024. You are Granite, developed by IBM. You are a helpful AI assistant." %}
|
||||
{%- set loop_messages = messages %}
|
||||
{%- endif %}
|
||||
{{- '<|start_of_role|>system<|end_of_role|>' + system_message + '<|end_of_text|> ' }}
|
||||
{%- for message in loop_messages %}
|
||||
{{- '<|start_of_role|>' + message['role'] + '<|end_of_role|>' + message['content'] + '<|end_of_text|> ' }}
|
||||
{%- if loop.last and add_generation_prompt %}
|
||||
{{- '<|start_of_role|>assistant<|end_of_role|>' }}
|
||||
{%- endif %}
|
||||
{%- endfor %})TEMPLATE",
|
||||
},
|
||||
// Hermes-3-Llama-3.2-3B.Q4_0.gguf, mistral-7b-openorca.gguf2.Q4_0.gguf
|
||||
@ -618,6 +638,70 @@ const std::unordered_map<std::string_view, std::string_view> CHAT_TEMPLATE_SUBST
|
||||
{%- if add_generation_prompt %}
|
||||
{{- '<|im_start|>assistant\n' }}
|
||||
{%- endif %})TEMPLATE",
|
||||
},
|
||||
// OLMoE-1B-7B-0125-Instruct-Q4_0.gguf (nomic-ai/gpt4all#3471)
|
||||
{
|
||||
// original
|
||||
R"TEMPLATE({{ bos_token }}{% for message in messages %}{% if message['role'] == 'system' %}{{ '<|system|>
|
||||
' + message['content'] + '
|
||||
' }}{% elif message['role'] == 'user' %}{{ '<|user|>
|
||||
' + message['content'] + '
|
||||
' }}{% elif message['role'] == 'assistant' %}{% if not loop.last %}{{ '<|assistant|>
|
||||
' + message['content'] + eos_token + '
|
||||
' }}{% else %}{{ '<|assistant|>
|
||||
' + message['content'] + eos_token }}{% endif %}{% endif %}{% if loop.last and add_generation_prompt %}{{ '<|assistant|>
|
||||
' }}{% endif %}{% endfor %})TEMPLATE",
|
||||
// replacement
|
||||
R"TEMPLATE({{- bos_token }}
|
||||
{%- for message in messages %}
|
||||
{%- if message['role'] == 'system' %}
|
||||
{{- '<|system|>\n' + message['content'] + '\n' }}
|
||||
{%- elif message['role'] == 'user' %}
|
||||
{{- '<|user|>\n' + message['content'] + '\n' }}
|
||||
{%- elif message['role'] == 'assistant' %}
|
||||
{%- if not loop.last %}
|
||||
{{- '<|assistant|>\n' + message['content'] + eos_token + '\n' }}
|
||||
{%- else %}
|
||||
{{- '<|assistant|>\n' + message['content'] + eos_token }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- if loop.last and add_generation_prompt %}
|
||||
{{- '<|assistant|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endfor %})TEMPLATE",
|
||||
},
|
||||
// OLMoE-1B-7B-0924-Instruct-Q4_0.gguf (nomic-ai/gpt4all#3471)
|
||||
{
|
||||
// original
|
||||
R"TEMPLATE({{ bos_token }}{% for message in messages %}
|
||||
{% if message['role'] == 'system' %}
|
||||
{{ '<|system|>
|
||||
' + message['content'] }}
|
||||
{% elif message['role'] == 'user' %}
|
||||
{{ '<|user|>
|
||||
' + message['content'] }}
|
||||
{% elif message['role'] == 'assistant' %}
|
||||
{{ '<|assistant|>
|
||||
' + message['content'] + eos_token }}
|
||||
{% endif %}
|
||||
{% if loop.last and add_generation_prompt %}
|
||||
{{ '<|assistant|>' }}
|
||||
{% endif %}
|
||||
{% endfor %})TEMPLATE",
|
||||
// replacement
|
||||
R"TEMPLATE({{- bos_token }}
|
||||
{%- for message in messages %}
|
||||
{%- if message['role'] == 'system' %}
|
||||
{{- '<|system|>\n' + message['content'] }}
|
||||
{%- elif message['role'] == 'user' %}
|
||||
{{- '<|user|>\n' + message['content'] }}
|
||||
{%- elif message['role'] == 'assistant' %}
|
||||
{{- '<|assistant|>\n' + message['content'] + eos_token }}
|
||||
{%- endif %}
|
||||
{%- if loop.last and add_generation_prompt %}
|
||||
{{- '<|assistant|>' }}
|
||||
{%- endif %}
|
||||
{%- endfor %})TEMPLATE",
|
||||
},
|
||||
// Phi-3.1-mini-128k-instruct-Q4_0.gguf (nomic-ai/gpt4all#3346)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user