from swift.llm import DatasetName, ModelType, SftArguments, sft_main
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
sft_args = SftArguments(
model_type=ModelType.qwen1half_7b_chat,
dataset=[DatasetName.ms_bench_mini],
train_dataset_sample=1000,
logging_steps=5,
max_length=2048,
learning_rate=5e-5,
warmup_ratio=0.4,
output_dir='output',
lora_target_modules=['ALL'],
self_cognition_sample=500,
model_name=['小黄', 'Xiao Huang'],
model_author=['魔搭', 'ModelScope'])
output = sft_main(sft_args)
best_model_checkpoint = output['best_model_checkpoint']
print(f'best_model_checkpoint: {best_model_checkpoint}')
print(f'''CUDA_VISIBLE_DEVICES=0 swift export \
--ckpt_dir {best_model_checkpoint} \
--quant_bits 4 --quant_method awq \
--merge_lora true''')
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352