Skip to content

Commit dfadce9

Browse files
committed
[model] support hy3 model
1 parent a61cfa6 commit dfadce9

7 files changed

Lines changed: 557 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Hy3 Full SFT training script
4+
# Recommended: 4 nodes with 32x GPUs (at least 80GB memory each)
5+
# For single-node multi-GPU: use torchrun or deepspeed launcher
6+
7+
set -x
8+
9+
MODEL_PATH=tencent/Hy3
10+
11+
# Use deepspeed zero-3 offload for full fine-tuning
12+
llamafactory-cli train \
13+
--model_name_or_path ${MODEL_PATH} \
14+
--trust_remote_code \
15+
--stage sft \
16+
--do_train \
17+
--finetuning_type full \
18+
--deepspeed examples/deepspeed/ds_z3_offload_config.json \
19+
--dataset identity,alpaca_en_demo \
20+
--template hy3 \
21+
--cutoff_len 262144 \
22+
--max_samples 1000 \
23+
--preprocessing_num_workers 16 \
24+
--dataloader_num_workers 4 \
25+
--output_dir saves/hy3/full/sft \
26+
--logging_steps 10 \
27+
--save_steps 500 \
28+
--plot_loss \
29+
--overwrite_output_dir \
30+
--save_only_model false \
31+
--report_to none \
32+
--per_device_train_batch_size 1 \
33+
--gradient_accumulation_steps 2 \
34+
--learning_rate 1e-5 \
35+
--num_train_epochs 3.0 \
36+
--lr_scheduler_type cosine \
37+
--warmup_ratio 0.1 \
38+
--bf16 \
39+
--ddp_timeout 180000000 \
40+
--flash_attn fa2
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### model
2+
model_name_or_path: tencent/Hy3
3+
trust_remote_code: true
4+
5+
### method
6+
stage: sft
7+
do_train: true
8+
finetuning_type: full
9+
deepspeed: examples/deepspeed/ds_z3_offload_config.json
10+
11+
### dataset
12+
dataset: identity,alpaca_en_demo
13+
template: hy3
14+
cutoff_len: 262144
15+
max_samples: 1000
16+
preprocessing_num_workers: 16
17+
dataloader_num_workers: 4
18+
19+
### output
20+
output_dir: saves/hy3/full/sft
21+
logging_steps: 10
22+
save_steps: 500
23+
plot_loss: true
24+
overwrite_output_dir: true
25+
save_only_model: false
26+
report_to: none # choices: [none, wandb, tensorboard, swanlab, mlflow]
27+
28+
### train
29+
per_device_train_batch_size: 1
30+
gradient_accumulation_steps: 2
31+
learning_rate: 1.0e-5
32+
num_train_epochs: 3.0
33+
lr_scheduler_type: cosine
34+
warmup_ratio: 0.1
35+
bf16: true
36+
ddp_timeout: 180000000
37+
resume_from_checkpoint: null
38+
flash_attn: fa2
39+
40+
### eval
41+
# eval_dataset: alpaca_en_demo
42+
# val_size: 0.1
43+
# per_device_eval_batch_size: 1
44+
# eval_strategy: steps
45+
# eval_steps: 500
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Hy3 LoRA SFT training script
4+
# Recommended: 8x GPUs with at least 80GB memory each
5+
# For single-node multi-GPU: use torchrun or deepspeed launcher
6+
7+
set -x
8+
9+
MODEL_PATH=tencent/Hy3
10+
11+
# Use deepspeed for multi-GPU training
12+
llamafactory-cli train \
13+
--model_name_or_path ${MODEL_PATH} \
14+
--trust_remote_code \
15+
--stage sft \
16+
--do_train \
17+
--finetuning_type lora \
18+
--lora_rank 64 \
19+
--lora_alpha 128 \
20+
--lora_dropout 0.05 \
21+
--lora_target q_proj,k_proj,v_proj,o_proj \
22+
--deepspeed examples/deepspeed/ds_z2_offload_config.json \
23+
--dataset identity,alpaca_en_demo \
24+
--template hy3 \
25+
--cutoff_len 8192 \
26+
--max_samples 1000 \
27+
--preprocessing_num_workers 16 \
28+
--dataloader_num_workers 4 \
29+
--output_dir saves/hy3/lora/sft \
30+
--logging_steps 10 \
31+
--save_steps 500 \
32+
--plot_loss \
33+
--overwrite_output_dir \
34+
--save_only_model false \
35+
--report_to none \
36+
--per_device_train_batch_size 1 \
37+
--gradient_accumulation_steps 8 \
38+
--learning_rate 2e-4 \
39+
--num_train_epochs 3.0 \
40+
--lr_scheduler_type cosine \
41+
--warmup_ratio 0.1 \
42+
--bf16 \
43+
--ddp_timeout 180000000 \
44+
--flash_attn fa2
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
### model
2+
model_name_or_path: tencent/Hy3
3+
trust_remote_code: true
4+
5+
### method
6+
stage: sft
7+
do_train: true
8+
finetuning_type: lora
9+
lora_rank: 64
10+
lora_alpha: 128
11+
lora_dropout: 0.05
12+
lora_target: q_proj,k_proj,v_proj,o_proj
13+
deepspeed: examples/deepspeed/ds_z2_offload_config.json
14+
15+
### dataset
16+
dataset: identity,alpaca_en_demo
17+
template: hy3
18+
cutoff_len: 8192
19+
max_samples: 1000
20+
preprocessing_num_workers: 16
21+
dataloader_num_workers: 4
22+
23+
### output
24+
output_dir: saves/hy3/lora/sft
25+
logging_steps: 10
26+
save_steps: 500
27+
plot_loss: true
28+
overwrite_output_dir: true
29+
save_only_model: false
30+
report_to: none # choices: [none, wandb, tensorboard, swanlab, mlflow]
31+
32+
### train
33+
per_device_train_batch_size: 1
34+
gradient_accumulation_steps: 8
35+
learning_rate: 2.0e-4
36+
num_train_epochs: 3.0
37+
lr_scheduler_type: cosine
38+
warmup_ratio: 0.1
39+
bf16: true
40+
ddp_timeout: 180000000
41+
resume_from_checkpoint: null
42+
flash_attn: fa2
43+
44+
### eval
45+
# eval_dataset: alpaca_en_demo
46+
# val_size: 0.1
47+
# per_device_eval_batch_size: 1
48+
# eval_strategy: steps
49+
# eval_steps: 500

src/llamafactory/data/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ def get_template_and_fix_tokenizer(tokenizer: "PreTrainedTokenizer", data_args:
843843
format_prefix=EmptyFormatter(slots=[{"bos_token"}]),
844844
stop_words=["<|hy_eos|>"],
845845
replace_eos=True,
846-
thought_words=("<think>", "</think>"),
846+
thought_words=("<think:opensource>", "</think:opensource>"),
847847
template_class=ReasoningTemplate,
848848
)
849849

src/llamafactory/extras/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,10 @@ def register_model_group(
12871287
DownloadSource.DEFAULT: "tencent/Hy3-preview",
12881288
DownloadSource.MODELSCOPE: "tencent/Hy3-preview",
12891289
},
1290+
"Hy3": {
1291+
DownloadSource.DEFAULT: "tencent/Hy3",
1292+
DownloadSource.MODELSCOPE: "tencent/Hy3",
1293+
},
12901294
},
12911295
template="hy3",
12921296
)

0 commit comments

Comments
 (0)