File size: 8,315 Bytes
cd7a521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "add_prefix_space": false,
  "audio_bos_token": "<|audio_start|>",
  "audio_eos_token": "<|audio_end|>",
  "audio_token": "<|audio_pad|>",
  "backend": "tokenizers",
  "bos_token": null,
  "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}\n{%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}\n{%- set _preserve_thinking = preserve_thinking if preserve_thinking is defined else true %}\n{%- set ns_state = namespace(thinking=enable_thinking) %}\n\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n    {%- if content is string %}\n        {{- content }}\n    {%- elif content is iterable and content is not mapping %}\n        {%- for item in content %}\n            {%- if item is mapping %}\n                {%- if item.type == 'image' or 'image' in item or 'image_url' in item %}\n                    {%- if is_system_content %}\n                        {{- raise_exception('System message cannot contain images.') }}\n                    {%- endif %}\n                    {%- if do_vision_count %}\n                        {%- set image_count.value = image_count.value + 1 %}\n                    {%- endif %}\n                    {%- if add_vision_id %}\n                        {{- 'Picture ' ~ image_count.value ~ ': ' }}\n                    {%- endif %}\n                    {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n                {%- elif item.type == 'video' or 'video' in item %}\n                    {%- if is_system_content %}\n                        {{- raise_exception('System message cannot contain videos.') }}\n                    {%- endif %}\n                    {%- if do_vision_count %}\n                        {%- set video_count.value = video_count.value + 1 %}\n                    {%- endif %}\n                    {%- if add_vision_id %}\n                        {{- 'Video ' ~ video_count.value ~ ': ' }}\n                    {%- endif %}\n                    {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n                {%- elif 'text' in item %}\n                    {{- item.text }}\n                {%- else %}\n                    {{- raise_exception('Unexpected item type in content.') }}\n                {%- endif %}\n            {%- else %}\n                {{- item | string }}\n            {%- endif %}\n        {%- endfor %}\n    {%- elif content is none or content is undefined %}\n        {{- '' }}\n    {%- else %}\n        {{- raise_exception('Unexpected content type.') }}\n    {%- endif %}\n{%- endmacro %}\n\n{%- if not messages %}\n    {{- raise_exception('No messages provided.') }}\n{%- endif %}\n\n{%- set _first_role = messages[0].role %}\n{%- if _first_role == 'system' or _first_role == 'developer' %}\n    {%- set _sys_msg = messages[0] %}\n    {%- set _msgs = messages[1:] %}\n{%- else %}\n    {%- set _sys_msg = none %}\n    {%- set _msgs = messages %}\n{%- endif %}\n\n{%- set _sc = '' %}\n{%- if _sys_msg is not none %}\n    {%- set _sc = render_content(_sys_msg.content, false, true) | trim %}\n{%- endif %}\n\n{%- if _sc %}\n    {{- '<|im_start|>system\\n' + _sc + '<|im_end|>\\n' }}\n{%- endif %}\n\n{%- set _last_idx = _msgs | length - 1 %}\n{%- set ns = namespace(last_query_index=_last_idx) %}\n\n{%- for message in _msgs[::-1] %}\n    {%- set index = (_msgs | length - 1) - loop.index0 %}\n    {%- if message.role == 'user' %}\n        {%- set ns.last_query_index = index %}\n        {%- break %}\n    {%- endif %}\n{%- endfor %}\n\n{%- for message in _msgs %}\n    {%- set is_system = (message.role == \"system\" or message.role == \"developer\") %}\n    {%- set content = render_content(message.content, true, is_system) | trim %}\n\n    {%- if is_system or message.role == 'user' %}\n        {%- if '<|think_off|>' in content %}\n            {%- set ns_state.thinking = false %}\n            {%- set content = content.split('<|think_off|>') | join('') | trim %}\n        {%- elif '<|think_on|>' in content %}\n            {%- set ns_state.thinking = true %}\n            {%- set content = content.split('<|think_on|>') | join('') | trim %}\n        {%- endif %}\n    {%- endif %}\n\n    {%- if is_system %}\n        {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n\n    {%- elif message.role == 'user' %}\n        {{- '<|im_start|>user\\n' + content + '<|im_end|>\\n' }}\n\n    {%- elif message.role == 'assistant' %}\n        {%- set reasoning_content = '' %}\n\n        {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n            {%- if message.reasoning_content is string %}\n                {%- set reasoning_content = message.reasoning_content %}\n            {%- else %}\n                {%- set reasoning_content = message.reasoning_content | string %}\n            {%- endif %}\n\n        {%- elif message.thinking is defined and message.thinking is not none %}\n            {%- if message.thinking is string %}\n                {%- set reasoning_content = message.thinking %}\n            {%- else %}\n                {%- set reasoning_content = message.thinking | string %}\n            {%- endif %}\n\n        {%- else %}\n            {%- set _think_end = '' %}\n\n            {%- if content.startswith('</think>') %}\n                {%- set _think_end = '</think>' %}\n            {%- elif content.startswith('</thinking>') %}\n                {%- set _think_end = '</thinking>' %}\n            {%- elif '\\n</think>' in content %}\n                {%- set _think_end = '\\n</think>' %}\n            {%- elif '\\n</thinking>' in content %}\n                {%- set _think_end = '\\n</thinking>' %}\n            {%- elif '\\n</ think>' in content %}\n                {%- set _think_end = '\\n</ think>' %}\n            {%- elif '\\n</think >' in content %}\n                {%- set _think_end = '\\n</think >' %}\n            {%- endif %}\n\n            {%- if _think_end %}\n                {%- if 'thinking' in _think_end %}\n                    {%- set _think_start = '<thinking>' %}\n                {%- else %}\n                    {%- set _think_start = '<think>' %}\n                {%- endif %}\n\n                {%- set reasoning_content = content.split(_think_end)[0].rstrip('\\n') %}\n\n                {%- if _think_start in reasoning_content %}\n                    {%- set reasoning_content = reasoning_content.split(_think_start)[-1].lstrip('\\n') %}\n                {%- endif %}\n\n                {%- set content = content.split(_think_end)[-1].lstrip('\\n') %}\n            {%- endif %}\n        {%- endif %}\n\n        {%- set reasoning_content = reasoning_content | trim %}\n\n        {%- if (_preserve_thinking or loop.index0 > ns.last_query_index) and reasoning_content %}\n            {{- '<|im_start|>assistant\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content + '<|im_end|>\\n' }}\n        {%- else %}\n            {{- '<|im_start|>assistant\\n' + content + '<|im_end|>\\n' }}\n        {%- endif %}\n\n    {%- else %}\n        {{- '<|im_start|>user\\n[' + message.role + ']: ' + content + '<|im_end|>\\n' }}\n    {%- endif %}\n{%- endfor %}\n\n{%- if add_generation_prompt %}\n    {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
  "clean_up_tokenization_spaces": false,
  "eos_token": "<|im_end|>",
  "errors": "replace",
  "image_token": "<|image_pad|>",
  "is_local": true,
  "local_files_only": false,
  "model_max_length": 262144,
  "model_specific_special_tokens": {
    "audio_bos_token": "<|audio_start|>",
    "audio_eos_token": "<|audio_end|>",
    "audio_token": "<|audio_pad|>",
    "image_token": "<|image_pad|>",
    "video_token": "<|video_pad|>",
    "vision_bos_token": "<|vision_start|>",
    "vision_eos_token": "<|vision_end|>"
  },
  "pad_token": "<|endoftext|>",
  "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
  "processor_class": "Qwen3VLProcessor",
  "split_special_tokens": false,
  "tokenizer_class": "Qwen2Tokenizer",
  "unk_token": null,
  "video_token": "<|video_pad|>",
  "vision_bos_token": "<|vision_start|>",
  "vision_eos_token": "<|vision_end|>"
}