ymcui / Chinese-LLaMA-Alpaca-2

中文LLaMA-2 & Alpaca-2大模型二期项目 + 64K超长上下文模型 (Chinese LLaMA-2 & Alpaca-2 LLMs with 64K long context models)
Apache License 2.0
7.09k stars 578 forks source link

合併 LoRa model 不成功, 沒有產生最終模型檔 #77

Closed wennycooper closed 1 year ago

wennycooper commented 1 year ago

提交前必须检查以下项目

问题类型

模型转换和合并

基础模型

LLaMA-2-7B

操作系统

Linux

详细描述问题

我嘗試按照文件上的步驟做模型合併, 結果不如預期. 雖然沒有報錯, 但沒有看到最終合併模型檔案

LLama 基模型放在 llama/llama-2-7b/

LLama-LoRA 模型放在 chinese-llama-2-lora-7b

# python llama/Chinese-LLaMA-Alpaca-2/scripts/merge_llama2_with_chinese_lora_low_mem.py --base_model llama/llama-2-7b/ --lora_model chinese-llama-2-lora-7b --output_type huggingface --output_dir llama-2-7b-combined
================================================================================
Base model: llama/llama-2-7b/
LoRA model: chinese-llama-2-lora-7b
Loading chinese-llama-2-lora-7b
You are using the legacy behaviour of the <class 'transformers.models.llama.tokenization_llama.LlamaTokenizer'>. This means that tokens that come after special tokens will not be properly handled. We recommend you to read the related pull request available at https://github.com/huggingface/transformers/pull/24565
Saving tokenizer
Done.
Check output dir: llama-2-7b-combined

# ls -al llama-2-7b-combined/     ### 沒有看到最終模型檔案
total 844
drwxr-xr-x  2 root root   4096 Aug  4 15:13 .
drwxrwxr-x 11 1000 1000   4096 Aug  4 15:06 ..
-rw-r--r--  1 root root    435 Aug  4 15:13 special_tokens_map.json
-rw-r--r--  1 root root 844403 Aug  4 15:13 tokenizer.model
-rw-r--r--  1 root root    766 Aug  4 15:13 tokenizer_config.json

# ls -al  llama/llama-2-7b/                  ### 基模型在這裡
total 13161080
drwxr-xr-x 2 root root        4096 Aug  4 14:15 .
drwxr-xr-x 6 root root        4096 Aug  4 14:23 ..
-rw-r--r-- 1 root root         100 Jul 14 07:00 checklist.chk
-rw-r--r-- 1 root root 13476925163 Jul 14 07:00 consolidated.00.pth
-rw-r--r-- 1 root root         102 Jul 14 07:00 params.json

# ls -al chinese-llama-2-lora-7b    ### LoRA模型在這裡
total 1197992
drwxr-xr-x  3 root root       4096 Aug  4 14:53 .
drwxrwxr-x 11 1000 1000       4096 Aug  4 15:06 ..
drwxr-xr-x  8 root root       4096 Aug  4 14:38 .git
-rw-r--r--  1 root root       1519 Aug  4 14:38 .gitattributes
-rw-r--r--  1 root root       1945 Aug  4 14:38 README.md
-rw-rw-r--  1 root root        471 Jul 27 12:52 adapter_config.json
-rw-rw-r--  1 root root 1225856253 Jul 27 12:41 adapter_model.bin
-rw-rw-r--  1 root root        435 Jul 27 12:41 special_tokens_map.json
-rw-rw-r--  1 root root     844403 Jul 27 12:41 tokenizer.model
-rw-rw-r--  1 root root        748 Jul 27 12:41 tokenizer_config.json

依赖情况(代码类问题务必提供)

# pip list | grep -E 'transformers|peft|torch'
ctransformers            0.2.5
peft                     0.3.0.dev0
pytorch-quantization     2.1.2
sentence-transformers    2.2.2
torch                    2.0.1
torch-tensorrt           1.5.0.dev0
torchdata                0.7.0a0
torchtext                0.16.0a0
torchvision              0.16.0a0
transformers             4.31.0

运行日志或截图

# 请在此处粘贴运行日志
ymcui commented 1 year ago

base model需要huggingface版本。 你可以参考这里,转换PTH到HF格式:https://github.com/ymcui/Chinese-LLaMA-Alpaca/wiki/手动模型合并与转换#step-1-将原版llama模型转换为hf格式

wennycooper commented 1 year ago

了解. 我下載huggingface的版本有解決了此問題. 感謝回覆!