执行 inference_hf.py 时提示缺少文件 (original) (raw)
提交前必须检查以下项目
- 请确保使用的是仓库最新代码(git pull),一些问题已被解决和修复。
- 由于相关依赖频繁更新,请确保按照Wiki中的相关步骤执行
- 我已阅读FAQ章节并且已在Issue中对问题进行了搜索,没有找到相似问题和解决方案
- 第三方插件问题:例如llama.cpp、text-generation-webui、LlamaChat等,同时建议到对应的项目中查找解决方案
- 模型正确性检查:务必检查模型的SHA256.md,模型不对的情况下无法保证效果和正常运行
问题类型
模型推理
基础模型
Alpaca-Plus-7B
操作系统
Windows
详细描述问题
在使用inference_hf.py推理时,遇到错误提示我没有pytorch_model.bin, tf_model.h5, model.ckpt.index 或 flax_model.msgpack,但是从一开始下载LLaMA的模型时,就没有这些文件,后续的转换、合并操作也未生成这些文件,想问问这种情况,要怎么处理呢:
- LLaMA模型不是从meta那边获取的,申请了获取模型但是一直没消息,所以我先用了别人私传的模型
PS D:\Chinese-LLaMA-Alpaca\Chinese-LLaMA-Alpaca\scripts\inference> python310 .\inference_hf.py --base_model D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models\7B --with_prompt --data_file D:\Chinese-LLaMA-Alpaca\llama.cpp\prompts\alpaca.txt --predictions_file .\out.txt --tokenizer_path D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models
Traceback (most recent call last):
File "D:\Chinese-LLaMA-Alpaca\Chinese-LLaMA-Alpaca\scripts\inference\inference_hf.py", line 92, in
base_model = LlamaForCausalLM.from_pretrained(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\modeling_utils.py", line 2405, in from_pretrained
raise EnvironmentError(
OSError: Error no file named pytorch_model.bin, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models\7B.
使用的模型是Alpaca-Plus-7B, --base_model的路径下的内容有:
PS D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models> ls
目录: D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-modelsMode LastWriteTime Length Name
d----- 2023/7/15 16:25 7B -a---- 2023/7/15 11:15 13771083975 consolidated.00.pth -a---- 2023/7/15 11:13 102 special_tokens_map.json -a---- 2023/7/15 11:13 757972 tokenizer.model -a---- 2023/7/15 11:13 760 tokenizer_config.json -a---- 2023/7/15 16:25 321 各个文件解释.txt
其中zh-models\7B文件夹的内容有:
PS D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models\7b> ls
目录: D:\Chinese-LLaMA-Alpaca\llama.cpp\zh-models\7bMode LastWriteTime Length Name
-a---- 2023/7/14 14:37 524 config.json -a---- 2023/7/15 11:19 13772213056 ggml-model-f16.bin -a---- 2023/7/15 11:47 5165677376 ggml-model-q5_1.bin -a---- 2023/7/15 11:13 101 params.json
整个项目的文件结构如下:
PS D:\Chinese-LLaMA-Alpaca> ls
目录: D:\Chinese-LLaMA-Alpaca
Mode LastWriteTime Length Name
d----- 2023/7/15 14:33 .idea
d----- 2023/7/14 15:29 .ipynb_checkpoints
d----- 2023/7/15 16:54 Chinese-LLaMA-Alpaca
d----- 2023/7/14 17:30 chinese_alpaca_plus_lora_7b
d----- 2023/7/14 17:11 chinese_llama_plus_lora_7b
d----- 2023/7/14 13:54 LLaMA-original-model
d----- 2023/7/15 10:52 llama.cpp
d----- 2023/7/11 16:39 OpenBLAS-0.3.23-x64
d----- 2023/7/15 9:55 OpenBLAS-0.3.23-x64 (1)
d----- 2023/7/15 15:13 test
d----- 2023/7/15 14:29 transformers
d----- 2023/7/14 17:41 w64devkit-fortran-1.19.0
d----- 2023/7/15 15:53 模型备份
-a---- 2023/7/15 16:43 39661 Chinese_LLaMA_Alpaca.ipynb
依赖情况(代码类问题务必提供)
$ pip310 list | grep -E 'transformers|peft|torch' peft 0.3.0 torch 1.13.1 transformers 4.28.1
运行日志或截图
合并后的consolidated.00.pth文件的sha256值与llama.cpp量化部署提供的值是一致的, 利用llama.cpp推理也能正常的运行:
PS D:\Chinese-LLaMA-Alpaca\llama.cpp> ./main -m zh-models/7B/ggml-model-q5_1.bin --color -f prompts/alpaca.txt -ins -c 2048 --temp 0.2 -n 256 --repeat_penalty 1.1 -b 8 -t 6 main: build = 831 (27ad57a) main: seed = 1689393361 llama.cpp: loading model from zh-models/7B/ggml-model-q5_1.bin llama_model_load_internal: format = ggjt v3 (latest) llama_model_load_internal: n_vocab = 49954 llama_model_load_internal: n_ctx = 2048 llama_model_load_internal: n_embd = 4096 llama_model_load_internal: n_mult = 256 llama_model_load_internal: n_head = 32 llama_model_load_internal: n_layer = 32 llama_model_load_internal: n_rot = 128 llama_model_load_internal: ftype = 9 (mostly Q5_1) llama_model_load_internal: n_ff = 11008 llama_model_load_internal: model size = 7B llama_model_load_internal: ggml ctx size = 0.08 MB llama_model_load_internal: mem required = 6717.79 MB (+ 1026.00 MB per state) llama_new_context_with_model: kv self size = 1024.00 MB
system_info: n_threads = 6 / 12 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | VSX = 0 | main: interactive mode on. Reverse prompt: '### Instruction:
' sampling: repeat_last_n = 64, repeat_penalty = 1.100000, presence_penalty = 0.000000, frequency_penalty = 0.000000, top_k = 40, tfs_z = 1.000000, top_p = 0.950000, typical_p = 1.000000, temp = 0.200000, mirostat = 0, mirostat_lr = 0.100000, mirostat_ent = 5.000000 generate: n_ctx = 2048, n_batch = 8, n_predict = 256, n_keep = 149
== Running in interactive mode. ==
- Press Ctrl+C to interject at any time.
- Press Return to return control to LLaMa.
- To return control without starting a new line, end your input with '/'.
- If you want to submit another line, end your input with ''.
Below is an instruction that describes a task. Write a response in Chinese that appropriately completes the request. 《原神》是由上海米哈游网络科技股份有限公司制作发行的一款开放世界冒险游戏,游戏发生在一个被称作“提瓦特”的幻想世界,在这里,被神选中的人将被授予“神之眼”,导引元素之力。玩家将扮演一位名为“旅行者”的神秘角色,在自由的旅行中邂逅性格各异、能力独特的同伴们,和他们一起击败强敌,找回失散的亲人——同时,逐步发掘“原神”的真相。请为《原神》写一段约100字的推广文章。
Below is an instruction that describes a task. Write a response in Chinese that appropriately completes the request.《原神》是由上海米哈游网络科技股份有限公司制作发行的一款开放世界冒险游戏,游戏发生在一个被称作"提瓦特"的幻想世界,在这里,被神选中的人将被授予"神之眼",导引元素之力。玩家将扮演一位名为"旅行者"的神秘角色,在自由的旅行中邂逅性格各异、能力独特的同伴们,和他们一起击败强敌,找回失散的亲人--同时,逐步发掘"原神"的真相。请为《原神》写一段约100字的推广文章。 《原神》是一款开放世界冒险游戏,玩家将扮演一位名为“旅行者”的神秘角色,在自由的旅行中邂逅性格各异、能力独特的同伴们,和他们一起击败强敌,找回失散的亲人--同时,逐步发掘"原神"的真相。游戏中,玩家可以探索各种不同的场景和任务,并与NPC和其他玩家 互动。游戏画面精美,音乐动听,操作简单易上手,适合所有年龄段的玩家。如果你喜欢冒险、
解谜和自由度高的游戏,那么《原神》一定不容错过!