Compare commits

...

14 Commits

Author SHA1 Message Date
Jared Van Bortel
e9f5d15c09 remove extra whitespace from replacements
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
2025-02-12 14:21:12 -05:00
Jared Van Bortel
0ce0189b97 changelog: add credit to ThiloteE
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
2025-02-12 14:18:53 -05:00
Jared Van Bortel
c45f1f9cd7 Merge branch 'main' into thilotee-rep-template-olmoe 2025-02-12 14:18:35 -05:00
Jared Van Bortel
62fbe796c4 add template replacement for OLMoE-1B-7B-0125
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
2025-02-12 11:58:48 -05:00
Jared Van Bortel
df95b7b0a4 tweak changelog entry and further simplify templates
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
2025-02-11 16:41:27 -05:00
Jared Van Bortel
b7ad59c5c5 Merge branch 'main' into thilotee-rep-template-olmoe 2025-02-11 16:18:35 -05:00
ThiloteE
c3d17d74d5 Add Changelog
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-08 15:27:21 +01:00
ThiloteE
34eaaa2301 Try adding granite out of the box via local QT
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-08 14:13:17 +01:00
ThiloteE
d3e2bb7e7c Try escaping single quote in system prompt
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-08 02:04:18 +01:00
ThiloteE
3fddf1de6e Go back to out of the box jinja for granite
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-08 01:49:03 +01:00
ThiloteE
ba7d3bef34 Try original with "
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-07 00:08:31 +01:00
ThiloteE
b79df8ed33 Remove \n\n from controls and try other original
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-07 00:03:06 +01:00
ThiloteE
dd3dfa11a4 Fix comments.
Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-06 23:30:53 +01:00
ThiloteE
bfe85d6c01 Add replacement jinjas for OLMoE-1B-7B-0924-Instruct and granite-3.1-8b-instruct
Added jinja replacement templates for 
- https://huggingface.co/ibm-granite/granite-3.1-8b-instruct
- https://huggingface.co/allenai/OLMoE-1B-7B-0924-Instruct

Differences to original templates (but doesn't prevent a merge!):
- [ ] ``\nToday's Date: \" + strftime_now('%B %d, %Y') + \".` as encountered in granite-3.1-8b-instruct's original tokenizer_config.json.

Signed-off-by: ThiloteE <73715071+ThiloteE@users.noreply.github.com>
2025-02-06 23:15:06 +01:00
2 changed files with 88 additions and 1 deletions

View File

@@ -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))

View File

@@ -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)
{