书生-进阶-第三关

目录

一、模型部署

1. 未部署时显存占用

2. 执行量化

lmdeploy lite auto_awq \
   /root/models/internlm2_5-1_8b-chat \
  --calib-dataset 'ptb' \
  --calib-samples 128 \
  --calib-seqlen 2048 \
  --w-bits 4 \
  --w-group-size 128 \
  --batch-size 1 \
  --search-scale False \
  --work-dir /root/models/internlm2_5-1_8b-chat-w4a16-4bit

3. 启动服务

lmdeploy serve api_server \
    /root/models/internlm2_5-1_8b-chat-w4a16-4bit/ \
    --model-format awq \
    --quant-policy 4 \
    --cache-max-entry-count 0.4\
    --server-name 0.0.0.0 \
    --server-port 23333 \
    --tp 1

4. 部署后显存占用

5. 启动Gradio网页

lmdeploy serve gradio http://localhost:23333 \
    --server-name 0.0.0.0 \
    --server-port 6006

6. 效果

二、工具调用

1. 启动模型OpenAI接口服务

conda activate lmdeploy
lmdeploy serve api_server \
    /root/models/internlm2_5-7b-chat \
    --model-format hf \
    --quant-policy 0 \
    --server-name 0.0.0.0 \
    --server-port 23333 \
    --tp 1

2. 修改Prompt要求模型加减法调用工具解决

messages = [{'role':'system','content':'Use a mathematical calculation tool to solve, do not attempt to solve it yourself,eg. add or mul.'},{'role': 'user', 'content': 'Compute (3+5)*2'}]

3.运行