qwen config upgrade
This commit is contained in:
parent
377cf77c16
commit
0de8db232b
@ -88,8 +88,8 @@ def is_dataset_cached(dataset_name):
|
||||
|
||||
|
||||
def evaluate():
|
||||
# model_name = "Qwen3-Embedding-0.6B"
|
||||
model_name = "llama-embed-nemotron-8b"
|
||||
model_name = "Qwen3-Embedding-0.6B"
|
||||
# model_name = "llama-embed-nemotron-8b"
|
||||
# model_name = "embeddinggemma-300m"
|
||||
model = CustomModel(model_name)
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
nproc_per_node=1
|
||||
|
||||
MLFLOW_TRACKING_URI=http://0.0.0.0:5004 \
|
||||
INFONCE_USE_BATCH=False \
|
||||
INFONCE_USE_BATCH=True \
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
NPROC_PER_NODE=$nproc_per_node \
|
||||
swift sft \
|
||||
@ -12,11 +12,12 @@ swift sft \
|
||||
--task_type embedding \
|
||||
--model_type qwen3_emb \
|
||||
--train_type lora \
|
||||
--lora_rank 8 \
|
||||
--lora_alpha 16 \
|
||||
--lora_rank 16 \
|
||||
--lora_alpha 32 \
|
||||
--target_modules all-linear \
|
||||
--dataset my_local_dataset \
|
||||
--custom_register_path $(pwd)/../../data/dataset/my_dataset_register.py \
|
||||
--max_length 2048 \
|
||||
--dataset v11_dataset_hn \
|
||||
--custom_register_path $(pwd)/../../data/dataset/v11_dataset_hn/generated.py \
|
||||
--split_dataset_ratio 0.005 \
|
||||
--eval_strategy steps \
|
||||
--output_dir output \
|
||||
@ -27,7 +28,8 @@ swift sft \
|
||||
--per_device_train_batch_size 16 \
|
||||
--per_device_eval_batch_size 16 \
|
||||
--gradient_accumulation_steps 4 \
|
||||
--learning_rate 2.4e-5 \
|
||||
--learning_rate 3.0e-6 \
|
||||
--lr_scheduler_type constant \
|
||||
--loss_type infonce \
|
||||
--label_names labels \
|
||||
--dataloader_drop_last true \
|
||||
|
||||
@ -4,6 +4,8 @@ import os
|
||||
from peft import PeftModel
|
||||
import torch
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
||||
import shutil
|
||||
os.environ["PEFT_BOFT_FORCE_CPU"] = "1"
|
||||
|
||||
def merge(base_model_path, peft_model_path, save_path):
|
||||
base_model = AutoModelForCausalLM.from_pretrained(base_model_path, torch_dtype="bfloat16")
|
||||
@ -11,14 +13,34 @@ def merge(base_model_path, peft_model_path, save_path):
|
||||
ft_model = ft_model.merge_and_unload()
|
||||
ft_model.save_pretrained(save_path)
|
||||
|
||||
def copy_selected_items(src_path, dst_path, items):
|
||||
os.makedirs(dst_path, exist_ok=True)
|
||||
|
||||
for item in items:
|
||||
source_item = os.path.join(src_path, item)
|
||||
dest_item = os.path.join(dst_path, item)
|
||||
|
||||
if not os.path.exists(source_item):
|
||||
print(f"⚠ {item} در مسیر مبدا پیدا نشد!")
|
||||
continue
|
||||
|
||||
if os.path.isdir(source_item):
|
||||
shutil.copytree(source_item, dest_item, dirs_exist_ok=True)
|
||||
elif os.path.isfile(source_item):
|
||||
shutil.copy2(source_item, dest_item)
|
||||
|
||||
def main():
|
||||
file_path = os.path.dirname(__file__)
|
||||
|
||||
base_model_path = file_path + "/../../data/models/Qwen3-Embedding-0.6B/model"
|
||||
peft_model_path = file_path + "/output/v1-20251122-184545/checkpoint-3434"
|
||||
save_path = file_path + "/output/v1-20251122-184545/merged_checkpoint-3434"
|
||||
peft_model_path = file_path + "/output/v17-20251202-223944/checkpoint-387"
|
||||
save_path = file_path + "/output/v17-20251202-223944/merged_checkpoint-387"
|
||||
merge(base_model_path, peft_model_path, save_path)
|
||||
|
||||
items = ["1_Pooling", "config_sentence_transformers.json", "merges.txt", "modules.json", "README.md", "tokenizer_config.json", "tokenizer.json",
|
||||
"vocab.json"]
|
||||
copy_selected_items(base_model_path, save_path, items)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user