0


240713-Xinference模型下载、管理及测试

Step 1. 安装Xinference

  • 安装 — Xinference

Step 2. 下载模型

方式1: UI界面下载
  • 命令行启动Xinference:
xinference-local --host0.0.0.0 --port9997
  • localhost:9997中,通过左侧的Launch Model 配置并下载模型
  • 如果模型已下载或配置好,则在右侧会显示cached字样
  • 具体可以参考这个视频:xinference一键管理主流大模型,手摸手教你本地部署和推理模型,本地部署glm4并简单测评,提供环境包_哔哩哔哩_bilibili在这里插入图片描述
方式2: 命令行下载
  • 命令行启动Xinference:
xinference-local --host0.0.0.0 --port9997
  • 以chatglm3-6B为例,下载并启动模型:
xinference launch --model-engine vLLM --model-name chatglm3 --size-in-billions 6 --model-format pytorch --quantization none
  • 下图,右边和左边分别是启动及下载的Bash命令,可以看到,在执行左边的命令的时候,右边可以显示下载的状态在这里插入图片描述

Step 3. 模型路径

  • Xinference设置的软链接- 模型默认的链接路径在~/.xinference/cache对应的文件夹中- 模型的实际下载路径则在~/.cache对应的文件夹中
  • 注意:在~/.xinference/cache/model_name中,多了一个__valid_download的文件
  • 该文件的内容包含如下,可能是用于后台检测,模型是否已经有效下载
{"model_type":"LLM", "address": null, "accelerators": null, "model_name":"chatglm3", "model_lang":["en", "zh"], "model_ability":["chat", "tools"], "model_description":"ChatGLM3 is the third generation of ChatGLM, still open-source and trained on Chinese and English data.", "model_format":"pytorch", "model_size_in_billions":6, "model_family":"chatglm3", "quantization":"none", "model_hub":"huggingface", "revision":"103caa40027ebfd8450289ca2f278eac4ff26405", "context_length":8192}(xinference)

在这里插入图片描述

Step 4. 模型使用

  • 登录:http://localhost:9997/ui/#/running_models/LLM
  • 点击:右侧红框按钮
  • 弹出:下图对话界面,可直接使用在这里插入图片描述

在这里插入图片描述

Step 5: 自行下载模型及使用的方法测试

  • 自行下载模型的方法: - HF-Mirror- 如何快速下载huggingface模型——全方法总结 - 知乎
  • 设置软链接
ln-s ~/Downloads/chatglm3-6b ~/.xinference/cache/chatglm3-pytorch-6b
  • 复制有效下载的文件,注意这里我更新了xinference下载模型的名字chatglm3-pytorch-6b-raw
cp ~/.xinference/cache/chatglm3-pytorch-6b-raw/__valid_download ~/.xinference/cache/chatglm3-pytorch-6b/__valid_download
  • 进行完上述操作后,重复执行Step 2中的操作,可以直接到Step 3的内容,无需下载模型

Step 6:这里有两个问题还需要解决:

  • 如何根据模型文件的命名规则,设置软链接?ln -s ~/Downloads/chatglm3-6b ~/.xinference/cache/chatglm3-pytorch-6b
  • 如何撰写__valid_download文件?如果没有这个文件,Xinference在执行下述命令后,似乎还是会继续默认的下载
xinference launch --model-engine vLLM --model-name chatglm3 --size-in-billions 6 --model-format pytorch --quantization none
  • 潜在解决方法(待测试):教你快速上手Xinference分布式推理框架-腾讯云开发者社区-腾讯云

问题整理

1. GLM4使用报错
  • xinference 后端驱动chatglm4-9b-chat,接入到dify/lobe-chat时出错,不能正常回答 · Issue #1746 · xorbitsai/inference · GitHub
  • pip install transformers==4.21.2 # Default 4.42.3

参考文献

  • 在Xinference上部署自定义大模型——FreedomIntelligence/HuatuoGPT2-13B为例 - 知乎
  • (51 封私信 / 80 条消息) localai, xinference, ollama 这些本地大模型部署工具的优缺点是什么? - 知乎

本文转载自: https://blog.csdn.net/qq_33039859/article/details/140396941
版权归原作者 GuokLiu 所有, 如有侵权,请联系我们删除。

“240713-Xinference模型下载、管理及测试”的评论:

还没有评论