Vllm进行Qwen2-vl部署(包含单卡多卡部署及爬虫请求)

打印 上一主题 下一主题

主题 891|帖子 891|积分 2675

1.简介

阿里云于今年9月宣布开源第二代视觉语言模型Qwen2-VL,包括 2B、7B、72B三个尺寸及其量化版本模型。Qwen2-VL具备完整图像、多语言的理解能力,性能强劲。
相比上代模型,Qwen2-VL 的基础性能全面提升,可以读懂不同分辨率和不同长宽比的图片,在 DocVQA、RealWorldQA、MTVQA 等基准测试创下全球领先的表现;可以理解 20 分钟以上长视频,支持基于视频的问答、对话和内容创作等应用;具备强盛的视觉智能体能力,可自主操作手机和机器人,借助复杂推理和决策的能力,Qwen2-VL 可以集成得手机、机器人等设备,根据视觉环境和文字指令进行自动操作;能理解图像视频中的多语言文本,包括中文、英文,大多数欧洲语言,日语、韩语、阿拉伯语、越南语等。

本篇博客将详细介绍怎样实现Qwen2-VL-7B的单卡部署和多卡部署,以及怎样使用requests库发送请求。
GitHub:https://github.com/QwenLM/Qwen2-VL
HuggingFace:https://huggingface.co/collections/Qwen/qwen2-vl-66cee7455501d7126940800d
魔搭 ModelScope:https://modelscope.cn/organization/qwen?tab=model
模型体验:https://huggingface.co/spaces/Qwen/Qwen2-VL
官方文档:Qwen2-VL、Qwen-VL怎样使用_大模型服务平台百炼(Model Studio)-阿里云资助中心
vllm官方文档:Engine Arguments — vLLM
2.部署

环境安装

我使用的是Python3.10的假造环境,留意下载好权重,不需要下载github代码。
起首安装qwen-vl-utils,内含torch2.4
  1. pip install qwen-vl-utils
复制代码
接着安装transformers
  1. pip install transformers
复制代码
接着安装
  1. pip install accelerate
复制代码
最后安装vllm框架,我这里的vllm版本是0.6.3,之前使用0.6.2会报keyerror的错误,假如出现了这个错误,可以进步vllm的版本,也可以按照下文的办法办理(详看报错办理部分)
  1. pip install vllm
复制代码
直接使用

通过以下代码检验模型环境有没有安装好,留意模型权重文件的相对位置
  1. from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
  2. from qwen_vl_utils import process_vision_info
  3. # default: Load the model on the available device(s)
  4. model = Qwen2VLForConditionalGeneration.from_pretrained(
  5.     "Qwen2-VL-7B", torch_dtype="auto", device_map="auto"
  6. )
  7. # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
  8. # model = Qwen2VLForConditionalGeneration.from_pretrained(
  9. #     "Qwen/Qwen2-VL-7B-Instruct",
  10. #     torch_dtype=torch.bfloat16,
  11. #     attn_implementation="flash_attention_2",
  12. #     device_map="auto",
  13. # )
  14. # default processer
  15. processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
  16. # The default range for the number of visual tokens per image in the model is 4-16384. You can set min_pixels and max_pixels according to your needs, such as a token count range of 256-1280, to balance speed and memory usage.
  17. # min_pixels = 256*28*28
  18. # max_pixels = 1280*28*28
  19. # processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
  20. messages = [
  21.     {
  22.         "role": "user",
  23.         "content": [
  24.             {
  25.                 "type": "image",
  26.                 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
  27.             },
  28.             {"type": "text", "text": "Describe this image."},
  29.         ],
  30.     }
  31. ]
  32. # Preparation for inference
  33. text = processor.apply_chat_template(
  34.     messages, tokenize=False, add_generation_prompt=True
  35. )
  36. image_inputs, video_inputs = process_vision_info(messages)
  37. inputs = processor(
  38.     text=[text],
  39.     images=image_inputs,
  40.     videos=video_inputs,
  41.     padding=True,
  42.     return_tensors="pt",
  43. )
  44. inputs = inputs.to("cuda")
  45. # Inference: Generation of the output
  46. generated_ids = model.generate(**inputs, max_new_tokens=128)
  47. generated_ids_trimmed = [
  48.     out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
  49. ]
  50. output_text = processor.batch_decode(
  51.     generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
  52. )
  53. print(output_text)
