Enabling granite4 chattemplate#5
Open
dangxuanhong wants to merge 8 commits intopadding-freefrom
Open
Conversation
Collaborator
dangxuanhong
commented
Jun 18, 2025
- This PR supports the granite4 chat template which is stored as a jinja2 file.
- It also supports the case where special chat tokens may need to be added to an existing tokenizer.
- A simple sample is added for testing purpose.
fabianlim
reviewed
Jun 18, 2025
|
|
||
| def _get_default_messages(): | ||
| # used for testing granite4 chat template | ||
| # messages = [ |
Collaborator
There was a problem hiding this comment.
we should have not comments here
fabianlim
reviewed
Jun 18, 2025
| ] | ||
| {"role": "system", "content": "You are a weather assistant that responds with relevant function calls instead of natural language."}, | ||
| {"role": "user", "content": "What's the weather like in Bengaluru?"}, | ||
| {"role": "assistant", "content": "get_coordinates(city='Bengaluru')"}, |
Collaborator
There was a problem hiding this comment.
what is this function _get_default_messages used for?
fabianlim
reviewed
Jun 18, 2025
| tokenizer.chat_template = CHAT_TEMPLATES[args.chat_template_name] | ||
| template_config = CHAT_TEMPLATES.get(args.chat_template_name) | ||
|
|
||
| accelerator.print(f"\n== template_config: {template_config}") |
Collaborator
There was a problem hiding this comment.
this is not needed if inline logic is removed
fabianlim
reviewed
Jun 18, 2025
|
|
||
| # add special tokens if they are provided: | ||
| if args.add_special_tokens is not None: | ||
| existing_special_tokens = tokenizer.special_tokens_map.get("additional_special_tokens", []) |
Collaborator
There was a problem hiding this comment.
wrap this logic in a functino and put it in the new utils file
fabianlim
reviewed
Jun 18, 2025
| return messages | ||
|
|
||
| def _get_default_tools(): | ||
| # used for testing granite4 chat template |
Collaborator
There was a problem hiding this comment.
move this to a new utils file
285fdc6 to
5f6c29c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.