您好,请教下ModelScope训练nlp_gpt3_text-generation_1.3B模型增大数据集与测试集后出现如下报错。这个该如何解决呢? RuntimeError: The expanded size of the tensor (541) must match the existing size (511) at non-singleton dimension 3. Target sizes: [1, 32, 511, 541]. Tensor sizes: [1, 1, 511, 511] 这个是训练代码哈 from modelscope.msdatasets import MsDataset from modelscope.trainers import build_trainer from modelscope.metainfo import Trainers from datasets import load_dataset import sys sys.setrecursionlimit(4000)
data_files = {"train": "train.csv", "test": "test.csv"}
dataset = load_dataset("csv", data_files=data_files, delimiter=",") dataset = MsDataset(dataset) train_dataset = MsDataset(dataset['train']).remap_columns({'text1': 'src_txt', 'text2': 'tgt_txt'})
.map(lambda example: {'src_txt': example['src_txt'] + '\n'}) eval_dataset = MsDataset(dataset['test']).remap_columns({'text1': 'src_txt', 'text2': 'tgt_txt'})
.map(lambda example: {'src_txt': example['src_txt'] + '\n'})
max_epochs = 10
tmp_dir = './gpt3_dureader'
num_warmup_steps = 200
def noam_lambda(current_step: int): current_step += 1 return min(current_step**(-0.5), current_step * num_warmup_steps**(-1.5))
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': 3e-4} cfg.train.dataloader = { 'batch_size_per_gpu': 2, 'workers_per_gpu': 1 } cfg.train.hooks.append({ 'type': 'MegatronHook' }) cfg.preprocessor.sequence_length = 512 cfg.model.checkpoint_model_parallel_size = 1 return cfg
kwargs = dict( model='./models/damo/nlp_gpt3_text-generation_1.3B', train_dataset=train_dataset, eval_dataset=eval_dataset, max_epochs=max_epochs, work_dir=tmp_dir, cfg_modify_fn=cfg_modify_fn)
trainer = build_trainer( name=Trainers.gpt3_trainer, default_args=kwargs) trainer.train()
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352