复制代码
假如返回结果,表示安装乐成。
我的3090 24g单卡可以完整运行Qwen2-VL-7B,假如爆显存可以试试2b版本的。
单卡部署

我的单卡是3090 24g,直接部署不能跑起来,需要适当调整一下参数。
文件位置如下:

在命令行中输入:
  1. vllm serve Qwen2-VL-7B --dtype auto --port 8000 --limit_mm_per_prompt image=4 --max_model_len 8784 --gpu_memory_utilization 0.8
复制代码
参数解释:


  • Qwen2-VL-7B:模型权重位置
  • dtype:数据类型,一样寻常直接auto就可以了,低版本的显卡可能需要自己设置,如2080要设置为half
  • port:端标语
  • limit_mm_per_prompt image=4,默认是1,如许每次请求可以输入多张图片
  • max_model_len:每次全球最大的token长度,爆显存了就改小
  • gpu_memory_utilization:GPU最大利用率,爆显存了就改小,我如今一样寻常设置为0.7-0.8
其他参数的文档:Engine Arguments — vLLM
见到下面的就说明模型启动了,可以开始调用了:

多卡部署

我的多卡设备是8张2080,分别是12g
文件位置如下:

在命令行中输入:
  1. vllm serve Qwen2-VL-7B --dtype half --port 8000 --tensor-parallel-size 4 --pipeline-parallel-size 2 --gpu-memory-utilization 0.7 --limit_mm_per_prompt image=4 --max_model_len 8784
复制代码
参数解释:


  • tensor-parallel-size:模型的权重将被分割成n部分分布在GPU上。
  • pipeline-parallel-size:设置流水线并行的大小为k,意味着模型的不同层将被分布到k个GPU上。
  • 保证n*k=8,正好便是您拥有的GPU数量。
requests调用

起首你要知道模型部署端的IP地点,Linux通过ifconfig查看,如下红框中的就是你的IP地点

然后你需要安装requests库
  1. pip install requests
复制代码
团体逻辑

这个代码实在是利用爬虫向我们的服务器发送请求,团体框架我已经写好,根本只需要改动data里面的东西就可以了。

官方文档:
Qwen2-VL、Qwen-VL怎样使用_大模型服务平台百炼(Model Studio)-阿里云资助中心
纯文本调用


  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. # 1.url
  6. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'    # 你的IP
  7. # 2.data
  8. data = {"model": "Qwen2-VL-7B",
  9.         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},     # 系统命令,一般不要改
  10.                      {"role": "user",
  11.                       "content": "什么是大语言模型"}],    # 用户命令,一般改这里
  12.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 1024}
  13. # 3.将字典转换为 JSON 字符串
  14. json_payload = json.dumps(data)
  15. # 4.发送 POST 请求
  16. headers = {'Content-Type': 'application/json'}
  17. response = requests.post(url, data=json_payload, headers=headers)
  18. # 5.打印响应内容
  19. print(response.json().get("choices", [])[0].get("message", []).get("content", []))      # 命令行启动,用这个打印
  20. # print(response.json())
复制代码
网络图片理解


  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. # 1.url
  6. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'
  7. # 2.data
  8. data = {"model": "Qwen2-VL-7B",
  9.         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
  10.                      {"role": "user",
  11.                       "content": [
  12.                           {"type": "image_url", "image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
  13.                           {"type": "text", "text": "Describe this image."},],}],
  14.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 512}
  15. # 3.将字典转换为 JSON 字符串
  16. json_payload = json.dumps(data)
  17. # 4.发送 POST 请求
  18. headers = {'Content-Type': 'application/json'}
  19. response = requests.post(url, data=json_payload, headers=headers)
  20. # 5.打印响应内容
  21. print(response.json().get("choices", [])[0].get("message", []).get("content", []))      # 命令行启动,用这个打印
  22. # print(response.json())
