Support native Transformers loading

#74
by LucaMotz - opened

I'm adding native Phi-3-vision support to Transformers in https://github.com/huggingface/transformers/pull/51214. This PR adds what the native processor needs on top of the existing files:

  • chat_template.json, a processor-only chat template, so processor.apply_chat_template works with images ({"type": "image"} renders <|image|>\n); the tokenizer keeps its own template, so prompts for trust_remote_code=True users and vLLM render as before;
  • <|image|> as the image token in tokenizer_config.json, with rstrip: false (also in tokenizer.json), so a prompt tokenized before its image placeholders are expanded keeps the newline after each image;
  • **kwargs in Phi3VProcessor.__init__ (processing_phi3_v.py), because Transformers 4.49–4.52 pass the chat template to the processor.

The weights, auto_map and the rest of the remote code are unchanged. With transformers 4.40–5.24 the remote processor loads and gives the same ids as before, and vLLM's chat path gives the same prompt ids.

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment