简介:本模型是基于swift框架,对qwe-7b-chat模型进行微调获得的。模型的功能是评估用户输入的一段话,模型能够准确给出这句话是消极的还是积极的。 swift框架
ubutu 22.04
cuda 12.0.1
pytho 3.10
pytorch 2.1.2 数据集:jdsetimetzh 微调的模型:qwe-7b-chat 通过以下命令安装Emotio_diff模型
2.训练方法
3.训练的步骤
3.1使用modelscope上的免费的GPU算力
3.2启动后进入命令行界面
3.3安装swift
git cloe https://github.com/modelscope/swift.git
cd swift
pip istall -e .[llm]
4.微调代码
import os
os.eviro['CUDA_VISIBLE_DEVICES'] = '0'
import torch
from swift.llm import (
DatasetName, IferArgumets, ModelType, SftArgumets,
ifer_mai, sft_mai, app_ui_mai, merge_lora_mai
)
model_type = ModelType.qwe_7b_chat
sft_args = SftArgumets(
model_type=model_type,
trai_dataset_sample=2000,
dataset=[DatasetName.jd_setimet_zh],
output_dir='output')
result = sft_mai(sft_args)
best_model_checkpoit = result['best_model_checkpoit']
prit(f'best_model_checkpoit: {best_model_checkpoit}')
torch.cuda.empty_cache()
ifer_args = IferArgumets(
ckpt_dir=best_model_checkpoit,
show_dataset_sample=10)
# merge_lora_mai(ifer_args)
result = ifer_mai(ifer_args)
5.示例代码
import os
os.eviro['CUDA_VISIBLE_DEVICES'] = '0'
import torch
from swift.llm import (
DatasetName, IferArgumets, ModelType, SftArgumets,
ifer_mai, sft_mai, app_ui_mai, merge_lora_mai
)
best_model_checkpoit = "/mt/workspace/output/qwe-7b-chat/v0-20240123-102915/checkpoit-100"
prit(f'best_model_checkpoit: {best_model_checkpoit}')
torch.cuda.empty_cache()
ifer_args = IferArgumets(
ckpt_dir=best_model_checkpoit,
show_dataset_sample=10)
# merge_lora_mai(ifer_args)
ifer_args.system="You are a expert i aalyzig emotios. The user will give some Chiese or Eglish seteces, ad you oly eed to aswer whether the emotio i the setece is 'positive' or 'agetive'. For example, the user iputs {Quality is very good, the material is very good, the workmaship is exquisite, the style is ice, the clothes are very beautiful}. Your aswer is {positive}. Besides the emotioal type of the setece (positive, egative), you do't eed to aswer ay other redudat words."
prit(f"ifer_args-->{ifer_args.system}")
result = ifer_mai(ifer_args)
torch.cuda.empty_cache()
6.结果
点击空白处退出提示
评论