Skip to content

Commit

Permalink
Fix tiktoken add generation prompt (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea authored Jan 20, 2024
1 parent 19368c6 commit c9a49d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llmfoundry/tokenizers/tiktoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def default_chat_template(self):
'{% else %}'
"{{ '\n' + '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' }}"
'{% endif %}'
'{% if (add_generation_prompt == true) %}'
'{% if (add_generation_prompt == true and loop.last) %}'
"{{ '\n' + '<|im_start|>' + 'assistant' + '\n' }}"
"{% elif (message['role'] == 'assistant') %}"
'{{ eos_token }}'
Expand Down
10 changes: 10 additions & 0 deletions tests/tokenizers/test_tiktoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
'Please summarize the goals in this text:\n\nGoing outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.',
'role':
'user'
}, {
'content': 'You should go outside and touch grass.',
'role': 'assistant'
}, {
'content': 'What else can I do?',
'role': 'user'
}]]

MULTI_TURN_GENERATE_STRING = [
Expand All @@ -118,6 +124,10 @@
Going outside has benefits include reducing stress and triggering the relaxation response, which can help us not only feel better mentally, but even heal faster from physical ailments.<|im_end|>
<|im_start|>assistant
You should go outside and touch grass.<|im_end|><|endoftext|>
<|im_start|>user
What else can I do?<|im_end|>
<|im_start|>assistant
"""
]

Expand Down

0 comments on commit c9a49d0

Please sign in to comment.