JazerJu commited on
Commit
a4c882c
·
verified ·
1 Parent(s): 0d152ea

Add files using upload-large-folder tool

Browse files
wemm/WeMM-Embedding-4B-nf4/additional_chat_templates/sentence_transformers.jinja ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#- Embedding template used by Sentence Transformers.
2
+
3
+ Renders the same surface form as chat_template.jinja for text and images. Video
4
+ is the exception: it renders as a bare <|video_pad|>, because the processor
5
+ expands that token into one <seconds><|vision_start|>...<|vision_end|> block per
6
+ frame and, from transformers 5.3, no longer consumes a surrounding pair. The
7
+ wrapped form therefore gains a second, unwanted pair of vision boundaries there.
8
+ This matches embedding_chat_template.jinja, which is bare for the same reason.
9
+
10
+ The tokenizer normalizer drops the role newline before a leading image and the
11
+ newline after the final <|im_end|>, then the post-processor appends <embedding>. #}
12
+ {%- for message in messages %}
13
+ {{- '<|im_start|>' + message.role + '\n' }}
14
+ {%- if message.content is string %}
15
+ {{- message.content }}
16
+ {%- elif message.content is iterable and message.content is not mapping %}
17
+ {%- for item in message.content %}
18
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
19
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
20
+ {%- elif 'video' in item or item.type == 'video' %}
21
+ {{- '<|video_pad|>' }}
22
+ {%- elif 'text' in item %}
23
+ {{- item.text }}
24
+ {%- else %}
25
+ {{- raise_exception('Unexpected item type in content.') }}
26
+ {%- endif %}
27
+ {%- endfor %}
28
+ {%- elif message.content is not none %}
29
+ {{- raise_exception('Unexpected content type.') }}
30
+ {%- endif %}
31
+ {{- '<|im_end|>\n' }}
32
+ {%- endfor %}