atomgit-ascend/fara-7b
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

microsoft/fara-7b 模型体验服务

1. 项目意义

本项目用于小窗体验场景下的模型体验,提供多模态模型的在线体验服务。用户可以通过 API 接口上传图片,获取图片中的文字识别结果。

2. 项目部署

2.1 部署环境

  • 默认部署环境:华为昇腾服务器
  • IP地址:111.13.109.88
  • NPU型号:910b

2.2 部署方法

项目采用 Dockerfile + docker-compose 方式进行部署。

2.2.1 环境准备

./
├── docker-compose.yaml
├── Dockerfile
├── model
│   └── microsoft
│       └── Fara-7B
│           ├── added_tokens.json
│           ├── chat_template.jinja
│           ├── config.json
│           ├── configuration.json
│           ├── generation_config.json
│           ├── merges.txt
│           ├── model-00001-of-00004.safetensors
│           ├── model-00002-of-00004.safetensors
│           ├── model-00003-of-00004.safetensors
│           ├── model-00004-of-00004.safetensors
│           ├── model.safetensors.index.json
│           ├── preprocessor_config.json
│           ├── README.md
│           ├── special_tokens_map.json
│           ├── tokenizer_config.json
│           ├── tokenizer.json
│           ├── video_preprocessor_config.json
│           └── vocab.json
├── t-unit
│   ├── dave.wav
│   ├── t-curl-chat.sh
│   ├── t-curl-image2txt.sh
└── vllm-start.sh
  • model:是本地模型,可以使用 hugginface 预先下载好
  • t-unit:是测试脚本

2.2.2 构建镜像

docker build -t models_inference_fara_7b:latest .

2.2.3 启动服务

docker-compose up -d

2.2.4 查看日志

docker-compose logs -f

2.2.5 停止服务

docker-compose down
  • 服务默认端口映射:18012:8000(宿主机端口:容器内端口)
  • 容器需要访问昇腾 NPU 设备,已配置相关设备挂载:
    • /dev/davinci12
    • /dev/davinci_manager
    • /dev/devmm_svm
    • /dev/hisi_hdc
  • 需要挂载昇腾驱动相关目录和文件
  • 模型路径:/data/model/microsoft/Fara-7B

3. 部署验证

# 聊天
curl -X POST http://localhost:18002/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fara",
    "messages": [
      {
        "role": "user",
        "content": "Tell me a short story."
      }
    ],
    "max_tokens": 200,
    "stream": true
  }'
# 图片输入请求

curl -X POST http://localhost:18002/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fara",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What are the animals in these images?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://vcg05.cfp.cn/creative/vcg/800/new/VCG41N1303803114.jpg"
            }
          }
        ]
      }
    ],
    "max_tokens": 2000
  }'