mindspore-lab / mindnlp

Easy-to-use and high-performance NLP and LLM framework based on MindSpore, compatible with models and datasets of 🤗Huggingface.
https://mindnlp.cqu.ai/
Apache License 2.0
703 stars 197 forks source link

mindnlp官方文档(https://mindnlp.cqu.ai/)示例代码错误反馈 #1794

Open Helloyouth2022 opened 2 weeks ago

Helloyouth2022 commented 2 weeks ago

错误1

https://mindnlp.cqu.ai/tutorials/quick_start/#load-the-model

image

改正:from mindnlp.core.optim import AdamW

错误2

https://mindnlp.cqu.ai/tutorials/quick_start/#prepare-a-dataset image

https://mindnlp.cqu.ai/tutorials/data_preprocess/ image

改正:from mindnlp.dataset import load_dataset

错误3

https://mindnlp.cqu.ai/tutorials/peft/#train-the-model

image

改正:import mindnlp.core.optim as optim
lvyufeng commented 2 weeks ago

ok

LmYjQ commented 1 day ago

@Helloyouth2022 错误1的下面我还遇到报错了。下面这一行会报错optimizer没有parameters属性

grad_fn = value_and_grad(forward_fn, None, optimizer.parameters)

Helloyouth2022 commented 1 day ago

@Helloyouth2022 错误1的下面我还遇到报错了。下面这一行会报错optimizer没有parameters属性

grad_fn = value_and_grad(forward_fn, None, optimizer.parameters)

下面也是需要更新的,mindnlp的optimizer不同于mindspore,应该通过model直接传进去:grad_fn = value_and_grad(forward_fn, None, model.trainable_params()) 建议先学习一下mindnlp的优化器的基本用法,和pytorch类似的,可以看看github源码或者更直接的:通过help(optimizer)打印帮助文档,optimizer是你创建的优化器对象

Helloyouth2022 commented 1 day ago

https://mindnlp.cqu.ai/tutorials/peft/#training-step image

optimizer(grads)相应地改为:optimizer.step(grads)

LmYjQ commented 2 hours ago

请问mindnlp里面有没有针对(类似mindspore中)Parameter类型的set_data()方法? 我在做联邦学习,需要手动对模型权重赋值。