Spaces:
Sleeping
Sleeping
Commit ·
e26d074
1
Parent(s): 93c8813
update
Browse files
examples/tutorials/dpo/ultrafeedback-dpo/step_2_train_dpo_model_single_gpu.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
https://huggingface.co/docs/trl/v0.16.1/en/sft_trainer
|
| 5 |
|
| 6 |
单卡 V00 32G 全参微调
|
| 7 |
-
python3
|
| 8 |
|
| 9 |
"""
|
| 10 |
import argparse
|
|
@@ -27,8 +27,7 @@ else:
|
|
| 27 |
from datasets import load_dataset
|
| 28 |
import torch
|
| 29 |
|
| 30 |
-
from modelscope import AutoModelForCausalLM
|
| 31 |
-
from transformers import AutoTokenizer
|
| 32 |
from trl import DPOConfig, DPOTrainer
|
| 33 |
|
| 34 |
|
|
|
|
| 4 |
https://huggingface.co/docs/trl/v0.16.1/en/sft_trainer
|
| 5 |
|
| 6 |
单卡 V00 32G 全参微调
|
| 7 |
+
python3 step_2_train_dpo_model_single_gpu.py
|
| 8 |
|
| 9 |
"""
|
| 10 |
import argparse
|
|
|
|
| 27 |
from datasets import load_dataset
|
| 28 |
import torch
|
| 29 |
|
| 30 |
+
from modelscope import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 31 |
from trl import DPOConfig, DPOTrainer
|
| 32 |
|
| 33 |
|
examples/tutorials/dpo/ultrafeedback-dpo/step_6_push_to_modelscope.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
# !/usr/bin/env python3
|
| 4 |
+
# -*- coding: utf-8 -*-
|
| 5 |
+
"""
|
| 6 |
+
python step_6_push_to_modelscope.py \
|
| 7 |
+
--model_dir /root/autodl-tmp/OpenMiniMind/temp/trainer_output/Qwen3-8B-sft-deepspeed/checkpoint-100 \
|
| 8 |
+
--repo_id gyd2021/Qwen3-8B-sft-deepspeed \
|
| 9 |
+
--token your_modelscope_token
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import argparse
|
| 14 |
+
import logging
|
| 15 |
+
|
| 16 |
+
# 设置日志格式
|
| 17 |
+
logging.basicConfig(
|
| 18 |
+
level=logging.INFO,
|
| 19 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
| 20 |
+
)
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
from modelscope.hub.api import HubApi
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def get_args():
|
| 27 |
+
parser = argparse.ArgumentParser()
|
| 28 |
+
|
| 29 |
+
parser.add_argument("--model_dir", type=str,)
|
| 30 |
+
parser.add_argument("--repo_id", type=str)
|
| 31 |
+
parser.add_argument("--token", type=str, default=None,)
|
| 32 |
+
parser.add_argument("--chunk_size", type=int, default=50)
|
| 33 |
+
|
| 34 |
+
return parser.parse_args()
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main():
|
| 38 |
+
args = get_args()
|
| 39 |
+
|
| 40 |
+
api = HubApi(token=args.token)
|
| 41 |
+
api.upload_folder(
|
| 42 |
+
repo_id=args.repo_id,
|
| 43 |
+
folder_path=args.model_dir,
|
| 44 |
+
)
|
| 45 |
+
return
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
main()
|