开发者社区 > ModelScope模型即服务 > 正文

微调模型是直接下载社区里面的模型到ubuntu服务器么,我运行会报错,是什么原因呀

我的模型是在这里下载的
image.png
image.png
下面是我的微调代码,模型路径我指定下载的文件夹
import tempfile
import time

from modelscope.msdatasets import MsDataset
from modelscope.metainfo import Trainers
from modelscope.trainers import build_trainer

载入数据集

dataset = MsDataset.load('文案1.json')

假设数据集中没有 train 和 validation 的分割,我们手动分割数据集

这里假设数据集中包含全部数据,数据以列表形式存储

data = dataset
print(data)

print(next(iter(data)))

train_dataset = data.remap_columns({'商品名称': 'src_txt', '文案al': 'tgt_txt'})
eval_dataset = data.remap_columns({'商品名称': 'src_txt', '文案al': 'tgt_txt'})
print(train_dataset)

for i, item in enumerate(train_dataset):
if i < 5:
print(item)
else:
break

num_warmup_steps = 500
def noam_lambda(current_step: int):
current_step += 1
return min(current_step(-0.5),
current_step * num_warmup_steps
(-1.5))

可以在代码修改 configuration 的配置

def cfg_modify_fn(cfg):
cfg.train.lr_scheduler = {
'type': 'LambdaLR',
'lr_lambda': noam_lambda,
'options': {
'by_epoch': False
}
}
cfg.train.optimizer = {
"type": "AdamW",
"lr": 1e-3,
"options": {}
}
cfg.train.max_epochs = 15
cfg.train.dataloader = {
"batch_size_per_gpu": 8,
"workers_per_gpu": 1
}
return cfg

kwargs = dict(
model='nlp_palm2.0_text-generation_commodity_chinese-base',
train_dataset=train_dataset,
eval_dataset=eval_dataset,
work_dir=tempfile.TemporaryDirectory().name,
cfg_modify_fn=cfg_modify_fn)
trainer = build_trainer(
name=Trainers.text_generation_trainer, default_args=kwargs)
trainer.train()

但是运行后报错
2024-07-27 20:11:22,544 - modelscope - INFO - Model file README.md is different from the latest version v1.0.0,This is because you are using an older version or the file is updated manually.
2024-07-27 20:11:22,546 - modelscope - INFO - initialize model from nlp_palm2.0_text-generation_commodity_chinese-base
2024-07-27 20:11:27,927 - modelscope - WARNING - ('CUSTOM_DATASETS', 'text-generation', 'palm-v2') not found in ast index file
2024-07-27 20:11:27,928 - modelscope - WARNING - ('CUSTOM_DATASETS', 'text-generation', 'palm-v2') not found in ast index file
2024-07-27 20:11:27,931 - modelscope - INFO - cuda is not available, using cpu instead.
2024-07-27 20:11:27,932 - modelscope - INFO - ==========================Training Config Start==========================
2024-07-27 20:11:27,933 - modelscope - INFO - {
"framework": "pytorch",
"task": "text-generation",
"model": {
"type": "palm-v2"
},
"pipeline": {
"type": "text-generation"
},
"preprocessor": {
"type": "text-gen-tokenizer",
"mode": "eval",
"use_fast": true
},
"train": {
"hooks": [
{
"type": "IterTimerHook"
}
],
"lr_scheduler": {
"type": "LambdaLR",
"lr_lambda": null,
"options": {
"by_epoch": false
}
},
"optimizer": {
"type": "AdamW",
"lr": 0.001,
"options": {}
},
"max_epochs": 15,
"dataloader": {
"batch_size_per_gpu": 8,
"workers_per_gpu": 1
},
"checkpoint": {
"period": {
"interval": 1,
"save_dir": "/tmp/tmpczm0yrho"
}
},
"logging": {
"interval": 10,
"out_dir": "/tmp/tmpczm0yrho"
},
"work_dir": "/tmp/tmpczm0yrho"
}
}
2024-07-27 20:11:27,933 - modelscope - INFO - ===========================Training Config End===========================
2024-07-27 20:11:27,934 - modelscope - WARNING - ('OPTIMIZER', 'default', 'AdamW') not found in ast index file
build_dataset error log: 'palm-v2 is not in the custom_datasets registry group text-generation. Please make sure the correct version of ModelScope library is used.' build_dataset error log: 'palm-v2 is not in the custom_datasets registry group text-generation. Please make sure the correct version of ModelScope library is used.'

展开
收起
dingtalk_mcdtil 2024-07-27 20:23:41 47 0
0 条回答
写回答
取消 提交回答

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS块储存产品全面解析 立即下载