Skip to content

Commit e65a268

Browse files
committed
Sync fix: Better chat format for Qwen2.5-VL by alcoftTAO
1 parent bc283d3 commit e65a268

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

llama_cpp/llama_chat_format.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,26 +3561,29 @@ class Qwen25VLChatHandler(Llava15ChatHandler):
35613561
DEFAULT_SYSTEM_MESSAGE = "You are a helpful assistant."
35623562

35633563
CHAT_FORMAT = (
3564-
"<|im_start|>system\n"
3565-
"You are a helpful assistant.<|im_end|>\n"
3564+
#"{% set image_count = namespace(value=0) %}"
3565+
#"{% set video_count = namespace(value=0) %}"
35663566
"{% for message in messages %}"
3567-
"{% if message['role'] == 'user' %}"
3568-
"<|im_start|>user\n"
3567+
"{% if loop.first and message['role'] != 'system' %}"
3568+
"<|im_start|>system\n"
3569+
"{{ self.DEFAULT_SYSTEM_MESSAGE }}<|im_end|>\n"
3570+
"{% endif %}"
3571+
"<|im_start|>{{ message['role'] }}\n"
35693572
"{% if message['content'] is string %}"
3570-
"{{ message['content'] }}"
3573+
"{{ message['content'] }}<|im_end|>\n"
35713574
"{% else %}"
35723575
"{% for content in message['content'] %}"
3573-
"{% if content['type'] == 'text' %}"
3574-
"{{ content['text'] }}"
3575-
"{% elif content['type'] == 'image_url' %}"
3576+
"{% if content['type'] == 'image_url' %}"
35763577
"{% if content.image_url is string %}"
35773578
"{{ content.image_url }}"
35783579
"{% else %}"
35793580
"{{ content.image_url.url }}"
35803581
"{% endif %}"
3582+
#"{% set image_count.value = image_count.value + 1 %}"
3583+
"{% elif content['type'] == 'text' %}"
3584+
"{{ content['text'] }}"
35813585
"{% endif %}"
35823586
"{% endfor %}"
3583-
"{% endif %}"
35843587
"<|im_end|>\n"
35853588
"{% endif %}"
35863589
"{% endfor %}"

0 commit comments

Comments
 (0)