Skip to content

Enabling granite4 chattemplate#5

Open
dangxuanhong wants to merge 8 commits intopadding-freefrom
padding-free-xh
Open

Enabling granite4 chattemplate#5
dangxuanhong wants to merge 8 commits intopadding-freefrom
padding-free-xh

Conversation

@dangxuanhong
Copy link
Copy Markdown
Collaborator

  • 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.

Comment thread open_instruct/utils.py Outdated

def _get_default_messages():
# used for testing granite4 chat template
# messages = [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have not comments here

Comment thread open_instruct/utils.py Outdated
]
{"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')"},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this function _get_default_messages used for?

Comment thread open_instruct/finetune.py Outdated
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}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed if inline logic is removed

Comment thread open_instruct/finetune.py Outdated

# 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", [])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap this logic in a functino and put it in the new utils file

Comment thread open_instruct/utils.py Outdated
return messages

def _get_default_tools():
# used for testing granite4 chat template
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to a new utils file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants