-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass chat template (backend only)
- Loading branch information
1 parent
25cea8d
commit 5f513b5
Showing
4 changed files
with
64 additions
and
36 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/instructlab/training/chat_templates/ibm_generic_tmpl.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from tokenizer_utils import SpecialTokens | ||
|
||
SPECIAL_TOKENS = SpecialTokens( | ||
system="<|system|>", | ||
user="<|user|>", | ||
assistant="<|assistant|>", | ||
eos="<|endoftext|>", | ||
pad="<|pad|>" | ||
) | ||
|
||
CHAT_TEMPLATE = ( | ||
"{% for message in messages %}" | ||
"{% if message['role'] == 'pretraining' %}" | ||
"{{'<|endoftext|>' + message['content'] + '<|endoftext|>'}}" | ||
"{% elif message['role'] == 'system' %}" | ||
"{{'<|system|>'+ '\n' + message['content'] + '\n'}}" | ||
"{% elif message['role'] == 'user' %}" | ||
"{{'<|user|>' + '\n' + message['content'] + '\n'}}" | ||
"{% elif message['role'] == 'assistant' %}" | ||
"{{'<|assistant|>' + '\n' + message['content'] + '<|endoftext|>' + ('' if loop.last else '\n')}}" | ||
"{% endif %}" | ||
"{% endfor %}" | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from tokenizer_utils import SpecialTokens | ||
|
||
SPECIAL_TOKENS = SpecialTokens( | ||
bos="<s>", | ||
eos="</s>", | ||
user="[INST]", | ||
assistant="[/INST]", | ||
|
||
|
||
) | ||
|
||
CHAT_TEMPLATE = ( | ||
"{{ '<s>' }}" | ||
"{% for message in messages %}" | ||
"{% if message['role'] == 'pretraining' %}" | ||
"{{ message['content'] + '</s>' }}" | ||
"{% elif message['role'] == 'user' %}" | ||
"{{ '[INST] ' + message['content'] + ' [/INST]' }}" | ||
"{% elif message['role'] == 'assistant' %}" | ||
"{{ message['content'] + '</s>'}}" | ||
"{% endif %}" | ||
"{% endfor %}" | ||
) |
This file contains 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
This file contains 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