复制代码
本舆图片理解


  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. def encode_image(image_path):       # 编码本地图片的函数
  6.     with open(image_path, "rb") as image_file:
  7.         return base64.b64encode(image_file.read()).decode('utf-8')
  8. # 1.url
  9. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'
  10. # 2.data
  11. image_path = "1.jpg"
  12. base64_image = encode_image(image_path)     # 编码本地图片
  13. data = {"model": "Qwen2-VL-7B",
  14.         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
  15.                      {"role": "user",
  16.                       "content": [
  17.                           {"type": "image_url","image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}},
  18.                           {"type": "text", "text": "这是什么"},],}],
  19.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 1024}
  20. # 3.将字典转换为 JSON 字符串
  21. json_payload = json.dumps(data)
  22. # 4.发送 POST 请求
  23. headers = {'Content-Type': 'application/json'}
  24. response = requests.post(url, data=json_payload, headers=headers)
  25. # 5.打印响应内容
  26. print(response.json().get("choices", [])[0].get("message", []).get("content", []))      # 命令行启动,用这个打印
  27. # print(response.json())
复制代码
多张图片理解


  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. def encode_image(image_path):       # 编码本地图片的函数
  6.     with open(image_path, "rb") as image_file:
  7.         return base64.b64encode(image_file.read()).decode('utf-8')
  8. # 1.url
  9. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'
  10. # 2.data
  11. ## 2.4使用本地图片,多张照片理解
  12. image_path1 = "1.jpg"
  13. image_path2 = "2.jpg"
  14. base64_image1 = encode_image(image_path1)
  15. base64_image2 = encode_image(image_path2)
  16. data = {"model": "Qwen2-VL-7B",
  17.         "messages":[
  18.         {
  19.             "role": "user",
  20.             "content": [
  21.                 {
  22.                     "type": "image_url",
  23.                     "image_url": {
  24.                         "url": f"data:image/jpeg;base64,{base64_image1}"
  25.                     },
  26.                 },
  27.                 {
  28.                     "type": "image_url",
  29.                     "image_url": {
  30.                         "url": f"data:image/jpeg;base64,{base64_image2}"
  31.                     },
  32.                 },
  33.                 {"type": "text", "text": "这些是什么"},
  34.             ],}
  35.         ],
  36.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 4096}
  37. # 3.将字典转换为 JSON 字符串
  38. json_payload = json.dumps(data)
  39. # 4.发送 POST 请求
  40. headers = {'Content-Type': 'application/json'}
  41. response = requests.post(url, data=json_payload, headers=headers)
  42. # 5.打印响应内容
  43. print(response.json().get("choices", [])[0].get("message", []).get("content", []))      # 命令行启动,用这个打印
  44. # print(response.json())
复制代码
多轮对话


  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. def encode_image(image_path):       # 编码本地图片的函数
  6.     with open(image_path, "rb") as image_file:
  7.         return base64.b64encode(image_file.read()).decode('utf-8')
  8. # 1.url
  9. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'
  10. # 2.data
  11. data = {"model": "Qwen2-VL-7B",     # 初始化data
  12.         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},],
  13.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 1024}
  14. # 纯语言的多轮对话
  15. text_ls = ["什么是大语言模型", "都有哪些", "写一首诗赞美一下他们"]
  16. for text in text_ls:        # 循环text_ls里面的所有问题
  17.     data["messages"].append({"role": "user",
  18.                       "content": [
  19.                           # {"type": "image_url","image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}},
  20.                           {"type": "text", "text": text},],})   # 将用户问题输入大模型的prompt
  21.     # 3.将字典转换为 JSON 字符串
  22.     json_payload = json.dumps(data)
  23.     # 4.发送 POST 请求
  24.     headers = {'Content-Type': 'application/json'}
  25.     response = requests.post(url, data=json_payload, headers=headers)
  26.     data["messages"].append({"role": "assistant",   # 将大模型的输出加入到data(prompt),用于下一次输入
  27.                             "content": [
  28.                                 {"type": "text", "text": response.json().get("choices", [])[0].get("message", []).get("content", [])}, ], })
  29.     print("User: ", text)
  30.     print("Answer: ", response.json().get("choices", [])[0].get("message", []).get("content", []))
  31.     print("-"*50)
  32. # print(response.json())
