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

为什么中文的 llama 和 对应的 lora 模型没办法在 alpaca lora 中使用呢?

Open Lufffya opened this issue 2 years ago • 6 comments

python generate.py 
--load_8bit 
--base_model '../Chinese-LLaMA-Alpaca/original_llama_7b_hf/' 
--lora_weights '../Chinese-LLaMA-Alpaca/chinese-alpaca-lora-7b/'

这是 alpaca-lora 中 inference 的命令, 但我使用的都是中文的 llama 和对应中文的 lora, 理论上应该是兼容才对,但目前似乎是出现了一些问题:

image

Lufffya avatar Apr 19 '23 09:04 Lufffya

最后一行已经说明问题了 词表大小不是32000

ymcui avatar Apr 19 '23 09:04 ymcui

对应中文的 lora, 理论上应该是兼容才对,但目前似乎是出现了一些问题:

词表大小不是从模型配置文件加载的吗,由配置文件决定,还是说你的意思是,源代码中模型结构已经被定义了,才导致的冲突?

Lufffya avatar Apr 19 '23 10:04 Lufffya

original_llama_7b_hf中的模型是原版llama?它的词表大小应该不是49954,所以无法加载。

可参考本项目中的scripts/inference_hf.py

airaria avatar Apr 19 '23 10:04 airaria

@airaria 哦哦,那我可能明白了,original_llama_7b_hf 是原版 llama 模型 的 hf 格式,而 LoRA 是你们提供的中文 Alpaca LoRA.

这样的话,我猜可能是扩充了原版 llama 词库原因,LoRA 对应了是扩充之后的 llama 模型,而我这里指定的是原版

Lufffya avatar Apr 19 '23 10:04 Lufffya

@airaria 哦哦,那我可能明白了,original_llama_7b_hf 是原版 llama 模型 的 hf 格式,而 LoRA 是你们提供的中文 Alpaca LoRA.

这样的话,我猜可能是扩充了原版 llama 词库原因,LoRA 对应了是扩充之后的 llama 模型,而我这里指定的是原版

所以如果你用自己的代码加载原版llama的话,需要先resize一下model的embedding大小至49954(alpaca),然后合并Lora,并使用chinese-alpaca的tokenizer,这样应该就正常了

airaria avatar Apr 19 '23 13:04 airaria

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 Apr 27 '23 00:04 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 04 '23 00:05 github-actions[bot]