自学内容网 自学内容网

Xinference部署Qwen3-Embedding-8B模型

下载模型(魔搭Qwen3-Embedding)

# 可选择通过魔搭进行下载
# 安装modelscope 可选新增虚拟环境后在安装
pip3 install modelscope
# 创建模型存放目录
mkdir /home/models
# 进入该目录
cd /home/models
# 下载模型
modelscope download --model Qwen/Qwen3-Embedding-8B

# 需要检验文件的大小及数量是否和官方的一样
# 如果缺少文件则可以选择wget获取
# 例如我缺少了/model-00002-of-00004.safetensors
wget https://www.modelscope.cn/models/Qwen/Qwen3-Embedding-8B/resolve/master/model-00002-of-00004.safetensors

安装Xinference

Qwen3-Embedding-8B模型需要Xinference版本为v1.7.0 历史版本不予支持

  1. 进入服务器创建docker-compose.yml
version: '3.9'
services:
  xinference:
    #image: xprobe/xinference:v0.14.3
    image: xprobe/xinference:v1.7.0
    restart: always
    command: xinference-local -H 0.0.0.0  
    ports: # 服务器端口:容器内端口
     - "9996:9997"
    # 将本地路径(~/xinference)挂载到容器路径(/root/.xinference)中
    volumes:
    # 服务器路径:容器内路径
    # 可将模型放在该目录下 这样在注册模型的时候方便使用
       - /home/models:/root/.xinference
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    runtime: nvidia
    # 模型源更改为 ModelScope, 默认为 HuggingFace
    environment:
       - XINFERENCE_MODEL_SRC=modelscope

  1. docker启动
# 服务器里进入该docker-compose.yml的目录下执行
docker compose up -d
  1. 进入容器内执行注册模型
# 获取所有镜像,找到刚刚启动的容器的名称或者id
docker ps

# 进入容器bash
docker exec -it 容器名称 bash

# 调用注册模型接口 注意model_path应该为刚刚容器挂载的路径
 curl -X POST "http://localhost:9997/v1/models"   -H "Content-Type: application/json"   -d '{
"model_type": "embedding",               
 "model_name": "Qwen3-Embedding-8B",
"model_uid": "Qwen3-Embedding-8B",  
"model_path": "/root/.xinference/Qwen3-Embedding-8B",  
"model_size_in_billions": 8,         
"quantization": "none",  
"model_format": "safetensors",             
"specifications": {                
"dimensions": 1024,                   
"max_tokens": 8192                   
 }
}'

# 启动模型 --model-name 是刚刚注册的model_name
xinference launch  --model-type embedding --model-name Qwen3-Embedding-8B --size-in-billions

打开xinference页面注册并启动

配置:
访问 http://服务器ip:9996,即可进入xinference配置页面进行配置,配置内容跟上文接口配置一致
在这里插入图片描述
启动
找到刚刚注册过的模型进行启动
在这里插入图片描述


原文地址:https://blog.csdn.net/qq_33407429/article/details/149122037

免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!