Skip to content

Commit

Permalink
FEAT: Support QvQ-72B-Preview (#2712)
Browse files Browse the repository at this point in the history
Co-authored-by: JunHowie <[email protected]>
  • Loading branch information
Jun-Howie and JunHowie authored Dec 27, 2024
1 parent ae7b3f6 commit 513af9d
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
47 changes: 47 additions & 0 deletions xinference/model/llm/llm_family.json
Original file line number Diff line number Diff line change
Expand Up @@ -8942,5 +8942,52 @@
"<|user|>",
"<|observation|>"
]
},
{
"version": 1,
"context_length": 32768,
"model_name": "QvQ-72B-Preview",
"model_lang": [
"en",
"zh"
],
"model_ability": [
"chat",
"vision"
],
"model_description": "QVQ-72B-Preview is an experimental research model developed by the Qwen team, focusing on enhancing visual reasoning capabilities.",
"model_specs": [
{
"model_format": "pytorch",
"model_size_in_billions": 72,
"quantizations": [
"4-bit",
"8-bit",
"none"
],
"model_id": "Qwen/QVQ-72B-Preview"
},
{
"model_format": "mlx",
"model_size_in_billions": 72,
"quantizations": [
"3bit",
"4bit",
"6bit",
"8bit",
"bf16"
],
"model_id": "mlx-community/QVQ-72B-Preview-{quantization}"
}
],
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}",
"stop_token_ids": [
151645,
151643
],
"stop": [
"<|im_end|>",
"<|endoftext|>"
]
}
]
49 changes: 49 additions & 0 deletions xinference/model/llm/llm_family_modelscope.json
Original file line number Diff line number Diff line change
Expand Up @@ -6673,5 +6673,54 @@
"<|user|>",
"<|observation|>"
]
},
{
"version": 1,
"context_length": 32768,
"model_name": "QvQ-72B-Preview",
"model_lang": [
"en",
"zh"
],
"model_ability": [
"chat",
"vision"
],
"model_description": "QVQ-72B-Preview is an experimental research model developed by the Qwen team, focusing on enhancing visual reasoning capabilities.",
"model_specs": [
{
"model_format": "pytorch",
"model_size_in_billions": 72,
"quantizations": [
"4-bit",
"8-bit",
"none"
],
"model_id": "Qwen/QVQ-72B-Preview",
"model_hub": "modelscope"
},
{
"model_format": "mlx",
"model_size_in_billions": 72,
"quantizations": [
"3bit",
"4bit",
"6bit",
"8bit",
"bf16"
],
"model_id": "mlx-community/QVQ-72B-Preview-{quantization}",
"model_hub": "modelscope"
}
],
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}",
"stop_token_ids": [
151645,
151643
],
"stop": [
"<|im_end|>",
"<|endoftext|>"
]
}
]
1 change: 1 addition & 0 deletions xinference/model/llm/transformers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"deepseek-v2.5",
"deepseek-v2-chat-0628",
"glm-edge-v",
"QvQ-72B-Preview",
]


Expand Down
2 changes: 2 additions & 0 deletions xinference/model/llm/transformers/qwen2_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def match(
llm_family = model_family.model_family or model_family.model_name
if "qwen2-vl-instruct".lower() in llm_family.lower():
return True
if "qvq-72b-preview".lower() in llm_family.lower():
return True
return False

def load(self):
Expand Down
1 change: 1 addition & 0 deletions xinference/model/llm/vllm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class VLLMGenerateConfig(TypedDict, total=False):
VLLM_SUPPORTED_MODELS.append("llama-3.2-vision")
VLLM_SUPPORTED_VISION_MODEL_LIST.append("llama-3.2-vision-instruct")
VLLM_SUPPORTED_VISION_MODEL_LIST.append("qwen2-vl-instruct")
VLLM_SUPPORTED_VISION_MODEL_LIST.append("QvQ-72B-Preview")


class VLLMModel(LLM):
Expand Down

0 comments on commit 513af9d

Please sign in to comment.