Fix Qwen3 thinking mode + increase max_new_tokens: training/train_sft.py
Browse files- training/train_sft.py +10 -6
training/train_sft.py
CHANGED
|
@@ -96,7 +96,7 @@ class SftConfig:
|
|
| 96 |
lr: float = 5e-5
|
| 97 |
grad_clip: float = 1.0
|
| 98 |
max_prompt_tokens: int = 2048
|
| 99 |
-
max_new_tokens: int =
|
| 100 |
bf16: bool = torch.cuda.is_available()
|
| 101 |
use_4bit: bool = True
|
| 102 |
gradient_checkpointing: bool = True
|
|
@@ -181,11 +181,15 @@ def build_sft_examples(
|
|
| 181 |
for action_dict in _expert_actions(env, task_id):
|
| 182 |
user_msg = build_observation_prompt(obs, is_first=(len(messages) == 1))
|
| 183 |
messages.append({"role": "user", "content": user_msg})
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
completion_text = json.dumps(action_dict, ensure_ascii=False)
|
| 190 |
prompt_ids = tokenizer(
|
| 191 |
prompt_text,
|
|
|
|
| 96 |
lr: float = 5e-5
|
| 97 |
grad_clip: float = 1.0
|
| 98 |
max_prompt_tokens: int = 2048
|
| 99 |
+
max_new_tokens: int = 384
|
| 100 |
bf16: bool = torch.cuda.is_available()
|
| 101 |
use_4bit: bool = True
|
| 102 |
gradient_checkpointing: bool = True
|
|
|
|
| 181 |
for action_dict in _expert_actions(env, task_id):
|
| 182 |
user_msg = build_observation_prompt(obs, is_first=(len(messages) == 1))
|
| 183 |
messages.append({"role": "user", "content": user_msg})
|
| 184 |
+
try:
|
| 185 |
+
prompt_text = tokenizer.apply_chat_template(
|
| 186 |
+
messages, tokenize=False, add_generation_prompt=True,
|
| 187 |
+
enable_thinking=False,
|
| 188 |
+
)
|
| 189 |
+
except TypeError:
|
| 190 |
+
prompt_text = tokenizer.apply_chat_template(
|
| 191 |
+
messages, tokenize=False, add_generation_prompt=True,
|
| 192 |
+
)
|
| 193 |
completion_text = json.dumps(action_dict, ensure_ascii=False)
|
| 194 |
prompt_ids = tokenizer(
|
| 195 |
prompt_text,
|