wenet
wenet copied to clipboard
LoRA support
LoRA support
references: https://github.com/microsoft/LoRA/tree/bugfix_MergedLinear https://kexue.fm/archives/9590 https://github.com/huggingface/peft (I think PEFT methods used in NLP all have the potential to tune the ASR model)
LoRA experiment:
gpus: 4*3090
lora_list in encoder
base_model | finetune_mathod | lora_rank | lora_alpha | lora_dropout | lora_list | decoding mode | test-aishell CER | wenetspeech-test-net CER | num of parameters | time/per-epoch | gpu mem |
---|---|---|---|---|---|---|---|---|---|---|---|
wenet_u2pp_conformer(wenetspeech) | baseline | / | / | / | / | attention rescoring | 5.83% | 10.82 % | / | / | / |
wenet_u2pp_conformer(wenetspeech) | aishell finetune (20 epochs) | / | / | / | / | attention rescoring | 3.16% | 17.02% | 122553574 | 645 seconds | 21170MB |
wenet_u2pp_conformer(wenetspeech) | aishell LoRA (20 epochs) | 8 | 8 | 0.1 | q,k,v,linear_out | attention rescoring | 5.08% | 14.32% | 393216 | 350 seconds | 17268MB |
wenet_u2pp_conformer(wenetspeech) | aishell LoRA (20 epochs) | 16 | 16 | 0.1 | q,k,v,linear_out | attention rescoring | 4.98% | 14.51 % | 786432 | 351 seconds | 17321MB |
thx ! any numbers?
thx ! any numbers?
I conducted experiments on my own data and will soon update the experiment results on the open-source data.
可以通过继承的方式, 比如loara_conformer_encoder, lora_attention, 重写encoder 和attention, 目录如下:
- wenet/fintune/lora/encoder.py
- wenet/fintune/lora/attention.py
然后在init_model.py 里边初始化,这样对原始代码几乎无侵入,并且fintue的方式还有lora变种 adapter等方式,可以方便后续扩展
可以通过继承的方式, 比如loara_conformer_encoder, lora_attention, 重写encoder 和attention, 目录如下:
- wenet/fintune/lora/encoder.py
- wenet/fintune/lora/attention.py
然后在init_model.py 里边初始化,这样对原始代码几乎无侵入,并且fintue的方式还有lora变种 adapter等方式,可以方便后续扩展
ok, it's a good idea
可以通过继承的方式, 比如loara_conformer_encoder, lora_attention, 重写encoder 和attention, 目录如下:
- wenet/fintune/lora/encoder.py
- wenet/fintune/lora/attention.py
然后在init_model.py 里边初始化,这样对原始代码几乎无侵入,并且fintue的方式还有lora变种 adapter等方式,可以方便后续扩展
实验很赞,另外同意周哥看法,
- 可以按照这种方式(wenet/fintune/lora/encoder.py 继承 wenet/transformer/encoder.py, attention同理)吗?现在loralib里的文件也可以统一放进
wenet/fintune/lora
, 好处之一是lora相关代码没有侵入修改,好处之二是后面可以追加wenet/fintune/adapter
实现 - rebase一下代码,将train.py的相关修改转移到其他文件中(具体修改已评论)
然后可以合并了
赞, 过两天看一下
辛苦了!great job !
hi @fclearner ,之前说LoRA还有个补丁要打,请问这个什么时候merge呢?
hi @fclearner ,之前说LoRA还有个补丁要打,请问这个什么时候merge呢?
其实就是encoder的参数传岔了。。。因为之前的一个commit,你可以自己修一下,我还没来得及验证代码。。周末看看
hi @fclearner ,之前说LoRA还有个补丁要打,请问这个什么时候merge呢?
hello,我大概改了一版,但我这边训练有点问题,晚上看下: https://github.com/fclearner/wenet/tree/LoRA_fix_args
hi @fclearner ,之前说LoRA还有个补丁要打,请问这个什么时候merge呢?
调model.eval()的时候会报错,不用deepspeed能跑,感觉是初始化的时候deepspeed有点问题,应该是类似这个issue的问题:https://github.com/huggingface/alignment-handbook/issues/57