Chinese-LLaMA-Alpaca icon indicating copy to clipboard operation
Chinese-LLaMA-Alpaca copied to clipboard

llama-7b和Lora权重合并之后,在自己的数据上继续fine-tuning

Open Tungsong opened this issue 1 year ago • 16 comments

微调完给出的answer一直在重复同一句话,而且也不是答案 微调方式参考的https://github.com/27182812/ChatGLM-LLaMA-chinese-insturct 训练了3个epoch,效果如下,请教有谁知道为什么会这样吗 企业微信截图_16810901118715

Tungsong avatar Apr 10 '23 01:04 Tungsong

是不是训练轮数过多了

thelongestusernameofall avatar Apr 10 '23 10:04 thelongestusernameofall

不太清楚你自己的数据格式是什么。alpaca是需要用特定的输入模板的。

Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Response:

ymcui avatar Apr 10 '23 10:04 ymcui

不太清楚你自己的数据格式是什么。alpaca是需要用特定的输入模板的。

Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:
{instruction}

### Response:

数据推理: feature = format_example(item) input_text = feature['context'] print(input_text) inputs = tokenizer(input_text, return_tensors="pt") input_ids = inputs["input_ids"].cuda()

def format_example(example: dict) -> dict: context = f"Instruction: {example['instruction']}\n" if example.get("input"): context += f"Input: {example['input']}\n" context += "Answer: " target = example["output"] return {"context": context, "target": target}

数据格式类似 { "instruction": "在哪儿下载wa4320-acn-fit的软件?谢谢 wa4320-acn-fit的软件丢失了,在哪儿下载wa4320-acn-fit的软件?谢谢", "input": "", "output": "您好:如果您想切换成瘦ap,可以直接把模式切换后,在AC上注册上线,就可以直接在ac上下载版本。" }, { "instruction": "求路由跟踪命令", "input": "", "output": "您好:tracert1.1.1.1备注:中间设备需要开启ipttenable和ipunenable否则看不到跳数" },

@ymcui 感觉数据格式没什么问题

Tungsong avatar Apr 10 '23 12:04 Tungsong

同样的问题,参考alpaca-lora微调后也是出现这种情况

Zombiessss avatar Apr 10 '23 13:04 Zombiessss

@Tungsong 你的输入还是没有用到模版,应该是这样的 https://github.com/ymcui/Chinese-LLaMA-Alpaca/issues/110#issuecomment-1501725033。

输入的instruction要放在模版里

airaria avatar Apr 10 '23 13:04 airaria

确实没有放到模板里,晚上回去试一下

Tungsong avatar Apr 11 '23 07:04 Tungsong

我有同样的问题。。使用了和Lora相同的Json数据格式

run93 avatar Apr 11 '23 21:04 run93

我测试了在 2M 和 50K 中文数据上 instruct tune 的 llama-LoRA 13B 模型,使用同样的generation 超参数,发现数据量少的模型会出现楼主说的重复问题,数据量大的模型则不会出现。所以,我感觉训练的数据量(以及数据质量)是关键。对于垂域来说,个人猜测可以将领域数据与通用数据结合起来,增加训练的数据量,或许可以避免重复问题(猜的,没试过)

ZihaoLin0123 avatar Apr 12 '23 11:04 ZihaoLin0123

我测试了在 2M 和 50K 中文数据上 instruct tune 的 llama-LoRA 13B 模型,使用同样的generation 超参数,发现数据量少的模型会出现楼主说的重复问题,数据量大的模型则不会出现。所以,我感觉训练的数据量(以及数据质量)是关键。对于垂域来说,个人猜测可以将领域数据与通用数据结合起来,增加训练的数据量,或许可以避免重复问题(猜的,没试过)

你的意思是2M的中文数据在llama-13b和lora权重合并后的模型上微调没有重复的问题,那这2M的数据是垂直领域的还是通用领域的呢

Tungsong avatar Apr 12 '23 11:04 Tungsong

我测试了在 2M 和 50K 中文数据上 instruct tune 的 llama-LoRA 13B 模型,使用同样的generation 超参数,发现数据量少的模型会出现楼主说的重复问题,数据量大的模型则不会出现。所以,我感觉训练的数据量(以及数据质量)是关键。对于垂域来说,个人猜测可以将领域数据与通用数据结合起来,增加训练的数据量,或许可以避免重复问题(猜的,没试过)

你的意思是2M的中文数据在llama-13b和lora权重合并后的模型上微调没有重复的问题,那这2M的数据是垂直领域的还是通用领域的呢

  1. 是的,没有重复问题
  2. 是通用的,没有在垂域上试过

使用的代码是 https://github.com/tloen/alpaca-lora 使用的默认参数(改了点儿batch size之类的),没有进行该repo中所述的扩充词表。

ZihaoLin0123 avatar Apr 12 '23 11:04 ZihaoLin0123

@ZihaoLin0123 我有个问题,您那边参考alpaca-lora 是在原始llama-13b的基础上微调,不进行词表扩充的话中文生成能力怎样呢,有和该repo的13b生成效果对比过吗

Tungsong avatar Apr 12 '23 11:04 Tungsong

@ZihaoLin0123 我有个问题,您那边参考alpaca-lora 是在原始llama-13b的基础上微调,不进行词表扩充的话中文生成能力怎样呢,有和该repo的13b生成效果对比过吗

没有详细比过,我也是刚跑完;但是随机测试了一些case感觉属于中规中矩的水平;后面有空确实可以拿这个repo里给出的测试benchmark测一下

ZihaoLin0123 avatar Apr 12 '23 11:04 ZihaoLin0123

@ZihaoLin0123 我有个问题,您那边参考alpaca-lora 是在原始llama-13b的基础上微调,不进行词表扩充的话中文生成能力怎样呢,有和该repo的13b生成效果对比过吗

没有详细比过,我也是刚跑完;但是随机测试了一些case感觉属于中规中矩的水平;后面有空确实可以拿这个repo里给出的测试benchmark测一下

所以训练垂直领域的数据究竟在原版的llama模型上tune有效果,还是扩充中文词表之后再tune好,还得接着试一下

Tungsong avatar Apr 12 '23 11:04 Tungsong

我有同样的问题。。使用了和Lora相同的Json数据格式

方便问一下,您是在这个repo扩充中文词表的基础上继续finetuning吗

Tungsong avatar Apr 12 '23 11:04 Tungsong

@Tungsong 能提供下你的fine-tuning代码吗? 新人不确定在这份代码上需要修改写什么? https://github.com/27182812/ChatGLM-LLaMA-chinese-insturct

magicleo avatar Apr 26 '23 06:04 magicleo

@Tungsong 能提供下你的fine-tuning代码吗? 新人不确定在这份代码上需要修改写什么? https://github.com/27182812/ChatGLM-LLaMA-chinese-insturct

建议你用https://github.com/tloen/alpaca-lora

Tungsong avatar Apr 27 '23 08:04 Tungsong

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your consideration.

github-actions[bot] avatar May 14 '23 22:05 github-actions[bot]

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

github-actions[bot] avatar May 17 '23 22:05 github-actions[bot]