Training procedure
Framework versions
git clone https://github.com/modelscope/swift.git
cd swift
pip install -e .[llm]
model finetune config
sft_args = SftArguments(
model_type=ModelType.qwen_7b_chat,
model_cache_dir='/mnt/nvme1/yongyang/llm_weights/qwen/Qwen-7B-Chat',
dataset=[DatasetName.leetcode_python_en],
train_dataset_sample=2000,
eval_steps=20,
logging_steps=5,
output_dir='output',
lora_target_modules='ALL',
self_cognition_sample=500,
model_name=['呼呼', 'huhu'],
model_author=['AI大模型实践小组', 'AI group'])
model inference
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
from swift.llm import ModelType, InferArguments, merge_lora_main, infer_main
best_model_checkpoint = 'path to model checkpoint'
infer_args = InferArguments(
model_type=ModelType.qwen_7b_chat,
model_cache_dir='/mnt/nvme1/yongyang/llm_weights/qwen/Qwen-7B-Chat',
ckpt_dir=best_model_checkpoint,
eval_human=True)
result = infer_main(infer_args)
评论