Skip to content

Add replacement jinjas for OLMoE and granite-3.1 #3471

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 14 commits into from
Feb 12, 2025

Conversation

ThiloteE
Copy link
Collaborator

@ThiloteE ThiloteE commented Feb 6, 2025

Describe your changes

Added jinja replacement templates for

Notes

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.

Issue ticket number and link

Resolves #3053.
Contributes to #3159.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • I have added thorough documentation for my code.
  • I have tagged PR with relevant project labels. I acknowledge that a PR without labels may be dismissed.
  • If this PR addresses a bug, I have provided both a screenshot/video of the original bug and the working solution.

…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 <[email protected]>
Signed-off-by: ThiloteE <[email protected]>
@ThiloteE
Copy link
Collaborator Author

ThiloteE commented Feb 6, 2025

  • Fix template of Granite 3.1. The original one is currently rendered in white text by GitHub. I am not sure where exactly is the error that breaks the syntax.
    image.
  • Add changelog.

Not ready for merge yet.

@ThiloteE
Copy link
Collaborator Author

ThiloteE commented Feb 8, 2025

This is the out of the box (original) template in GPT4All for ibm-granite/granite-3.1-3b-a800m-instruct:

{%- 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 %}

@cebtenzzre maybe you can run it through your script. I am at a loss what exactly breaks the syntax. When I edit the file locally in QT and run, it gets replaced correctly, but when pulling from this branch, it doesn't, so something is off and I don't know what exactly.

@ThiloteE
Copy link
Collaborator Author

ThiloteE commented Feb 8, 2025

Running this branch with latest changes are functional, as can be seen in these screenshots:
image
image

The GUI in GitHub still complains, but maybe that's simply a GitHub issue.

I will add a changelog and then I will mark this PR ready for review, because I am out of ideas.

Signed-off-by: ThiloteE <[email protected]>
@ThiloteE ThiloteE requested a review from cebtenzzre February 8, 2025 14:27
@ThiloteE ThiloteE added the models label Feb 8, 2025
@cebtenzzre cebtenzzre merged commit 1b84182 into main Feb 12, 2025
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add olmoe architecture
2 participants