webAI-ColVec1.1-8b / additional_chat_templates /sentence_transformers.jinja
tomaarsen's picture
tomaarsen HF Staff
Integrate with Sentence Transformers and implement replace_image_token
1a16bfe verified
Raw
History Blame
714 Bytes
{%- for message in messages -%}
{%- set ns = namespace(has_image=false, text='') -%}
{%- if message['content'] is string -%}
{%- set ns.text = message['content'] -%}
{%- else -%}
{%- for item in message['content'] -%}
{%- if 'image' in item or 'image_url' in item or item.type == 'image' -%}
{%- set ns.has_image = true -%}
{%- elif 'text' in item -%}
{%- set ns.text = ns.text + item.text -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- if ns.has_image -%}
{{- '<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe the image.<|im_end|><|endoftext|>' -}}
{%- else -%}
{{- '<|im_start|>user\nQuery: ' + ns.text + '<|endoftext|>' * 10 + '<|im_end|><|endoftext|>' -}}
{%- endif -%}
{%- endfor -%}