复制代码
全部

  1. import requests
  2. import json
  3. from PIL import Image
  4. import base64
  5. import time
  6. def encode_image(image_path):       # 编码本地图片的函数
  7.     with open(image_path, "rb") as image_file:
  8.         return base64.b64encode(image_file.read()).decode('utf-8')
  9. start = time.time()
  10. # 1.url
  11. url = 'http://XX.XX.XX.XX:8000/v1/chat/completions'
  12. # 2.data
  13. ## 2.1如果server.py启动,用这个data
  14. data = {"model": "Qwen2-VL-7B",
  15.         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},     # 系统命令,一般不要改
  16.                      {"role": "user",
  17.                       "content": "Tell me something about large language models."}],    # 用户命令,一般改这里
  18.         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 1024}
  19. ## 2.2使用网络图片(url网址),用这个data
  20. # data = {"model": "Qwen2-VL-7B",
  21. #         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
  22. #                      {"role": "user",
  23. #                       "content": [
  24. #                           {"type": "image_url","image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
  25. #                           {"type": "text", "text": "Describe this image."},],}],
  26. #         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 512}
  27. ## 2.3使用本地图片,用这个data
  28.     ## 只支持一张图片,可以进行OCR、翻译、计算题目、编写前端代码等
  29. # image_path = "jieti.jpg"
  30. # base64_image = encode_image(image_path)
  31. # data = {"model": "Qwen2-VL-7B",
  32. #         "messages": [{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
  33. #                      {"role": "user",
  34. #                       "content": [
  35. #                           {"type": "image_url","image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}},
  36. #                           {"type": "text", "text": "解一下这道题"},],}],
  37. #         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 1024}
  38. ## 2.4使用本地图片,多张照片理解
  39. # image_path1 = "1.jpg"
  40. # image_path2 = "2.jpg"
  41. # base64_image1 = encode_image(image_path1)
  42. # base64_image2 = encode_image(image_path2)
  43. # data = {"model": "Qwen2-VL-7B",
  44. #         "messages":[
  45. #         {
  46. #             "role": "user",
  47. #             "content": [
  48. #                 {
  49. #                     "type": "image_url",
  50. #                     "image_url": {
  51. #                         "url": f"data:image/jpeg;base64,{base64_image1}"
  52. #                     },
  53. #                 },
  54. #                 {
  55. #                     "type": "image_url",
  56. #                     "image_url": {
  57. #                         "url": f"data:image/jpeg;base64,{base64_image2}"
  58. #                     },
  59. #                 },
  60. #                 {"type": "text", "text": "这些是什么"},
  61. #             ],}
  62. #         ],
  63. #         "temperature": 0.7,"top_p": 0.8,"repetition_penalty": 1.05,"max_tokens": 4096}
  64. # 3.将字典转换为 JSON 字符串
  65. json_payload = json.dumps(data)
  66. # 4.发送 POST 请求
  67. headers = {'Content-Type': 'application/json'}
  68. response = requests.post(url, data=json_payload, headers=headers)
  69. # 5.打印响应内容
  70. print(response.json().get("choices", [])[0].get("message", []).get("content", []))
  71. # print(response.json())        # 调试用
  72. print("
  73. 总时间:", time.time()-start, "秒")
复制代码
留意事项

阿里云文档(可以自己开个账号体验72b的模型):https://help.aliyun.com/zh/model-studio/developer-reference/use-qwen-by-calling-api
留意:我们的模型和官方API的调用在一些细节上不一样!
模型调用方面:

  • 不要问消息,模型的知识库不够新
  • 多图推理最多4张图,固然你可以自己设置
  • 单图推理时,图片分辨率不建议超过8000*10000的,否则会有下面的警告。固然运行还是能正常运行。
    DecompressionBombWarning: Image size (100444051 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack.
3.功能演示

OCR


  1. user:提取上面的文字。
  2. 回答:
  3. 1一份燕麦片35克
  4. 2沸水210毫升
  5. 3沸水烧煮或微波炉加热2分钟,搅拌均匀即可食用。
复制代码
翻译


  1. user:翻译一下。
  2. 回答:
  3. 阿里巴巴云,成立于2009年,是全球领先的云计算提供商。我们致力于为全球数百万企业、开发者和政府机构提供全面的云计算服务,帮助他们实现数字化转型。我们的目标是成为全球领先的企业级云计算服务提供商。
复制代码
写前端代码


  1. user:看图写前端代码
  2. 回答:
  3. 根据提供的图片,以下是一个简单的前端代码示例,使用HTML和CSS来创建一个类似于图片中展示的页面布局。这个示例包括一个输入框用于提问、两个按钮(模型调用和应用创建)以及一些文本说明。
  4. ```html
  5. <!DOCTYPE html>
  6. <html lang="zh">
  7. <head>
  8.     <meta charset="UTF-8">
  9.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  10.     <title>阿里云百炼</title>
  11.     <style>
  12.         body {
  13.             font-family: Arial, sans-serif;
  14.             background-color: #f0f2f5;
  15.         }
  16.         
  17.         .container {
  18.             max-width: 1200px;
  19.             margin: 0 auto;
  20.             padding: 20px;
  21.         }
  22.         
  23.         .header {
  24.             text-align: center;
  25.             margin-bottom: 20px;
  26.         }
  27.         
  28.         .input-container {
  29.             display: flex;
  30.             justify-content: space-between;
  31.             align-items: center;
  32.             margin-bottom: 20px;
  33.         }
  34.         
  35.         .input-box {
  36.             width: calc(100% - 150px);
  37.             height: 40px;
  38.             border: 1px solid #ccc;
  39.             padding: 10px;
  40.         }
  41.         
  42.         .submit-button {
  43.             width: 150px;
  44.             height: 40px;
  45.             background-color: #4CAF50;
  46.             color: white;
  47.             border: none;
  48.             cursor: pointer;
  49.         }
  50.         
  51.         .button-container {
  52.             display: flex;
  53.             justify-content: space-between;
  54.             align-items: center;
  55.             margin-top: 20px;
  56.         }
  57.         
  58.         .button-container button {
  59.             width: 200px;
  60.             height: 40px;
  61.             background-color: #007BFF;
  62.             color: white;
  63.             border: none;
  64.             cursor: pointer;
  65.         }
  66.         
  67.         .button-container button:hover {
  68.             background-color: #0056b3;
  69.         }
  70.     </style>
  71. </head>
  72. <body>
  73.     <div class="container">
  74.         <div class="header">
  75.             你好,欢迎使用阿里云百炼
  76.         </div>
  77.         <div class="input-container">
  78.             <div class="input-box">
  79.                 请输入您想问的问题
  80.             </div>
  81.             <button class="submit-button">提交</button>
  82.         </div>
  83.         <div class="button-container">
  84.             <button>立即调用</button>
  85.             <button>查看教程</button>
  86.         </div>
  87.         <div class="button-container">
  88.             <button>立即创建</button>
  89.             <button>查看教程</button>
  90.         </div>
  91.     </div>
  92. </body>
  93. </html>
  94. ```
  95. 这个代码示例仅提供了基本的结构和样式,你可以根据需要添加更多的功能和样式。例如,你可以添加JavaScript来处理表单提交和按钮点击事件。
  96. 进程已结束,退出代码为 0
复制代码
提取表格


  1. user:提取表格
  2. 回答:
  3. 以下是表格内容的文本形式:
  4. | Model | Public Data | Total Score | Quality Score | Semantic Score | Motion Smoothness | Dynamic Degree |
  5. |-------|-------------|-------------|---------------|----------------|--------------------|----------------|
  6. | Gen-2 | ×           | 80.58       | 82.47         | 73.03          | 99.58              | 18.89          |
  7. | Pika 1.0 | ×           | 80.69       | 82.92         | 71.77          | 99.50              | 47.50          |
  8. | CogVideoX-2B | ×           | 80.91       | 82.18         | 75.83          | 97.73              | 59.86          |
  9. | CogVideoX-5B | ×           | 81.61       | 82.75         | 77.04          | 96.92              | 70.97          |
  10. | Kling | ×           | 81.85       | 83.38         | 75.68          | 99.40              | 46.94          |
  11. | Gen-3 Alpha | ×           | 82.32       | 84.11         | 75.17          | 99.23              | 60.14          |
  12. | Open-Sora Plan v1.1 | √           | 78.00       | 80.91         | 66.38          | 98.28              | 47.72          |
  13. | Open-Sora 1.2 | √           | 79.76       | 81.35         | 73.39          | 98.50              | 42.39          |
  14. | VideoCrafter2 | √           | 80.44       | 82.20         | 73.42          | 97.73              | 42.50          |
  15. | T2V-Turbo | √           | 81.01       | 82.57         | 74.76          | 97.34              | 49.17          |
  16. | Ours | √           | 81.72       | 84.74         | 69.62          | 99.12              | 64.63          |
复制代码
解答数学题


  1. user:解一下这道题
  2. 回答:
  3. 好的,我们来分别计算两个图形的表面积和体积。
  4. ### 图形1
  5. 这是一个长方体,长为4cm,宽为3cm,高为2cm。
  6. #### 表面积
  7. 长方体的表面积公式是:
  8. [ A = 2lw + 2lh + 2wh ]
  9. 其中,( l ) 是长,( w ) 是宽,( h ) 是高。
  10. 代入数值:
  11. [ A = 2         imes 4         imes 3 + 2         imes 4         imes 2 + 2         imes 3         imes 2 ]
  12. [ A = 24 + 16 + 12 ]
  13. [ A = 52         ext{ cm}^2 ]
  14. #### 体积
  15. 长方体的体积公式是:
  16. [ V = lwh ]
  17. 代入数值:
  18. [ V = 4         imes 3         imes 2 ]
  19. [ V = 24         ext{ cm}^3 ]
  20. ### 图形2
  21. 这是一个正方体,边长为3cm。
  22. #### 表面积
  23. 正方体的表面积公式是:
  24. [ A = 6a^2 ]
  25. 其中,( a ) 是边长。
  26. 代入数值:
  27. [ A = 6         imes 3^2 ]
  28. [ A = 6         imes 9 ]
  29. [ A = 54         ext{ cm}^2 ]
  30. #### 体积
  31. 正方体的体积公式是:
  32. [ V = a^3 ]
  33. 代入数值:
  34. [ V = 3^3 ]
  35. [ V = 27         ext{ cm}^3 ]
  36. 综上所述,图形1的表面积为52 cm2,体积为24 cm3;图形2的表面积为54 cm2,体积为27 cm3。
复制代码
其他

同济子豪兄基于Qwen2-VL做的机器人:直播
4.报错办理

IndexError: list index out of range

assert “factor” in rope_scaling
将config.json里面的"type": “mrope"改为"rope_type”: “mrope”
原因:vllm版本不兼容,0.6.3新版本不需要
假如多轮对话超了怎么办?
**我们部署时对输入长度做了限制。**假如多轮对话很多次后,很有可能超出大模型支持的长度。
一个办理方法:让大模型对历史信息做摘要。 给大模型一个提示词,让他总结上下文, 然后删除data[“message”]里面的上下文(user和assistant), 把大模型总结的部分输入进去(“assistant”)。
因此,我们存储的不再是整个对话,而是其摘要版本。这有助于管理标记数量,并答应LLM有效地处理对话。感爱好的同砚可以了解一下LangChain的ConversationSummaryMemory。
拓展阅读:大模型——怎样实现超长多轮对话_大语言模型多轮对话-CSDN博客
5.总结

Qwen2-VL是由阿里云推出的一款多模态大型视觉语言模型,它在前代Qwen-VL的基础上进行了巨大更新,具有以下特点:

  • 图像理解能力增强:Qwen2-VL在视觉理解基准测试中实现了开始进的性能,包括MathVista、DocVQA、RealWorldQA、MTVQA等,能够理解不同分辨率和比例的图像。
  • 视频理解能力:Qwen2-VL能够理解超过20分钟的视频,通过在线流媒体能力,可以用于视频问答、对话、内容创作等。
  • 代理操作能力:Qwen2-VL具备复杂推理和决策能力,可以集成得手机、机器人等设备中,基于视觉环境和文本指令自动操作。
  • 多语言支持:除了支持英语和中文,Qwen2-VL如今还支持图像中不同语言文本的理解,包括大多数欧洲语言、日语、韩语、阿拉伯语、越南语等。
  • 模型架构更新:Qwen2-VL引入了动态分辨率处理和多模态旋转位置嵌入(M-ROPE),增强了其多模态处理能力。
  • 开源和API:Qwen2-VL的Qwen2-VL-2B和Qwen2-VL-7B模型已开源,并发布了Qwen2-VL-72B的API,方便开发者和研究人员使用。
Qwen2-VL的这些特性使其在多模态场景中的表现与顶尖模型如GPT-4o和Claude3.5-Sonnet相匹配,超越了所有其他开放权重的LVLM模型。
假如您在阅读这篇关于Qwen2-VL模型的总结后,觉得内容对您有所开导或者资助,我非常希望您能够给予积极的反馈。请不吝您的称赞,通过点赞、收藏、关注来表达您对这篇文章的认可;最后,假如您对大模型或者深度学习技能话题感爱好,接待关注我,如许您就可以第一时间获取到最新的信息和深入的分析。
您的每一个点赞、每一次收藏和每一个关注,都是对我工作的最大支持和鼓励。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

南七星之家

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表