-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add setup_chat_format
for adding new special tokens to model for training chat models
#1242
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot ! I left some early comments, in addition can you:
- document its usage in the SFTTrainer docs?
- and also add a slow test here: https://github.com/huggingface/trl/blob/main/tests/slow/test_sft_slow.py#L36 with an end-to-end example
Thanks!
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot !
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
…aining chat models (huggingface#1242) * first draft * 64 * sourabs suggestion * wip tests * make style happy * add check * docstring * fix docstring * Update tests/test_model_utils.py Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com> * move tests * add todo for abstract class * make style happy * add slow tests and imports * add documentation * sft_trainer.mdx aktualisieren Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com> --------- Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
What does this PR do?
This PR adds a new
util
methodsetup_chat_format
, which automatically defines thechat_template
for a tokenizer, adds special tokens, resizes the model embedding layer (optional to a multiple of 64)It also introduces the
ChatMlSpecialTokens
dataclass, which is used in thesetup_chat_format
. This will make it easy to extend to different formats in the future, e.g., llama, but for now, we only addchatml
.Open Discussions
Should we add more dummy tokens to the tokenizer when the embedding layer is extended to a multiple of x? This can lead to downstream issues with llama.cpp