Skip to content

Commit

Permalink
Merge pull request QwenLM#227 from QwenLM/fix-sft-chat-template
Browse files Browse the repository at this point in the history
Update finetune.py
  • Loading branch information
JustinLin610 authored Mar 29, 2024
2 parents 0b43330 + f9a4b42 commit 120ae27
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/sft/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

IGNORE_TOKEN_ID = LabelSmoother.ignore_index

TEMPLATE = "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content']}}{% if loop.last %}{{ '<|im_end|>'}}{% else %}{{ '<|im_end|>\n' }}{% endif %}{% endfor %}"

local_rank = None


Expand Down Expand Up @@ -146,6 +148,7 @@ def preprocess(
texts.append(
tokenizer.apply_chat_template(
msg,
chat_template=TEMPLATE,
tokenize=True,
add_generation_prompt=False,
padding=True,
Expand Down

0 comments on commit 120ae27

Please sign in to comment.