Skip to content

Commit 15a0343

Browse files
authored
chore: add chat_template_kwargs in default train configs (#1353)
Signed-off-by: Yuki Huang <[email protected]>
1 parent 355aa98 commit 15a0343

File tree

6 files changed

+6
-0
lines changed

6 files changed

+6
-0
lines changed

examples/configs/distillation_math.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ policy: &POLICY_BASE
3131
model_name: "Qwen/Qwen3-1.7B-Base"
3232
tokenizer:
3333
name: ${..model_name} ## specify if you'd like to use a tokenizer different from the model's default
34+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
3435
train_global_batch_size: 64
3536
train_micro_batch_size: 1
3637
generation_batch_size: 64

examples/configs/dpo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ policy:
3232
model_name: "meta-llama/Llama-3.2-1B-Instruct"
3333
tokenizer:
3434
name: "meta-llama/Llama-3.2-1B-Instruct"
35+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
3536

3637
# number of preference samples per batch
3738
# each preference sample corresponds to a pair of chosen and rejected responses

examples/configs/grpo_math_1B.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ policy:
4646
model_name: "Qwen/Qwen2.5-1.5B"
4747
tokenizer:
4848
name: ${policy.model_name} ## specify if you'd like to use a tokenizer different from the model's default
49+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
4950
train_global_batch_size: 512
5051
train_micro_batch_size: 4
5152
generation_batch_size: 32 # Only used when generating using HF backend

examples/configs/grpo_math_1B_megatron.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ policy:
3939
model_name: "Qwen/Qwen2.5-1.5B"
4040
tokenizer:
4141
name: ${policy.model_name} ## specify if you'd like to use a tokenizer different from the model's default
42+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
4243
train_global_batch_size: 512
4344
train_micro_batch_size: 4
4445
generation_batch_size: 64 # Only used when generating using megatron backend

examples/configs/rm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ policy:
2828
# We don't use the "default" chat template because the Llama tokenizer inserts the current
2929
# date in the system prompt, which could make the reward model's output date-dependent.
3030
chat_template: "{{- bos_token }}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = '' %}\n{%- endif %}\n\n{#- System message #}\n{{- '<|start_header_id|>system<|end_header_id|>\n\n' }}\n{{- system_message }}\n{{- '<|eot_id|>' }}\n\n{%- for message in messages %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id>\n\n' }}\n{%- endif %}"
31+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
3132
train_global_batch_size: 128
3233
train_micro_batch_size: 1
3334
max_total_sequence_length: 8192

examples/configs/sft.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ policy:
2727
name: ${policy.model_name} ## specify if you'd like to use a tokenizer different from the model's default
2828
# chat_template can be a Jinja template string or path to a .jinja file
2929
chat_template: "{% for message in messages %}{%- if message['role'] == 'system' %}{{'Context: ' + message['content'].strip()}}{%- elif message['role'] == 'user' %}{{' Question: ' + message['content'].strip() + ' Answer:'}}{%- elif message['role'] == 'assistant' %}{{' ' + message['content'].strip()}}{%- endif %}{% endfor %}"
30+
chat_template_kwargs: null # can be used to pass kwargs to the chat template, e.g., enable_thinking=true
3031
train_global_batch_size: 32
3132
train_micro_batch_size: 1
3233
max_total_sequence_length: 1024

0 commit comments

Comments
 (0)