Facico / Chinese-Vicuna

Chinese-Vicuna: A Chinese Instruction-following LLaMA-based Model —— 一个中文低资源的llama+lora方案,结构参考alpaca
https://github.com/Facico/Chinese-Vicuna
Apache License 2.0
4.14k stars 422 forks source link

关于chat训练效果与语料关联不上的疑问 #193

Closed grantchenhuarong closed 1 year ago

grantchenhuarong commented 1 year ago

大佬好,近段使用chat的continue训练方式,对于legal_counsel_with_article_v2.json的1000条语料,进行了训练。然后对输出的权重模型,用chat.py加载做了gradio的网页对话,感觉都跟语料没有太多的联系上。如下图 image

原本的语料是这样子的 image

不知道有没有兄弟姐妹尝试过复现这个训练,请求一下指导。

grantchenhuarong commented 1 year ago

训练的时候使用单卡的4090,用的是finetune_chat_continue.sh,加载了Chinese-Vicuna-lora-7b-chatv1/train_4800_args的Lora模型,使用micro-batch=3, total_batch=32的默认值。

为多跑几个epochs,修改了finetune_chat.py当中MAX_STEPS = 4800 + len(data["train"]) // MICRO_BATCH_SIZE * 10

后边看好像也没有多少用处,更多轮的模型权重都测试返回英文了。。。。。。估计3~6个左右就好了。

整个时间长度是11小时左右跑完 image

grantchenhuarong commented 1 year ago

上边有个报错信息,set back the RNG states of the GPU because of the following error: list object has no attribute 'clone', 后边又提示说model is not a 'PreTrainedModel', only saving its state dict

会是这个原因,导致没有更新参数么?

grantchenhuarong commented 1 year ago

或者说是这个v2的语料,instruction上列举了多行依据的法律法规,本身就构成了一个list,而不是简单一个字符串,送进去运算了? image 对比其它语料 image 尝试了其它训练,全部都有上边提示的异常信息。

grantchenhuarong commented 1 year ago

看了下transformer.trainer.py,它的save逻辑判断我们初始finetune装载的不是PretrainedModel... image

grantchenhuarong commented 1 year ago

在finetune_chat.py开始训练前,model已经被包裹成为PeftModelForCausalLM了,有没有影响呀?

transformers.Trainer: <class 'peft.peft_model.PeftModelForCausalLM'>

grantchenhuarong commented 1 year ago

按照最新的requirements更新依赖后,解决了其中的一个报错,但是还剩下一个。 image

grantchenhuarong commented 1 year ago

最终通过调整整理语料的格式,重新训练就结果好很多了。prompt.py里头有instruct和chat模式两种的格式定义,需要按照要求的来。chat模式的input,output都是数组,成对出现的。也支持仅有一组对话的格式。