Support Phi-4 Multi-Modal (text + vision only) (#6494)

This commit is contained in:
Lifu Huang
2025-05-24 21:43:38 -07:00
committed by GitHub
parent 681e7af32b
commit 022012aae8
8 changed files with 650 additions and 6 deletions
+20
View File
@@ -661,6 +661,20 @@ register_conv_template(
)
)
# TODO (lifuhuang): Refactor BaseMultimodalProcessor to support the default image token "<|image_{index}|>" in the future.
register_conv_template(
Conversation(
name="phi-4-mm",
system_message="You are a helpful language and vision assistant. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language.",
system_template="<|system|>{system_message}<|end|>",
roles=("<|user|>", "<|assistant|>"),
sep_style=SeparatorStyle.NO_COLON_SINGLE,
sep="<|end|>",
stop_str="<|end|>",
image_token="<|endoftext10|>",
)
)
register_conv_template(
Conversation(
name="chatml",
@@ -945,3 +959,9 @@ def match_openbmb_minicpm(model_path: str):
def match_moonshot_kimivl(model_path: str):
if re.search(r"kimi.*vl", model_path, re.IGNORECASE):
return "kimi-vl"
@register_conv_template_matching_function
def match_phi_4_mm(model_path: str):
if "phi-4-multimodal" in model_path.lower():
return "phi-4-mm"