wenda-LLM / wenda

闻达:一个LLM调用平台。目标为针对特定环境的高效内容生成,同时考虑个人和中小企业的计算资源局限性,以及知识安全和私密性问题
GNU Affero General Public License v3.0
6.23k stars 810 forks source link

项目加载ChatGLM2-6B源项目提供的模型失败并解决 #454

Closed fangg2000 closed 1 year ago

fangg2000 commented 1 year ago

我直接下载的是ChatGLM2-6B源项目提供的模型,直接执行时无法加载模型,报huggingface_hub.utils._validators.HFValidationError异常: image

开始我以为是模型下载的不全,然后我直接把整个目录下的文件都下载了,还是不行。。。会话时还是会报“错误name 'model' is not defined”

但我发现别人配置里面加载的path: "model\Chatglm2-6B"是可以的,所以我看了下加载模型的代码(在llms/llm_glm6b.py文件),嗯,和ChatGLM2-6B项目加载的代码的确不一样,我修改如下:

`# tokenizer = AutoTokenizer.from_pretrained(

settings.llm.path, local_files_only=True, trust_remote_code=True,revision="v1.1.0")

# model = AutoModel.from_pretrained(
#     settings.llm.path, local_files_only=True, trust_remote_code=True, revision="v1.1.0")

model_path = "/home/fangg/tts/wenda-main/model/chatglm2-6b-int4"
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().cuda()

` 然后,成功了,希望对像我这样的刚开始的新手有帮助。

image

l15y commented 1 year ago

看起来是斜杠用错了,你改了哪里?

fangg2000 commented 1 year ago

输出显示一反斜杠,但config.json里面是双反斜杠的,这个我试过很多次,没有问题。另外,如果是斜杠,则系统会在前面加上“https://huggingface.co/

l15y commented 1 year ago

transformers在不同系统下对两种斜杠的处理逻辑是反的,挺奇葩