Zero-Shot Image Classification
Transformers
Safetensors
siglip
vision
alexwengg commited on
Commit
8a47809
·
verified ·
1 Parent(s): 75de2d5

Remove the Gemma chat template from tokenizer_config.json

Browse files

SigLIP2's text tower reuses the Gemma tokenizer, and `tokenizer_config.json` still carries Gemma's `chat_template`. SigLIP2 has no chat format, so tools that honor a tokenizer's chat template wrap the text in `<start_of_turn>user ... <end_of_turn>` markers and drop EOS. For example, vLLM's `/v1/embeddings` with `messages` returns a different embedding than for the same plain text (11 tokens instead of 6 for "a photo of a cat"; vLLM-side fix in https://github.com/vllm-project/vllm/pull/66624).

This PR removes that one key. Tokenizer and processor output are unchanged (checked with Transformers); only `apply_chat_template` stops working, which has no meaning for this model.

The same template is in the other fixed-resolution SigLIP2 checkpoints, which could take the same one-line change: `siglip2-base-patch16-256`, `-384`, `-512`, `siglip2-base-patch32-256`, `siglip2-large-patch16-256`, `-384`, `-512`, `siglip2-so400m-patch14-224`, `-384`, `siglip2-so400m-patch16-256`, `-384`, `-512`, and `siglip2-giant-opt-patch16-256`, `-384`. The NaFlex checkpoints don't have it.

Files changed (1) hide show
  1. tokenizer_config.json +0 -1
tokenizer_config.json CHANGED
@@ -2000,7 +2000,6 @@
2000
  "<end_of_turn>"
2001
  ],
2002
  "bos_token": "<bos>",
2003
- "chat_template": "{{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + '\n' + message['content'] | trim + '<end_of_turn>\n' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model\n'}}{% endif %}",
2004
  "clean_up_tokenization_spaces": false,
2005
  "do_lower_case": true,
2006
  "eos_token": "<eos>",
 
2000
  "<end_of_turn>"
2001
  ],
2002
  "bos_token": "<bos>",
 
2003
  "clean_up_tokenization_spaces": false,
2004
  "do_lower_case": true,
2005
  "eos_token": "<eos>",